|
From: <ma...@us...> - 2003-12-20 03:37:29
|
Update of /cvsroot/sharedaemon/ui-wx/src
In directory sc8-pr-cvs1:/tmp/cvs-serv5284/src
Modified Files:
Images.cpp Images.h MainDlg.cpp wxInterface.cpp
Log Message:
Fixed toolbar images
Index: Images.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/Images.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- Images.cpp 19 Dec 2003 23:50:11 -0000 1.34
+++ Images.cpp 20 Dec 2003 03:37:26 -0000 1.35
@@ -316,23 +316,14 @@
wxBitmap tmp, tmp_new;
int x, y;
- tmp = wxBitmap(100, 100);
- mdc.SelectObject(tmp);
-
mdc.SetTextForeground(wxColour(10, 10, 10));
#ifdef __WXMAC__
mdc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL));
#else
mdc.SetFont(wxFont(10, wxDECORATIVE, wxNORMAL, wxBOLD));
#endif
- mdc.GetTextExtent(name, &x, &y);
- x+=6;
- y+=36;
- x>tool_img_width ? tool_img_width=x : x=tool_img_width;
- y>tool_img_height ? tool_img_height=y : y=tool_img_width;
-
- tmp_new = wxBitmap(x, y);
+ tmp_new = wxBitmap(tool_img_width, tool_img_height);
mdc.SelectObject(tmp_new);
mdc.BeginDrawing();
@@ -349,7 +340,7 @@
GetImage(image),
(tmp_new.GetWidth()-32)/2, 2, true
);
- mdc.SetTextForeground( wxColour(1,1,1));
+ mdc.SetTextForeground(wxColour(1,1,1));
mdc.GetTextExtent(name, &x, &y);
mdc.DrawText(name, (tmp_new.GetWidth()-x)/2, 36);
#ifndef __WXMSW__ /* Use wxMask for transparency */
@@ -363,4 +354,32 @@
wxBitmap *new_image = new wxBitmap(tmp_new);
images.Append(image, new_image);
return *new_image;
+}
+
+/********************************************************* CalcToolBitmapSize */
+/* This method loops through the passed wxArrayString and calculates the text */
+/* length for each of the strings using memorydc and GetTextExtent method. If */
+/* calculated text length exceeds what is stored in global variables, update */
+/* the global variables with new values. All this is neccesery to do before */
+/* calling MakeToolImage(),otherwise the toolbar won't be correctly centered. */
+/* @names wxArrayString containing all toolbar button names. */
+/******************************************************************************/
+void CImages::CalcToolBitmapSize(const wxArrayString &names) {
+unsigned int i=0; /* Loop counter */
+int x, y; /* For storing image size */
+wxMemoryDC mdc; /* Memory drawing context */
+
+#ifdef __WXMAC__
+ mdc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL));
+#else
+ mdc.SetFont(wxFont(10, wxDECORATIVE, wxNORMAL, wxBOLD));
+#endif
+
+ for (i=0;i<names.GetCount();i++) {
+ mdc.GetTextExtent(names.Item(i), &x, &y);
+ x+=6;
+ y+=36;
+ x>tool_img_width ? tool_img_width=x : x=tool_img_width;
+ y>tool_img_height ? tool_img_height=y : y=tool_img_width;
+ }
}
Index: Images.h
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/Images.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Images.h 18 Dec 2003 04:25:36 -0000 1.16
+++ Images.h 20 Dec 2003 03:37:26 -0000 1.17
@@ -42,6 +42,7 @@
void LoadImages();
inline wxBitmap& GetImage(const wxString &name);
void UpdateImages(wxWindow *parent);
+ void CalcToolBitmapSize(const wxArrayString &names);
private:
ListOfBitmaps images;
};
Index: MainDlg.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- MainDlg.cpp 19 Dec 2003 23:50:11 -0000 1.29
+++ MainDlg.cpp 20 Dec 2003 03:37:26 -0000 1.30
@@ -165,9 +165,9 @@
icon.CopyFromBitmap(img->GetImage(wxT("mule")));
SetIcon(icon);
- #ifdef wxHAS_TASK_BAR_ICON
- systray = new CSysTray();
- #endif
+#ifdef wxHAS_TASK_BAR_ICON
+ systray = new CSysTray();
+#endif
m_mainsizer = new wxFlexGridSizer(1);
m_mainsizer->AddGrowableCol(0);
@@ -211,12 +211,11 @@
LoadAndShowDialogPages();
- img->MakeToolImage(_("Connect"), wxT("btn_connect"));
- img->MakeToolImage(_("Preferences"), wxT("btn_guisettings"));
- CreateMyToolBar();
+ CreateMyToolBar(true);
CreateMyMenuBar();
wxGetApp().mainframe_active = true;
+ start_up = false;
}
/****************************************************************** ~CMainDlg */
@@ -242,12 +241,12 @@
m_config->Write(wxT("Start Page"), GetCurPage()->short_title);
}
- #ifdef wxHAS_TASK_BAR_ICON
- #ifdef __WXMSW__
- systray->RemoveIcon();
- #endif
- delete systray;
+#ifdef wxHAS_TASK_BAR_ICON
+ #ifdef __WXMSW__
+ systray->RemoveIcon();
#endif
+ delete systray;
+#endif
wxMenuBar *mb = GetMenuBar();
if (mb != NULL) {
@@ -296,7 +295,6 @@
new_page->content->Show(true);
cur_page = new_page;
Layout();
- start_up = false;
UpdateToolBar();
UpdateMenuBar();
return true;
@@ -333,9 +331,22 @@
MyToolBar *tb = new MyToolBar(
this, ID_TOOLBAR, wxDefaultPosition, wxDefaultSize,
- tool_align|wxNO_BORDER|wxTB_3DBUTTONS|wxTB_FLAT
+ tool_align|wxNO_BORDER|wxTB_3DBUTTONS|wxTB_FLAT|wxCLIP_CHILDREN
);
+ if (start_up) {
+ wxArrayString names;
+ names.Add(_("Connect"));
+ for (i=0;i<pages.GetCount();i++) {
+ if (pages.IsEmpty()) {
+ break;
+ }
+ names.Add(pages.Item(i)->GetData()->short_title);
+ }
+ names.Add(_("Preferences"));
+ img->CalcToolBitmapSize(names);
+ }
+
tb->SetToolBitmapSize(
wxSize(img->tool_img_width, img->tool_img_height)
);
@@ -886,6 +897,13 @@
m_config->Write(
wxT("/General/Show MenuBar"), false
);
+ if (GetToolBar() == NULL) {
+ m_config->Write(
+ wxT("/General/Show ToolBar"),
+ true
+ );
+ CreateMyToolBar();
+ }
}
CreateMyMenuBar();
break;
@@ -898,6 +916,13 @@
m_config->Write(
wxT("/General/Show ToolBar"), false
);
+ if (GetMenuBar() == NULL) {
+ m_config->Write(
+ wxT("/General/Show MenuBar"),
+ true
+ );
+ CreateMyMenuBar();
+ }
}
CreateMyToolBar();
UpdateMenuBar();
@@ -1012,7 +1037,9 @@
newpage->image = image;
newpage->id = id;
- img->MakeToolImage(newpage->short_title, newpage->image);
+ if (!start_up) {
+ img->MakeToolImage(newpage->short_title, newpage->image);
+ }
pages.Append(short_title, newpage);
if (update_bars) {
Index: wxInterface.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/wxInterface.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- wxInterface.cpp 18 Dec 2003 04:25:36 -0000 1.10
+++ wxInterface.cpp 20 Dec 2003 03:37:26 -0000 1.11
@@ -73,12 +73,11 @@
} // No need to delete splash - it will be deleted by wx
Localize();
-
/* Display the main dialog */
mainframe = new CMainDlg(
NULL, -1, APPVER_LONG, wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE|
- wxNO_FULL_REPAINT_ON_RESIZE,
+ wxNO_FULL_REPAINT_ON_RESIZE,
m_locale
);
mainframe->Show( TRUE );
|