PixelLightAPI  .
MessageBox.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: MessageBox.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_MESSAGEBOX_H__
00024 #define __PLGUI_MESSAGEBOX_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/String/String.h>
00032 #include <PLCore/Base/Event/EventHandler.h>
00033 #include "PLGui/Widgets/Windows/Dialog.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLGui {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Forward declarations                                  ]
00044 //[-------------------------------------------------------]
00045 class Label;
00046 class Button;
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Classes                                               ]
00051 //[-------------------------------------------------------]
00052 /**
00053 *  @brief
00054 *    Message box
00055 */
00056 class MessageBox : public Dialog {
00057 
00058 
00059     //[-------------------------------------------------------]
00060     //[ Class definition                                      ]
00061     //[-------------------------------------------------------]
00062     pl_class(PLGUI_RTTI_EXPORT, MessageBox, "PLGui", PLGui::Dialog, "Message box")
00063         pl_constructor_0(DefaultConstructor, "Default constructor", "")
00064     pl_class_end
00065 
00066 
00067     //[-------------------------------------------------------]
00068     //[ Public functions                                      ]
00069     //[-------------------------------------------------------]
00070     public:
00071         /**
00072         *  @brief
00073         *    Constructor
00074         *
00075         *  @param[in] pParent
00076         *    Pointer to parent widget
00077         *  @param[in] nType
00078         *    Message box type
00079         *  @param[in] sTitle
00080         *    Message box title
00081         *  @param[in] sText
00082         *    Message box text
00083         */
00084         PLGUI_API MessageBox(Widget *pParent = nullptr, EMessageBox nType = MessageBoxOk, const PLCore::String &sTitle = "Message Box", const PLCore::String &sText = "Message");
00085 
00086         /**
00087         *  @brief
00088         *    Constructor
00089         *
00090         *  @param[in] nType
00091         *    Message box type
00092         *  @param[in] sTitle
00093         *    Message box title
00094         *  @param[in] sText
00095         *    Message box text
00096         */
00097         PLGUI_API MessageBox(EMessageBox nType, const PLCore::String &sTitle, const PLCore::String &sText);
00098 
00099         /**
00100         *  @brief
00101         *    Destructor
00102         */
00103         PLGUI_API virtual ~MessageBox();
00104 
00105         /**
00106         *  @brief
00107         *    Get message box type
00108         *
00109         *  @return
00110         *    Type of message box
00111         */
00112         PLGUI_API EMessageBox GetType() const;
00113 
00114         /**
00115         *  @brief
00116         *    Get text
00117         *
00118         *  @return
00119         *    Text
00120         */
00121         PLGUI_API PLCore::String GetText() const;
00122 
00123         /**
00124         *  @brief
00125         *    Set text
00126         *
00127         *  @param[in] sText
00128         *    Text
00129         */
00130         PLGUI_API void SetText(const PLCore::String &sText);
00131 
00132         /**
00133         *  @brief
00134         *    Get button text
00135         *
00136         *  @param[in] nButton
00137         *    Button ID
00138         *
00139         *  @return
00140         *    Text
00141         */
00142         PLGUI_API PLCore::String GetButtonText(EMessageBoxButton nButton) const;
00143 
00144         /**
00145         *  @brief
00146         *    Set button text
00147         *
00148         *  @param[in] nButton
00149         *    Button ID
00150         *  @param[in] sText
00151         *    Text
00152         */
00153         PLGUI_API void SetButtonText(EMessageBoxButton nButton, const PLCore::String &sText);
00154 
00155 
00156     //[-------------------------------------------------------]
00157     //[ Private virtual Dialog functions                      ]
00158     //[-------------------------------------------------------]
00159     private:
00160         PLGUI_API virtual void OnCloseDialog(int nResult);
00161 
00162 
00163     //[-------------------------------------------------------]
00164     //[ Private functions                                     ]
00165     //[-------------------------------------------------------]
00166     public:
00167         /**
00168         *  @brief
00169         *    Create message box
00170         *
00171         *  @param[in] nType
00172         *    Message box type
00173         *  @param[in] sTitle
00174         *    Message box title
00175         *  @param[in] sText
00176         *    Message box text
00177         */
00178         void CreateMessageBox(EMessageBox nType, const PLCore::String &sTitle, const PLCore::String &sText);
00179 
00180         /**
00181         *  @brief
00182         *    Button 'Ok' has been clicked
00183         */
00184         void OnButtonOk();
00185 
00186         /**
00187         *  @brief
00188         *    Button 'Cancel' has been clicked
00189         */
00190         void OnButtonCancel();
00191 
00192         /**
00193         *  @brief
00194         *    Button 'Yes' has been clicked
00195         */
00196         void OnButtonYes();
00197 
00198         /**
00199         *  @brief
00200         *    Button 'No' has been clicked
00201         */
00202         void OnButtonNo();
00203 
00204 
00205     //[-------------------------------------------------------]
00206     //[ Private data                                          ]
00207     //[-------------------------------------------------------]
00208     private:
00209         // Event handlers
00210         PLCore::EventHandler<>  EventHandlerOk;
00211         PLCore::EventHandler<>  EventHandlerCancel;
00212         PLCore::EventHandler<>  EventHandlerYes;
00213         PLCore::EventHandler<>  EventHandlerNo;
00214 
00215         // Data
00216         EMessageBox          m_nType;           /**< Message box type */
00217         PLCore::String       m_sText;           /**< Message box text */
00218 
00219         // Widgets
00220         Label               *m_pLabel;          /**< Text label */
00221         Box                 *m_pBox;            /**< Button box */
00222         Button              *m_pButtonOk;       /**< Button 'Ok' */
00223         Button              *m_pButtonCancel;   /**< Button 'Cancel' */
00224         Button              *m_pButtonYes;      /**< Button 'Yes' */
00225         Button              *m_pButtonNo;       /**< Button 'No' */
00226 
00227 
00228 };
00229 
00230 
00231 //[-------------------------------------------------------]
00232 //[ Namespace                                             ]
00233 //[-------------------------------------------------------]
00234 } // PLGui
00235 
00236 
00237 #endif // __PLGUI_MESSAGEBOX_H__


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