PixelLightAPI  .
WidgetHandler.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: WidgetHandler.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_WIDGETHANDLER_H__
00024 #define __PLGUI_WIDGETHANDLER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Event/EventHandler.h>
00032 #include "PLGui/PLGui.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLGui {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class Widget;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Classes                                               ]
00049 //[-------------------------------------------------------]
00050 /**
00051 *  @brief
00052 *    Widget handler class
00053 *
00054 *  @remarks
00055 *    A widget handler is a smart pointer to widgets. Use it whenever you want to store a pointer
00056 *    to a widget for a longer time, this way you can be sure that the pointer will be reset to a null pointer
00057 *    if the widget has been destroyed in the meantime.
00058 */
00059 class WidgetHandler {
00060 
00061 
00062     //[-------------------------------------------------------]
00063     //[ Public functions                                      ]
00064     //[-------------------------------------------------------]
00065     public:
00066         /**
00067         *  @brief
00068         *    Constructor
00069         */
00070         PLGUI_API WidgetHandler();
00071 
00072         /**
00073         *  @brief
00074         *    Copy constructor
00075         *
00076         *  @param[in] cOther
00077         *    Widget handler
00078         */
00079         PLGUI_API WidgetHandler(const WidgetHandler &cOther);
00080 
00081         /**
00082         *  @brief
00083         *    Destructor
00084         */
00085         PLGUI_API ~WidgetHandler();
00086 
00087         /**
00088         *  @brief
00089         *    Get widget pointer
00090         *
00091         *  @return
00092         *    Pointer to widget, can be a null pointer
00093         */
00094         PLGUI_API Widget *GetWidget() const;
00095 
00096         /**
00097         *  @brief
00098         *    Set widget pointer
00099         *
00100         *  @param[in] pWidget
00101         *    Pointer to widget, can be a null pointer
00102         *
00103         *  @return
00104         *    'true' if all went fine, else 'false'
00105         */
00106         PLGUI_API bool SetWidget(Widget *pWidget);
00107 
00108         /**
00109         *  @brief
00110         *    Clear widget pointer
00111         */
00112         PLGUI_API void Clear();
00113 
00114         /**
00115         *  @brief
00116         *    Check if the widget pointer is valid
00117         *
00118         *  @return
00119         *    'true' if the handler points to a valid widget, else 'false'
00120         */
00121         PLGUI_API bool IsValid() const;
00122 
00123         /**
00124         *  @brief
00125         *    Compare operator
00126         *
00127         *  @param[in] cOther
00128         *    Widget handler
00129         *
00130         *  @return
00131         *    'true' if equal, else 'false'
00132         */
00133         PLGUI_API bool operator ==(const WidgetHandler &cOther) const;
00134 
00135         /**
00136         *  @brief
00137         *    Assignment operator
00138         *
00139         *  @param[in] cOther
00140         *    Widget handler
00141         *
00142         *  @return
00143         *    Reference to this object
00144         */
00145         PLGUI_API WidgetHandler &operator =(const WidgetHandler &cOther);
00146 
00147 
00148     //[-------------------------------------------------------]
00149     //[ Private functions                                     ]
00150     //[-------------------------------------------------------]
00151     private:
00152         void OnWidgetDestroy();
00153 
00154 
00155     //[-------------------------------------------------------]
00156     //[ Private data                                          ]
00157     //[-------------------------------------------------------]
00158     private:
00159         // Event handlers
00160         PLCore::EventHandler<>  EventHandlerDestroy;    /**< Widget is going to be destroyed */
00161 
00162         // Data
00163         Widget *m_pWidget; /**< Pointer to widget, can be a null pointer */
00164 
00165 
00166 };
00167 
00168 
00169 //[-------------------------------------------------------]
00170 //[ Namespace                                             ]
00171 //[-------------------------------------------------------]
00172 } // PLGui
00173 
00174 
00175 #endif // __PLGUI_WIDGETHANDLER_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:01
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported