diff options
author | André Nusser <andre.nusser@googlemail.com> | 2017-05-05 22:35:47 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2017-05-05 22:35:47 +0200 |
commit | 72e6e0401677740a286ab937194c61db1448e4c9 (patch) | |
tree | c39de5f7b2fbfbcf02bb4c9c514fefde4cd2a07b /plugingui/textedit.h | |
parent | 33639dddd8b1b01739994b7427d70ffc676cb22d (diff) |
Refactor TextEdit widget.
Diffstat (limited to 'plugingui/textedit.h')
-rw-r--r-- | plugingui/textedit.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/plugingui/textedit.h b/plugingui/textedit.h index 5959ae9..6ce59b6 100644 --- a/plugingui/textedit.h +++ b/plugingui/textedit.h @@ -27,27 +27,32 @@ #pragma once #include <string> -#include <list> +#include <vector> -#include "widget.h" #include "font.h" -#include "painter.h" +#include "notifier.h" #include "scrollbar.h" #include "texturedbox.h" -#include "notifier.h" +#include "widget.h" -namespace GUI { +namespace GUI +{ -class TextEdit : public Widget { +class TextEdit + : public Widget +{ public: - TextEdit(Widget *parent); + TextEdit(Widget* parent); virtual ~TextEdit(); // From Widget - bool isFocusable() override { return true; } + bool isFocusable() override + { + return true; + } void resize(std::size_t width, std::size_t height) override; - std::string text(); + std::string getText(); void setText(const std::string& text); void setReadOnly(bool readonly); @@ -65,20 +70,23 @@ protected: private: void scrolled(int value); - TexturedBox box{getImageCache(), ":resources/widget.png", - 0, 0, // atlas offset (x, y) - 7, 1, 7, // dx1, dx2, dx3 - 7, 63, 7}; // dy1, dy2, dy3 + TexturedBox box{getImageCache(), ":resources/widget.png", 0, + 0, // atlas offset (x, y) + 7, 1, 7, // dx1, dx2, dx3 + 7, 63, 7}; // dy1, dy2, dy3 + + static constexpr std::size_t x_border{10}; + static constexpr std::size_t y_border{8}; ScrollBar scroll; Font font; - std::string _text; + std::string text; bool readonly{true}; bool needs_preprocessing{false}; - std::list< std::string > preprocessedtext; + std::vector<std::string> preprocessed_text; }; } // GUI:: |