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 "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
00101 static const String EventSelectionChanged;
00102
00103
00104
00105
00106 static const String ContentPaneNameSuffix;
00107 static const String TabButtonNameSuffix;
00108 static const String TabButtonPaneNameSuffix;
00109 static const String ButtonScrollLeftSuffix;
00110 static const String ButtonScrollRightSuffix;
00111
00112
00113
00114
00115
00123 size_t getTabCount(void) const;
00124
00131 TabPanePosition getTabPanePosition(void) const
00132 { return d_tabPanePos; }
00133
00140 void setTabPanePosition(TabPanePosition pos);
00141
00148 void setSelectedTab(const String &name);
00149
00156 void setSelectedTab(uint ID);
00157
00164 void setSelectedTabAtIndex(size_t index);
00165
00171 void makeTabVisible(const String &name);
00172
00178 void makeTabVisible(uint ID);
00179
00185 void makeTabVisibleAtIndex(size_t index);
00186
00199 Window* getTabContentsAtIndex(size_t index) const;
00200
00213 Window* getTabContents(const String& name) const;
00214
00227 Window* getTabContents(uint ID) const;
00228
00241 bool isTabContentsSelected(Window* wnd) const;
00242
00250 size_t getSelectedTabIndex() const;
00251
00256 const UDim& getTabHeight(void) const { return d_tabHeight; }
00257
00262 const UDim& getTabTextPadding(void) const { return d_tabPadding; }
00263
00264
00265
00266
00267
00278 virtual void initialiseComponents(void);
00279
00284 void setTabHeight(const UDim& height);
00285
00290 void setTabTextPadding(const UDim& padding);
00291
00300 void addTab(Window* wnd);
00307 void removeTab(const String& name);
00314 void removeTab(uint ID);
00315
00316
00317
00318
00319
00324 TabControl(const String& type, const String& name);
00325
00326
00331 virtual ~TabControl(void);
00332
00333
00334 protected:
00335
00336
00337
00338
00349 virtual void drawSelf(const RenderingContext&) { }
00350
00355 virtual void addButtonForTabContent(Window* wnd);
00360 virtual void removeButtonForTabContent(Window* wnd);
00366 TabButton* getButtonForTabContents(Window* wnd) const;
00371 String makeButtonName(Window* wnd);
00372
00379 virtual void selectTab_impl(Window* wnd);
00380
00381
00388 virtual void makeTabVisible_impl(Window* wnd);
00389
00390
00401 virtual bool testClassName_impl(const String& class_name) const
00402 {
00403 if (class_name=="TabControl") return true;
00404 return Window::testClassName_impl(class_name);
00405 }
00406
00418 Window* getTabButtonPane() const;
00419
00431 Window* getTabPane() const;
00432
00433 void performChildWindowLayout();
00434 int writeChildWindowsXML(XMLSerializer& xml_stream) const;
00435
00436
00437 virtual bool validateWindowRenderer(const String& name) const
00438 {
00439 return (name == "TabControl");
00440 }
00441
00450 TabButton* createTabButton(const String& name) const;
00451
00453 void removeTab_impl(Window* window);
00454
00455
00456
00457
00458
00463 virtual void onSelectionChanged(WindowEventArgs& e);
00464
00473 virtual void onFontChanged(WindowEventArgs& e);
00474
00475
00476
00477
00478 UDim d_tabHeight;
00479 UDim d_tabPadding;
00480 typedef std::vector<TabButton*> TabButtonVector;
00481 TabButtonVector d_tabButtonVector;
00482 float d_firstTabOffset;
00483 TabPanePosition d_tabPanePos;
00484 float d_btGrabPos;
00485
00486 std::map<Window*, Event::ScopedConnection> d_eventConnections;
00487
00488
00489
00498
00499
00507 void calculateTabButtonSizePosition(size_t index);
00508
00509 protected:
00510
00511
00512
00513 static TabControlProperties::TabHeight d_tabHeightProperty;
00514 static TabControlProperties::TabTextPadding d_tabTextPaddingProperty;
00515 static TabControlProperties::TabPanePosition d_tabPanePosition;
00516
00517
00518
00519
00520 void addTabControlProperties(void);
00521
00522 void addChild_impl(Window* wnd);
00523 void removeChild_impl(Window* wnd);
00524
00525
00526
00527
00528 bool handleContentWindowTextChanged(const EventArgs& args);
00529 bool handleTabButtonClicked(const EventArgs& args);
00530 bool handleScrollPane(const EventArgs& e);
00531 bool handleDraggedPane(const EventArgs& e);
00532 bool handleWheeledPane(const EventArgs& e);
00533 };
00534
00535
00536 }
00537
00538
00539 #if defined(_MSC_VER)
00540 # pragma warning(pop)
00541 #endif
00542
00543 #endif // end of guard _CEGUITabControl_h_