TextInput.hpp
Go to the documentation of this file.
1 
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 GOSU_UNIQUE_PTR<Impl> pimpl;
27 #if defined(GOSU_CPP11_ENABLED)
28  TextInput(TextInput&&) = delete;
29  TextInput& operator=(TextInput&&) = delete;
30  TextInput(const TextInput&) = delete;
31  TextInput& operator=(const TextInput&) = delete;
32 #endif
33 
34  public:
35  TextInput();
36  virtual ~TextInput();
37 
38  std::wstring text() const;
39 
42  void setText(const std::wstring& text);
43 
45  unsigned caretPos() const;
48  void setCaretPos(unsigned pos);
49 
53  unsigned selectionStart() const;
55  void setSelectionStart(unsigned pos);
56 
57  // Platform-specific communication with Gosu::Input.
58  #if defined(GOSU_IS_MAC)
59  bool feedNSEvent(void* event);
60  #elif defined(GOSU_IS_WIN)
61  bool feedMessage(unsigned long message, unsigned long wparam, unsigned long lparam);
62  #elif defined(GOSU_IS_X)
63  bool feedXEvent(void* display, void* event);
64  #endif
65 
69  virtual std::wstring filter(const std::wstring& textIn) const
70  {
71  return textIn;
72  }
73  };
74 }
75 
76 #endif
Includes all parts of C++03 (TR1) that are relevant for Gosu.
void setSelectionStart(unsigned pos)
Sets the start of the selection as returned by selectionStart.
Contains declarations of all of Gosu&#39;s available classes.
void setText(const std::wstring &text)
Replaces the current text by the given string and positions the cursor at the end of the text...
unsigned caretPos() const
Position of the caret as the index of the character that it&#39;s left to.
std::wstring text() const
virtual ~TextInput()
void setCaretPos(unsigned pos)
Sets the caret position as returned by caretPos.
Macros and utility functions to facilitate programming on all of Gosu&#39;s supported platforms...
TextInput instances are invisible objects that build a text string from input, using the current oper...
Definition: TextInput.hpp:23
unsigned selectionStart() const
If there is a selection, the selectionStart() member yields its beginning, using the same indexing sc...
virtual std::wstring filter(const std::wstring &textIn) const
Overridable filter that is applied to all new text that is entered.
Definition: TextInput.hpp:69