|
From: <ma...@us...> - 2003-12-27 12:38:59
|
Update of /cvsroot/sharedaemon/ui-wx/src
In directory sc8-pr-cvs1:/tmp/cvs-serv9898
Modified Files:
GUISettingsDlg.cpp MainDlg.cpp MainDlg.h
Log Message:
Fixed most bugs in page detaching engine that new pages-list handling produced.
Index: GUISettingsDlg.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/GUISettingsDlg.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- GUISettingsDlg.cpp 27 Dec 2003 07:39:54 -0000 1.32
+++ GUISettingsDlg.cpp 27 Dec 2003 12:38:55 -0000 1.33
@@ -131,7 +131,24 @@
GetShowTool()->SetValue(show_toolbar);
GetShowMenu()->SetValue(show_menubar);
GetRememberLast()->SetValue(remember_last);
- GetStartPage()->SetStringSelection(_(startpage));
+
+ /**
+ * The StartPage choice box is generated from mainframe pagelist,
+ * so its safe to do this here w/o much error-checking...
+ * We iterate on the choice contents, look up the key string matching
+ * our client-data in choice and compare that keystring to what we
+ * have in m_config. If match is found, set selection to that one.
+ * The reason for all this mess is that we have *translated* strings
+ * in choice control, but *un-translated* strings in config.
+ */
+ for (short i=0;i<GetStartPage()->GetCount();i++) {
+ Page *p = (Page*)GetStartPage()->GetClientData(i);
+ wxString str = mainframe->GetPageList().Find(p)->GetKeyString();
+ if (str == startpage) {
+ GetStartPage()->SetStringSelection(p->short_title);
+ break;
+ }
+ }
switch (tool_align) {
case wxTB_HORIZONTAL: tool_align = 0; break;
@@ -197,10 +214,12 @@
Page *start_page = (Page*)GetStartPage()->GetClientData(
GetStartPage()->GetSelection()
);
- m_config->Write(
- wxT("StartPage"),
- mainframe->GetPageList().Find(start_page)->GetKeyString()
- );
+ if (start_page != NULL) {
+ wxPageListNode* nod = mainframe->GetPageList().Find(start_page);
+ if (nod != NULL) {
+ m_config->Write(wxT("StartPage"), nod->GetKeyString());
+ }
+ }
m_config->Write(wxT("Remember last"), GetRememberLast()->GetValue());
/* Iconsets data */
@@ -245,25 +264,7 @@
/* If iconset setting was changed update the images in gui */
if (old_icon_set != icon_set) {
- mainframe->Freeze();
-
- img->LoadImages();
- img->UpdateImages(mainframe);
- mainframe->CreateMyToolBar(true);
- serverwnd->SetLogBookImages();
- statisticswnd->GetTree()->GetTreeImages();
- statisticswnd->GetTree()->GenerateTree();
-
- wxIcon icon;
- icon.CopyFromBitmap(img->GetImage(wxT("mule")));
- mainframe->SetIcon(icon);
-#ifdef wxHAS_TASK_BAR_ICON
- #ifdef __WXMSW__
- systray->SetIcon(icon);
- #endif
-#endif
-
- mainframe->Thaw();
+ mainframe->UpdateImages();
}
}
Index: MainDlg.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- MainDlg.cpp 27 Dec 2003 07:39:54 -0000 1.42
+++ MainDlg.cpp 27 Dec 2003 12:38:55 -0000 1.43
@@ -95,13 +95,14 @@
/******************************************************************************/
void DetachedFrame::OnClose(wxCommandEvent &event) {
cnt->content->Hide();
+ Hide();
if (wxGetApp().mainframe_active) {
cnt->content->Reparent(mainframe);
mainframe->AddPage(cnt, true);
} else {
delete cnt;
}
- Destroy();
+ event.Skip();
}
BEGIN_EVENT_TABLE(CMainDlg, wxFrame)
@@ -246,14 +247,19 @@
if (cur_page == NULL) {
start_up = true; /* Assume startup */
} else if (to_show == wxEmptyString) {
+ wxLogDebug(wxT("wxEmptyString passed for showing."));
return false; /* Nothing to show */
} else if (to_show == wxT("")) {
+ wxLogDebug(wxT("Empty string passed for showing."));
return false; /* Nothing to show */
} else if (pages.Find(cur_page)->GetKeyString() == to_show) {
+ wxLogDebug(wxT("Page `%s` is already shown!"), to_show.c_str());
return false; /* Already shown */
} else if (pages.Find(to_show) == NULL) {
+ wxLogDebug(wxT("Page `%s` not found."), to_show.c_str());
return false; /* Not found */
}
+
wxLogDebug(wxT("Setting active page to `%s`"), to_show.c_str());
Page *new_page = pages.Find(to_show)->GetData();
if (new_page == NULL) {
@@ -950,16 +956,23 @@
pages.DeleteObject(page);
pages.DeleteContents(false);
- delete GetToolBar()->RemoveTool(page->id);
+ if (GetToolBar() != NULL) {
+ delete GetToolBar()->RemoveTool(page->id);
+ }
+ if (GetMenuBar() != NULL) {
+ delete GetMenuBar()->FindItem(page->id);
+ }
GetToolBar()->Realize();
start_up = true;
if (!pages.IsEmpty()) {
+ cur_page = NULL;
SetActivePage(pages.Item(0)->GetKeyString());
}
UpdateToolBar();
UpdateMenuBar();
+ start_up = false;
}
/************************************************************** DetachCurPage */
@@ -970,6 +983,10 @@
/* from pages list. */
/******************************************************************************/
void CMainDlg::DetachCurPage() {
+ wxLogDebug(
+ wxT("Detaching page `%s`."),
+ GetCurPage()->short_title.c_str()
+ );
new DetachedFrame(
NULL, -1, GetCurPage()->short_title, wxDefaultPosition,
GetCurPage()->content->GetSize(), wxDEFAULT_FRAME_STYLE|
@@ -1041,4 +1058,41 @@
CreateMyToolBar();
CreateMyMenuBar();
}
+}
+
+/*************************************************************** UpdateImages */
+/* This method updates all images in GUI (including detached frames) by going */
+/* through the list of pages and calling images->UpdateImages on each of them.*/
+/******************************************************************************/
+void CMainDlg::UpdateImages() {
+ Freeze();
+
+ img->LoadImages();
+ wxLogDebug(wxT("Updating all pages images..."));
+ for (size_t i=0;i<pages.GetCount();i++) {
+ if (pages.IsEmpty()) {
+ break;
+ }
+ wxLogDebug(
+ wxT("Count = %d Current = %d"), pages.GetCount(), i
+ );
+ wxLogDebug(
+ wxT("Updating `%s` page images."),
+ pages[i]->short_title.c_str()
+ );
+ img->UpdateImages(pages[i]->content);
+ }
+ CreateMyToolBar(true);
+ serverwnd->SetLogBookImages();
+ statisticswnd->GetTree()->GetTreeImages();
+ statisticswnd->GetTree()->GenerateTree();
+
+ wxIcon icon;
+ icon.CopyFromBitmap(img->GetImage(wxT("mule")));
+ SetIcon(icon);
+#if defined(wxHAS_TASK_BAR_ICON) && defined(__WXMSW__)
+ systray->SetIcon(icon);
+#endif
+
+ Thaw();
}
Index: MainDlg.h
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- MainDlg.h 26 Dec 2003 11:36:32 -0000 1.17
+++ MainDlg.h 27 Dec 2003 12:38:55 -0000 1.18
@@ -134,6 +134,7 @@
bool updatebars = false
);
void AddPage(Page *page, bool updatebars = false); /* Adds new page */
+ void UpdateImages(); /* Updates images */
wxLocale &m_locale; /* Localization object */
/* These need to be publically available */
@@ -226,7 +227,7 @@
bool start_up; /* Should we remember last page between sessions */
wxFlexGridSizer *m_mainsizer; /* Main frame sizer */
Page *cur_page; /* Current active dialog page */
- PageList pages; /* List of loaded dialog pages */
+ PageList pages; /* List of dialog pages in this frame */
};
#endif
|