TextInput.hpp
Go to the documentation of this file.
1 
2 
3 
4 #ifndef GOSU_TEXTINPUT_HPP
5 #define GOSU_TEXTINPUT_HPP
6 
7 #include <Gosu/Fwd.hpp>
8 #include <Gosu/Platform.hpp>
9 #include <Gosu/TR1.hpp>
10 #include <string>
11 
12 namespace Gosu
13 {
23  class TextInput
24  {
25  struct Impl;
26  const std::auto_ptr<Impl> pimpl;
27 
28  public:
29  TextInput();
30  virtual ~TextInput();
31 
32  std::wstring text() const;
33 
36  void setText(const std::wstring& text);
37 
39  unsigned caretPos() const;
42  void setCaretPos(unsigned pos);
43 
47  unsigned selectionStart() const;
49  void setSelectionStart(unsigned pos);
50 
51  // Platform-specific communication with Gosu::Input.
52  #if defined(GOSU_IS_MAC)
53  bool feedNSEvent(void* event);
54  #elif defined(GOSU_IS_WIN)
55  bool feedMessage(unsigned long message, unsigned long wparam, unsigned long lparam);
56  #elif defined(GOSU_IS_X)
57  bool feedXEvent(void* display, void* event);
58  #endif
59 
63  virtual std::wstring filter(const std::wstring& textIn) const
64  {
65  return textIn;
66  }
67  };
68 }
69 
70 #endif