00001 #ifndef GLWX_H
00002 #define GLWX_H
00003
00004 #include "glwxConfig.h"
00005 #include "TextureUtils.h"
00006 #include "GenUtils.h"
00007 #include "XMLUtils.h"
00008 #include "Font.h"
00009
00073 typedef enum
00074 {
00075 MB_UNKNOWN_BUTTON,
00076 MB_BUTTON1,
00077 MB_BUTTON2,
00078 MB_BUTTON3,
00079 } MOUSEBUTTON;
00080
00081 typedef enum
00082 {
00083 ME_CLICKED,
00084 ME_DOUBLE_CLICKED,
00085 ME_PRESSED,
00086 ME_DRAGGED,
00087 ME_RELEASED,
00088 ME_MOVED,
00089 ME_SCROLLING_UP,
00090 ME_SCROLLING_DOWN,
00091 ME_SCROLLING_NONE
00092 } MOUSEEVENT;
00093
00094 typedef enum
00095 {
00096 AT_CENTER,
00097 AT_CORNERLU,
00098 AT_CORNERRU,
00099 AT_CORNERLD,
00100 AT_CORNERRD
00101 } ANCHORTYPE;
00102
00103 typedef enum
00104 {
00105 TE_BACKSPACE_DELETE,
00106 TE_SIMPLE_DELETE,
00107 TE_INSERT_CHAR,
00108 TE_BATCH_DELETE,
00109 TE_PARSE_VISIBLE
00110 } TEXTEVENT;
00111
00112 typedef enum
00113 {
00114 WT_SLIDER = 1,
00115 WT_BUTTON,
00116 WT_CHECK_BOX,
00117 WT_CHECK_BOX_MARK,
00118 WT_RADIO_BUTTON,
00119 WT_CHECK_RB_MARK,
00120 WT_LABEL,
00121 WT_TEXT_AREA,
00122 WT_MATERIAL_SURFACE,
00123 WT_PANEL,
00124 WT_SEPARATOR,
00125 WT_TEXT_BOX,
00126 WT_COMBO_BOX,
00127 WT_TABBED_PANEL,
00128 WT_UNKNOWN
00129 } WIDGETTYPE;
00130
00131 typedef enum
00132 {
00133 PL_FREE_LAYOUT,
00134 PL_YAXIS_LAYOUT,
00135 PL_YAXIS_CEN_LAYOUT,
00136 PL_XAXIS_LAYOUT,
00137 PL_GRID_LAYOUT
00138 } PANELLAYOUT;
00139
00140
00141 typedef enum
00142 {
00143 OR_HORIZONTAL,
00144 OR_VERTICAL
00145 } ORIENTATION;
00146
00147 typedef enum
00148 {
00149 KE_PRESSED = 1,
00150 KE_RELEASED
00151 } KEYBOARDEVENT;
00152
00153 typedef enum
00154 {
00155 KB_PAUSE = 19,
00156 KB_ENTER = 13,
00157 KB_SPACE = 32,
00158 KB_ESCAPE = 27,
00159 KB_BACK_SPACE = 8,
00160 KB_NUMPAD_PLUS = 107,
00161 KB_NUMPAD_MINUS = 109,
00162
00163 KB_LEFT = 37,
00164 KB_UP, KB_RIGHT, KB_DOWN,
00165
00166 KB_0 = 48,
00167 KB_1, KB_2, KB_3, KB_4, KB_5, KB_6, KB_7,
00168 KB_8, KB_9,
00169
00170 KB_A = 65,
00171 KB_B, KB_C, KB_D, KB_E, KB_F, KB_G, KB_H,
00172 KB_I, KB_J, KB_K, KB_L, KB_M, KB_N, KB_O,
00173 KB_P, KB_Q, KB_R, KB_S, KB_T, KB_U, KB_V,
00174 KB_W, KB_X, KB_Y, KB_Z,
00175
00176 KB_NUMPAD0 = 96,
00177 KB_NUMPAD1, KB_NUMPAD2, KB_NUMPAD3, KB_NUMPAD4,
00178 KB_NUMPAD5, KB_NUMPAD6, KB_NUMPAD7, KB_NUMPAD8,
00179 KB_NUMPAD9,
00180
00181 KB_F1 = 112,
00182 KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7,
00183 KB_F8, KB_F9, KB_F10, KB_F11, KB_F12
00184 } KEYBOARDBUTTON;
00185
00186
00187
00188
00189
00190
00191
00192
00193 class KeyEvent
00194 {
00195 public:
00196 KeyEvent(int id);
00197 KeyEvent(const KeyEvent& copy);
00198 KeyEvent &operator= (const KeyEvent& copy);
00199
00200 bool displayable();
00201 char getKeyChar();
00202 int getKeyID();
00203 bool getUsed();
00204 void setUsed(bool value);
00205
00206 private:
00207 int id;
00208 bool used;
00209 };
00210
00211
00212
00213
00214
00215
00216
00217 class MouseEvent
00218 {
00219 public:
00220 MouseEvent();
00221 MouseEvent(int id, int xMouse,
00222 int yMouse, int yInvMouse,
00223 int scrolling = ME_SCROLLING_NONE);
00224 MouseEvent(const MouseEvent& copy);
00225 MouseEvent &operator= (const MouseEvent& copy);
00226
00227 int getScrolling();
00228 int getButtonID();
00229 int getX();
00230 int getY();
00231 int getYInverse();
00232
00233 void consume();
00234 bool getUsed();
00235 void setUsed(bool value);
00236 private:
00237 bool used;
00238 int scrolling,
00239 buttonID,
00240 x,
00241 y,
00242 yInverse;
00243 };
00244
00245
00246
00247
00248
00249
00250
00251 class GUIRectangle;
00252 class GUIEvent
00253 {
00254 public:
00255 GUIEvent(GUIRectangle *element);
00256 GUIEvent(const GUIEvent& copy);
00257 GUIEvent &operator= (const GUIEvent& copy);
00258
00259 GUIRectangle *getEventSource();
00260 const std::string &getCallbackString();
00261
00262 void setConsumed(bool);
00263 bool isConsumed();
00264
00265 private:
00266 GUIRectangle *eventSource;
00267 std::string callbackString;
00268 bool consumed;
00269 };
00270
00271
00272
00273
00274
00275
00276
00277 class GUIEventListener
00278 {
00279 public:
00280 virtual void actionPerformed(GUIEvent &evt) = 0;
00281 };
00282
00283
00284
00285
00286
00287
00288
00289 class GUIFont : public NamedObject
00290 {
00291 public:
00292 GUIFont(const std::string &guiFontPath = "") : NamedObject(guiFontPath){}
00293
00294 ~GUIFont();
00295
00296 CFont *getFontObject();
00297
00298 bool operator ==(const GUIFont &compare);
00299 bool operator !=(const GUIFont &compare);
00300
00301 bool loadXMLSettings(const TiXmlElement *node);
00302 bool build();
00303
00304 private:
00305 CFont font;
00306 };
00307
00308
00309
00310
00311
00312
00313
00314 class GUIText
00315 {
00316 public:
00317 GUIText(const std::string &text = "");
00318
00319 GUIText(const GUIText & text);
00320 GUIText &operator =(const GUIText &text);
00321 GUIText &operator =(const std::string &text);
00322
00323 virtual bool loadXMLSettings(const TiXmlElement *node);
00324
00325 void computeDimensions();
00326 void printCenteredXY(int x, int y, int startIndex = 0, int endIndex = -1);
00327 void printCenteredX (int x, int y, int startIndex = 0, int endIndex = -1);
00328 void printCenteredY (int x, int y, int startIndex = 0, int endIndex = -1);
00329 void print(int x, int y, int startIndex = 0, int endIndex = -1);
00330
00331 const std::string &getString();
00332
00333 void setString(const std::string &text);
00334 void setString(const char *text);
00335 void clear();
00336
00337 void setSize(int x, int y);
00338 void setSize(const Tuple2i& size);
00339 const Tuple2i& getSize();
00340
00341 void setColor(float r, float g, float b);
00342 void setColor(const Tuple3f &color);
00343 const Tuple3f &getColor();
00344
00345 int getHeight();
00346 int getWidth();
00347
00348 void setHeightScale(float hs);
00349 void setWidthScale(float ws);
00350 void setScales(Tuple2f scales);
00351
00352 float getHeightScale();
00353 float getWidthScale();
00354 const Tuple2f & getScales();
00355
00356 bool needUpdating();
00357 void forceUpdate(bool update);
00358
00359 void setFontIndex(int fontIndex);
00360 int getFontIndex();
00361
00362 protected:
00363 std::string text;
00364 Tuple2i position,
00365 size;
00366 Tuple2f scales;
00367 Tuple3f color;
00368 bool update;
00369 int fontIndex;
00370 };
00371
00372
00373
00374
00375
00376
00377
00378 class GUIFontManager
00379 {
00380 public:
00381 static int addFont(const TiXmlElement *fontNodex);
00382 static int findFontIndex(GUIFont *font);
00383 static GUIFont *getFont(size_t index);
00384
00385 static void setCurrentFont(GUIFont *currentFont);
00386 static void setCurrentFont(size_t index);
00387 static GUIFont *getCurrentFont();
00388
00389 static void setDefaultFont(GUIFont *defaultFont);
00390 static void setDefaultFont(size_t index);
00391 static GUIFont *getDefaultFont();
00392 static int getCharacterWidth(char Char, GUIFont *font);
00393 static int getCharacterWidth(char Char, int index);
00394
00395 static void clear();
00396
00397 private:
00398 static bool addFont(GUIFont *font);
00399
00400 static vector<GUIFont *> guiFontList;
00401
00402 static GUIFont *currentFont,
00403 *defaultFont;
00404 };
00405
00406
00407
00408
00409
00410
00411
00412 class GUITexCoordDescriptor
00413 {
00414
00415 private:
00416 void setType(const std::string &type);
00417
00418 Tuple4f texCoords;
00419 int widgetType;
00420
00421 public:
00422
00423 GUITexCoordDescriptor(const int type = WT_UNKNOWN);
00424 GUITexCoordDescriptor(const GUITexCoordDescriptor ©);
00425 GUITexCoordDescriptor &operator =(const GUITexCoordDescriptor ©);
00426
00427 static void setTextureWidth(int width);
00428 static void setTextureHeight(int height);
00429
00430 static int getTextureWidth();
00431 static int getTextureHeight();
00432
00433 void loadXMLSettings(const TiXmlElement *element);
00434 void setType(int type);
00435 int getType();
00436
00437 void setTexCoords(float x, float y, float z, float w);
00438 void setTexCoords(const Tuple4f& texCoords);
00439
00440 const Tuple4f &getTexCoords();
00441 };
00442
00443
00444
00445
00446
00447
00448
00449 class GUIRectangle
00450 {
00451 protected:
00452 GUIRectangle *parent;
00453
00454 std::string callbackString;
00455
00456 Tuple4i windowBounds;
00457 Tuple2f position,
00458 dimensions;
00459
00460 bool mouseOver,
00461 released,
00462 focused,
00463 pressed,
00464 clicked,
00465 visible,
00466 active,
00467 update;
00468
00469 int lastAction,
00470 widgetType,
00471 anchor,
00472 z;
00473
00474 public:
00475 GUIRectangle(const std::string &callback = "");
00476 virtual ~GUIRectangle(){};
00477
00478 void setCallbackString(const std::string& callback);
00479 const std::string &getCallbackString();
00480
00481 bool loadXMLSettings(const TiXmlElement *node);
00482
00483 void setDimensions(float width, float height);
00484 void setDimensions(const Tuple2f &dimensions);
00485 const Tuple2f &getDimensions();
00486
00487 void setPosition(float xScaleOrPosition, float yScaleOrPosition);
00488 void setPosition(const Tuple2f &scalesOrPosition);
00489 const Tuple2f &getPosition();
00490 virtual Tuple2i getCenter();
00491
00492 int getWidth();
00493 int getHeight();
00494
00495 void setActive(bool active);
00496 bool isActive();
00497
00498 void setAnchorPoint(const std::string &anchor);
00499 void setAnchorPoint(int anchor);
00500 int getAnchorPoint();
00501
00502 virtual void forceUpdate(bool update);
00503
00504 void setVisible(bool active);
00505 bool isVisible();
00506
00507 bool isAttached();
00508 int getWidgetType();
00509
00510 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo, bool reservedBits = false);
00511 virtual void checkKeyboardEvents(KeyEvent &evt, int extraInfo);
00512 virtual void render(float) = 0;
00513
00514 virtual void setParent(GUIRectangle *parent);
00515 virtual GUIRectangle *getParent();
00516
00517 virtual GUITexCoordDescriptor *getTexCoordsInfo(int type);
00518 virtual GUIEventListener *getEventsListener();
00519
00520 virtual void enableGUITexture();
00521 virtual void disableGUITexture();
00522
00523 virtual void setZCoordinate(int z);
00524 virtual int getZCoordinate();
00525
00526 virtual const void computeWindowBounds();
00527 virtual const Tuple4i &getWindowBounds();
00528
00529 bool eventDetected();
00530 bool isMouseOver();
00531 bool isReleased();
00532 bool isFocused();
00533 bool isDragged();
00534 bool isClicked();
00535 bool isPressed();
00536 };
00537
00538 typedef vector<GUITexCoordDescriptor> GUITexCoordsInfo;
00539 typedef DistanceObject<GUIRectangle*> ZWidget;
00540 typedef vector<GUIRectangle *> Widgets;
00541 typedef vector<ZWidget> ZWidgets;
00542
00543
00544
00545
00546
00547
00548
00549 class GUIClippedRectangle
00550 {
00551 protected:
00552 Texture texture;
00553 Tuple2f texCoords[7];
00554
00555 Tuple4f textureRectangle,
00556 bgColor;
00557
00558 Tuple3f bordersColor;
00559 Tuple2i vertices[7];
00560 bool drawBackground,
00561 drawBounds;
00562 int clipSize;
00563
00564 public:
00565 GUIClippedRectangle(int clipSize = 5);
00566 void enableBGColor(bool enable);
00567 bool isBGColorOn();
00568
00569 void computeClippedBounds(const Tuple4i &windowBounds);
00570
00571 void setClipSize(int clipSize);
00572 int getClipSize();
00573
00574 void setVisibleBounds(bool visible);
00575 bool boundsVisible();
00576
00577 void setBGColor(float x, float y, float z, float alpha);
00578 void setBGColor(const Tuple4f& color);
00579 const Tuple4f &getBGColor();
00580 const Tuple2i *getVertices() const;
00581
00582 void setBordersColor(const Tuple3f& color);
00583 void setBordersColor(float x, float y, float z);
00584 const Tuple3f &getBordersColor();
00585 const Tuple2f *getTexCoords() const;
00586
00587 void setTextureRectangle(float x, float y, float z, float w);
00588 void setTextureRectangle(const Tuple4f &textureRectangle);
00589 const Tuple4f &getTextureRectangle();
00590
00591 Texture &getTexture();
00592 void setTexture(const Texture & texture);
00593
00594 virtual void renderClippedBounds();
00595 virtual bool loadXMLClippedRectangleInfo(const TiXmlElement *element);
00596 };
00597
00598
00599
00600
00601
00602
00603
00604 class GUISeparator : public GUIRectangle
00605 {
00606 public:
00607 GUISeparator(int orientation = OR_HORIZONTAL);
00608 virtual bool loadXMLSettings(const TiXmlElement *element);
00609 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo){};
00610 virtual void checkKeyboardEvents(KeyEvent &evt, int extraInfo){};
00611 virtual void render(float);
00612
00613 virtual const Tuple4i &getWindowBounds();
00614 virtual const void computeWindowBounds();
00615
00616 void setOrientation(int orientation);
00617 int getOrientation();
00618
00619 void setRatio(float ratio);
00620 float getRatio();
00621 private:
00622 int orientation;
00623 float ratio;
00624 };
00625
00626
00627
00628
00629
00630
00631
00632 class GUIAlphaElement : public GUIRectangle
00633 {
00634
00635 protected:
00636 GUIText label;
00637 Tuple4f color;
00638 float alphaFadeScale,
00639 minAlpha;
00640
00641 void modifyCurrentAlpha(float tick);
00642 public:
00643 GUIAlphaElement(const std::string &callback = "");
00644
00645 virtual void render(float clockTick) = 0;
00646 virtual bool loadXMLSettings(const TiXmlElement *node);
00647
00648 void setMinAlpha(float minAlpha);
00649 float getMinAlpha();
00650
00651 void setAlphaFadeScale(float scale);
00652 float getAlphaFadeScale();
00653
00654 void setAlpha(float alpha);
00655 float getAlpha();
00656
00657 void setLabelString(const std::string &label);
00658 const std::string &getLabelString();
00659
00660 void setColor(const Tuple3f& color);
00661 void setColor(float x, float y, float z);
00662 const Tuple4f &getColor();
00663
00664 GUIText * getLabel();
00665 };
00666
00667
00668
00669
00670
00671
00672
00673 class GUILabel : public GUIAlphaElement
00674 {
00675 public:
00676 GUILabel(const std::string &labelString = "Unknown Label",
00677 const std::string &callbackString = "");
00678
00679 virtual void render(float clockTick);
00680 virtual bool loadXMLSettings(const TiXmlElement *element);
00681 virtual const Tuple4i &getWindowBounds();
00682 };
00683
00684
00685
00686
00687
00688
00689
00690 class GUITextBox : public GUIAlphaElement
00691 {
00692 public:
00693 GUITextBox(const std::string &callback = "",
00694 const std::string &fieldText = "");
00695
00696 virtual void render(float clockTick);
00697 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo, bool reservedBits = false);
00698 virtual void checkKeyboardEvents(KeyEvent &evt, int extraInfo);
00699 virtual bool loadXMLSettings(const TiXmlElement *node);
00700 virtual const Tuple4i &getWindowBounds();
00701 void setText(const std::string &text);
00702 const std::string &getText() const;
00703
00704 bool textChanged();
00705
00706 void setBordersColor(const Tuple3f& color);
00707 void setBordersColor(float r, float g, float b);
00708 const Tuple3f &getBordersColor() const;
00709
00710 void setPadding(const Tuple2i& p);
00711 void setPadding(int x, int y);
00712 const Tuple2i &getPadding() const;
00713
00714 protected:
00715 Tuple2i padding;
00716 Tuple3f bordersColor,
00717 textColor;
00718 float blinkerTimer;
00719 size_t blinkerPosition,
00720 textStartIndex,
00721 textEndIndex;
00722 bool blinkerOn;
00723
00724 private:
00725 void setupText(int type, char info = 0);
00726 void setupBlinker(size_t mouseX);
00727 };
00728
00729
00730
00731
00732
00733
00734
00735 class GUIButton : public GUIAlphaElement, public GUIClippedRectangle
00736 {
00737 public:
00738 GUIButton(const std::string &callback = "");
00739
00740 virtual void render(float clockTick);
00741 virtual bool loadXMLSettings(const TiXmlElement *node);
00742 virtual const void computeWindowBounds();
00743
00744 void enableBounce(bool bounce);
00745 bool bounceEnabled();
00746
00747 private:
00748 bool bounce;
00749 };
00750
00751
00752
00753
00754
00755
00756
00757 class GUICheckBox : public GUIAlphaElement
00758 {
00759 public:
00760 GUICheckBox(const std::string &callback = "");
00761
00762 virtual void render(float clockTick);
00763 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo, bool reservedBits = false);
00764 virtual bool loadXMLSettings(const TiXmlElement *node);
00765 virtual void setChecked(bool enabled);
00766
00767 void setAlphaMark(float mark);
00768 float getAlphaMark();
00769
00770 void setMinAlphaMark(float mark);
00771 float getMinAlphaMark();
00772
00773 bool isChecked();
00774
00775 void setBGColor(const Tuple3f& color);
00776 void setBGColor(float x, float y, float z);
00777 const Tuple3f &getBGColor();
00778 virtual const Tuple4i &getWindowBounds();
00779
00780 protected:
00781 Tuple3f bgColor;
00782 float markRatio,
00783 alphaMark,
00784 minAlphaMark;
00785 bool checked;
00786 int extra,
00787 markOffset,
00788 primaryTexDesc,
00789 secondaryTexDesc;
00790 };
00791
00792
00793
00794
00795
00796
00797
00798 class GUIRadioButton : public GUICheckBox
00799 {
00800 public:
00801 GUIRadioButton(const std::string &callback = "");
00802 virtual void checkMouseEvents(MouseEvent &newEvent, int extraInfo, bool bits);
00803 };
00804
00805
00806
00807
00808
00809
00810
00811 class GUISlider : public GUIAlphaElement
00812 {
00813 public:
00814 GUISlider(const std::string &callback = "",
00815 const int orientation = OR_HORIZONTAL);
00816
00817 virtual const Tuple4i &getWindowBounds();
00818 virtual void checkMouseEvents(MouseEvent &evt, int extreaInfo, bool reservedBits = false);
00819 virtual bool loadXMLSettings(const TiXmlElement *element);
00820 virtual void render(float clockTick);
00821
00822 float getProgress();
00823 void setProgress(float zeroToOne);
00824
00825 void setDiscDimensions(const Tuple2i& dimensions);
00826 void setDiscDimensions(int width, int height);
00827 int getOrientation();
00828
00829 const Tuple2i &getDiscDimensions();
00830
00831 private:
00832 Tuple4i realWindowBounds;
00833 Tuple2i discDimensions;
00834 float progress;
00835 int orientation,
00836 offset;
00837
00838 void renderVertical();
00839 };
00840
00841
00842
00843
00844
00845
00846
00847 class GUIPanel : public GUIRectangle,
00848 public GUIClippedRectangle
00849 {
00850 protected:
00851 Widgets elements;
00852 Tuple2i interval;
00853 int layout;
00854
00855 private:
00856 void packFreeLayout();
00857 void packYAxisLayout();
00858 void packXAxisLayout();
00859 void correctPosition();
00860
00861 public:
00862 GUIPanel(const std::string &callback = "");
00863 virtual ~GUIPanel();
00864 GUIRectangle *getWidgetByCallbackString(const std::string &name);
00865
00866 void setInterval(int width, int height);
00867 void setInterval(const Tuple2i &dimensions);
00868 const Tuple2i &getInterval();
00869
00870 void setLayout(int layout);
00871 int getLayout();
00872
00873 int getTreeHeight();
00874
00875 virtual bool loadXMLSettings(const char *stackPath);
00876 virtual bool loadXMLSettings(const TiXmlElement *element);
00877
00878 virtual void notify(GUIRectangle *element);
00879 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo, bool bitInfo = false);
00880 virtual void checkKeyboardEvents(KeyEvent &evt, int extraInfo);
00881 virtual void render(float tick);
00882
00883 virtual void collectZWidgets(ZWidgets &container);
00884 virtual void forceUpdate(bool);
00885 virtual bool addWidget(GUIRectangle *widget);
00886 virtual void pack();
00887 virtual void clear();
00888
00889 int getWidgetCountByType(int type);
00890 Widgets &getWidgets();
00891 };
00892
00893
00894
00895
00896
00897
00898
00899 class GUIFrame : public GUIPanel
00900 {
00901 private:
00902 GUIEventListener *listener;
00903 GUITexCoordsInfo texCoords;
00904 Texture elementsTexture;
00905 Tuple2i windowSize;
00906 int updateCount;
00907 public:
00908 GUIFrame();
00909 ~GUIFrame();
00910
00911 virtual bool loadXMLSettings(const TiXmlElement *element);
00912
00913 void addOrReplaceTexCoordsInfo(GUITexCoordDescriptor &info);
00914 void setElementsTexture(const char* texturePath);
00915 void setElementsTexture(const Texture &texture);
00916 void setGUIEventListener(GUIEventListener *listener);
00917 Texture *getElementsTexture();
00918
00919 virtual GUITexCoordDescriptor *getTexCoordsInfo(int type);
00920 virtual GUIEventListener *getEventsListener();
00921
00922 virtual const Tuple4i &getWindowBounds();
00923 virtual void forceUpdate(bool update);
00924 virtual void enableGUITexture();
00925 virtual void disableGUITexture();
00926 virtual void render(float tick);
00927 virtual void clear();
00928 };
00929
00930
00931
00932
00933
00934
00935
00936 class GUIComboBox : public GUIRectangle, public GUIEventListener
00937 {
00938 public:
00939 GUIComboBox(const std::string& cbs = "");
00940 virtual ~GUIComboBox();
00941
00942 virtual GUIEventListener *getEventsListener();
00943 virtual const void computeWindowBounds();
00944 virtual bool loadXMLSettings(const TiXmlElement *node);
00945 virtual void render(float clockTick);
00946 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo, bool reservedBits = false);
00947 virtual void actionPerformed(GUIEvent &evt);
00948
00949 void setFontScales(float w, float h);
00950 void setFontScales(const Tuple2f &scales);
00951 const Tuple2f &getFontScales();
00952
00953 void addItem(const std::string &item);
00954 const vector<std::string> &getItems() const;
00955
00956 const char* getSelectedItem() const;
00957 const char* getItem(size_t index) const;
00958 int getItemIndex(const std::string &item);
00959
00960 void setScrollingColor(float r, float g, float b, float alpha);
00961 void setScrollingColor(const Tuple4f &rgba);
00962 const Tuple4f &getScrollingColor() const;
00963
00964 void enableScrollingRectangle(bool);
00965 bool scrollingRectangleEnabled();
00966
00967 bool isDeployed();
00968
00969 private:
00970
00971 void finalizeSize();
00972
00973 vector<std::string> items;
00974 GUIButton *dropMenuButton;
00975 GUIPanel *upperPanel,
00976 *lowerPanel;
00977 GUILabel *currentSelection;
00978
00979 Tuple4i scrollingRectangle;
00980 Tuple4f scrollingColor;
00981 Tuple2f fontScales;
00982
00983 bool displayScrollingRectangle,
00984 lockItems,
00985 deployed;
00986
00987 int selectionIndex,
00988 fontIndex;
00989 };
00990
00991
00992
00993
00994
00995
00996
00997 class GUITabbedPanel : public GUIRectangle, public GUIEventListener
00998 {
00999 public:
01000 GUITabbedPanel(const std::string &callback = "");
01001 ~GUITabbedPanel();
01002
01003 virtual GUIEventListener *getEventsListener();
01004 virtual const void computeWindowBounds();
01005 virtual bool loadXMLSettings(const TiXmlElement *node);
01006 virtual void render(float clockTick);
01007 virtual void checkMouseEvents(MouseEvent &evt, int extraInfo, bool reservedBits = false);
01008 virtual void checkKeyboardEvents(KeyEvent &evt, int extraInfo);
01009 virtual void actionPerformed(GUIEvent &evt);
01010
01011 void setTabButtonsColor(float r, float g, float b);
01012 void setTabButtonsColor(const Tuple3f& color);
01013 const Tuple3f &getTabButtonsColor() const;
01014
01015 void setTabButtonsBordersColor(float r, float g, float b);
01016 void setTabButtonsBordersColor(const Tuple3f& color);
01017 const Tuple3f &getTabButtonsBordersColor() const;
01018
01019 void setFontScales(float w, float h);
01020 void setFontScales(const Tuple2f &scales);
01021 const Tuple2f &getFontScales();
01022
01023 bool addPanel(GUIPanel *panel);
01024 const GUIPanel* getCurrentPanel() const;
01025 const int getCurrentPanelIndex() const;
01026
01027 GUIButton *getTabButton(int index);
01028 GUIPanel *getLowerPanel();
01029 private:
01030 GUIPanel *upperPanel,
01031 *lowerPanel,
01032 *mainPanel;
01033
01034 Tuple3f tabButtonsBordersColor,
01035 tabButtonsColor;
01036 Tuple2f fontScales;
01037 bool lockItems;
01038 int fontIndex;
01039 };
01040
01041 #endif //GLWX_H