PixelLightAPI  .
TabBarEntry.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: TabBarEntry.h                                  *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLGUI_TABBARENTRY_H__
00024 #define __PLGUI_TABBARENTRY_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLGui/Gui/Resources/Image.h"
00032 #include "PLGui/Widgets/Widget.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLGui {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class TabBar;
00045 class TabBarButton;
00046 
00047 
00048 //[-------------------------------------------------------]
00049 //[ Classes                                               ]
00050 //[-------------------------------------------------------]
00051 /**
00052 *  @brief
00053 *    Tab bar entry
00054 */
00055 class TabBarEntry : public Widget {
00056 
00057 
00058     //[-------------------------------------------------------]
00059     //[ Class definition                                      ]
00060     //[-------------------------------------------------------]
00061     pl_class(PLGUI_RTTI_EXPORT, TabBarEntry, "PLGui", PLGui::Widget, "Tab bar entry")
00062         pl_constructor_0(DefaultConstructor, "Default constructor", "")
00063     pl_class_end
00064 
00065 
00066     //[-------------------------------------------------------]
00067     //[ Friends                                               ]
00068     //[-------------------------------------------------------]
00069     friend class TabBar;
00070 
00071 
00072     //[-------------------------------------------------------]
00073     //[ Public functions                                      ]
00074     //[-------------------------------------------------------]
00075     public:
00076         /**
00077         *  @brief
00078         *    Constructor
00079         *
00080         *  @param[in] pParent
00081         *    Pointer to parent widget
00082         */
00083         PLGUI_API TabBarEntry(Widget *pParent = nullptr);
00084 
00085         /**
00086         *  @brief
00087         *    Destructor
00088         */
00089         PLGUI_API virtual ~TabBarEntry();
00090 
00091         /**
00092         *  @brief
00093         *    Get TabBar
00094         *
00095         *  @return
00096         *    TabBar
00097         */
00098         PLGUI_API TabBar *GetTabBar() const;
00099 
00100         /**
00101         *  @brief
00102         *    Get text
00103         *
00104         *  @return
00105         *    Text
00106         */
00107         PLGUI_API PLCore::String GetText() const;
00108 
00109         /**
00110         *  @brief
00111         *    Set text
00112         *
00113         *  @param[in] sText
00114         *    Text
00115         */
00116         PLGUI_API void SetText(const PLCore::String &sText);
00117 
00118         /**
00119         *  @brief
00120         *    Get icon
00121         *
00122         *  @return
00123         *    Image
00124         */
00125         PLGUI_API const Image &GetIcon() const;
00126 
00127         /**
00128         *  @brief
00129         *    Set icon
00130         *
00131         *  @param[in] cIcon
00132         *    Image
00133         */
00134         PLGUI_API void SetIcon(const Image &cIcon);
00135 
00136         /**
00137         *  @brief
00138         *    Get associated widget
00139         *
00140         *  @return
00141         *    Widget (can be a null pointer)
00142         *
00143         *  @remarks
00144         *    see SetWidget()
00145         */
00146         PLGUI_API Widget *GetWidget() const;
00147 
00148         /**
00149         *  @brief
00150         *    Set associated widget
00151         *
00152         *  @param[in] pWidget
00153         *    Widget (can be a null pointer)
00154         *
00155         *  @remarks
00156         *    You can use this function to associate a widget with a tab entry.
00157         *    Note however that this is only a pure data slot and is not used by the
00158         *    TabBar at all, so the TabBar doesn't automatically show or hide widgets
00159         *    based on the currently selected tab. If you want functionality like that,
00160         *    you can use TabContainer which has implemented that already and provides
00161         *    a window container with an associated TabBar to select windows.
00162         */
00163         PLGUI_API void SetWidget(Widget *pWidget);
00164 
00165         /**
00166         *  @brief
00167         *    Get associated data
00168         *
00169         *  @return
00170         *    Data pointer
00171         *
00172         *  @remarks
00173         *    see SetData()
00174         */
00175         PLGUI_API void *GetUserData() const;
00176 
00177         /**
00178         *  @brief
00179         *    Set associated data
00180         *
00181         *  @param[in] pData
00182         *    Data pointer
00183         *
00184         *  @remarks
00185         *    You can use this function to associate arbitrary data with a tab entry.
00186         *    This is a pure user data that is not used by the TabBar itself.
00187         */
00188         PLGUI_API void SetUserData(void *pData);
00189 
00190         /**
00191         *  @brief
00192         *    Get tab index
00193         *
00194         *  @return
00195         *    Index of tab
00196         */
00197         PLGUI_API int GetIndex() const;
00198 
00199         /**
00200         *  @brief
00201         *    Check if tab can be closed by the user
00202         *
00203         *  @return
00204         *    'true' if tab is closable, else 'false'
00205         */
00206         PLGUI_API bool IsClosable() const;
00207 
00208 
00209     //[-------------------------------------------------------]
00210     //[ Protected functions                                   ]
00211     //[-------------------------------------------------------]
00212     protected:
00213         /**
00214         *  @brief
00215         *    Set TabBar
00216         *
00217         *  @param[in] pTabBar
00218         *    TabBar
00219         */
00220         PLGUI_API void SetTabBar(TabBar *pTabBar);
00221 
00222         /**
00223         *  @brief
00224         *    Set tab index
00225         *
00226         *  @param[in] nIndex
00227         *    Index of tab
00228         */
00229         PLGUI_API void SetIndex(int nIndex);
00230 
00231         /**
00232         *  @brief
00233         *    Set if tab can be closed by the user
00234         *
00235         *  @param[in] bClosable
00236         *    'true' if tab is closable, else 'false'
00237         */
00238         PLGUI_API void SetClosable(bool bClosable);
00239 
00240 
00241     //[-------------------------------------------------------]
00242     //[ Protected virtual Widget functions                    ]
00243     //[-------------------------------------------------------]
00244     protected:
00245         PLGUI_API virtual PLMath::Vector2i OnPreferredSize(const PLMath::Vector2i &vRefSize) const;
00246         PLGUI_API virtual void OnAdjustContent();
00247         PLGUI_API virtual void OnMouseEnter();
00248         PLGUI_API virtual void OnMouseLeave();
00249         PLGUI_API virtual void OnMouseButtonClick(PLCore::uint32 nButton, const PLMath::Vector2i &vPos);
00250 
00251 
00252     //[-------------------------------------------------------]
00253     //[ Protected data                                        ]
00254     //[-------------------------------------------------------]
00255     protected:
00256         // Tab data
00257         PLCore::String     m_sText;         /**< Text displayed in tab */
00258         Image              m_cIcon;         /**< Tab icon */
00259         Widget            *m_pWidget;       /**< Widget associated with the tab (data only!) */
00260         void              *m_pData;         /**< User data */
00261 
00262         // Internal data (only to be set from TabBar itself!)
00263         TabBar            *m_pTabBar;       /**< TabBar to which the entry belongs */
00264         int                m_nIndex;        /**< Tab index */
00265         bool               m_bClosable;     /**< Can the tab be closed by the user? */
00266 
00267         // Child widgets
00268         TabBarButton      *m_pButtonClose;  /**< Button to close the tab */
00269 
00270 
00271 };
00272 
00273 
00274 //[-------------------------------------------------------]
00275 //[ Namespace                                             ]
00276 //[-------------------------------------------------------]
00277 } // PLGui
00278 
00279 
00280 #endif // __PLGUI_TABBARENTRY_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:04
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported