Revision: 7463
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7463&view=rev
Author:   vadz
Date:     2008-05-03 19:24:51 -0700 (Sat, 03 May 2008)

Log Message:
-----------
allow toggling tool/status bar visibility and full-screen view; also replaced a 
couple of wxChar* config paths with char*

Modified Paths:
--------------
    trunk/M/CHANGES
    trunk/M/include/FolderView.h
    trunk/M/include/MFrame.h
    trunk/M/include/Moptions.h
    trunk/M/include/gui/wxComposeView.h
    trunk/M/include/gui/wxFolderView.h
    trunk/M/include/gui/wxMDialogs.h
    trunk/M/include/gui/wxMFrame.h
    trunk/M/include/gui/wxMainFrame.h
    trunk/M/include/gui/wxMenuDefs.h
    trunk/M/include/gui/wxMessageView.h
    trunk/M/src/adb/AdbFrame.cpp
    trunk/M/src/classes/MessageView.cpp
    trunk/M/src/classes/Moptions.cpp
    trunk/M/src/classes/PGPClickInfo.cpp
    trunk/M/src/gui/wxComposeView.cpp
    trunk/M/src/gui/wxFolderView.cpp
    trunk/M/src/gui/wxMApp.cpp
    trunk/M/src/gui/wxMFrame.cpp
    trunk/M/src/gui/wxMainFrame.cpp
    trunk/M/src/gui/wxMenuDefs.cpp
    trunk/M/src/gui/wxMessageView.cpp
    trunk/M/src/gui/wxMsgCmdProc.cpp
    trunk/M/src/gui/wxTextDialog.cpp
    trunk/M/src/mail/SendMessageCC.cpp
    trunk/M/src/modules/Calendar.cpp

Modified: trunk/M/CHANGES
===================================================================
--- trunk/M/CHANGES     2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/CHANGES     2008-05-04 02:24:51 UTC (rev 7463)
@@ -9,6 +9,7 @@
 Release 0.68 '' September xx, 2007
 ---------------------------------------
 
+2008-05-04 VZ: Allow toggling tool/status bars and showing full-screen.
 2008-05-02 VZ: Add support for server-side spam filters.
 2008-04-25 VZ: Add support for filtering on individual headers to the GUI.
 2008-04-23 VZ: Allow using wildcards in the headers selected to be seen.

Modified: trunk/M/include/FolderView.h
===================================================================
--- trunk/M/include/FolderView.h        2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/FolderView.h        2008-05-04 02:24:51 UTC (rev 7463)
@@ -89,6 +89,9 @@
    /// return pointer to associated mail folder (IncRef()'d as usual)
    MailFolder *GetMailFolder() const;
 
+   /// Return true if we have an opened folder.
+   bool HasFolder() const { return m_ASMailFolder != NULL; }
+
    //@}
 
    /// event processing function

Modified: trunk/M/include/MFrame.h
===================================================================
--- trunk/M/include/MFrame.h    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/MFrame.h    2008-05-04 02:24:51 UTC (rev 7463)
@@ -26,7 +26,7 @@
    MFrameBase(const String& str) : name(str) { }
 
    /// retrieve the name of the window class
-   const wxChar *GetName() const { return name.c_str(); }
+   const char *GetName() const { return name.c_str(); }
 
    // VZ: this could lead to an ambiguity as wxFrame (from which wxMFrame
    //     derives as well) has this (virtual) method too

Modified: trunk/M/include/Moptions.h
===================================================================
--- trunk/M/include/Moptions.h  2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/Moptions.h  2008-05-04 02:24:51 UTC (rev 7463)
@@ -31,6 +31,9 @@
 extern const MOption MP_HEIGHT;
 extern const MOption MP_ICONISED;
 extern const MOption MP_MAXIMISED;
+extern const MOption MP_SHOW_TOOLBAR;
+extern const MOption MP_SHOW_STATUSBAR;
+extern const MOption MP_SHOW_FULLSCREEN;
 extern const MOption MP_SHOWLOG;
 extern const MOption MP_LOGFILE;
 extern const MOption MP_DEBUG_CCLIENT;
@@ -468,6 +471,12 @@
 #define   MP_ICONISED_NAME         "Iconised"
 /// window maximized?
 #define   MP_MAXIMISED_NAME         "Maximised"
+/// tool bars shown?
+#define   MP_SHOW_TOOLBAR_NAME    "ShowToolBar"
+/// status bars shown?
+#define   MP_SHOW_STATUSBAR_NAME  "ShowStatusBar"
+/// window shown full-screen?
+#define   MP_SHOW_FULLSCREEN_NAME "ShowFullScreen"
 
 /// show log window?
 #define   MP_SHOWLOG_NAME          "ShowLog"
@@ -1313,6 +1322,12 @@
 #define   MP_ICONISED_DEFVAL 0l
 /// window maximized?
 #define   MP_MAXIMISED_DEFVAL 0l
+/// tool bars shown?
+#define   MP_SHOW_TOOLBAR_DEFVAL    1L
+/// status bars shown?
+#define   MP_SHOW_STATUSBAR_DEFVAL  1L
+/// window shown full-screen?
+#define   MP_SHOW_FULLSCREEN_DEFVAL 0L
 /// show log window?
 #define   MP_SHOWLOG_DEFVAL  1
 /// the file to save log messages to (if not empty)

Modified: trunk/M/include/gui/wxComposeView.h
===================================================================
--- trunk/M/include/gui/wxComposeView.h 2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxComposeView.h 2008-05-04 02:24:51 UTC (rev 7463)
@@ -435,12 +435,13 @@
    kbStringList m_extraHeadersValues;
 
 private:
