Crazy Eddies GUI System: CEGUITabControl.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# CEGUITabControl.h

    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 CEGUIEXPORT 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
    00351         virtual bool    testClassName_impl(const String& class_name) const
    00352         {
    00353                 if (class_name==(const utf8*)"TabControl")      return true;
    00354                 return Window::testClassName_impl(class_name);
    00355         }
    00356
    00357         void performChildWindowLayout();
    00358     int writeChildWindowsXML(OutStream& out_stream) const;
    00359
    00360         /*************************************************************************
    00361                 New event handlers
    00362         *************************************************************************/
    00363
    00368         virtual void    onSelectionChanged(WindowEventArgs& e);
    00369
    00378         virtual void    onFontChanged(WindowEventArgs& e);
    00379
    00380         /*************************************************************************
    00381                 Implementation Data
    00382         *************************************************************************/
    00383     Window*     d_tabButtonPane;
    00384     TabPane*    d_tabContentPane;
    00385     float       d_abs_tabHeight;
    00386     float       d_rel_tabHeight;
    00387     float       d_abs_tabPadding;
    00388     float       d_rel_tabPadding;
    00389     uint        d_nextTabIndex;
    00390     typedef std::map<uint, TabButton*> TabButtonIndexMap;
    00391     TabButtonIndexMap d_tabButtonIndexMap;
    00392     /*************************************************************************
    00393     Abstract Implementation Functions (must be provided by derived class)
    00394     *************************************************************************/
    00405     virtual TabPane*    createTabContentPane(const String& name) const          = 0;
    00406
    00417     virtual Window*     createTabButtonPane(const String& name) const;
    00418
    00427     virtual TabButton*  createTabButton(const String& name) const               = 0;
    00428
    00440     void calculateTabButtonSizePosition(TabButton* btn, uint targetIndex);
    00441
    00442 protected:
    00443         /*************************************************************************
    00444                 Static Properties for this class
    00445         *************************************************************************/
    00446         static TabControlProperties::TabHeight                  d_tabHeightProperty;
    00447     static TabControlProperties::AbsoluteTabHeight      d_absoluteTabHeightProperty;
    00448     static TabControlProperties::RelativeTabHeight      d_relativeTabHeightProperty;
    00449
    00450     static TabControlProperties::TabTextPadding                 d_tabTextPaddingProperty;
    00451     static TabControlProperties::AbsoluteTabTextPadding d_absoluteTabTextPaddingProperty;
    00452     static TabControlProperties::RelativeTabTextPadding d_relativeTabTextPaddingProperty;
    00453         /*************************************************************************
    00454                 Private methods
    00455         *************************************************************************/
    00456         void    addTabControlProperties(void);
    00457
    00458     void    addChild_impl(Window* wnd);
    00459     void    removeChild_impl(Window* wnd);
    00460
    00461     /*************************************************************************
    00462     Event handlers
    00463     *************************************************************************/
    00464     bool handleContentWindowTextChanged(const EventArgs& args);
    00465     bool handleTabButtonClicked(const EventArgs& args);
    00466 };
    00467
    00468
    00469
    00470 } // End of  CEGUI namespace section
    00471
    00472
    00473 #if defined(_MSC_VER)
    00474 #       pragma warning(pop)
    00475 #endif
    00476
    00477 #endif  // end of guard _CEGUITabControl_h_