PixelLightAPI  .
Window.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Window.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_WINDOW_H__
00024 #define __PLGUI_WINDOW_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLGui/Widgets/Containers/ContainerWidget.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLGui {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Forward declarations                                  ]
00042 //[-------------------------------------------------------]
00043 class SystemButton;
00044 
00045 
00046 //[-------------------------------------------------------]
00047 //[ Classes                                               ]
00048 //[-------------------------------------------------------]
00049 /**
00050 *  @brief
00051 *    Base class for windows (widgets with a border and a title bar)
00052 */
00053 class Window : public ContainerWidget {
00054 
00055 
00056     //[-------------------------------------------------------]
00057     //[ Class definition                                      ]
00058     //[-------------------------------------------------------]
00059     pl_class(PLGUI_RTTI_EXPORT, Window, "PLGui", PLGui::Widget, "Base class for windows (widgets with a border and a title bar)")
00060         // Attributes
00061         pl_attribute(SystemButtons, pl_flag_type(ESystemButton),    7,                          ReadWrite,  GetSet, "System Buttons",               "")
00062         pl_attribute(ShowTitleBar,  bool,                           true,                       ReadWrite,  GetSet, "Show title bar?",              "")
00063         pl_attribute(ShowBorder,    bool,                           true,                       ReadWrite,  GetSet, "Show border?",                 "")
00064         pl_attribute(Resizable,     bool,                           true,                       ReadWrite,  GetSet, "Is window resizable?",         "")
00065         pl_attribute(MinSize,       PLMath::Vector2i,               PLMath::Vector2i(-1, -1),   ReadWrite,  GetSet, "Minimum size for resizing",    "")
00066         pl_attribute(MaxSize,       PLMath::Vector2i,               PLMath::Vector2i(-1, -1),   ReadWrite,  GetSet, "Maximum size for resizing",    "")
00067         // Constructors
00068         pl_constructor_0(DefaultConstructor,    "Default constructor",  "")
00069     pl_class_end
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 Window(Widget *pParent = nullptr);
00084 
00085         /**
00086         *  @brief
00087         *    Destructor
00088         */
00089         PLGUI_API virtual ~Window();
00090 
00091         /**
00092         *  @brief
00093         *    Get system buttons
00094         *
00095         *  @return
00096         *    Flags describing the displayed system buttons
00097         */
00098         PLGUI_API PLCore::uint32 GetSystemButtons() const;
00099 
00100         /**
00101         *  @brief
00102         *    Set system buttons
00103         *
00104         *  @param[in] nButtons
00105         *    Flags describing the displayed system buttons
00106         */
00107         PLGUI_API void SetSystemButtons(PLCore::uint32 nButtons);
00108 
00109         /**
00110         *  @brief
00111         *    Check if a title bar is displayed
00112         *
00113         *  @return
00114         *    'true' if title bar is visible, else 'false'
00115         */
00116         PLGUI_API bool GetShowTitleBar() const;
00117 
00118         /**
00119         *  @brief
00120         *    Set if a title bar is displayed
00121         *
00122         *  @param[in] bVisible
00123         *    'true' if title bar is visible, else 'false'
00124         */
00125         PLGUI_API void SetShowTitleBar(bool bVisible);
00126 
00127         /**
00128         *  @brief
00129         *    Check if a border is displayed
00130         *
00131         *  @return
00132         *    'true' if border is visible, else 'false'
00133         */
00134         PLGUI_API bool GetShowBorder() const;
00135 
00136         /**
00137         *  @brief
00138         *    Set if a border is displayed
00139         *
00140         *  @param[in] bVisible
00141         *    'true' if border is visible, else 'false'
00142         */
00143         PLGUI_API void SetShowBorder(bool bVisible);
00144 
00145         /**
00146         *  @brief
00147         *    Check if the window is resizable
00148         *
00149         *  @return
00150         *    'true' if window is resizable, else 'false'
00151         */
00152         PLGUI_API bool GetResizable() const;
00153 
00154         /**
00155         *  @brief
00156         *    Set if the window is resizable
00157         *
00158         *  @param[in] bResizable
00159         *    'true' if window is resizable, else 'false'
00160         */
00161         PLGUI_API void SetResizable(bool bResizable);
00162 
00163         /**
00164         *  @brief
00165         *    Get minimum size for resizing
00166         *
00167         *  @return
00168         *    Size
00169         */
00170         PLGUI_API PLMath::Vector2i GetMinSize() const;
00171 
00172         /**
00173         *  @brief
00174         *    Set minimum size for resizing
00175         *
00176         *  @param[in] vSize
00177         *    Size
00178         */
00179         PLGUI_API void SetMinSize(const PLMath::Vector2i &vSize);
00180 
00181         /**
00182         *  @brief
00183         *    Get maximum size for resizing
00184         *
00185         *  @return
00186         *    Size
00187         */
00188         PLGUI_API PLMath::Vector2i GetMaxSize() const;
00189 
00190         /**
00191         *  @brief
00192         *    Set maximum size for resizing
00193         *
00194         *  @param[in] vSize
00195         *    Size
00196         */
00197         PLGUI_API void SetMaxSize(const PLMath::Vector2i &vSize);
00198 
00199 
00200     //[-------------------------------------------------------]
00201     //[ Protected virtual WidgetFunctions functions           ]
00202     //[-------------------------------------------------------]
00203     protected:
00204         PLGUI_API virtual void OnDraw(Graphics &cGraphics) override;
00205         PLGUI_API virtual void OnAdjustContent() override;
00206         PLGUI_API virtual void OnWindowState(EWindowState nWindowState) override;
00207         PLGUI_API virtual void OnEnterFullscreen() override;
00208         PLGUI_API virtual void OnLeaveFullscreen() override;
00209         PLGUI_API virtual void OnActivate(bool bActivate) override;
00210         PLGUI_API virtual void OnMove(const PLMath::Vector2i &vPos) override;
00211         PLGUI_API virtual void OnMouseMove(const PLMath::Vector2i &vPos) override;
00212         PLGUI_API virtual void OnMousePosUpdate(const PLMath::Vector2i &vPos) override;
00213         PLGUI_API virtual void OnMouseLeave() override;
00214         PLGUI_API virtual void OnMouseButtonDown(PLCore::uint32 nButton, const PLMath::Vector2i &vPos) override;
00215         PLGUI_API virtual void OnMouseButtonUp(PLCore::uint32 nButton, const PLMath::Vector2i &vPos) override;
00216         PLGUI_API virtual void OnMouseButtonDoubleClick(PLCore::uint32 nButton, const PLMath::Vector2i &vPos) override;
00217 
00218 
00219     //[-------------------------------------------------------]
00220     //[ Protected data                                        ]
00221     //[-------------------------------------------------------]
00222     protected:
00223         // Exported variables
00224         PLCore::uint32       m_nSystemButtons;      /**< System buttons that are available in this window */
00225         bool                 m_bShowTitleBar;       /**< Show title of window? */
00226         bool                 m_bShowBorder;         /**< Show window border? */
00227         bool                 m_bResizable;          /**< Is window resizable? */
00228 
00229         // Data
00230         PLMath::Vector2i     m_vMinSize;            /**< Minimum size for resizing */
00231         PLMath::Vector2i     m_vMaxSize;            /**< Maximum size for resizing */
00232 
00233         // System buttons
00234         SystemButton        *m_pSysButtonMinimize;  /**< System button to minimize the window size */
00235         SystemButton        *m_pSysButtonMaximize;  /**< System button to maximize or restore the window size */
00236         SystemButton        *m_pSysButtonClose;     /**< System button to close the window */
00237 
00238         // Movement state
00239         PLMath::Vector2i     m_vPos;                /**< Current widget position */
00240         PLMath::Vector2i     m_vMousePos;           /**< Current mouse position */
00241         bool                 m_bMouseTitle;         /**< Is the mouse position on the title bar? */
00242         bool                 m_bMouseLeft;          /**< Is the mouse position on the left border? */
00243         bool                 m_bMouseRight;         /**< Is the mouse position on the right border? */
00244         bool                 m_bMouseTop;           /**< Is the mouse position on the top border? */
00245         bool                 m_bMouseBottom;        /**< Is the mouse position on the bottom border? */
00246         bool                 m_bMove;               /**< Is the window currently moved? */
00247         bool                 m_bSizeXLeft;          /**< Is the window currently sized (left border)? */
00248         bool                 m_bSizeXRight;         /**< Is the window currently sized (right border)? */
00249         bool                 m_bSizeYTop;           /**< Is the window currently sized (top border)? */
00250         bool                 m_bSizeYBottom;        /**< Is the window currently sized (bottom border)? */
00251 
00252 
00253 };
00254 
00255 
00256 //[-------------------------------------------------------]
00257 //[ Namespace                                             ]
00258 //[-------------------------------------------------------]
00259 } // PLGui
00260 
00261 
00262 #endif // __PLGUI_WINDOW_H__


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