+   // implement base class pure virtual methods
+   virtual void DoCreateToolBar();
+   virtual void DoCreateStatusBar();
+
    /// initialize the menubar
    void CreateMenu();
 
-   /// initialize the toolbar and statusbar
-   void CreateToolAndStatusBars();
-
    /// create and initialize the editor
    void CreateEditor(void);
 

Modified: trunk/M/include/gui/wxFolderView.h
===================================================================
--- trunk/M/include/gui/wxFolderView.h  2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxFolderView.h  2008-05-04 02:24:51 UTC (rev 7463)
@@ -436,15 +436,16 @@
    */
    virtual Profile *GetFolderProfile(void) const;
 
-   /// don't even think of using this!
-   wxFolderViewFrame(void) { wxFAIL_MSG(_T("unreachable")); }
-
 protected:
    // event processing
    void OnCommandEvent(wxCommandEvent& event);
    void OnUpdateUI(wxUpdateUIEvent& event);
 
 private:
+   // implement base class pure virtual methods
+   virtual void DoCreateToolBar();
+   virtual void DoCreateStatusBar();
+
    void InternalCreate(wxFolderView *fv, wxMFrame *parent = NULL);
 
    /// ctor
@@ -453,7 +454,8 @@
    /// the associated folder view
    wxFolderView *m_FolderView;
 
-   DECLARE_DYNAMIC_CLASS_NO_COPY(wxFolderViewFrame)
+   DECLARE_ABSTRACT_CLASS(wxFolderViewFrame)
+   DECLARE_NO_COPY_CLASS(wxFolderViewFrame)
    DECLARE_EVENT_TABLE()
 };
 

Modified: trunk/M/include/gui/wxMDialogs.h
===================================================================
--- trunk/M/include/gui/wxMDialogs.h    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxMDialogs.h    2008-05-04 02:24:51 UTC (rev 7463)
@@ -222,7 +222,7 @@
 void MDialog_ShowText(wxWindow *parent,
                       const wxChar *title,
                       const wxChar *text,
-                      const wxChar *configPath = NULL);
+                      const char *configPath = NULL);
 
 } // extern "C"
 

Modified: trunk/M/include/gui/wxMFrame.h
===================================================================
--- trunk/M/include/gui/wxMFrame.h      2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxMFrame.h      2008-05-04 02:24:51 UTC (rev 7463)
@@ -38,13 +38,13 @@
       // read the frame position and size from config (the variables needn't be
       // initialized, they will receive some values in any case), returns FALSE
       // if there is no config object to read settings from
-   static bool RestorePosition(const wxChar *name,
+   static bool RestorePosition(const char *name,
                                int *x, int *y, int *w, int *h,
                                bool *iconised = NULL, bool *maximised = NULL);
 
       //  save the given frame's position and size in config file
-   static void SavePosition(const wxChar *name, wxFrame *frame);
-   static void SavePosition(const wxChar *name, wxWindow *frame);
+   static void SavePosition(const char *name, wxFrame *frame);
+   static void SavePosition(const char *name, wxWindow *frame);
 
    /// dummy ctor for DECLARE_DYNAMIC_CLASS
    wxMFrame() : MFrameBase(M_EMPTYSTRING) { FAIL_MSG(_T("unreachable")); }
@@ -100,11 +100,65 @@
    void OnCloseWindow(wxCloseEvent& event);
 
 protected:
-   static void SavePositionInternal(const wxChar *name, wxWindow *frame, bool 
isFrame);
+   /// Flags for SaveState()
+   enum
+   {
+      /// Geometry is always saved
+      Save_Geometry = 0,
 
+      /// Minimized/maximized/full-screen state of a frame
+      Save_State = 1,
+
+      /// Status of the tool/status bars
+      Save_View = 2
+   };
+
+   /**
+      Save state of this window in config.
+
+      Window geometry is always saved, for the frames we can also save their
+      minimized/maximized state as well as whether their tool/status bar should
+      be shown.
+    */
+   static void SaveState(const char *name, wxWindow *frame, int flags);
+
+   /**
+      Create the tool and status bars if they are configured to be shown.
+
+      This method calls the pure virtual DoCreateToolBar() and
+      DoCreateStatusBar() if necessary.
+    */
+   void CreateToolAndStatusBars();
+
+   /**
+      Convenient function for derived classes: show the frame either normally
+      or full-screen, depending on the last saved state.
+    */
+   void ShowInInitialState();
+
    /// is it initialised?
    bool m_initialised;
 
+private:
+   // implement these to create tool/status bars for this frame: they're called
+   // by wxMFrame itself when the user decides to show a previously 
non-existent call them from
+   // bar and also from the derived classes ctor via CreateToolAndStatusBars()
+   virtual void DoCreateToolBar() = 0;
+   virtual void DoCreateStatusBar() = 0;
+
+   // get the config object with its path set to the frames option
+   //
+   // may return NULL during the initial program execution
+   wxConfigBase *GetFrameOptionsConfig() const
+   {
+      return GetFrameOptionsConfig(MFrameBase::GetName());
+   }
+
+   // same as above except takes the frame name as parameter so it can be used
+   // from the static methods
+   static wxConfigBase *GetFrameOptionsConfig(const char *name);
+
+
 #ifdef USE_PYTHON
    /// update the state (enabled/disabled) of the "Run Python script" menu item
    void UpdateRunPyScriptMenu();
@@ -115,7 +169,8 @@
 #endif // USE_PYTHON
 
    DECLARE_EVENT_TABLE()
-   DECLARE_DYNAMIC_CLASS_NO_COPY(wxMFrame)
+   DECLARE_ABSTRACT_CLASS(wxMFrame)
+   DECLARE_NO_COPY_CLASS(wxMFrame)
 };
 
 #endif

