PixelLightAPI  .
Label.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Label.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_LABEL_H__
00024 #define __PLGUI_LABEL_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLGraphics/Color/Color4.h>
00032 #include "PLGui/Gui/Resources/Font.h"
00033 #include "PLGui/Widgets/Widget.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLGui {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Classes                                               ]
00044 //[-------------------------------------------------------]
00045 /**
00046 *  @brief
00047 *    Widget that displays a static text
00048 */
00049 class Label : public Widget {
00050 
00051 
00052     //[-------------------------------------------------------]
00053     //[ Class definition                                      ]
00054     //[-------------------------------------------------------]
00055     pl_class(PLGUI_RTTI_EXPORT, Label, "PLGui", PLGui::Widget, "Widget that displays a static text")
00056         // Attributes
00057         pl_attribute(Color,     PLGraphics::Color4,         PLGraphics::Color4::Black,  ReadWrite,  GetSet, "Text color",                   "")
00058         pl_attribute(Align,     pl_enum_type(EAlign),       AlignLeft,                  ReadWrite,  GetSet, "Text alignment (horizontal)",  "")
00059         pl_attribute(VAlign,    pl_enum_type(EVAlign),      AlignMiddle,                ReadWrite,  GetSet, "Text alignment (vertical)",    "")
00060         pl_attribute(Wrap,      pl_enum_type(ETextWrap),    TextWrap,                   ReadWrite,  GetSet, "Text wrapping",                "")
00061         pl_attribute(Style,     pl_flag_type(ETextStyle),   0,                          ReadWrite,  GetSet, "Text style",                   "")
00062         pl_attribute(Text,      PLCore::String,             "",                         ReadWrite,  GetSet, "Text label",                   "")
00063         // Constructors
00064         pl_constructor_0(DefaultConstructor,    "Default constructor",  "")
00065     pl_class_end
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 Label(Widget *pParent = nullptr);
00080 
00081         /**
00082         *  @brief
00083         *    Destructor
00084         */
00085         PLGUI_API virtual ~Label();
00086 
00087         /**
00088         *  @brief
00089         *    Get font
00090         *
00091         *  @return
00092         *    Font
00093         */
00094         PLGUI_API const Font &GetFont() const;
00095 
00096         /**
00097         *  @brief
00098         *    Set font
00099         *
00100         *  @param[in] cFont
00101         *    Font
00102         */
00103         PLGUI_API void SetFont(const Font &cFont);
00104 
00105         /**
00106         *  @brief
00107         *    Get color
00108         *
00109         *  @return
00110         *    Color
00111         */
00112         PLGUI_API PLGraphics::Color4 GetColor() const;
00113 
00114         /**
00115         *  @brief
00116         *    Set color
00117         *
00118         *  @param[in] cColor
00119         *    Color
00120         */
00121         PLGUI_API void SetColor(const PLGraphics::Color4 &cColor);
00122 
00123         /**
00124         *  @brief
00125         *    Get horizontal alignment
00126         *
00127         *  @return
00128         *    Alignment
00129         */
00130         PLGUI_API EAlign GetAlign() const;
00131 
00132         /**
00133         *  @brief
00134         *    Set horizontal alignment
00135         *
00136         *  @param[in] nAlign
00137         *    Alignment
00138         */
00139         PLGUI_API void SetAlign(EAlign nAlign);
00140 
00141         /**
00142         *  @brief
00143         *    Get vertical alignment
00144         *
00145         *  @return
00146         *    Alignment
00147         */
00148         PLGUI_API EVAlign GetVAlign() const;
00149 
00150         /**
00151         *  @brief
00152         *    Set vertical alignment
00153         *
00154         *  @param[in] nAlign
00155         *    Alignment
00156         */
00157         PLGUI_API void SetVAlign(EVAlign nAlign);
00158 
00159         /**
00160         *  @brief
00161         *    Get text wrapping
00162         *
00163         *  @return
00164         *    Wrapping mode
00165         */
00166         PLGUI_API ETextWrap GetWrap() const;
00167 
00168         /**
00169         *  @brief
00170         *    Set text wrapping
00171         *
00172         *  @param[in] nWrap
00173         *    Wrapping mode
00174         */
00175         PLGUI_API void SetWrap(ETextWrap nWrap);
00176 
00177         /**
00178         *  @brief
00179         *    Get text style
00180         *
00181         *  @return
00182         *    Text style
00183         */
00184         PLGUI_API PLCore::uint32 GetStyle() const;
00185 
00186         /**
00187         *  @brief
00188         *    Set text style
00189         *
00190         *  @param[in] nStyle
00191         *    Text style
00192         */
00193         PLGUI_API void SetStyle(PLCore::uint32 nStyle);
00194 
00195         /**
00196         *  @brief
00197         *    Get text
00198         *
00199         *  @return
00200         *    Text
00201         */
00202         PLGUI_API PLCore::String GetText() const;
00203 
00204         /**
00205         *  @brief
00206         *    Set text
00207         *
00208         *  @param[in] sText
00209         *    Text
00210         */
00211         PLGUI_API void SetText(const PLCore::String &sText);
00212 
00213 
00214     //[-------------------------------------------------------]
00215     //[ Protected virtual WidgetFunctions functions           ]
00216     //[-------------------------------------------------------]
00217     private:
00218         PLGUI_API virtual PLMath::Vector2i OnPreferredSize(const PLMath::Vector2i &vRefSize) const override;
00219         PLGUI_API virtual void OnDraw(Graphics &cGraphics) override;
00220 
00221 
00222     //[-------------------------------------------------------]
00223     //[ Private data                                          ]
00224     //[-------------------------------------------------------]
00225     private:
00226         // Exported variables
00227         PLGraphics::Color4  m_cColor;
00228         EAlign              m_nAlign;
00229         EVAlign             m_nVAlign;
00230         ETextWrap           m_nWrap;
00231         PLCore::uint32      m_nStyle;
00232         PLCore::String      m_sText;
00233 
00234         // Private data
00235         Font                m_cFont;        /**< Used font */
00236 
00237 
00238 };
00239 
00240 
00241 //[-------------------------------------------------------]
00242 //[ Namespace                                             ]
00243 //[-------------------------------------------------------]
00244 } // PLGui
00245 
00246 
00247 #endif // __PLGUI_LABEL_H__


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