From: <ma...@us...> - 2003-11-27 15:21:32
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv18402 Modified Files: Images.cpp Log Message: Tbar buttons are now transparent on wxX11 and wxGTK (thanks Sebastien). Also cleaned up drawing code into one forloop. Index: Images.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/Images.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Images.cpp 27 Nov 2003 13:52:51 -0000 1.25 +++ Images.cpp 27 Nov 2003 15:21:29 -0000 1.26 @@ -153,19 +153,28 @@ */ void CImages::MakeToolImages() { wxBitmap tmp, tmp_new; + wxMask *tmp_mask; wxMemoryDC mdc; wxCoord x, y, width = 0, height = 0; - wxArrayString btntxt; + wxArrayString btntxt, btnimg; /* List of button names */ btntxt.Add(_("Connect")); + btnimg.Add(wxT("btn_connect")); btntxt.Add(_("Servers")); + btnimg.Add(wxT("btn_servers")); btntxt.Add(_("Search")); + btnimg.Add(wxT("btn_search")); btntxt.Add(_("Transfer")); + btnimg.Add(wxT("btn_transfer")); btntxt.Add(_("Shared Files")); + btnimg.Add(wxT("btn_shared")); btntxt.Add(_("Messaging")); + btnimg.Add(wxT("btn_messages")); btntxt.Add(_("Statistics")); + btnimg.Add(wxT("btn_statistics")); btntxt.Add(_("Preferences")); + btnimg.Add(wxT("btn_guisettings")); /* Temporary bitmap for measuring text lengths. 100 pixels should be enuff. */ tmp = wxBitmap(100, 100); @@ -190,70 +199,21 @@ m_config->Write(wxT("/General/ToolButtonBackground"), background); mdc.SetBrush(wxBrush(*wxTheColourDatabase->FindColour(background), wxSOLID)); - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_connect")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(0), &x, &y); - mdc.DrawText(btntxt.Item(0), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_connect")) = tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_servers")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(1), &x, &y); - mdc.DrawText(btntxt.Item(1), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_servers")) = tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_search")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(2), &x, &y); - mdc.DrawText(btntxt.Item(2), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_search"))= tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_transfer")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(3), &x, &y); - mdc.DrawText(btntxt.Item(3), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_transfer")) = tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_shared")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(4), &x, &y); - mdc.DrawText(btntxt.Item(4), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_shared")) = tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_messages")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(5), &x, &y); - mdc.DrawText(btntxt.Item(5), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_messages")) = tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_statistics")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(6), &x, &y); - mdc.DrawText(btntxt.Item(6), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_statistics")) = tmp_new; - - tmp_new = wxBitmap(width, height); - mdc.SelectObject(tmp_new); - mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); - mdc.DrawBitmap(GetImage(wxT("btn_guisettings")), (tmp_new.GetWidth()-32)/2, 2, true); - mdc.GetTextExtent(btntxt.Item(7), &x, &y); - mdc.DrawText(btntxt.Item(7), (tmp_new.GetWidth()-x)/2, 36); - GetImage(wxT("btn_guisettings")) = tmp_new; - + /* Loop through our lists of texts/images and draw images for toolbar */ + for (unsigned int i=0;i<btntxt.GetCount();i++) { + tmp_new = wxBitmap(width, height); + mdc.SelectObject(tmp_new); + mdc.SetBrush(wxBrush(wxColour(0, 0, 0), wxSOLID)); + mdc.DrawRectangle(0, 0, tmp_new.GetWidth(), tmp_new.GetHeight()); + mdc.SetBrush(wxBrush(*wxTheColourDatabase->FindColour(background), wxSOLID)); + mdc.DrawBitmap(GetImage(btnimg.Item(i)), (tmp_new.GetWidth()-32)/2, 2, true); + mdc.SetTextForeground( wxColour(1,1,1)); + mdc.GetTextExtent(btntxt.Item(i), &x, &y); + mdc.DrawText(btntxt.Item(i), (tmp_new.GetWidth()-x)/2, 36); + tmp_mask = new wxMask(tmp_new, wxColour(0,0,0)); + tmp_new.SetMask(tmp_mask); + GetImage(btnimg.Item(i)) = tmp_new; + } } /** |