PixelLightAPI  .
ScrollWidget.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ScrollWidget.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_SCROLLWIDGET_H__
00024 #define __PLGUI_SCROLLWIDGET_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 ScrollBar;
00044 
00045 
00046 //[-------------------------------------------------------]
00047 //[ Classes                                               ]
00048 //[-------------------------------------------------------]
00049 /**
00050 *  @brief
00051 *    Container that allows it's content to be scrolled
00052 */
00053 class ScrollWidget : public ContainerWidget {
00054 
00055 
00056     //[-------------------------------------------------------]
00057     //[ Class definition                                      ]
00058     //[-------------------------------------------------------]
00059     pl_class(PLGUI_RTTI_EXPORT, ScrollWidget, "PLGui", PLGui::ContainerWidget, "Container that allows it's content to be scrolled")
00060         // Attributes
00061         pl_attribute(ScrollBarStyleX,   pl_enum_type(EScrollBarStyle),  ScrollBarStyleDynamic,  ReadWrite,  GetSet, "Style of horizontal scrollbar",    "")
00062         pl_attribute(ScrollBarStyleY,   pl_enum_type(EScrollBarStyle),  ScrollBarStyleDynamic,  ReadWrite,  GetSet, "Style of horizontal scrollbar",    "")
00063         // Constructors
00064         pl_constructor_0(DefaultConstructor,    "Default constructor",  "")
00065         // Slots
00066         pl_slot_1(OnInnerWidgetSize,    const PLMath::Vector2i&,    "Size callback",        "")
00067         pl_slot_1(OnScrollBarXChanged,  int,                        "Scrollbar callback",   "")
00068         pl_slot_1(OnScrollBarYChanged,  int,                        "Scrollbar callback",   "")
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 ScrollWidget(Widget *pParent = nullptr);
00084 
00085         /**
00086         *  @brief
00087         *    Destructor
00088         */
00089         PLGUI_API virtual ~ScrollWidget();
00090 
00091         /**
00092         *  @brief
00093         *    Get scrollbar style of horizontal scrollbar
00094         *
00095         *  @return
00096         *    Scrollbar style (when to show the scrollbar)
00097         */
00098         PLGUI_API EScrollBarStyle GetScrollBarStyleX() const;
00099 
00100         /**
00101         *  @brief
00102         *    Set scrollbar style of horizontal scrollbar
00103         *
00104         *  @param[in] nStyle
00105         *    Scrollbar style (when to show the scrollbar)
00106         *
00107         *  @remarks
00108         *    Use this to define if a scrollbar shall be visible always, never
00109         *    or be hidden if it is currently not needed.
00110         */
00111         PLGUI_API void SetScrollBarStyleX(EScrollBarStyle nStyle);
00112 
00113         /**
00114         *  @brief
00115         *    Get scrollbar style of vertical scrollbar
00116         *
00117         *  @return
00118         *    Scrollbar style (when to show the scrollbar)
00119         */
00120         PLGUI_API EScrollBarStyle GetScrollBarStyleY() const;
00121 
00122         /**
00123         *  @brief
00124         *    Set scrollbar style of vertical scrollbar
00125         *
00126         *  @param[in] nStyle
00127         *    Scrollbar style (when to show the scrollbar)
00128         *
00129         *  @remarks
00130         *    Use this to define if a scrollbar shall be visible always, never
00131         *    or be hidden if it is currently not needed.
00132         */
00133         PLGUI_API void SetScrollBarStyleY(EScrollBarStyle nStyle);
00134 
00135         /**
00136         *  @brief
00137         *    Get content widget
00138         *
00139         *  @return
00140         *    Content widget
00141         */
00142         PLGUI_API virtual Widget *GetContentWidget() const;
00143 
00144 
00145     //[-------------------------------------------------------]
00146     //[ Public virtual Widget functions                       ]
00147     //[-------------------------------------------------------]
00148     public:
00149         PLGUI_API virtual void OnSize(const PLMath::Vector2i &vSize) override;
00150         PLGUI_API virtual void OnAdjustContent() override;
00151 
00152 
00153     //[-------------------------------------------------------]
00154     //[ Protected functions                                   ]
00155     //[-------------------------------------------------------]
00156     protected:
00157         /**
00158         *  @brief
00159         *    Called when the size of the inner window has changed
00160         *
00161         *  @param[in] vSize
00162         *    Size
00163         */
00164         void OnInnerWidgetSize(const PLMath::Vector2i &vSize);
00165 
00166         /**
00167         *  @brief
00168         *    Called when the horizontal scrollbar has changed it's value
00169         *
00170         *  @param[in] nX
00171         *    New X-position
00172         */
00173         void OnScrollBarXChanged(int nX);
00174 
00175         /**
00176         *  @brief
00177         *    Called when the vertical scrollbar has changed it's value
00178         *
00179         *  @param[in] nY
00180         *    New Y-position
00181         */
00182         void OnScrollBarYChanged(int nY);
00183 
00184         /**
00185         *  @brief
00186         *    Show or hide scroll bars according to the widget size
00187         */
00188         void AdjustScrollBars();
00189 
00190 
00191     //[-------------------------------------------------------]
00192     //[ Protected data                                        ]
00193     //[-------------------------------------------------------]
00194     protected:
00195         // Options
00196         EScrollBarStyle  m_nScrollBarStyleX;    /**< Scrollbar style for horizontal scrollbar */
00197         EScrollBarStyle  m_nScrollBarStyleY;    /**< Scrollbar style for vertical scrollbar */
00198 
00199         // Data
00200         Widget          *m_pInnerWidget;        /**< Innermost widget that is scrolled */
00201         ScrollBar       *m_pScrollBarX;         /**< Scroll bar (horizontal) */
00202         ScrollBar       *m_pScrollBarY;         /**< Scroll bar (vertical) */
00203         bool             m_bScrollBarX;         /**< Is a horizontal scrollbar visible? */
00204         bool             m_bScrollBarY;         /**< Is a vertical scrollbar visible? */
00205 
00206 
00207 };
00208 
00209 
00210 //[-------------------------------------------------------]
00211 //[ Namespace                                             ]
00212 //[-------------------------------------------------------]
00213 } // PLGui
00214 
00215 
00216 #endif // __PLGUI_SCROLLWIDGET_H__


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