Modified: trunk/M/include/gui/wxMainFrame.h
===================================================================
--- trunk/M/include/gui/wxMainFrame.h   2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxMainFrame.h   2008-05-04 02:24:51 UTC (rev 7463)
@@ -63,6 +63,7 @@
    void OnCommandEvent(wxCommandEvent &event);
    void OnIdentChange(wxCommandEvent &event);
    void OnIdle(wxIdleEvent &event);
+   void OnUpdateUIEnableIfHasFolder(wxUpdateUIEvent& event);
    void OnUpdateUIEnableIfHasPreview(wxUpdateUIEvent& event);
    void OnAbout(wxCommandEvent &) { OnMenuCommand(WXMENU_HELP_ABOUT);}
 
@@ -138,6 +139,10 @@
 #endif // wxHAS_POWER_EVENTS
 
 private:
+   // implement base class pure virtual methods
+   virtual void DoCreateToolBar();
+   virtual void DoCreateStatusBar();
+
    /// create and initialize the modules menu
    void MakeModulesMenu(void);
 

Modified: trunk/M/include/gui/wxMenuDefs.h
===================================================================
--- trunk/M/include/gui/wxMenuDefs.h    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxMenuDefs.h    2008-05-04 02:24:51 UTC (rev 7463)
@@ -271,7 +271,11 @@
    WXMENU_VIEW_SHOWUID,
 #endif // EXPERIMENTAL_show_uid
    WXMENU_VIEW_SHOWMIME,
-   WXMENU_VIEW_END = WXMENU_VIEW_SHOWMIME,
+   WXMENU_VIEW_SEP2,
+   WXMENU_VIEW_TOOLBAR,
+   WXMENU_VIEW_STATUSBAR,
+   WXMENU_VIEW_FULLSCREEN,
+   WXMENU_VIEW_END = WXMENU_VIEW_FULLSCREEN,
 
    WXMENU_COMPOSE_BEGIN = WXMENU_VIEW_END,
    WXMENU_COMPOSE_INSERTFILE,

Modified: trunk/M/include/gui/wxMessageView.h
===================================================================
--- trunk/M/include/gui/wxMessageView.h 2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/include/gui/wxMessageView.h 2008-05-04 02:24:51 UTC (rev 7463)
@@ -100,6 +100,10 @@
    virtual bool OnMEvent(MEventData& event);
 
 private:
+   // implement base class pure virtual methods
+   virtual void DoCreateToolBar();
+   virtual void DoCreateStatusBar();
+
    /// the message view shown inside this frame
    MessageView *m_MessageView;
 

Modified: trunk/M/src/adb/AdbFrame.cpp
===================================================================
--- trunk/M/src/adb/AdbFrame.cpp        2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/adb/AdbFrame.cpp        2008-05-04 02:24:51 UTC (rev 7463)
@@ -773,6 +773,10 @@
   ~wxAdbEditFrame();
 
 private:
+  // implement base class pure virtual methods
+  virtual void DoCreateToolBar() { CreateMToolbar(this, WXFRAME_ADB); }
+  virtual void DoCreateStatusBar() { CreateStatusBar(2); }
+
   // associate an ADB entry with the notebook panels
   void UpdateNotebook();
 
@@ -1194,8 +1198,7 @@
 
 void ShowAdbFrame(wxFrame *parent)
 {
-  wxFrame *pAdbFrame = new wxAdbEditFrame(parent);
-  pAdbFrame->Show(TRUE);
+  new wxAdbEditFrame(parent);
 
   mApplication->GetProfile()->writeEntry(MP_SHOWADBEDITOR, TRUE);
 }
@@ -1268,12 +1271,8 @@
   // toolbar and status bar
   // ----------------------
 
-  // standard M toolbar
-  CreateMToolbar(this, WXFRAME_ADB);
+  CreateToolAndStatusBars();
 
-  // create a status bar with 2 panes
-  CreateStatusBar(2);
-
   // make a panel with some items
   // ----------------------------
   wxPanel *panel = new wxPanel(this, -1);
@@ -1343,8 +1342,6 @@
   // final initializations
   // ---------------------
 
-  RestoreSettings1();
-
   // create the root item
   m_root = new AdbTreeRoot(m_astrAdb, m_astrProviders);
   m_root->TreeInsert(*m_treeAdb);
@@ -1353,6 +1350,8 @@
   m_current = m_root;
 
   RestoreSettings2();
+
+  ShowInInitialState();
 }
 
 void wxAdbEditFrame::TransferSettings(bool bSave)

Modified: trunk/M/src/classes/MessageView.cpp
===================================================================
--- trunk/M/src/classes/MessageView.cpp 2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/classes/MessageView.cpp 2008-05-04 02:24:51 UTC (rev 7463)
@@ -3546,7 +3546,7 @@
          title << _T(" ('") << filename << _T("')");
       }
 
