PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: WindowContainer.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_WINDOWCONTAINER_H__ 00024 #define __PLGUI_WINDOWCONTAINER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Container/List.h> 00032 #include "PLGui/Widgets/Widget.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLGui { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Base class for window containers 00047 */ 00048 class WindowContainer : public Widget { 00049 00050 00051 //[-------------------------------------------------------] 00052 //[ Class definition ] 00053 //[-------------------------------------------------------] 00054 pl_class(PLGUI_RTTI_EXPORT, WindowContainer, "PLGui", PLGui::Widget, "Base class for window containers") 00055 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00056 pl_class_end 00057 00058 00059 //[-------------------------------------------------------] 00060 //[ Public events ] 00061 //[-------------------------------------------------------] 00062 public: 00063 PLCore::Event<Widget*> EventAddWindow; /**< Window has been added */ 00064 PLCore::Event<Widget*> EventRemoveWindow; /**< Window has been removed */ 00065 PLCore::Event<int> EventSelectWindow; /**< Current selection has been changed */ 00066 00067 00068 //[-------------------------------------------------------] 00069 //[ Public functions ] 00070 //[-------------------------------------------------------] 00071 public: 00072 /** 00073 * @brief 00074 * Constructor 00075 * 00076 * @param[in] pParent 00077 * Pointer to parent widget 00078 */ 00079 PLGUI_API WindowContainer(Widget *pParent = nullptr); 00080 00081 /** 00082 * @brief 00083 * Destructor 00084 */ 00085 PLGUI_API virtual ~WindowContainer(); 00086 00087 /** 00088 * @brief 00089 * Get content widget 00090 * 00091 * @return 00092 * Content widget 00093 * 00094 * @remarks 00095 * If a widget is a container for other widgets, a container widget is often used as the parent for all of 00096 * the child widgets. This is e.g. necessary to separate the "outside" from the "inside", e.g. there may be 00097 * other (internal) child widgets, that are also children of the same parent (e.g. buttons in the title bar or 00098 * frame widgets). So if you want to insert widgets inside other widgets, you should use the widget returned 00099 * by GetContentWidget() as the parent widget, not the widget itself. If a widget don't have a content widget, 00100 * it will return a pointer to itself as the content widget. 00101 */ 00102 PLGUI_API virtual Widget *GetContentWidget() const; 00103 00104 /** 00105 * @brief 00106 * Clear container 00107 */ 00108 PLGUI_API void Clear(); 00109 00110 /** 00111 * @brief 00112 * Get list of windows inside the container 00113 * 00114 * @return 00115 * List of windows 00116 */ 00117 PLGUI_API const PLCore::Container<Widget*> &GetWindows() const; 00118 00119 /** 00120 * @brief 00121 * Add window to container 00122 * 00123 * @param[in] pWindow 00124 * Window 00125 */ 00126 PLGUI_API void AddWindow(Widget *pWindow); 00127 00128 /** 00129 * @brief 00130 * Remove window from container 00131 * 00132 * @param[in] pWindow 00133 * Window 00134 */ 00135 PLGUI_API void RemoveWindow(Widget *pWindow); 00136 00137 /** 00138 * @brief 00139 * Get currently selected window 00140 * 00141 * @return 00142 * Index of currently selected window 00143 */ 00144 PLGUI_API int GetSelection() const; 00145 00146 /** 00147 * @brief 00148 * Set currently selected window 00149 * 00150 * @param[in] nWindow 00151 * Index of currently selected window 00152 */ 00153 PLGUI_API void SetSelection(int nWindow); 00154 00155 /** 00156 * @brief 00157 * Set currently selected window 00158 * 00159 * @param[in] pWindow 00160 * Pointer to currently selected window 00161 */ 00162 PLGUI_API void SetSelection(Widget *pWindow); 00163 00164 00165 //[-------------------------------------------------------] 00166 //[ Protected virtual WindowContainer functions ] 00167 //[-------------------------------------------------------] 00168 protected: 00169 /** 00170 * @brief 00171 * Called when a window has been added 00172 * 00173 * @param[in] pWindow 00174 * Window 00175 */ 00176 PLGUI_API virtual void OnAddWindow(Widget *pWindow); 00177 00178 /** 00179 * @brief 00180 * Called when a window has been removed 00181 * 00182 * @param[in] pWindow 00183 * Window 00184 */ 00185 PLGUI_API virtual void OnRemoveWindow(Widget *pWindow); 00186 00187 /** 00188 * @brief 00189 * Called when the current selection has been changed 00190 * 00191 * @param[in] nWindow 00192 * Index of currently selected window 00193 */ 00194 PLGUI_API virtual void OnSelectWindow(int nWindow); 00195 00196 00197 //[-------------------------------------------------------] 00198 //[ Protected virtual Widget functions ] 00199 //[-------------------------------------------------------] 00200 protected: 00201 PLGUI_API virtual void OnAdjustContent(); 00202 00203 00204 //[-------------------------------------------------------] 00205 //[ Protected data ] 00206 //[-------------------------------------------------------] 00207 public: 00208 Widget *m_pContentWidget; /**< Inner widget that contains the content windows */ 00209 PLCore::List<Widget*> m_lstWindows; /**< List of windows */ 00210 int m_nSelection; /**< Index of currently selected window */ 00211 Widget *m_pSelection; /**< Pointer to currently selected window */ 00212 00213 00214 }; 00215 00216 00217 //[-------------------------------------------------------] 00218 //[ Namespace ] 00219 //[-------------------------------------------------------] 00220 } // PLGui 00221 00222 00223 #endif // __PLGUI_WINDOWCONTAINER_H__
|