Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUITabControl.h

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUITabControl.h
00003         created:        08/08/2004
00004         author:         Steve Streeting
00005         
00006         purpose:        Interface to base class for TabControl widget
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUITabControl_h_
00027 #define _CEGUITabControl_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "elements/CEGUITabControlProperties.h"
00032 #include "elements/CEGUITabPane.h"
00033 #include <vector>
00034 
00035 
00036 #if defined(_MSC_VER)
00037 #       pragma warning(push)
00038 #       pragma warning(disable : 4251)
00039 #endif
00040 
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00045 
00046     // Forward declaration
00047     class TabButton;
00048 
00053 class CEGUIBASE_API TabControl : public Window
00054 {
00055 public:
00056         static const String EventNamespace;                             
00057 
00058 
00059         /*************************************************************************
00060                 Constants
00061         *************************************************************************/
00062         // event names
00063         static const String EventSelectionChanged;                      
00064 
00065 
00066         /*************************************************************************
00067                 Accessor Methods
00068         *************************************************************************/
00076         uint    getTabCount(void) const;
00077 
00078 
00084     void    setSelectedTab(const String &name);
00085 
00091     void    setSelectedTab(uint ID);
00092 
00098     void    setSelectedTabAtIndex(uint index);
00099 
00112     Window*     getTabContentsAtIndex(uint index) const;
00113 
00126     Window*     getTabContents(const String& name) const;
00127 
00140     Window*     getTabContents(uint ID) const;
00141 
00154     bool        isTabContentsSelected(Window* wnd) const;
00155 
00163     uint        getSelectedTabIndex() const;
00164         
00169     float getRelativeTabHeight(void) const { return d_rel_tabHeight; }
00174     float getAbsoluteTabHeight(void) const { return d_abs_tabHeight; }
00179     float getTabHeight(void) const;
00185     float getTabTextPadding(void) const;
00190     float getRelativeTabTextPadding(void) const { return d_rel_tabPadding; }
00195     float getAbsoluteTabTextPadding(void) const { return d_abs_tabPadding; }
00196 
00197 
00198     /*************************************************************************
00199                 Manipulator Methods
00200         *************************************************************************/
00211         virtual void    initialise(void);
00212 
00217     void setRelativeTabHeight(float height);
00222     void setAbsoluteTabHeight(float height);
00227     void setTabHeight(float height);
00228 
00234     void setTabTextPadding(float);
00239     void setRelativeTabTextPadding(float);
00244     void setAbsoluteTabTextPadding(float);
00253     void addTab(Window* wnd);
00260     void removeTab(const String& name);
00267     void removeTab(uint ID);
00268 
00269 
00270         /*************************************************************************
00271                 Construction and Destruction
00272         *************************************************************************/
00277         TabControl(const String& type, const String& name);
00278 
00279 
00284         virtual ~TabControl(void);
00285 
00286 
00287 protected:
00288 
00289         /*************************************************************************
00290                 Implementation Functions
00291         *************************************************************************/
00302     virtual     void    drawSelf(float z) { /* do nothing; rendering handled by children */ }
00303 
00308         void    addTabControlEvents(void);
00309 
00314     virtual void addButtonForTabContent(Window* wnd);
00319     virtual void removeButtonForTabContent(Window* wnd);
00325         TabButton* getButtonForTabContents(Window* wnd) const;
00330     String makeButtonName(Window* wnd);
00331     
00338     virtual void selectTab_impl(Window* wnd);
00339 
00340 
00341 
00342         /*************************************************************************
00343                 New event handlers
00344         *************************************************************************/
00345 
00350         virtual void    onSelectionChanged(WindowEventArgs& e);
00351 
00360         virtual void    onFontChanged(WindowEventArgs& e);
00361         /*************************************************************************
00362                 Overridden Event handlers
00363         *************************************************************************/
00364     void onSized(WindowEventArgs& e);
00365 
00366         /*************************************************************************
00367                 Implementation Data
00368         *************************************************************************/
00369     Window*     d_tabButtonPane;    
00370     TabPane*    d_tabContentPane;   
00371     float       d_abs_tabHeight;    
00372     float       d_rel_tabHeight;    
00373     float       d_abs_tabPadding;    
00374     float       d_rel_tabPadding;    
00375     uint        d_nextTabIndex;     
00376     typedef std::map<uint, TabButton*> TabButtonIndexMap; 
00377     TabButtonIndexMap d_tabButtonIndexMap;  
00378     /*************************************************************************
00379     Abstract Implementation Functions (must be provided by derived class)
00380     *************************************************************************/
00388     virtual TabPane*    createTabContentPane(void) const                = 0;
00389 
00397     virtual Window*     createTabButtonPane(void) const;
00398 
00407     virtual TabButton*  createTabButton(const String& name) const               = 0;
00408 
00420     void calculateTabButtonSizePosition(TabButton* btn, uint targetIndex);
00428     virtual void        layoutComponentWidgets();
00429 
00430 protected:
00431         /*************************************************************************
00432                 Static Properties for this class
00433         *************************************************************************/
00434         static TabControlProperties::TabHeight                  d_tabHeightProperty;
00435     static TabControlProperties::AbsoluteTabHeight      d_absoluteTabHeightProperty;
00436     static TabControlProperties::RelativeTabHeight      d_relativeTabHeightProperty;
00437 
00438     static TabControlProperties::TabTextPadding                 d_tabTextPaddingProperty;
00439     static TabControlProperties::AbsoluteTabTextPadding d_absoluteTabTextPaddingProperty;
00440     static TabControlProperties::RelativeTabTextPadding d_relativeTabTextPaddingProperty;
00441         /*************************************************************************
00442                 Private methods
00443         *************************************************************************/
00444         void    addTabControlProperties(void);
00445 
00450     void        addChild_impl(Window* wnd);
00451 
00452     /*************************************************************************
00453     Event handlers
00454     *************************************************************************/
00455     bool handleContentWindowTextChanged(const EventArgs& args);
00456     bool handleTabButtonClicked(const EventArgs& args);
00457 };
00458 
00459 
00460 
00461 } // End of  CEGUI namespace section
00462 
00463 
00464 #if defined(_MSC_VER)
00465 #       pragma warning(pop)
00466 #endif
00467 
00468 #endif  // end of guard _CEGUITabControl_h_

Generated on Wed Feb 16 12:41:07 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1