-      MDialog_ShowText(GetParentFrame(), title, content, _T("MimeView"));
+      MDialog_ShowText(GetParentFrame(), title, content, "MimeView");
    }
    else
    {

Modified: trunk/M/src/classes/Moptions.cpp
===================================================================
--- trunk/M/src/classes/Moptions.cpp    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/classes/Moptions.cpp    2008-05-04 02:24:51 UTC (rev 7463)
@@ -94,6 +94,9 @@
 const MOption MP_HEIGHT;
 const MOption MP_ICONISED;
 const MOption MP_MAXIMISED;
+const MOption MP_SHOW_TOOLBAR;
+const MOption MP_SHOW_STATUSBAR;
+const MOption MP_SHOW_FULLSCREEN;
 const MOption MP_SHOWLOG;
 const MOption MP_LOGFILE;
 const MOption MP_DEBUG_CCLIENT;
@@ -512,6 +515,9 @@
     DEFINE_OPTION(MP_HEIGHT),
     DEFINE_OPTION(MP_ICONISED),
     DEFINE_OPTION(MP_MAXIMISED),
+    DEFINE_OPTION(MP_SHOW_TOOLBAR),
+    DEFINE_OPTION(MP_SHOW_STATUSBAR),
+    DEFINE_OPTION(MP_SHOW_FULLSCREEN),
     DEFINE_OPTION(MP_SHOWLOG),
     DEFINE_OPTION(MP_LOGFILE),
     DEFINE_OPTION(MP_DEBUG_CCLIENT),

Modified: trunk/M/src/classes/PGPClickInfo.cpp
===================================================================
--- trunk/M/src/classes/PGPClickInfo.cpp        2008-05-03 21:21:53 UTC (rev 
7462)
+++ trunk/M/src/classes/PGPClickInfo.cpp        2008-05-04 02:24:51 UTC (rev 
7463)
@@ -240,7 +240,7 @@
       MDialog_ShowText(m_msgView->GetWindow(),
                        _("PGP Information"),
                        allText,
-                       _T("PGPDetails"));
+                       "PGPDetails");
    }
    else // no log??
    {
@@ -254,7 +254,7 @@
    MDialog_ShowText(m_msgView->GetWindow(),
                     _("PGP Message Raw Text"),
                     m_textRaw,
-                    _T("PGPRawText"));
+                    "PGPRawText");
 }
 
 // ----------------------------------------------------------------------------

Modified: trunk/M/src/gui/wxComposeView.cpp
===================================================================
--- trunk/M/src/gui/wxComposeView.cpp   2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxComposeView.cpp   2008-05-04 02:24:51 UTC (rev 7463)
@@ -920,7 +920,7 @@
                GetFrame(m_window),
                wxString::Format(_("Attached file \"%s\""), filename.c_str()),
                content,
-               _T("AttachView")
+               "AttachView"
             );
          }
          break;
@@ -1934,11 +1934,13 @@
    }
 }
 
-void
-wxComposeView::CreateToolAndStatusBars()
+void wxComposeView::DoCreateToolBar()
 {
    CreateMToolbar(this, WXFRAME_COMPOSE);
+}
 
+void wxComposeView::DoCreateStatusBar()
+{
    CreateStatusBar(2);
    static const int s_widths[] = { -1, 90 };
    SetStatusWidths(WXSIZEOF(s_widths), s_widths);
@@ -2187,7 +2189,7 @@
    // build menu
    CreateMenu();
 
-   // and tool/status bars
+   // and tool/status bars if needed
    CreateToolAndStatusBars();
 
 #if wxUSE_DRAG_AND_DROP
@@ -2224,8 +2226,8 @@
    // note that we must show and layout the frame before setting the control
    // values or the text would be scrolled to the right in the text fields as
    // they initially don't have enough space to show it...
-   Show();
    Layout();
+   ShowInInitialState();
 
    // initialize the controls
    // -----------------------

Modified: trunk/M/src/gui/wxFolderView.cpp
===================================================================
--- trunk/M/src/gui/wxFolderView.cpp    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxFolderView.cpp    2008-05-04 02:24:51 UTC (rev 7463)
@@ -5334,7 +5334,7 @@
                        wxFolderViewFrame::OnUpdateUI)
 END_EVENT_TABLE()
 
-IMPLEMENT_DYNAMIC_CLASS(wxFolderViewFrame, wxMFrame)
+IMPLEMENT_ABSTRACT_CLASS(wxFolderViewFrame, wxMFrame)
 
 // ----------------------------------------------------------------------------
 // wxFolderViewFrame ctor and such
@@ -5347,11 +5347,6 @@
 
    m_FolderView = fv;
 
-   // add a toolbar to the frame
-   //
-   // NB: the buttons must have the same ids as the menu commands
-   CreateMToolbar(this, WXFRAME_FOLDER);
-
    // construct menubar
    AddFileMenu();
    AddEditMenu();
@@ -5365,10 +5360,10 @@
    m_FolderView->CreateViewMenu();
    AddLanguageMenu();
 
-   // and the status bar
-   CreateStatusBar();
+   // and the tool/status bar if necessary
+   CreateToolAndStatusBars();
 
-   Show(true);
+   ShowInInitialState();
 }
 
 wxFolderViewFrame *
@@ -5410,6 +5405,16 @@
    m_FolderView = NULL;
 }
 
