Update of /cvsroot/mahogany/M/include/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1181/include/gui

Modified Files:
        wxOptionsPage.h 
Log Message:
really fixed identity editing: now the pages in the identity dialog are of correct 
(dynamically determined) type; in particular the field of disabled authentificators 
may now be set at identity level

Index: wxOptionsPage.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/gui/wxOptionsPage.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -b -u -2 -r1.68 -r1.69
--- wxOptionsPage.h     11 Jul 2004 21:41:52 -0000      1.68
+++ wxOptionsPage.h     19 Sep 2004 15:41:15 -0000      1.69
@@ -191,10 +191,4 @@
    int HelpId(void) const { return m_HelpId; }
 
-   /// only for HandleButton() hack, don't call directly
-   bool IsControl(wxObject *obj, size_t n) const
-   {
-      return GetControl(n) == obj;
-   }
-
 protected:
    /// get the name of the folder we're editing the options of
@@ -221,4 +215,10 @@
       { return m_aControls[n - m_nFirst]; }
 
+   // check whether the given object is the field with this index
+   bool IsControl(wxObject *obj, size_t n) const
+   {
+      return GetControl(n) == obj;
+   }
+
    // get the dirty flag for the control with index n
    bool IsDirty(size_t n) const
@@ -334,4 +334,16 @@
    static const ConfigValueDefault ms_aConfigDefaults[];
 
+protected:
+   // ctor for pages created via static New()
+   wxOptionsPageStandard(wxNotebook *parent,
+                         const wxChar *title,
+                         Profile *profile,
+                         FieldInfoArray aFields,
+                         ConfigValuesArray aDefaults,
+                         size_t nFields,
+                         size_t nOffset = 0,
+                         int helpID = -1,
+                         int image = -1);
+
 private:
    DECLARE_NO_COPY_CLASS(wxOptionsPageStandard)
@@ -371,4 +383,20 @@
                         int image = -1);
 
+   // for wxOptionsPageDesc usage
+   static wxOptionsPage *New(wxNotebook *parent,
+                             const wxChar *title,
+                             Profile *profile,
+                             FieldInfoArray aFields,
+                             ConfigValuesArray aDefaults,
+                             size_t nFields,
+                             size_t nOffset = 0,
+                             int helpID = -1,
+                             int image = -1)
+   {
+      return new wxOptionsPageDynamic(parent, title, profile,
+                                      aFields, aDefaults, nFields, nOffset,
+                                      helpID, image);
+   }
+
 private:
    DECLARE_NO_COPY_CLASS(wxOptionsPageDynamic)
@@ -378,37 +406,82 @@
 // using this structure is more convenient than passing all these parameters
 // around separately
+//
+// this used to be a dummy struct, now it is a real class but we'd have to
+// change all fwd declarations if we changed it here, so leave it alone
 struct wxOptionsPageDesc
 {
+public:
+   // a pointer to creation function may be specified to create a page of given
+   // type instead of generic wxOptionsPageDynamic
+   typedef wxOptionsPage *(*NewFunc_t)
+                           (
+                              wxNotebook *parent,
+                              const wxChar *title,
+                              Profile *profile,
+                              wxOptionsPage::FieldInfoArray aFields,
+                              ConfigValuesArray aDefaults,
+                              size_t nFields,
+                              size_t nOffset,
+                              int helpID,
+                              int image
+                           );
+
+   // default ctor needed to be able to create arrays of these objects, but it
+   // really should never be used
    wxOptionsPageDesc()
    {
-      nFields = 0;
    }
 
-   wxOptionsPageDesc(const wxChar *title_,
-                     const wxChar *image_,
-                     int helpId_,
-                     const wxOptionsPage::FieldInfo *aFields_,
-                     ConfigValuesArray aDefaults_,
-                     size_t nFields_,
-                     size_t nOffset_ = 0)
-      : title(title_),
-        image(image_),
-        helpId(helpId_),
-        aFields(aFields_),
-        aDefaults(aDefaults_),
-        nFields(nFields_),
-        nOffset(nOffset_)
+   wxOptionsPageDesc(const wxChar *title,
+                     const wxChar *image,
+                     int helpId,
+                     const wxOptionsPage::FieldInfo *aFields,
+                     ConfigValuesArray aDefaults,
+                     size_t nFields,
+                     size_t nOffset = 0,
+                     NewFunc_t createFunc = wxOptionsPageDynamic::New)
+      : m_title(title),
+        m_image(image),
+        m_helpId(helpId),
+        m_aFields(aFields),
+        m_aDefaults(aDefaults),
+        m_nFields(nFields),
+        m_nOffset(nOffset),
+        m_pfnNew(createFunc)
    {
    }
 
-   String title;        // the page title in the notebook
-   String image;        // image
+   // create a page from this description
+   wxOptionsPage *New(wxNotebook *parent, Profile *profile, int image) const
+   {
+      return (*m_pfnNew)
+             (
+                parent,
+                wxGetTranslation(m_title),
+                profile,
+                m_aFields,
+                m_aDefaults,
+                m_nFields,
+                m_nOffset,
+                m_helpId,
+                image
+             );
+   }
+
+   const String& GetImage() const { return m_image; }
+
+private:
+   String m_title;        // the page title in the notebook
+   String m_image;        // image
 
-   int helpId;
+   int m_helpId;
 
    // the fields description
-   const wxOptionsPage::FieldInfo *aFields;
-   ConfigValuesArray aDefaults;
-   size_t nFields, nOffset;
+   const wxOptionsPage::FieldInfo *m_aFields;
+   ConfigValuesArray m_aDefaults;
+   size_t m_nFields,
+          m_nOffset;
+
+   NewFunc_t m_pfnNew;
 };
 
