libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UITextEntry.hpp
Go to the documentation of this file.
1 #ifndef UITEXTENTRY_HPP
2 #define UITEXTENTRY_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "UIWidget.hpp"
23 
24 namespace AlgAudio{
25 
26 class UITextEntry : public UIWidget{
27 public:
28  static std::shared_ptr<UITextEntry> Create(std::weak_ptr<Window> parent_window, std::string text = "");
29  virtual void CustomDraw(DrawContext& c) override;
33  void SetText(std::string text);
34  void SetFontSize(int size);
35  std::string GetText() const {return text;}
38  void SetDefaultText(std::string d) {
39  default_text = d;
40  if(text == "") UpdateText();
41  }
43  void SetDigitsOnly(bool d) {digits_only = d;}
46  void SetMaxLength(int l);
47  virtual void OnFocusChanged(bool) override;
48  virtual void OnKeyboard(KeyData) override;
49 private:
50  UITextEntry(std::weak_ptr<Window>, std::string t = "");
51  void Init();
52  void UpdateText();
53  std::string text;
54  std::string default_text = "";
55  std::shared_ptr<SDLTextTexture> text_texture;
56  int fontsize = 12;
57  bool digits_only = false;
58  int max_length = -1;
59 
60  bool was_edited_since_received_focus = false;
61 };
62 
63 } // namespace AlgAudio
64 
65 #endif // UITEXTENTRY_HPP
Definition: UIWidget.hpp:65
Signal on_edited
Definition: UITextEntry.hpp:32
Definition: DrawContext.hpp:65
Definition: UITextEntry.hpp:26
void SetDigitsOnly(bool d)
Definition: UITextEntry.hpp:43
std::string GetText() const
Definition: UITextEntry.hpp:35
virtual void CustomDraw(DrawContext &c) override
void SetDefaultText(std::string d)
Definition: UITextEntry.hpp:38
virtual void OnFocusChanged(bool) override
Definition: Alertable.hpp:26
static std::shared_ptr< UITextEntry > Create(std::weak_ptr< Window > parent_window, std::string text="")
Signal on_edit_exitted
Definition: UITextEntry.hpp:31
void SetFontSize(int size)
void SetText(std::string text)
Definition: Signal.hpp:145
Signal on_edit_complete
Definition: UITextEntry.hpp:30
void SetMaxLength(int l)
Definition: Utilities.hpp:157
virtual void OnKeyboard(KeyData) override