+void wxFolderViewFrame::DoCreateToolBar()
+{
+   CreateMToolbar(this, WXFRAME_FOLDER);
+}
+
+void wxFolderViewFrame::DoCreateStatusBar()
+{
+   CreateStatusBar();
+}
+
 wxFolderViewFrame::~wxFolderViewFrame()
 {
    delete m_FolderView;

Modified: trunk/M/src/gui/wxMApp.cpp
===================================================================
--- trunk/M/src/gui/wxMApp.cpp  2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxMApp.cpp  2008-05-04 02:24:51 UTC (rev 7463)
@@ -153,7 +153,7 @@
 // ----------------------------------------------------------------------------
 
 // the name of config section where the log window position is saved
-#define  LOG_FRAME_SECTION    _T("LogWindow")
+static const char *LOG_FRAME_SECTION = "LogWindow";
 
 // trace mask for timer events
 #define TRACE_TIMER _T("timer")
@@ -1243,7 +1243,6 @@
 wxMFrame *wxMApp::CreateTopLevelFrame()
 {
    m_topLevelFrame = new wxMainFrame();
-   m_topLevelFrame->Show(true);
    SetTopWindow(m_topLevelFrame);
    return m_topLevelFrame;
 }

Modified: trunk/M/src/gui/wxMFrame.cpp
===================================================================
--- trunk/M/src/gui/wxMFrame.cpp        2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxMFrame.cpp        2008-05-04 02:24:51 UTC (rev 7463)
@@ -76,6 +76,9 @@
 extern const MOption MP_ICONISED;
 extern const MOption MP_MAXIMISED;
 extern const MOption MP_MSGVIEW_DEFAULT_ENCODING;
+extern const MOption MP_SHOW_TOOLBAR;
+extern const MOption MP_SHOW_STATUSBAR;
+extern const MOption MP_SHOW_FULLSCREEN;
 extern const MOption MP_USEPYTHON;
 extern const MOption MP_WIDTH;
 extern const MOption MP_XPOS;
@@ -150,7 +153,7 @@
 // wxWin macros
 // ----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxMFrame, wxFrame)
+IMPLEMENT_ABSTRACT_CLASS(wxMFrame, wxFrame)
 
 BEGIN_EVENT_TABLE(wxMFrame, wxFrame)
    EVT_MENU(-1,    wxMFrame::OnCommandEvent)
@@ -189,6 +192,7 @@
 #endif // USE_PYTHON
 
    m_initialised = false;
+
    Create(name, parent);
 }
 
@@ -259,7 +263,7 @@
    delete m_pyOptHandler;
 #endif // USE_PYTHON
 
-   SavePosition(MFrameBase::GetName(), this);
+   SaveState(MFrameBase::GetName(), this, Save_Geometry | Save_State | 
Save_View);
 }
 
 // ----------------------------------------------------------------------------
@@ -346,20 +350,31 @@
 // saving and restoring frame position
 // ----------------------------------------------------------------------------
 
-bool wxMFrame::RestorePosition(const wxChar *name,
+/* static */
+wxConfigBase *wxMFrame::GetFrameOptionsConfig(const char *name)
+{
+   wxConfigBase *pConf = mApplication->GetProfile()->GetConfig();
+   if ( pConf != NULL )
+   {
+      String path;
+      path << Profile::GetFramesPath() << '/' << name;
+      pConf->SetPath(path);
+   }
+
+   return pConf;
+}
+
+bool wxMFrame::RestorePosition(const char *name,
                                int *x, int *y, int *w, int *h,
                                bool *i, bool *m)
 {
-   // only i can be NULL
+   // only i and m might be NULL
    CHECK( x && y && w && h, FALSE,
           _T("NULL pointer in wxMFrame::RestorePosition") );
 
-   wxConfigBase *pConf = mApplication->GetProfile()->GetConfig();
+   wxConfigBase * const pConf = GetFrameOptionsConfig(name);
    if ( pConf != NULL )
    {
-      String path;
-      path << Profile::GetFramesPath() << '/' << name;
-      pConf->SetPath(path);
       *x = GetOptionValue(pConf, MP_XPOS);
       *y = GetOptionValue(pConf, MP_YPOS);
       *w = GetOptionValue(pConf, MP_WIDTH);
@@ -370,6 +385,7 @@
       if ( m )
           *m = GetOptionValue(pConf, MP_MAXIMISED).GetBoolValue();
 
+
       // assume that if one entry existed, then the other existed too
       return pConf->HasEntry(GetOptionName(MP_XPOS));
    }
@@ -389,84 +405,144 @@
    }
 }
 
+void wxMFrame::CreateToolAndStatusBars()
+{
+   bool tb, sb;
+
+   wxConfigBase * const pConf = GetFrameOptionsConfig();
+   if ( pConf != NULL )
+   {
+      tb = GetOptionValue(pConf, MP_SHOW_TOOLBAR).GetBoolValue();
+      sb = GetOptionValue(pConf, MP_SHOW_STATUSBAR).GetBoolValue();
+   }
+   else
+   {
+      tb = GetNumericDefault(MP_SHOW_TOOLBAR) != 0;
+      sb = GetNumericDefault(MP_SHOW_STATUSBAR) != 0;
+   }
+
+   wxMenuBar * const mb = GetMenuBar();
+   mb->Check(WXMENU_VIEW_TOOLBAR, tb);
+   mb->Check(WXMENU_VIEW_STATUSBAR, sb);
+
+   if ( tb )
+      DoCreateToolBar();
+   if ( sb )
+      DoCreateStatusBar();
+}
+
+void wxMFrame::ShowInInitialState()
+{
+   bool showFullScreen;
+   wxConfigBase * const pConf = GetFrameOptionsConfig();
+   if ( pConf )
+      showFullScreen = GetOptionValue(pConf, 
MP_SHOW_FULLSCREEN).GetBoolValue();
+   else
+      showFullScreen = GetNumericDefault(MP_SHOW_FULLSCREEN) != 0;
+
+   Show(true);
+
+   if ( showFullScreen )
+      ShowFullScreen(true);
+}
+
 void
-wxMFrame::SavePosition(const wxChar *name, wxWindow *frame)
+wxMFrame::SavePosition(const char *name, wxWindow *frame)
 {
-   SavePositionInternal(name, frame, FALSE);
+   SaveState(name, frame, Save_Geometry);
 }
 
 void
-wxMFrame::SavePosition(const wxChar *name, wxFrame *frame)
+wxMFrame::SavePosition(const char *name, wxFrame *frame)
 {
-   SavePositionInternal(name, frame, TRUE);
+   SaveState(name, frame, Save_Geometry | Save_State);
 }
 