@@ -439,5 +512,38 @@
    virtual bool TransferDataFromWindow();
 
+   // for wxOptionsPageDesc
+   static wxOptionsPage *New(wxNotebook *parent,
+                             const wxChar *title,
+                             Profile *profile,
+                             FieldInfoArray aFields,
+                             ConfigValuesArray aDefaults,
+                             size_t nFields,
+                             size_t nOffset = 0,
+                             int helpID = -1,
+                             int image = -1)
+   {
+      return new wxOptionsPageNetwork(parent, title, profile,
+                                      aFields, aDefaults, nFields, nOffset,
+                                      helpID, image);
+   }
+
 private:
+   // ctor for New()
+   wxOptionsPageNetwork(wxNotebook *parent,
+                        const wxChar *title,
+                        Profile *profile,
+                        FieldInfoArray aFields,
+                        ConfigValuesArray aDefaults,
+                        size_t nFields,
+                        size_t nOffset = 0,
+                        int helpID = -1,
+                        int image = -1)
+      : wxOptionsPageStandard(parent, title, profile,
+                              aFields, aDefaults, nFields, nOffset,
+                              helpID, image)
+   {
+   }
+
+
    wxString m_oldAuthsDisabled;
 
@@ -483,12 +589,37 @@
    void OnButton(wxCommandEvent& event);
 
-   // the meat of OnButton(): also used by the identity dialog
-   //
-   // return true if btn is one of our buttons, false if we didn't handle it
-   static bool HandleButton(Profile *profile,
-                            wxObject *btn,
-                            wxOptionsPage *win);
+   // for wxOptionsPageDesc
+   static wxOptionsPage *New(wxNotebook *parent,
+                             const wxChar *title,
+                             Profile *profile,
+                             FieldInfoArray aFields,
+                             ConfigValuesArray aDefaults,
+                             size_t nFields,
+                             size_t nOffset = 0,
+                             int helpID = -1,
+                             int image = -1)
+   {
+      return new wxOptionsPageCompose(parent, title, profile,
+                                      aFields, aDefaults, nFields, nOffset,
+                                      helpID, image);
+   }
 
 private:
+   // ctor for New()
+   wxOptionsPageCompose(wxNotebook *parent,
+                        const wxChar *title,
+                        Profile *profile,
+                        FieldInfoArray aFields,
+                        ConfigValuesArray aDefaults,
+                        size_t nFields,
+                        size_t nOffset = 0,
+                        int helpID = -1,
+                        int image = -1)
+      : wxOptionsPageStandard(parent, title, profile,
+                              aFields, aDefaults, nFields, nOffset,
+                              helpID, image)
+   {
+   }
+
    DECLARE_EVENT_TABLE()
    DECLARE_NO_COPY_CLASS(wxOptionsPageCompose)



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to