- Timestamp:
- Jun 20, 2006, 11:51:17 AM (18 years ago)
- Location:
- branches/gui/src
- Files:
-
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/defs/class_id.h
r8538 r8614 363 363 CL_GLGUI_TEXTFIELD = 0x00000b61, 364 364 CL_GLGUI_IMAGE = 0x00000b70, 365 CL_GLGUI_TABLE = 0x00000b71, 365 366 366 367 CL_GLGUI_NOTIFIER = 0x00000b80, -
branches/gui/src/lib/gui/gl/Makefile.am
r8599 r8614 26 26 glgui_inputline.cc \ 27 27 glgui_textfield.cc \ 28 glgui_table.cc \ 28 29 glgui_image.cc \ 29 30 glgui_window.cc \ … … 52 53 glgui_inputline.h \ 53 54 glgui_textfield.h \ 55 glgui_table.h \ 54 56 glgui_image.h \ 55 57 glgui_window.h \ -
branches/gui/src/lib/gui/gl/glgui_table.cc
r8613 r8614 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI 17 17 18 #include "glgui_ inputline.h"18 #include "glgui_table.h" 19 19 20 20 namespace OrxGui … … 23 23 * @brief standard constructor 24 24 */ 25 GLGui InputLine::GLGuiInputLine ()25 GLGuiTable::GLGuiTable () 26 26 { 27 27 this->init(); … … 32 32 * @brief standard deconstructor 33 33 */ 34 GLGui InputLine::~GLGuiInputLine()34 GLGuiTable::~GLGuiTable() 35 35 {} 36 37 float GLGuiInputLine::repeatDelay = 0.3f;38 float GLGuiInputLine::repeatRate = 0.01f;39 40 36 41 37 /** 42 38 * @brief initializes the GUI-element 43 39 */ 44 void GLGui InputLine::init()40 void GLGuiTable::init() 45 41 { 46 this->setClassID(CL_GLGUI_ INPUTLINE, "GLGuiInputLine");42 this->setClassID(CL_GLGUI_TABLE, "GLGuiTable"); 47 43 48 44 this->setFocusable(true); 45 this->setClickable(true); 49 46 50 this->_clearOnEnter = false;51 this->_text.setParent2D(this);52 this->_text.setRelCoor2D(4,4);53 this->_text.setFont("fonts/final_frontier.ttf", 20);54 this->_text.setLineWidth(400);55 this->_text.setDotsPosition(LimitedWidthText::Begin);56 this->_text.setColor(foregroundColor());57 this->_text.setVisibility(false);58 47 this->resize(); 59 60 this->delayNext = 0.0;61 this->pressedKey = SDLK_FIRST;62 this->pressedKeyName = SDLK_FIRST;63 64 48 } 65 49 66 50 67 /** 68 * @brief sets the Text of the InputLine 69 * @param text The new Text. 70 */ 71 void GLGuiInputLine::setText(const std::string& text) 51 void GLGuiTable::setRowCount(unsigned int rowCount) 72 52 { 73 this->_text.setText(text); 74 this->changedText(); 53 this->_headers.resize(rowCount); 54 for (unsigned int i = 0; i < rowCount; i++) 55 this->_entries[i].resize(rowCount); 56 57 if (!this->isVisible()) 58 this->hiding(); 75 59 } 76 60 77 /** 78 * @brief appends text to the InputLine 79 * @param appendText the Text to append 80 */ 81 void GLGuiInputLine::append(const std::string& appendText) 61 void GLGuiTable::setColumnCount(unsigned int columnCount) 82 62 { 83 this->_text.append(appendText); 84 this->changedText(); 63 this->_entries.resize(columnCount); 64 if (!this->isVisible()) 65 this->hiding(); 85 66 } 86 67 87 68 88 /**89 * @brief appends a Character to the InputLine90 * @param character the Character to append.91 */92 void GLGuiInputLine::appendCharacter(char character)93 {94 this->_text.appendCharacter(character);95 this->changedText();96 }97 98 99 /**100 * @brief Removes Characters from the InputLine101 * @param chars The count of characters to remove102 */103 void GLGuiInputLine::removeCharacters(unsigned int chars)104 {105 this->_text.removeCharacters(chars);106 this->changedText();107 }108 109 void GLGuiInputLine::clear()110 {111 this->_text.clear();112 this->changedText();113 }114 115 /**116 * @brief If the Text has been changed this function is called.117 *118 * This Function also emits the Signal textChanged.119 */120 void GLGuiInputLine::changedText()121 {122 this->resize();123 this->setFrontColor(Color(1,1,1,1), true);124 emit(this->textChanged(this->_text.text()));125 }126 69 127 70 … … 129 72 * removes the focus from this Widget. 130 73 */ 131 void GLGui InputLine::removedFocus()74 void GLGuiTable::removedFocus() 132 75 { 133 76 GLGuiWidget::removedFocus(); 134 this->pressedKey = 0;135 this->pressedKeyName = 0;136 77 } 137 78 138 /**139 * @brief handles the EnterPush-Event.140 *141 * Emmits th EnterPushed Signal with the current Line,142 * and if _clearOnEnter is pushed clears the Line.143 */144 void GLGuiInputLine::pushEnter()145 {146 emit(this->enterPushed(this->_text.text()));147 if (this->_clearOnEnter)148 this->clear();149 }150 79 151 80 … … 155 84 * @return true if the event was catched. 156 85 */ 157 bool GLGui InputLine::processEvent(const Event& event)86 bool GLGuiTable::processEvent(const Event& event) 158 87 { 159 if (event.bPressed)160 {161 if (event.type == SDLK_BACKSPACE)162 {163 this->delayNext = GLGuiInputLine::repeatDelay;164 this->pressedKey = SDLK_BACKSPACE;165 this->pressedKeyName = SDLK_BACKSPACE;166 this->removeCharacters(1);167 return true;168 }169 else if(event.type == SDLK_RETURN || event.type == SDLK_KP_ENTER)170 {171 this->pushEnter();172 return true;173 }174 // any other keyboard key175 else if (likely(event.type < 127))176 {177 this->delayNext = GLGuiInputLine::repeatDelay;178 179 this->appendCharacter(event.x);180 this->pressedKey = event.type;181 this->pressedKeyName = event.x;182 return true;183 }184 }185 else // if(!event.bPressed)186 {187 if (this->pressedKey == event.type)188 {189 this->pressedKeyName = 0;190 this->pressedKey = 0;191 this->delayNext = 0.0;192 return true;193 }194 }195 88 return false; 196 89 } … … 200 93 * @brief Resizes the Widget to the new Size-constraints. 201 94 */ 202 void GLGui InputLine::resize()95 void GLGuiTable::resize() 203 96 { 204 this->_text.setRelCoor2D(borderLeft(), borderTop());205 this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));206 97 GLGuiWidget::resize(); 207 /* this->frontRect().setTopLeft(borderLeft(), borderTop());208 this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/209 98 } 210 99 211 void GLGui InputLine::updateFrontColor()100 void GLGuiTable::updateFrontColor() 212 101 { 213 this->_text.setColor(foregroundColor()); 102 for (unsigned int i = 0; i < this->rowCount(); ++i) 103 { 104 this->_headers[i].setColor(this->foregroundColor()); 105 for (unsigned int j = 0; j < this->columnCount(); ++j) 106 this->_entries[i][j].setColor(this->foregroundColor()); 107 } 214 108 } 215 109 216 void GLGui InputLine::hiding()110 void GLGuiTable::hiding() 217 111 { 218 this->_text.setVisibility(false); 112 for (unsigned int i = 0; i < this->rowCount(); ++i) 113 { 114 this->_headers[i].setVisibility(false); 115 for (unsigned int j = 0; j < this->columnCount(); ++j) 116 this->_entries[i][j].setVisibility(false); 117 } 219 118 } 220 119 221 void GLGui InputLine::showing()120 void GLGuiTable::showing() 222 121 { 223 this->_text.setVisibility(true); 122 for (unsigned int i = 0; i < this->rowCount(); ++i) 123 { 124 this->_headers[i].setVisibility(true); 125 for (unsigned int j = 0; j < this->columnCount(); ++j) 126 this->_entries[i][j].setVisibility(true); 127 } 224 128 } 225 129 226 130 /** 227 * @brief ticks the InputLine131 * @brief ticks the Table 228 132 * @param dt the time passed. 229 133 */ 230 void GLGui InputLine::tick(float dt)134 void GLGuiTable::tick(float dt) 231 135 { 232 GLGuiWidget::tick(dt);233 if (this->delayNext > 0.0)234 this->delayNext -= dt;235 else if (this->pressedKey != SDLK_FIRST )236 {237 this->delayNext = GLGuiInputLine::repeatRate;238 switch (this->pressedKey)239 {240 case SDLK_BACKSPACE:241 this->removeCharacters(1);242 break;243 default:244 {245 if (likely(this->pressedKey < 127))246 this->appendCharacter(this->pressedKeyName);247 }248 }249 }250 251 252 136 } 253 137 254 138 /** 255 * @brief draws the GLGui InputLine139 * @brief draws the GLGuiTable 256 140 */ 257 void GLGui InputLine::draw() const141 void GLGuiTable::draw() const 258 142 { 259 143 this->beginDraw(); -
branches/gui/src/lib/gui/gl/glgui_table.h
r8613 r8614 1 1 /*! 2 * @file glgui_ inputline.h3 * The gl_ INPUTLINE widget of th openglGUI2 * @file glgui_table.h 3 * The gl_TABLE widget of th openglGUI 4 4 * 5 5 */ 6 6 7 #ifndef _GLGUI_ INPUTLINE_H8 #define _GLGUI_ INPUTLINE_H7 #ifndef _GLGUI_TABLE_H 8 #define _GLGUI_TABLE_H 9 9 10 10 #include "glgui_widget.h" … … 16 16 { 17 17 18 //! This is InputLine part of the openglGUI class18 //! This is Table part of the openglGUI class 19 19 /** 20 * The InputLine is a Widget, that displays a Line, that can be manipulated through20 * The Table is a Widget, that displays a Line, that can be manipulated through 21 21 * Writing Text on it. 22 22 * 23 23 * Whenever the Text is changed the textChanged signal is emitted. 24 24 */ 25 class GLGui InputLine : public OrxGui::GLGuiWidget25 class GLGuiTable : public OrxGui::GLGuiWidget 26 26 { 27 27 28 28 public: 29 GLGui InputLine();30 virtual ~GLGui InputLine();29 GLGuiTable(); 30 virtual ~GLGuiTable(); 31 31 32 unsigned int columnCount() const { return this->_headers.size(); }; 33 unsigned int rowCount() const { return this->_entries.size(); }; 34 //const std::vector<std::string>& headers() const { return this->_headers; }; 35 //const std::vector<std::vector<std::string> >& entries() const { return this->_entries; }; 32 36 33 /** @returns the text of the inputLine */34 const std::string& _getText() const { return this->_text.text(); };37 void setRowCount(unsigned int rowCount); 38 void setColumnCount(unsigned int columnCount); 35 39 36 void setText(const std::string& text); 37 void append(const std::string& appendText); 38 void appendCharacter(char character); 39 void removeCharacters(unsigned int chars); 40 void clear(); 40 void setHeader(unsigned int number, const std::string& headerName); 41 void setHeader(const std::vector<std::string>& headerNames); 41 42 42 void clearOnEnter(bool clear = true) { this->_clearOnEnter = clear; };43 void setEntry(unsigned int column, unsigned int rowNumber, const std::string& name); 43 44 44 virtual void removedFocus(); 45 void setColumnWidth(unsigned int column, float size); 46 void setRowSize(unsigned int row, unsigned int size); 45 47 46 48 virtual void tick(float dt); 47 49 virtual void draw() const; 48 50 49 virtual bool processEvent(const Event& event);50 51 DeclareSignal1(textChanged, const std::string&);52 DeclareSignal1(enterPushed, const std::string&);53 51 54 52 protected: 53 virtual void removedFocus(); 54 55 55 virtual void updateFrontColor(); 56 56 virtual void hiding(); … … 58 58 virtual void resize(); 59 59 60 virtual bool processEvent(const Event& event); 61 60 62 61 63 private: 62 64 void init(); 63 void pushEnter(); 64 void changedText(); 65 66 private: 67 typedef std::vector<LimitedWidthText> TableTextList; 68 TableTextList _headers; 69 std::vector<TableTextList> _entries; //!< inner is by column, outer is by row. 65 70 66 71 67 private:68 LimitedWidthText _text; //!< The Text to display inside of the InputLine.69 bool _clearOnEnter; //!< Clear on Enter70 71 Uint16 pressedKey; //!< the pressed key that will be repeated.72 Uint16 pressedKeyName; //!< The Name of the Key, that was pressed.73 74 float delayNext; //!< How much time must pass before next output.75 76 static float repeatDelay; //!< Repead Delay.77 static float repeatRate; //!< Repeat Rate.78 72 }; 79 73 } 80 74 81 #endif /* _GLGUI_ INPUTLINE_H */75 #endif /* _GLGUI_TABLE_H */
Note: See TracChangeset
for help on using the changeset viewer.