From 72e6e0401677740a286ab937194c61db1448e4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Fri, 5 May 2017 22:35:47 +0200 Subject: Refactor TextEdit widget. --- plugingui/textedit.h | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'plugingui/textedit.h') 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 -#include +#include -#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 preprocessed_text; }; } // GUI:: -- cgit v1.2.3