Update of /cvsroot/mahogany/M/src/util
In directory sc8-pr-cvs1:/tmp/cvs-serv1491/src/util

Modified Files:
        upgrade.cpp 
Log Message:
fixed adding the page to the sizers twice; added justTest parameter to 
RunInstallWizard()

Index: upgrade.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/util/upgrade.cpp,v
retrieving revision 1.203
retrieving revision 1.204
diff -b -u -2 -r1.203 -r1.204
--- upgrade.cpp 30 Apr 2003 00:17:17 -0000      1.203
+++ upgrade.cpp 21 Jul 2003 00:22:36 -0000      1.204
@@ -57,4 +57,5 @@
 #include <wx/confbase.h>
 #include <wx/fileconf.h>
+#include <wx/sizer.h>
 
 #ifdef USE_DIALUP
@@ -217,5 +218,5 @@
 #ifdef USE_WIZARD
 
-#ifndef OS_WIN
+#if 0 // ndef OS_WIN
 #   define USE_HELPERS_PAGE
 #endif // OS_WIN
@@ -237,5 +238,5 @@
 //   InstallWizard_MiscPage,             // other common options
 #ifdef USE_HELPERS_PAGE
-//   InstallWizard_HelpersPage,          // external programs set up
+   InstallWizard_HelpersPage,          // external programs set up
 #endif // USE_HELPERS_PAGE
 
@@ -365,7 +366,7 @@
    void OnWizardCancel(wxWizardEvent& event);
 
-protected:
    wxWizardPage *GetPageById(InstallWizardPageId id) const;
 
+protected:
    // creates an "enhanced panel" for placing controls into under the static
    // text (explanation)
@@ -445,31 +446,10 @@
    InstallWizardDialUpPage(wxWizard *wizard);
 
-   virtual bool TransferDataFromWindow()
-   {
-#if defined(OS_WIN)
-      gs_installWizardData.connection = m_connections->GetValue();
-#elif defined(OS_UNIX)
-      gs_installWizardData.dialCommand = m_connect->GetValue();
-      gs_installWizardData.hangupCommand = m_disconnect->GetValue();
-#endif // platform
-
-      return true;
-   }
-
-   virtual bool TransferDataToWindow()
-   {
-#if defined(OS_WIN)
-      if ( !gs_installWizardData.connection.empty() )
-         m_connections->SetValue(gs_installWizardData.connection);
-#elif defined(OS_UNIX)
-      m_connect->SetValue(gs_installWizardData.dialCommand);
-      m_disconnect->SetValue(gs_installWizardData.hangupCommand);
-#endif // platform
-
-      return true;
-   }
+   virtual bool TransferDataFromWindow();
+   virtual bool TransferDataToWindow();
 
 private:
 #if defined(OS_WIN)
+   bool m_firstShow;
    wxComboBox *m_connections;
 #elif defined(OS_UNIX)
@@ -613,5 +593,9 @@
 
 // the function which runs the install wizard
-extern bool RunInstallWizard();
+extern bool RunInstallWizard(
+#ifdef DEBUG
+                             bool justTest = false
+#endif // DEBUG
+                            );
 
 #endif // USE_WIZARD
@@ -721,5 +705,5 @@
 //         CREATE_PAGE(Misc);
 #ifdef USE_HELPERS_PAGE
-//         CREATE_PAGE(Helpers);
+         CREATE_PAGE(Helpers);
 #endif // USE_HELPERS_PAGE
 