+// helper function which either writes the given boolean value option to the
+// config or deletes it from it if the new value is the same as default one
+//
+// notice that this only works for the frame values as there is no inheritance
+// with the frames profiles, otherwise deleting the value wouldn't have been
+// enough
+static void
+UpdateBoolConfigValue(wxConfigBase *pConf,
+                      const MOption opt,
+                      bool value)
+{
+   // to compare boolean value with option value we need to cast it to long to
+   // avoid ambiguities
+   const long lValue = value;
+
+   if ( GetOptionValue(pConf, opt) != lValue )
+   {
+      // current value must be changed but how?
+      if ( lValue == GetNumericDefault(opt) )
+      {
+         // it's enough to just delete the existing value
+         pConf->DeleteEntry(GetOptionName(opt));
+      }
+      else // we must really write the new value to the config
+      {
+         pConf->Write(GetOptionName(opt), value);
+      }
+   }
+   //else: we already have the right value in the config, nothing to do
+
+   ASSERT_MSG( GetOptionValue(pConf, opt) == lValue,
+               "didn't update a boolean option correctly" );
+}
+
 void
-wxMFrame::SavePositionInternal(const wxChar *name, wxWindow *frame, bool 
isFrame)
+wxMFrame::SaveState(const char *name, wxWindow *frame, int flags)
 {
-   wxConfigBase *pConf = mApplication->GetProfile()->GetConfig();
-   if ( pConf != NULL )
+   wxConfigBase *pConf = GetFrameOptionsConfig(name);
+   if ( !pConf )
+      return;
+
+   if ( flags & Save_State )
    {
-      String path;
-      path << Profile::GetFramesPath() << '/' << name;
+      wxFrame *fr = wxDynamicCast(frame, wxFrame);
+      CHECK_RET( fr, "should have a frame when saving state" );
 
-      pConf->SetPath(path);
-
-      if ( isFrame )
+      if ( flags & Save_View )
       {
-         wxFrame *fr = (wxFrame *)frame;
+         UpdateBoolConfigValue(pConf, MP_SHOW_TOOLBAR,
+                               fr->GetToolBar() != NULL);
+         UpdateBoolConfigValue(pConf, MP_SHOW_STATUSBAR,
+                               fr->GetStatusBar() != NULL);
+      }
 
-         // IsIconized() is broken in wxGTK, it returns TRUE sometimes when the
-         // frame is not at all iconized - no idea why :-(
+      UpdateBoolConfigValue(pConf, MP_SHOW_FULLSCREEN, fr->IsFullScreen());
+
+      // IsIconized() is broken in wxGTK, it returns TRUE sometimes when the
+      // frame is not at all iconized - no idea why :-(
 #ifdef __WXGTK__
-         bool isIconized = false;
+      bool isIconized = false;
 #else
-         bool isIconized = fr->IsIconized();
+      bool isIconized = fr->IsIconized();
 #endif
-         bool isMaximized = fr->IsMaximized();
+      bool isMaximized = fr->IsMaximized();
 
-         // the frames are rarely icon/maximized, so don't write these
-         // settings to config unless really needed
-         if ( GetOptionValue(pConf, MP_ICONISED) )
-         {
-            if ( !isIconized )
-               pConf->DeleteEntry(GetOptionName(MP_ICONISED));
-         }
-         else // !iconized in config
-         {
-            if ( isIconized )
-               pConf->Write(GetOptionName(MP_ICONISED), isIconized);
-         }
+      UpdateBoolConfigValue(pConf, MP_ICONISED, isIconized);
+      UpdateBoolConfigValue(pConf, MP_MAXIMISED, isMaximized);
 
-         if ( GetOptionValue(pConf, MP_MAXIMISED) )
-         {
-            if ( !isMaximized )
-               pConf->DeleteEntry(GetOptionName(MP_MAXIMISED));
-         }
-         else // !maximized in config
-         {
-            if ( isMaximized )
-               pConf->Write(GetOptionName(MP_MAXIMISED), isMaximized);
-         }
-
-         if ( isMaximized || isIconized )
-         {
-            // don't remember the coords in this case: wxWindows returns
-            // something weird for them for iconized frames and we don't need
-            // them for maximized ones anyhow
-            return;
-         }
+      if ( isMaximized || isIconized )
+      {
+         // don't remember the coords in this case: wxWindows returns
+         // something weird for them for iconized frames and we don't need
+         // them for maximized ones anyhow
+         return;
       }
+   }
 
-      int x, y;
-      frame->GetPosition(&x, &y);
-      pConf->Write(GetOptionName(MP_XPOS), (long)x);
-      pConf->Write(GetOptionName(MP_YPOS), (long)y);
+   int x, y;
+   frame->GetPosition(&x, &y);
+   pConf->Write(GetOptionName(MP_XPOS), (long)x);
+   pConf->Write(GetOptionName(MP_YPOS), (long)y);
 
-      frame->GetSize(&x,&y);
-      pConf->Write(GetOptionName(MP_WIDTH), (long)x);
-      pConf->Write(GetOptionName(MP_HEIGHT), (long)y);
-   }
+   frame->GetSize(&x,&y);
+   pConf->Write(GetOptionName(MP_WIDTH), (long)x);
+   pConf->Write(GetOptionName(MP_HEIGHT), (long)y);
 }
 
 // ----------------------------------------------------------------------------
@@ -1023,6 +1099,34 @@
                                                    enc);
          }
          break;
