1 /* 2 # PostgreSQL Database Modeler (pgModeler) 3 # 4 # Copyright 2006-2020 - Raphael Araújo e Silva <raphael@pgmodeler.io> 5 # 6 # This program is free software: you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation version 3. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # The complete text of GPLv3 is at LICENSE file on source code root directory. 16 # Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/> 17 */ 18 19 /** 20 \ingroup libobjrenderer 21 \class TextboxView 22 \brief Represents the textbox in a graphical way on the object scene 23 */ 24 25 #ifndef TEXTBOX_VIEW_H 26 #define TEXTBOX_VIEW_H 27 28 #include "textbox.h" 29 #include "baseobjectview.h" 30 #include "roundedrectitem.h" 31 #include "textpolygonitem.h" 32 33 class TextboxView: public BaseObjectView { 34 private: 35 Q_OBJECT 36 37 //! \brief Indicates the the font / color styles will be overriden (need to call setColorStyle, setFontStyle) 38 bool override_style; 39 40 QString txtbox_tooltip; 41 42 protected: 43 //! \brief Graphical item that represent the box 44 QGraphicsPolygonItem *box; 45 46 //! \brief Graphical item that represent the text 47 QGraphicsSimpleTextItem *text; 48 49 TextPolygonItem *text_item; 50 51 //! \brief Configures the shadow for the textbox 52 void configureObjectShadow(); 53 54 //! \brief Configures the selection for the textbox 55 void configureObjectSelection(); 56 57 //! \brief Configures the basic attributes for textbox 58 void __configureObject(); 59 60 public: 61 TextboxView(Textbox *txtbox, bool override_style=false); 62 virtual ~TextboxView(); 63 64 /*! \brief Sets the fill and border color for the text box. This method has effect only when 65 the style can be overriden (via constructor) */ 66 void setColorStyle(const QBrush &fill_style, const QPen &border_style); 67 68 /*! \brief Sets the font style for the text box. This method has effect only when 69 the style can be overriden (via constructor) */ 70 void setFontStyle(const QTextCharFormat &fmt); 71 72 void setToolTip(const QString &tooltip); 73 74 QVariant itemChange(GraphicsItemChange change, const QVariant &value); 75 76 protected slots: 77 virtual void configureObject(); 78 }; 79 80 #endif 81