dlgquestion.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/dlgquestion.h
00003  * \brief MGUI::DLG_QUESTION class definitions
00004  *
00005  * \if NODOC
00006  * $Id: dlgquestion.h_v 1.7 2004/11/19 16:30:54 mju Exp $
00007  *
00008  * $Log: dlgquestion.h_v $
00009  * Revision 1.7  2004/11/19 16:30:54  mju
00010  * Add ability to add non-standard buttons.
00011  * Use INT32 for response values so works with non-std buttons.
00012  *
00013  * Revision 1.6  2003/10/03 19:58:19  linux32build!build
00014  * Doxygen
00015  *
00016  * Revision 1.2  2003/09/08 13:32:29  mju
00017  * Fix virtual override name.
00018  *
00019  * Revision 1.1  2003/09/05 21:26:50  mju
00020  * Initial revision
00021  *
00022  * \endif
00023 **/
00024 
00025 #ifndef  INC_MGUI_DLGQUESTION_H
00026 #define  INC_MGUI_DLGQUESTION_H
00027 
00028 #ifndef  INC_MI32_MDLG_H
00029 #include <mi32/mdlg.h>
00030 #endif
00031 
00032 #ifndef  INC_MGUI_DLGSHELL_H
00033 #include <mgui/dlgshell.h>
00034 #endif
00035 
00036 #ifndef  INC_MGUI_LISTITEM_H
00037 #include <mgui/listitem.h>
00038 #endif
00039 
00040 #ifndef  INC_MGUI_CTRL_H
00041 #include <mgui/ctrl.h>
00042 #endif
00043 
00044 
00045 namespace MGUI {
00046 
00047 //! Dialog to display question to user with pushbutton responses.
00048 //! Also allows for optional toggle to always show / never show.
00049 //! @see MdlgQuestion.
00050 class DLG_QUESTION : public MGUI::DLGSHELL {
00051    public:
00052 
00053       enum TOGGLETYPE {
00054          TOGGLETYPE_NeverAsk,          //!< Toggle "on" to never ask again, default is "off"
00055          TOGGLETYPE_AlwaysAsk          //!< Toggle "on" to always ask, default is "on"
00056          };
00057 
00058       //! Constructor.
00059       DLG_QUESTION (
00060          const MISTRING& dlgtitle,           //!< Text for title
00061          const MISTRING& text,               //!< Text for question
00062          DLGQ_STYLE style,                   //!< Dialog style
00063          INT32 dftresponse,                  //!< Default response value
00064          HELPID helpid = HELPID__None        //!< Help ID
00065          );
00066 
00067       //! Destructor.
00068       ~DLG_QUESTION (
00069          );
00070 
00071       //! Add non-standard button with text and response.
00072       //! Button will be added to left of any "standard" buttons used.
00073       void AddButton (
00074          const MISTRING& text,
00075          INT32 response
00076          );
00077 
00078       //! Determine if user doesn't want to see question again.
00079       //! @return true if user does not want to see question, false if does.
00080       bool CheckNoShow (
00081          ) const;
00082 
00083       //! Get response from dialog.
00084       INT32 GetResponse (
00085          ) const { return (m_response); }
00086 
00087       //! Set up toggle for whether user wants to see question again.
00088       //! @return true if user does not want to see question, false if does.
00089       bool SetupToggle (
00090          const char *IniGroup,               //!< Ini group
00091          const char *IniName,                //!< Ini name to store toggle state
00092          const MISTRING& ToggleText,         //!< Text to show for toggle
00093          TOGGLETYPE ToggleType               //!< Meaning of toggle
00094          );
00095 
00096    private:
00097 
00098       #ifndef GENERATING_DOXYGEN_OUTPUT
00099       class BUTTON : public MGUI::CTRL_PUSHBUTTON {
00100          public:
00101             BUTTON (
00102                DLG_QUESTION *pDlg,
00103                INT32 response
00104                );
00105             BUTTON (
00106                const BUTTON& rhs
00107                );
00108             void Create (
00109                MGUI::LAYOUT_PANE_BASE& ParentPane,
00110                const char *label
00111                ) { CTRL_PUSHBUTTON::Create(ParentPane,label,true); }
00112             void Create (
00113                MGUI::LAYOUT_PANE_BASE& ParentPane,
00114                const MISTRING& label
00115                ) { CTRL_PUSHBUTTON::Create(ParentPane,label,true); }
00116          private:
00117             DLG_QUESTION *m_pDlg;
00118             INT32 m_response;
00119             virtual void OnPressed ();
00120          };
00121 
00122       INT32 m_response;
00123       MISTRING m_text;
00124       DLGQ_STYLE m_style;
00125       MILIST<LISTITEM> m_ExtraButtonItems;
00126       char *m_ToggleIniGroup;
00127       char *m_ToggleIniName;
00128       MISTRING m_ToggleText;
00129       TOGGLETYPE m_ToggleType;
00130       CTRL_LABEL m_TextLabel;
00131       CTRL_TOGGLEBUTTON_T<DLG_QUESTION> m_Toggle;
00132       MILIST<BUTTON> m_Buttons;
00133 
00134       BUTTON& CreateButtonLow (
00135          const char *label,
00136          DLGRESPONSE response
00137          );
00138 
00139       void OnToggle ();
00140 
00141       void SetResponse (
00142          INT32 response
00143          ) { m_response = response; }
00144 
00145       //! DLGSHELL overrides.
00146       virtual ERRVALUE v_CreateContent ();
00147       virtual void v_OnCancel ();
00148       virtual void v_OnOK ();
00149 
00150       friend class DLG_QUESTION::BUTTON;
00151       #endif // GENERATING_DOXYGEN_OUTPUT
00152    };
00153 
00154 
00155 }  // End namespace MGUI
00156 
00157 
00158 #endif   // INC_MGUI_DLGQUESTION_H

Generated on Wed May 31 15:26:44 2006 for TNTsdk by  doxygen 1.3.8-20040913