+
+      case WXMENU_VIEW_TOOLBAR:
+         if ( GetMenuBar()->IsChecked(id) )
+         {
+            DoCreateToolBar();
+         }
+         else // hide the toolbar
+         {
+            delete GetToolBar();
+            SetToolBar(NULL);
+         }
+         break;
+
+      case WXMENU_VIEW_STATUSBAR:
+         if ( GetMenuBar()->IsChecked(id) )
+         {
+            DoCreateStatusBar();
+         }
+         else // hide the status bar
+         {
+            delete GetStatusBar();
+            SetStatusBar(NULL);
+         }
+         break;
+
+      case WXMENU_VIEW_FULLSCREEN:
+         ShowFullScreen(GetMenuBar()->IsChecked(id));
+         break;
    }
 }
 

Modified: trunk/M/src/gui/wxMainFrame.cpp
===================================================================
--- trunk/M/src/gui/wxMainFrame.cpp     2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxMainFrame.cpp     2008-05-04 02:24:51 UTC (rev 7463)
@@ -555,6 +555,10 @@
 
    EVT_IDLE(wxMainFrame::OnIdle)
 
+   EVT_UPDATE_UI(WXMENU_VIEW_SHOWMIME, 
wxMainFrame::OnUpdateUIEnableIfHasFolder)
+   EVT_UPDATE_UI(WXMENU_VIEW_SHOWRAWTEXT, 
wxMainFrame::OnUpdateUIEnableIfHasFolder)
+
+   EVT_UPDATE_UI(WXMENU_VIEW_HEADERS, 
wxMainFrame::OnUpdateUIEnableIfHasPreview)
    EVT_UPDATE_UI(WXMENU_EDIT_FIND, wxMainFrame::OnUpdateUIEnableIfHasPreview)
    EVT_UPDATE_UI(WXMENU_EDIT_FINDAGAIN, 
wxMainFrame::OnUpdateUIEnableIfHasPreview)
 
@@ -591,8 +595,6 @@
    SetIcon(ICON(_T("MainFrame")));
    SetTitle(_("Copyright (C) 1997-2007 The Mahogany Developers Team"));
 
-   CreateStatusBar();
-
    // create the child controls
    m_splitter = new wxPSplitterWindow(_T("MainSplitter"), this, -1,
                                       wxDefaultPosition, wxDefaultSize,
@@ -643,7 +645,7 @@
 
    AddHelpMenu();
 
-   CreateMToolbar(this, WXFRAME_MAIN);
+   CreateToolAndStatusBars();
 
    // disable the operations which don't make sense for viewer
    wxMenuBar *menuBar = GetMenuBar();
@@ -667,8 +669,20 @@
    m_splitter->SplitVertically(winLeft, winRight, sizeFrame.x/3);
 
    m_FolderTree->GetWindow()->SetFocus();
+
+   ShowInInitialState();
 }
 
+void wxMainFrame::DoCreateToolBar()
+{
+   CreateMToolbar(this, WXFRAME_MAIN);
+}
+
+void wxMainFrame::DoCreateStatusBar()
+{
+   CreateStatusBar();
+}
+
 void wxMainFrame::AddFolderMenu(void)
 {
    WXADD_MENU(GetMenuBar(), FOLDER, _("&Folder"));
@@ -801,7 +815,6 @@
    if ( hasFolder != s_hasFolder )
    {
       EnableMMenu(MMenu_Message, this, hasFolder);
-      EnableMMenu(MMenu_View, this, hasFolder);
 
       // also update the toolbar buttons
       static const int buttonsToDisable[] =
@@ -815,10 +828,13 @@
          WXTBAR_MSG_DELETE,
       };
 
-      wxToolBar *tbar = GetToolBar();
-      for ( size_t n = 0; n < WXSIZEOF(buttonsToDisable); n++ )
+      wxToolBar * const tbar = GetToolBar();
+      if ( tbar )
       {
-         EnableToolbarButton(tbar, buttonsToDisable[n], hasFolder);
+         for ( size_t n = 0; n < WXSIZEOF(buttonsToDisable); n++ )
+         {
+            EnableToolbarButton(tbar, buttonsToDisable[n], hasFolder);
+         }
       }
 
       s_hasFolder = hasFolder;
@@ -835,6 +851,11 @@
    }
 }
 