@@ -740,11 +724,33 @@
 wxEnhancedPanel *InstallWizardPage::CreateEnhancedPanel(wxStaticText *text)
 {
+#if !wxCHECK_VERSION(2,5,0)
    wxSize sizeLabel = text->GetSize();
    wxSize sizePage = ((wxWizard *)GetParent())->GetPageSize();
 //   wxSize sizePage = ((wxWizard *)GetParent())->GetSize();
    wxCoord y = sizeLabel.y + 2*LAYOUT_Y_MARGIN;
+#endif
 
    wxEnhancedPanel *panel = new wxEnhancedPanel(this, true /* scrolling */);
+#if !wxCHECK_VERSION(2,5,0)
    panel->SetSize(0, y, sizePage.x, sizePage.y - y);
+#endif
+
+#if wxCHECK_VERSION(2,5,0)
+   wxBoxSizer *pageSizer = new wxBoxSizer(wxVERTICAL);
+   SetSizer(pageSizer);
+
+   pageSizer->Add(
+      text,
+      0, // No vertical stretching
+      wxALL, // Border all around, no horizontal stretching
+      5 // Border width
+   );
+
+   pageSizer->Add(
+      panel,
+      1, // Vertical stretching
+      wxEXPAND // No border, horizontal stretching
+   );
+#endif
 
    panel->SetAutoLayout(true);
@@ -763,5 +769,5 @@
                         : InstallWizardPage(wizard, InstallWizard_WelcomePage)
 {
-   (void)new wxStaticText(this, -1, _(
+   wxStaticText *introduction = new wxStaticText(this, -1, _(
       "Welcome to Mahogany!\n"
       "\n"
@@ -790,4 +796,5 @@
                 );
 
+#if !wxCHECK_VERSION(2,5,0)
    wxSize sizeBox = m_checkbox->GetSize(),
           sizePage = wizard->GetPageSize();
@@ -795,4 +802,22 @@
    // adjust the vertical position
    m_checkbox->Move(5, sizePage.y - 2*sizeBox.y);
+#else
+   wxBoxSizer *pageSizer = new wxBoxSizer(wxVERTICAL);
+   pageSizer->Add(
+      introduction,
+      0, // No vertical stretching
+      wxALL, // Border all around, no horizontal stretching
+      5 // Border width
+   );
+   pageSizer->Add(
+      m_checkbox,
+      0, // No vertical stretching
+      wxALL, // Border all around
+      5 // Border width
+   );
+
+   SetSizer(pageSizer);
+   pageSizer->Fit(this);
+#endif
 }
 
@@ -853,5 +878,10 @@
    wxEnhancedPanel *panel = CreateEnhancedPanel(text);
    panel->CreateButton(_("&Import..."), NULL);
+
+#if !wxCHECK_VERSION(2,5,0)
    panel->Layout();
+#else
+   GetSizer()->Fit(this);
+#endif
 }
 
@@ -895,5 +925,9 @@
    m_email = panel->CreateTextWithLabel(labels[3], widthMax, m_login);
 
+#if !wxCHECK_VERSION(2,5,0)
    panel->Layout();
+#else
+   GetSizer()->Fit(this);
+#endif
 }
 
@@ -989,5 +1023,9 @@
    m_nntp = panel->CreateTextWithLabel(labels[4], widthMax, m_smtp);
 
+#if !wxCHECK_VERSION(2,5,0)
    panel->Layout();
+#else
+   GetSizer()->Fit(this);
+#endif
 }
 
@@ -1144,4 +1182,47 @@
 
 #if defined(OS_WIN)
+   // do create controls now
+   long widthMax = GetMaxLabelWidth(labels, panel);
+
+   m_connections = panel->CreateComboBox(_("&Dial up connection to use"),
+      widthMax, NULL);
+
+   m_firstShow = true;
+#elif defined(OS_UNIX)
+   labels.Add(_("Command to &connect:"));
+   labels.Add(_("Command to &disconnect:"));
+
+   long widthMax = GetMaxLabelWidth(labels, panel);
+
+   m_connect = panel->CreateTextWithLabel(labels[0], widthMax, NULL);
+   m_disconnect = panel->CreateTextWithLabel(labels[1], widthMax, m_connect);
+#endif // platform
+
+#if !wxCHECK_VERSION(2,5,0)
+   panel->Layout();
+#else
+   GetSizer()->Fit(this);
+#endif
+}
+
+bool InstallWizardDialUpPage::TransferDataFromWindow()
+{
+#if defined(OS_WIN)
+   gs_installWizardData.connection = m_connections->GetValue();
+#elif defined(OS_UNIX)
+   gs_installWizardData.dialCommand = m_connect->GetValue();
+   gs_installWizardData.hangupCommand = m_disconnect->GetValue();
+#endif // platform
+
+   return true;
+}
+
+bool InstallWizardDialUpPage::TransferDataToWindow()
+{
+#if defined(OS_WIN)
+   if(m_firstShow)
+   {
+      m_firstShow = false;
+
    // get all existing RAS connections
    wxDialUpManager *dial = wxDialUpManager::Create();
@@ -1161,27 +1242,18 @@
    }
 
-   // concatenate all connection names into one ':' separated string
-   wxString comboChoices = _("&Dial up connection to use");
-   labels.Add(comboChoices);
    for ( size_t n = 0; n < nCount; n++ )
    {
-      comboChoices << ':' << connections[n];
+         m_connections->Append(connections[n]);
+      }
    }
 
