PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: TabContainer.h * 00003 * 00004 * Copyright (C) 2002-2012 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_TABCONTAINER_H__ 00024 #define __PLGUI_TABCONTAINER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLGui/Widgets/Containers/WindowContainer.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLGui { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 class TabBar; 00044 class TabBarEntry; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Tab container 00053 */ 00054 class TabContainer : public WindowContainer { 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Class definition ] 00059 //[-------------------------------------------------------] 00060 pl_class(PLGUI_RTTI_EXPORT, TabContainer, "PLGui", PLGui::WindowContainer, "Tab container") 00061 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00062 pl_class_end 00063 00064 00065 //[-------------------------------------------------------] 00066 //[ Public events ] 00067 //[-------------------------------------------------------] 00068 public: 00069 PLCore::Event<> EventCreateWindow; /**< New window shall be created */ 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 TabContainer(Widget *pParent = nullptr); 00084 00085 /** 00086 * @brief 00087 * Destructor 00088 */ 00089 PLGUI_API virtual ~TabContainer(); 00090 00091 /** 00092 * @brief 00093 * Get side the tabbar is positioned on 00094 * 00095 * @return 00096 * Side 00097 */ 00098 PLGUI_API ESide GetSide() const; 00099 00100 /** 00101 * @brief 00102 * Set side the tabbar is positioned on 00103 * 00104 * @param[in] nSide 00105 * Side 00106 */ 00107 PLGUI_API void SetSide(ESide nSide); 00108 00109 /** 00110 * @brief 00111 * Get TabBar options 00112 * 00113 * @return 00114 * TabBar options (combination of ETabBarOption values) 00115 */ 00116 PLGUI_API PLCore::uint32 GetOptions() const; 00117 00118 /** 00119 * @brief 00120 * Set TabBar options 00121 * 00122 * @param[in] nOptions 00123 * TabBar options 00124 */ 00125 PLGUI_API void SetOptions(PLCore::uint32 nOptions); 00126 00127 /** 00128 * @brief 00129 * Get tab width 00130 * 00131 * @return 00132 * Tab width 00133 * 00134 * @remarks 00135 * see SetTabWidth() 00136 */ 00137 PLGUI_API PLCore::uint32 GetTabWidth() const; 00138 00139 /** 00140 * @brief 00141 * Set tab width 00142 * 00143 * @param[in] nWidth 00144 * Tab width 00145 * 00146 * @note 00147 * - If side is SideTop or SideBottom and StaticTabSize is *not* set, tabs have a floating size. 00148 * In that case, the width set by nWidth is the maximum size that a tab can have. 00149 * - If side is SideLeft or SideRight, or StaticTabSize is set, tabs have a static size. 00150 * In that case, every tab will get exactly the width set by nWidth. 00151 */ 00152 PLGUI_API void SetTabWidth(PLCore::uint32 nWidth); 00153 00154 /** 00155 * @brief 00156 * Get tab height 00157 * 00158 * @return 00159 * Tab height 00160 */ 00161 PLGUI_API PLCore::uint32 GetTabHeight() const; 00162 00163 /** 00164 * @brief 00165 * Set tab height 00166 * 00167 * @param[in] nHeight 00168 * Tab height 00169 */ 00170 PLGUI_API void SetTabHeight(PLCore::uint32 nHeight); 00171 00172 00173 //[-------------------------------------------------------] 00174 //[ Protected virtual TabContainer functions ] 00175 //[-------------------------------------------------------] 00176 protected: 00177 /** 00178 * @brief 00179 * Called when a new window shall be created 00180 */ 00181 PLGUI_API void OnCreateWindow(); 00182 00183 00184 //[-------------------------------------------------------] 00185 //[ Protected virtual WindowContainer functions ] 00186 //[-------------------------------------------------------] 00187 protected: 00188 PLGUI_API virtual void OnAddWindow(Widget *pWindow); 00189 PLGUI_API virtual void OnRemoveWindow(Widget *pWindow); 00190 PLGUI_API virtual void OnSelectWindow(int nWindow); 00191 00192 00193 //[-------------------------------------------------------] 00194 //[ Protected virtual Widget functions ] 00195 //[-------------------------------------------------------] 00196 protected: 00197 PLGUI_API virtual void OnAdjustContent(); 00198 00199 00200 //[-------------------------------------------------------] 00201 //[ Private functions ] 00202 //[-------------------------------------------------------] 00203 private: 00204 /** 00205 * @brief 00206 * Called when a tab to be is closed 00207 * 00208 * @param[in] pTab 00209 * Tab 00210 */ 00211 void OnTabBarCloseTab(TabBarEntry *pTab); 00212 00213 /** 00214 * @brief 00215 * Called when the current selection has been changed 00216 * 00217 * @param[in] nTab 00218 * Index of currently selected tab 00219 */ 00220 void OnTabBarSelectTab(int nTab); 00221 00222 /** 00223 * @brief 00224 * Called when a new tab shall be created 00225 */ 00226 void OnTabBarCreateTab(); 00227 00228 /** 00229 * @brief 00230 * Find tab that belongs to a certain window 00231 * 00232 * @param[in] pWindow 00233 * Window 00234 * 00235 * @return 00236 * Tab entry belonging to the window (or a null pointer) 00237 */ 00238 TabBarEntry *FindTab(Widget *pWindow) const; 00239 00240 00241 //[-------------------------------------------------------] 00242 //[ Protected data ] 00243 //[-------------------------------------------------------] 00244 public: 00245 // Event handlers 00246 PLCore::EventHandler<TabBarEntry*> EventHandlerCloseTab; 00247 PLCore::EventHandler<int> EventHandlerSelectTab; 00248 PLCore::EventHandler<> EventHandlerCreateTab; 00249 00250 // Widgets 00251 TabBar *m_pTabBar; /**< Tab-bar */ 00252 00253 00254 }; 00255 00256 00257 //[-------------------------------------------------------] 00258 //[ Namespace ] 00259 //[-------------------------------------------------------] 00260 } // PLGui 00261 00262 00263 #endif // __PLGUI_TABCONTAINER_H__
|