00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CEGUITabControl_h_
00031 #define _CEGUITabControl_h_
00032
00033 #include "CEGUIBase.h"
00034 #include "CEGUIWindow.h"
00035 #include "elements/CEGUITabControlProperties.h"
00036 #include <vector>
00037
00038
00039 #if defined(_MSC_VER)
00040 # pragma warning(push)
00041 # pragma warning(disable : 4251)
00042 #endif
00043
00044
00045
00046 namespace CEGUI
00047 {
00048
00049
00050 class TabButton;
00051
00056 class CEGUIEXPORT TabControlWindowRenderer : public WindowRenderer
00057 {
00058 public:
00063 TabControlWindowRenderer(const String& name);
00064
00073 virtual TabButton* createTabButton(const String& name) const = 0;
00074 };
00075
00080 class CEGUIEXPORT TabControl : public Window
00081 {
00082 public:
00083 static const String EventNamespace;
00084 static const String WidgetTypeName;
00085
00086 enum TabPanePosition
00087 {
00088 Top,
00089 Bottom
00090 };
00091
00092
00093
00094
00095
00096 static const String EventSelectionChanged;
00097
00098
00099
00100
00101 static const String ContentPaneNameSuffix;
00102 static const String TabButtonNameSuffix;
00103 static const String TabButtonPaneNameSuffix;
00104 static const String ButtonScrollLeftSuffix;
00105 static const String ButtonScrollRightSuffix;
00106
00107
00108
00109
00110
00118 size_t getTabCount(void) const;
00119
00126 TabPanePosition getTabPanePosition(void) const
00127 { return d_tabPanePos; }
00128
00135 void setTabPanePosition(TabPanePosition pos);
00136
00143 void setSelectedTab(const String &name);
00144
00151 void setSelectedTab(uint ID);
00152
00159 void setSelectedTabAtIndex(size_t index);
00160
00166 void makeTabVisible(const String &name);
00167
00173 void makeTabVisible(uint ID);
00174
00180 void makeTabVisibleAtIndex(size_t index);
00181
00194 Window* getTabContentsAtIndex(size_t index) const;
00195
00208 Window* getTabContents(const String& name) const;
00209
00222 Window* getTabContents(uint ID) const;
00223
00236 bool isTabContentsSelected(Window* wnd) const;
00237
00245 size_t getSelectedTabIndex() const;
00246
00251 const UDim& getTabHeight(void) const { return d_tabHeight; }
00252
00257 const UDim& getTabTextPadding(void) const { return d_tabPadding; }
00258
00259
00260
00261
00262
00273 virtual void initialiseComponents(void);
00274
00279 void setTabHeight(const UDim& height);
00280
00285 void setTabTextPadding(const UDim& padding);
00286
00295 void addTab(Window* wnd);
00302 void removeTab(const String& name);
00309 void removeTab(uint ID);
00310
00311
00312
00313
00314
00319 TabControl(const String& type, const String& name);
00320
00321
00326 virtual ~TabControl(void);
00327
00328
00329 protected:
00330
00331
00332
00333
00344 virtual void drawSelf(float z) { }
00345
00350 virtual void addButtonForTabContent(Window* wnd);
00355 virtual void removeButtonForTabContent(Window* wnd);
00361 TabButton* getButtonForTabContents(Window* wnd) const;
00366 String makeButtonName(Window* wnd);
00367
00374 virtual void selectTab_impl(Window* wnd);
00375
00376
00383 virtual void makeTabVisible_impl(Window* wnd);
00384
00385
00396 virtual bool testClassName_impl(const String& class_name) const
00397 {
00398 if (class_name=="TabControl") return true;
00399 return Window::testClassName_impl(class_name);
00400 }
00401
00413 Window* getTabButtonPane() const;
00414
00426 Window* getTabPane() const;
00427
00428 void performChildWindowLayout();
00429 int writeChildWindowsXML(XMLSerializer& xml_stream) const;
00430
00431
00432 virtual bool validateWindowRenderer(const String& name) const
00433 {
00434 return (name == "TabControl");
00435 }
00436
00445 TabButton* createTabButton(const String& name) const;
00446
00448 void removeTab_impl(Window* window);
00449
00450
00451
00452
00453
00458 virtual void onSelectionChanged(WindowEventArgs& e);
00459
00468 virtual void onFontChanged(WindowEventArgs& e);
00469
00470
00471
00472
00473 UDim d_tabHeight;
00474 UDim d_tabPadding;
00475 typedef std::vector<TabButton*> TabButtonVector;
00476 TabButtonVector d_tabButtonVector;
00477 float d_firstTabOffset;
00478 TabPanePosition d_tabPanePos;
00479 float d_btGrabPos;
00480
00481 std::map<Window*, Event::ScopedConnection> d_eventConnections;
00482
00483
00484
00493
00494
00502 void calculateTabButtonSizePosition(size_t index);
00503
00504 protected:
00505
00506
00507
00508 static TabControlProperties::TabHeight d_tabHeightProperty;
00509 static TabControlProperties::TabTextPadding d_tabTextPaddingProperty;
00510 static TabControlProperties::TabPanePosition d_tabPanePosition;
00511
00512
00513
00514
00515 void addTabControlProperties(void);
00516
00517 void addChild_impl(Window* wnd);
00518 void removeChild_impl(Window* wnd);
00519
00520
00521
00522
00523 bool handleContentWindowTextChanged(const EventArgs& args);
00524 bool handleTabButtonClicked(const EventArgs& args);
00525 bool handleScrollPane(const EventArgs& e);
00526 bool handleDraggedPane(const EventArgs& e);
00527 bool handleWheeledPane(const EventArgs& e);
00528 };
00529
00530
00531 }
00532
00533
00534 #if defined(_MSC_VER)
00535 # pragma warning(pop)
00536 #endif
00537
00538 #endif // end of guard _CEGUITabControl_h_