+void wxMainFrame::OnUpdateUIEnableIfHasFolder(wxUpdateUIEvent& event)
+{
+   event.Enable( m_FolderView && m_FolderView->HasFolder() );
+}
+
 void wxMainFrame::OnUpdateUIEnableIfHasPreview(wxUpdateUIEvent& event)
 {
    event.Enable( m_FolderView && m_FolderView->HasPreview() );

Modified: trunk/M/src/gui/wxMenuDefs.cpp
===================================================================
--- trunk/M/src/gui/wxMenuDefs.cpp      2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxMenuDefs.cpp      2008-05-04 02:24:51 UTC (rev 7463)
@@ -448,7 +448,7 @@
    // view
 
    // the available accelerators for this menu:
-   // ABCDEFGIJKNOPQRSTUVXYZ
+   // ABCDEGIJKNOPQRXYZ
    { WXMENU_SUBMENU,       gettext_noop("&Viewer to use"), "", wxITEM_NORMAL },
    { WXMENU_SUBMENU,       "", "", wxITEM_NORMAL },
    { WXMENU_SUBMENU,       gettext_noop("&Filters"), "", wxITEM_NORMAL },
@@ -460,6 +460,10 @@
    { WXMENU_VIEW_SHOWUID,  "Show message UID&L", "", wxITEM_NORMAL },
 #endif // EXPERIMENTAL_show_uid
    { WXMENU_VIEW_SHOWMIME, gettext_noop("Show &MIME 
structure...\tShift-Ctrl-Z"), gettext_noop("Show the MIME structure of the 
message") , wxITEM_NORMAL },
+   { WXMENU_SEPARATOR,     "",                  ""                         , 
wxITEM_NORMAL },
+   { WXMENU_VIEW_TOOLBAR, gettext_noop("Show &tool bar"), "", wxITEM_CHECK },
+   { WXMENU_VIEW_STATUSBAR, gettext_noop("Show &status bar"), "", wxITEM_CHECK 
},
+   { WXMENU_VIEW_FULLSCREEN, gettext_noop("F&ull screen\tF11"), "", 
wxITEM_CHECK },
 
    // compose
 

Modified: trunk/M/src/gui/wxMessageView.cpp
===================================================================
--- trunk/M/src/gui/wxMessageView.cpp   2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxMessageView.cpp   2008-05-04 02:24:51 UTC (rev 7463)
@@ -501,22 +501,28 @@
    m_MessageView->CreateViewMenu();
    AddLanguageMenu();
 
-   // add a toolbar to the frame
-   CreateMToolbar(this, WXFRAME_MESSAGE);
+   CreateToolAndStatusBars();
 
-   // a status bar
-   CreateStatusBar(2);
-   static const int s_widths[] = { -1, 70 };
-   SetStatusWidths(WXSIZEOF(s_widths), s_widths);
-
    // do it after creating the menu as it access the "Toggle headers" item in
    // it
    m_MessageView->SetFolder(asmf);
    m_MessageView->ShowMessage(uid);
 
-   Show(true);
+   ShowInInitialState();
 }
 
+void wxMessageViewFrame::DoCreateToolBar()
+{
+   CreateMToolbar(this, WXFRAME_MESSAGE);
+}
+
+void wxMessageViewFrame::DoCreateStatusBar()
+{
+   CreateStatusBar(2);
+   static const int s_widths[] = { -1, 70 };
+   SetStatusWidths(WXSIZEOF(s_widths), s_widths);
+}
+
 void
 wxMessageViewFrame::OnMenuCommand(int id)
 {

Modified: trunk/M/src/gui/wxMsgCmdProc.cpp
===================================================================
--- trunk/M/src/gui/wxMsgCmdProc.cpp    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxMsgCmdProc.cpp    2008-05-04 02:24:51 UTC (rev 7463)
@@ -793,7 +793,7 @@
    }
    else
    {
-      MDialog_ShowText(GetFrame(), _("Raw message text"), text, 
_T("RawMsgPreview"));
+      MDialog_ShowText(GetFrame(), _("Raw message text"), text, 
"RawMsgPreview");
    }
 }
 

Modified: trunk/M/src/gui/wxTextDialog.cpp
===================================================================
--- trunk/M/src/gui/wxTextDialog.cpp    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/gui/wxTextDialog.cpp    2008-05-04 02:24:51 UTC (rev 7463)
@@ -49,7 +49,7 @@
    MTextDialog(wxWindow *parent,
                const wxString& title,
                const wxString& text,
-               const wxChar *configPath);
+               const char *configPath);
 
    virtual ~MTextDialog();
 
@@ -97,7 +97,7 @@
    int m_flagsFind;
 
    // the path for our size/position info in config (may be NULL)
-   const wxChar *m_configPath;
+   const char *m_configPath;
 
    DECLARE_EVENT_TABLE()
    DECLARE_NO_COPY_CLASS(MTextDialog)
@@ -124,7 +124,7 @@
 MTextDialog::MTextDialog(wxWindow *parent,
                          const wxString& title,
                          const wxString& text,
-                         const wxChar *configPath)
+                         const char *configPath)
            : wxDialog(parent,
                       -1,
                       _T("Mahogany: ") + title,
@@ -357,7 +357,7 @@
 void MDialog_ShowText(wxWindow *parent,
                       const wxChar *title,
                       const wxChar *text,
-                      const wxChar *configPath)
+                      const char *configPath)
 {
    // show the dialog modelessly because otherwise we wouldn't be able to show
    // a find dialog from it

Modified: trunk/M/src/mail/SendMessageCC.cpp
===================================================================
--- trunk/M/src/mail/SendMessageCC.cpp  2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/mail/SendMessageCC.cpp  2008-05-04 02:24:51 UTC (rev 7463)
@@ -1498,7 +1498,7 @@
 {
    String textTmp;
    WriteToString(textTmp);
-   MDialog_ShowText(m_frame, _T("Outgoing message text"), textTmp, 
_T("SendPreview"));
+   MDialog_ShowText(m_frame, _("Outgoing message text"), textTmp, 
"SendPreview");
 
    if ( text )
       *text = textTmp;

Modified: trunk/M/src/modules/Calendar.cpp
===================================================================
--- trunk/M/src/modules/Calendar.cpp    2008-05-03 21:21:53 UTC (rev 7462)
+++ trunk/M/src/modules/Calendar.cpp    2008-05-04 02:24:51 UTC (rev 7463)
@@ -507,6 +507,10 @@
 
 
 private:
+   // implement base class pure virtual methods
+   virtual void DoCreateToolBar() { }
+   virtual void DoCreateStatusBar() { CreateStatusBar(); }
+
    MInterface * m_MInterface;
    /// profile settings
    Profile *m_Profile;
@@ -658,9 +662,9 @@
    new MMessagesCalDropTarget(this);
 #endif // wxUSE_DRAG_AND_DROP
 
-   CreateStatusBar();
    GetConfig();
-   Show(m_Show);
+   if ( m_Show )
+      ShowInInitialState();
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to