wxIScan
wxoptionsdialog.h
Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 // Project:     wxIView
00003 // Purpose:     Complex wxWidgets sample
00004 // Name:        wxoptionsdialog.h
00005 // Author:      Daniel Nell
00006 // Created:     2006/02/16
00007 // Copyright:   (c) Daniel Nell
00008 // Licence:     wxWindows licence
00009 // Modified by:
00010 /////////////////////////////////////////////////////////////////////////////
00011 
00012 #ifndef __WXOPTIONSDIALOG_H
00013 #define __WXOPTIONSDIALOG_H
00014 
00015 
00016 /////////////////////////////////////////////////////////////////////////////
00017 //  Constants
00018 //
00019 #define WXOPTIONSDIALOGMAXOPTION   100
00020 #define WXOPTIONSDIALOGIDOPTION    31101
00021 
00022 
00023 /////////////////////////////////////////////////////////////////////////////
00024 //  Forward declarations
00025 //
00026 class wxBoxSizer;
00027 class wxCheckBox;
00028 class wxStaticLine;
00029 class wxBookCtrlBase;
00030 
00031 
00032 /////////////////////////////////////////////////////////////////////////////
00033 //  class wxOptionBase
00034 //
00035 /// \brief The (abstract) option for an options dialog.
00036 ///
00037 /// This class represents an (abstract) option (more or less an inteface)
00038 /// used by inheriting classes in an options dialog.
00039 class wxOptionBase
00040 {
00041   public:
00042     /// Default constructor.
00043     wxOptionBase(){}
00044 
00045     /// Virtual destructor.
00046     virtual ~wxOptionBase(){};
00047 
00048   public:
00049     // Abstract member functions
00050     virtual bool AddToSizer( wxBoxSizer *poSizer ) = 0;    ///< ...
00051     virtual void Setup( wxWindow *poWindow, int nId ) = 0; ///< ...
00052     virtual void StoreValue() = 0;                         ///< In implementation: Store the value in the connected variables.
00053 };
00054 
00055 
00056 /////////////////////////////////////////////////////////////////////////////
00057 //  class wxOptionStaticLine
00058 //
00059 /// \brief The static line pseudo option for an options dialog.
00060 ///
00061 /// This class represents a static line object used in an option
00062 /// dialog.
00063 class wxOptionStaticLine : public wxOptionBase
00064 {
00065   public:
00066     /// \brief Default constructor.
00067     wxOptionStaticLine();
00068 
00069   public:
00070     // Member functions
00071     virtual bool AddToSizer( wxBoxSizer *poSizer );        ///< ...
00072     virtual void Setup( wxWindow *poWindow, int nId );     ///< ... (Nothing to do.)
00073     virtual void StoreValue(){}                            ///< Store the value in the connected variables. (Nothing to do.)
00074 
00075   protected:
00076     // Member variables.
00077     wxStaticLine *m_poStaticLine;
00078 };
00079 
00080 
00081 /////////////////////////////////////////////////////////////////////////////
00082 //  class wxOptionCheckBox
00083 //
00084 /// \brief The boolean option for an options dialog.
00085 ///
00086 /// This class represents a boolean (checkbox) option used in an
00087 /// options dialog.
00088 class wxOptionCheckBox : public wxOptionBase
00089 {
00090   public:
00091     /// \brief Default constructor.
00092     ///
00093     /// \param  strText         ...
00094     /// \param  pbValue         ...
00095     wxOptionCheckBox( const wxString &strText, bool *pbValue );
00096 
00097   public:
00098     // Member functions
00099     virtual bool AddToSizer( wxBoxSizer *poSizer );     ///< ...
00100     virtual void Setup( wxWindow *poWindow, int nId );  ///< ...
00101     virtual void StoreValue();                          ///< Store the value in the connected variables.
00102 
00103   protected:
00104     // Member variables.
00105     bool *m_pbValue;                                    ///< ...
00106     wxCheckBox *m_poCheckBox;                           ///< ...
00107     wxString m_strText;                                 ///< ...
00108 };
00109 
00110 
00111 /////////////////////////////////////////////////////////////////////////////
00112 //  class wxOptionTextBox
00113 //
00114 /// \brief The text input box for an options dialog.
00115 ///
00116 /// This class represents a text (wxTextCtrl) option used in an
00117 /// options dialog.
00118 class wxOptionTextBox : public wxOptionBase
00119 {
00120   public:
00121     /// \brief Default constructor.
00122     ///
00123     /// \param  strText         ...
00124     /// \param  pstrValue       ...
00125     /// \param  nWidth          ...
00126     wxOptionTextBox( const wxString &strText, wxString *pstrValue, int nWidth= 400 );
00127 
00128   public:
00129     // Member functions
00130     virtual bool AddToSizer( wxBoxSizer *poSizer );     ///< ...
00131     virtual void Setup( wxWindow *poWindow, int nId );  ///< ...
00132     virtual void StoreValue();                          ///< Store the value in the connected variables.
00133 
00134   protected:
00135     wxWindow *m_poWindow;                               ///< ...
00136     wxString m_strText;                                 ///< ...
00137     wxString *m_pstrValue;                              ///< ...
00138     wxTextCtrl *m_poTextCtrl;                           ///< ...
00139     int m_nWidth;                                       ///< ...
00140 };
00141 
00142 
00143 /////////////////////////////////////////////////////////////////////////////
00144 //  class wxOptionComboBox
00145 //
00146 /// \brief The text input box with history for an options dialog.
00147 ///
00148 /// This class represents a text option with history (wxComboBox)
00149 /// used in an options dialog.
00150 class wxOptionComboBox : public wxOptionBase
00151 {
00152   public:
00153     /// \brief Default constructor.
00154     ///
00155     /// \param  strText         ...
00156     /// \param  pstrValue       ...
00157     /// \param  nWidth          ...
00158     wxOptionComboBox( const wxString &strText, wxString *pstrValue, int nWidth= 400 );
00159 
00160     /// \brief Virtual destructor.
00161     virtual ~wxOptionComboBox();
00162 
00163   public:
00164     // Member functions
00165     virtual bool AddToSizer( wxBoxSizer *poSizer );     ///< ...
00166     virtual void Setup( wxWindow *poWindow, int nId );  ///< ...
00167     virtual void StoreValue();                          ///< Store the value in the connected variables.
00168 
00169   protected:
00170     wxWindow *m_poWindow;                               ///< ...
00171     wxString m_strText;                                 ///< ...
00172     wxString *m_pstrValue;                              ///< ...
00173     wxComboBox *m_poComboBox;                           ///< ComboBox control
00174     int m_nWidth;                                       ///< ...
00175     int m_nId;                                          ///< ID of the control (for the config section).
00176     wxArrayString m_astrValueHistory;                   ///< Array of historical entries for the drop down list.
00177 };
00178 
00179 
00180 /////////////////////////////////////////////////////////////////////////////
00181 //  class wxOptionsDialog
00182 //
00183 /// \brief The standard options dialog.
00184 ///
00185 /// This class represents the application's options dialog.
00186 class wxOptionsDialog : public wxDialog
00187 {
00188   public:
00189     /// \brief Standard constructor
00190     ///
00191     /// \param poParentWindow   a pointer to parent window (the window owner).
00192     wxOptionsDialog( wxWindow *poParentWindow );
00193 
00194     /// Virtual destructor.
00195     virtual ~wxOptionsDialog();
00196 
00197   public:
00198     // Member functions
00199     virtual void SetupDialog();                             ///< Setup the dialog window.
00200     virtual bool AppendOption( wxOptionBase *poOption );    ///< Append the given option object to the options list.
00201     virtual wxWindow *GetParent(){ return this; }           ///< ...
00202 
00203   protected:
00204     void OnOk( wxCommandEvent& oEvent );                    ///< Handler for pressed OK button.
00205 
00206   protected:
00207     int m_nOptionCount;                                     ///< Number of option objects.
00208     int m_nOptionId;                                        ///< ID of the next control to add.
00209     wxOptionBase *m_apoOptions[WXOPTIONSDIALOGMAXOPTION];   ///< Array of option objects.
00210 
00211   private:
00212     // Any class wishing to process wxWindows events must use this macro.
00213     DECLARE_EVENT_TABLE()
00214 };
00215 
00216 
00217 #if __NOTYETRELEASED__ >= 2
00218 /////////////////////////////////////////////////////////////////////////////
00219 //  class wxOptionsBookDialog
00220 //
00221 /// \brief The list-/choice-/notebook options dialog.
00222 ///
00223 /// This class represents the application's options dialog with tabs.
00224 class wxOptionsBookDialog : public wxOptionsDialog
00225 {
00226   public:
00227     /// \brief Standard constructor
00228     ///
00229     /// \param poParentWindow   a pointer to parent window (the window owner).
00230     /// \param strPageName      the name of the page/tab.
00231     /// \param poBookCtrl       a pointer to the note-/list-/choicebook control.
00232     wxOptionsBookDialog( wxWindow *poParentWindow, const wxString &strPageName,
00233                          wxBookCtrlBase *poBookCtrl= NULL );
00234 
00235   public:
00236     // Member functions
00237     virtual wxWindow *GetParent(){ return m_poParentForControls; } ///< ...
00238     virtual bool AddPage( const wxString &strPageName);     ///< ...
00239 
00240   protected:
00241     wxBookCtrlBase *m_poBookCtrl;                           ///< ...
00242     wxWindow *m_poParentForControls;                        ///< ...
00243 };
00244 #endif // __NOTYETRELEASED__
00245 
00246 #endif // __WXOPTIONSDIALOG_H