From: <ma...@us...> - 2003-11-21 14:13:39
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv31967 Modified Files: GUISettingsDlg.cpp MainDlg.cpp MainDlg.h Log Message: Toolbar/Menubar displayment/orientation can now be changed w/o restart. Index: GUISettingsDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/GUISettingsDlg.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- GUISettingsDlg.cpp 20 Nov 2003 01:27:26 -0000 1.16 +++ GUISettingsDlg.cpp 21 Nov 2003 14:13:36 -0000 1.17 @@ -194,19 +194,13 @@ * If show_menu or show_tool or tool_align value doesn't match what was * previously written in config, display the notification box. */ - if ( - ((old_show_menu != show_menu) || - (old_show_tool != show_tool) || - (old_tool_align != tool_align)) && - (notfirstload) - ) { - ::wxMessageBox( - _("Menubar and Toolbar settings changes\n" - "require interface restart to take effect."), - _("Restart needed"), - wxOK|wxCENTRE|wxICON_INFORMATION - ); - } +// ::wxMessageBox( +// _("Menubar and Toolbar settings changes\n" +// "require interface restart to take effect."), +// _("Restart needed"), +// wxOK|wxCENTRE|wxICON_INFORMATION +// ); +// } /* And finally save to config object. */ m_config->Write(wxT("Font"), GetFont()->GetSelection()); @@ -246,6 +240,15 @@ wxT("CurLang"), GetLang()->GetString(GetLang()->GetSelection()) ); + + if ((old_show_tool != show_tool) || (old_tool_align != tool_align)) { + mainframe->CreateMyToolBar(); + } + + if (old_show_menu != show_menu) { + mainframe->CreateMenuBar(); + } + } /* Index: MainDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MainDlg.cpp 20 Nov 2003 12:02:20 -0000 1.2 +++ MainDlg.cpp 21 Nov 2003 14:13:36 -0000 1.3 @@ -85,23 +85,14 @@ int height, width, posx, posy; start_up = true; - /* Create toolbar */ - show_tool = true; - m_config->Read(wxT("/General/Show toolbar"), &show_tool, true); - if (show_tool) { - CreateMyToolBar(); - } + CreateMyToolBar(); /* Create status bar */ statusbar = new CStatusBar(this); SetStatusBar(statusbar); /* Create menu bar */ - bool show_menu; - m_config->Read(wxT("/General/Show menubar"), &show_menu, false); - if (show_menu) { - CreateMenuBar(); - } + CreateMenuBar(); /* Set application icon */ wxIcon icon; @@ -214,6 +205,18 @@ */ void CMainDlg::CreateMyToolBar() { int tool_align; + + wxToolBar *tb = GetToolBar(); + delete tb; + SetToolBar(NULL); + + /* Create toolbar */ + bool show_tool = true; + m_config->Read(wxT("/General/Show toolbar"), &show_tool, true); + if (!show_tool) { + return; + } + m_config->Read( wxT("/General/Toolbar alignment"), &tool_align, wxTB_HORIZONTAL ); @@ -261,6 +264,7 @@ /* And go live */ tb->Realize(); + SetToolBar(tb); } /* @@ -289,8 +293,8 @@ */ void CMainDlg::ShowServerWnd(wxCommandEvent &event) { if (show_tool) { - tb->ToggleTool(m_lastbtn, false); - tb->ToggleTool(ID_BTN_SERVERS, true); + GetToolBar()->ToggleTool(m_lastbtn, false); + GetToolBar()->ToggleTool(ID_BTN_SERVERS, true); } m_lastbtn = ID_BTN_SERVERS; SetActiveDialog(serverwnd); @@ -301,11 +305,6 @@ */ wxSizeEvent null_event; serverwnd->OnSize(null_event); - - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -313,16 +312,11 @@ */ void CMainDlg::ShowTransferWnd(wxCommandEvent &event) { if (show_tool) { - tb->ToggleTool(m_lastbtn, false); - tb->ToggleTool(ID_BTN_TRANSFER, true); + GetToolBar()->ToggleTool(m_lastbtn, false); + GetToolBar()->ToggleTool(ID_BTN_TRANSFER, true); } m_lastbtn = ID_BTN_TRANSFER; SetActiveDialog(transferwnd); - - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -330,15 +324,11 @@ */ void CMainDlg::ShowSearchWnd(wxCommandEvent &event) { if (show_tool) { - tb->ToggleTool(m_lastbtn, false); - tb->ToggleTool(ID_BTN_SEARCH, true); + GetToolBar()->ToggleTool(m_lastbtn, false); + GetToolBar()->ToggleTool(ID_BTN_SEARCH, true); } m_lastbtn = ID_BTN_SEARCH; SetActiveDialog(searchwnd); - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -346,15 +336,11 @@ */ void CMainDlg::ShowSharedFilesWnd(wxCommandEvent &event) { if (show_tool) { - tb->ToggleTool(m_lastbtn, false); - tb->ToggleTool(ID_BTN_SHARED_FILES, true); + GetToolBar()->ToggleTool(m_lastbtn, false); + GetToolBar()->ToggleTool(ID_BTN_SHARED_FILES, true); } m_lastbtn = ID_BTN_SHARED_FILES; SetActiveDialog(sharedfileswnd); - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -362,15 +348,11 @@ */ void CMainDlg::ShowMessagesWnd(wxCommandEvent &event) { if (show_tool) { - tb->ToggleTool(m_lastbtn, false); - tb->ToggleTool(ID_BTN_MESSAGES, true); + GetToolBar()->ToggleTool(m_lastbtn, false); + GetToolBar()->ToggleTool(ID_BTN_MESSAGES, true); } m_lastbtn = ID_BTN_MESSAGES; SetActiveDialog(messageswnd); - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -378,25 +360,17 @@ */ void CMainDlg::ShowStatisticsWnd(wxCommandEvent &event) { if (show_tool) { - tb->ToggleTool(m_lastbtn, false); - tb->ToggleTool(ID_BTN_STATISTICS, true); + GetToolBar()->ToggleTool(m_lastbtn, false); + GetToolBar()->ToggleTool(ID_BTN_STATISTICS, true); } m_lastbtn = ID_BTN_STATISTICS; SetActiveDialog(statisticswnd); - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** * Sends command to core to connect to any server */ void CMainDlg::ConnectToAnyServer(wxCommandEvent &event) { - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -409,10 +383,6 @@ ); guisettings->ShowModal(); delete guisettings; - /** - * Force toolbar refresh to fix OS X drawing problems - */ - tb->Refresh(); } /** @@ -446,11 +416,18 @@ * Generates our menubar. */ void CMainDlg::CreateMenuBar() { + bool show_menu = false; + SetMenuBar(NULL); + + m_config->Read(wxT("/General/Show menubar"), &show_menu, false); + if (!show_menu) { + return; + } wxMenu *file_menu = new wxMenu(); file_menu->Append(ID_FILE_CONNECT, _("Connect")); file_menu->Append(ID_FILE_EXIT, _("Quit")); - + wxMenu *edit_menu = new wxMenu(); edit_menu->Append(ID_EDIT_GUI_SETTINGS, _("Preferences")); Index: MainDlg.h =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MainDlg.h 20 Nov 2003 01:27:26 -0000 1.1 +++ MainDlg.h 21 Nov 2003 14:13:36 -0000 1.2 @@ -64,20 +64,20 @@ ~CMainDlg(); wxLocale &m_locale; + void CreateMyToolBar(); + void CreateMenuBar(); private: DECLARE_EVENT_TABLE() - + /* Member event handler functions */ - void OnCloseWindow( wxCloseEvent &event ); + void OnCloseWindow( wxCloseEvent &event ); void OnBtnGUIOk(wxCommandEvent &event); void OnBtnGUICancel(wxCommandEvent &event); - - /* Member functions */ + + /* Member functions */ void SetActiveDialog(wxWindow* dlg); - void CreateMyToolBar(); void CreateSysTray(); - void CreateMenuBar(); void LoadAndShowDialogPages(); void ConnectToAnyServer(wxCommandEvent &event); @@ -96,7 +96,6 @@ // between sessions or not int m_lastbtn; // Last toggled toolbar button wxSizer *m_mainsizer; // Sizer to make dialog pages switching easier. - wxToolBar *tb; // Main toolbar wxWindow *activewnd; // Current active dialog page }; |