-   // do create controls now
-   long widthMax = GetMaxLabelWidth(labels, panel);
-
-   m_connections = panel->CreateComboBox(comboChoices, widthMax, NULL);
+   if ( !gs_installWizardData.connection.empty() )
+      m_connections->SetValue(gs_installWizardData.connection);
 #elif defined(OS_UNIX)
-   labels.Add(_("Command to &connect:"));
-   labels.Add(_("Command to &disconnect:"));
-
-   long widthMax = GetMaxLabelWidth(labels, panel);
-
-   m_connect = panel->CreateTextWithLabel(labels[0], widthMax, NULL);
-   m_disconnect = panel->CreateTextWithLabel(labels[1], widthMax, m_connect);
+   m_connect->SetValue(gs_installWizardData.dialCommand);
+   m_disconnect->SetValue(gs_installWizardData.hangupCommand);
 #endif // platform
 
-   panel->Layout();
+   return true;
 }
 
@@ -1330,5 +1402,9 @@
 #endif // USE_PYTHON
 
+#if !wxCHECK_VERSION(2,5,0)
    panel->Layout();
+#else
+   GetSizer()->Fit(this);
+#endif
 }
 
@@ -1407,5 +1483,9 @@
    }
 
+#if !wxCHECK_VERSION(2,5,0)
    panel->Layout();
+#else
+   GetSizer()->Fit(this);
+#endif
 }
 
@@ -1477,5 +1557,9 @@
 static void SetupServers(void);
 
-bool RunInstallWizard()
+bool RunInstallWizard(
+#ifdef DEBUG
+                      bool justTest
+#endif // DEBUG
+                     )
 {
    // as we use a static array, make sure that only one install wizard is
@@ -1531,5 +1615,5 @@
 
    wxIconManager *iconManager = mApplication->GetIconManager();
-   wxWizard *wizard = wxWizardBase::Create
+   wxWizard *wizard = new wxWizard
                       (
                         NULL,                         // parent
@@ -1537,4 +1621,9 @@
                         _("Mahogany Installation"),   // title
                         iconManager->GetBitmap("install_welcome") // def image
+#if wxCHECK_VERSION(2,5,0)
+                        ,
+                        wxDefaultPosition,
+                        wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
+#endif
                       );
 
@@ -1542,5 +1631,12 @@
    memset(gs_wizardPages, 0, sizeof(gs_wizardPages));
 
-   gs_wizardPages[InstallWizard_WelcomePage] = new InstallWizardWelcomePage(wizard);
+   InstallWizardWelcomePage *welcomePage
+      = new InstallWizardWelcomePage(wizard);
+
+   gs_wizardPages[InstallWizard_WelcomePage] = welcomePage;
+
+#if wxCHECK_VERSION(2,5,0)
+   wizard->GetPageAreaSizer()->Add(welcomePage);
+#endif
 
    // the wizard may be either cancelled or a checkbox may be used to skip it
@@ -1558,4 +1654,9 @@
    gs_isWizardRunning = false;
 
+#ifdef DEBUG
+   if ( justTest )
+      return true;
+#endif // DEBUG
+
    // make sure we have some _basic_ things set up whether the wizard ran or
    // not (basic here meaning that the program will not operate properly
@@ -1605,4 +1706,8 @@
    }
 
+   // Don't reset defaults when running wizard second time and stopping it
+   // No effect on users, but it's awfully annoying when testing
+   if(gs_wizardPages[InstallWizard_IdentityPage])
+   {
    // transfer the wizard settings from InstallWizardData
    profile->writeEntry(MP_FROM_ADDRESS, gs_installWizardData.email);
@@ -1610,4 +1715,5 @@
    profile->writeEntry(MP_ORGANIZATION, gs_installWizardData.organization);
    profile->writeEntry(MP_USERNAME, gs_installWizardData.login);
+   }
 
    // write the values even if they're empty as otherwise we'd try to create



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to