From 389d906b21e2cf2939fad5990383f2b33dcc6373 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 24 Mar 2002 00:21:26 +0000 Subject: [PATCH] don't use wxApp::GetStdIcon git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/controls/controls.cpp | 11 ++++++----- samples/drawing/drawing.cpp | 7 ++++--- samples/widgets/notebook.cpp | 10 ++++++---- src/generic/logg.cpp | 31 ++++++++++++++++++++++--------- src/generic/msgdlgg.cpp | 20 +++++++++++++++++--- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 5b76022c9f..e4b7ae08e7 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -29,6 +29,7 @@ #include "wx/tglbtn.h" #include "wx/notebook.h" #include "wx/imaglist.h" +#include "wx/artprov.h" #if wxUSE_TOOLTIPS #include "wx/tooltip.h" @@ -721,12 +722,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) panel = new wxPanel(m_notebook); #if !defined(__WXMOTIF__) && !defined(__WIN16__) // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16. - wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); + wxIcon icon = wxArtProvider::GetIcon(wxART_INFORMATION); wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon, wxPoint(10, 10)); bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10)); - bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION)); + bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION)); #endif // !Motif wxBitmap bitmap( 100, 100 ); @@ -751,9 +752,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) } #endif - wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)), - bmp2(wxTheApp->GetStdIcon(wxICON_WARNING)), - bmp3(wxTheApp->GetStdIcon(wxICON_QUESTION)); + wxBitmap bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION)), + bmp2(wxArtProvider::GetBitmap(wxART_WARNING)), + bmp3(wxArtProvider::GetBitmap(wxART_QUESTION)); wxBitmapButton *bmpBtn = new wxBitmapButton ( panel, -1, diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index d96730ad2c..b8c1079ae3 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -37,6 +37,7 @@ #include "wx/colordlg.h" #include "wx/image.h" +#include "wx/artprov.h" // ---------------------------------------------------------------------------- // ressources @@ -368,7 +369,7 @@ MyCanvas::MyCanvas(MyFrame *parent) m_owner = parent; m_show = Show_Default; m_smile_bmp = wxBitmap(smile_xpm); - m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); + m_std_icon = wxArtProvider::GetIcon(wxART_INFORMATION); } void MyCanvas::DrawTestBrushes(wxDC& dc) @@ -553,9 +554,9 @@ void MyCanvas::DrawDefault(wxDC& dc) memdc.SelectObject( wxNullBitmap ); dc.DrawBitmap( bitmap, 10, 170 ); - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); image.Rescale( 60,210 ); - bitmap = image.ConvertToBitmap(); + bitmap = wxBitmap(image); dc.DrawBitmap( bitmap, 50, 170 ); // test the rectangle outline drawing - there should be one pixel between diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index 92d8c089d5..170e535864 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -41,6 +41,7 @@ #include "wx/sizer.h" #include "wx/notebook.h" +#include "wx/artprov.h" #include "widgets.h" @@ -320,10 +321,11 @@ void NotebookWidgetsPage::CreateImageList() { // create a dummy image list with a few icons m_imageList = new wxImageList(32, 32); - m_imageList->Add(wxTheApp->GetStdIcon(wxICON_INFORMATION)); - m_imageList->Add(wxTheApp->GetStdIcon(wxICON_QUESTION)); - m_imageList->Add(wxTheApp->GetStdIcon(wxICON_WARNING)); - m_imageList->Add(wxTheApp->GetStdIcon(wxICON_ERROR)); + wxSize size(32, 32); + m_imageList->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size)); + m_imageList->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size)); + m_imageList->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size)); + m_imageList->Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size)); } m_notebook->SetImageList(m_imageList); diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index fd60b1f972..5bff11e876 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -52,6 +52,7 @@ #include "wx/file.h" #include "wx/textfile.h" #include "wx/statline.h" +#include "wx/artprov.h" #ifdef __WXMSW__ // for OutputDebugString() @@ -734,8 +735,19 @@ wxLogDialog::wxLogDialog(wxWindow *parent, sizerButtons->Add(m_btnDetails, 0, wxCENTRE | wxTOP, MARGIN/2 - 1); #ifndef __WIN16__ - wxIcon icon = wxTheApp->GetStdIcon((int)(style & wxICON_MASK)); - sizerAll->Add(new wxStaticBitmap(this, -1, icon), 0); + wxBitmap bitmap; + switch ( style & wxICON_MASK ) + { + case wxICON_ERROR: + bitmap = wxArtProvider::GetIcon(wxART_ERROR, wxART_MESSAGE_BOX); break; + case wxICON_INFORMATION: + bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX); break; + case wxICON_WARNING: + bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX); break; + default: + wxFAIL_MSG(_T("incorrect log style")); + } + sizerAll->Add(new wxStaticBitmap(this, -1, bitmap), 0); #endif // !Win16 const wxString& message = messages.Last(); @@ -795,11 +807,11 @@ void wxLogDialog::CreateDetailsControls() wxImageList *imageList = new wxImageList(ICON_SIZE, ICON_SIZE); // order should be the same as in the switch below! - static const int icons[] = + static const wxChar* icons[] = { - wxICON_ERROR, - wxICON_EXCLAMATION, - wxICON_INFORMATION + wxART_ERROR, + wxART_WARNING, + wxART_INFORMATION }; bool loadedIcons = TRUE; @@ -807,19 +819,20 @@ void wxLogDialog::CreateDetailsControls() #ifndef __WIN16__ for ( size_t icon = 0; icon < WXSIZEOF(icons); icon++ ) { - wxBitmap bmp = wxTheApp->GetStdIcon(icons[icon]); + wxBitmap bmp = wxArtProvider::GetBitmap(icons[icon], wxART_MESSAGE_BOX, + wxSize(ICON_SIZE, ICON_SIZE)); // This may very well fail if there are insufficient colours available. // Degrade gracefully. if ( !bmp.Ok() ) { + wxLogError("FAILED fro %s:", icons[icon]); loadedIcons = FALSE; break; } - wxImage img(bmp); - imageList->Add(img.Rescale(ICON_SIZE, ICON_SIZE).ConvertToBitmap()); + imageList->Add(bmp); } m_listctrl->SetImageList(imageList, wxIMAGE_LIST_SMALL); diff --git a/src/generic/msgdlgg.cpp b/src/generic/msgdlgg.cpp index f4f383f676..0326abef58 100644 --- a/src/generic/msgdlgg.cpp +++ b/src/generic/msgdlgg.cpp @@ -39,6 +39,7 @@ #include #include "wx/generic/msgdlgg.h" +#include "wx/artprov.h" #if wxUSE_STATLINE #include "wx/statline.h" @@ -72,9 +73,22 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, // 1) icon if (style & wxICON_MASK) { - wxStaticBitmap *icon = new wxStaticBitmap( - this, -1, wxTheApp->GetStdIcon((int)(style & wxICON_MASK))); - icon_text->Add( icon, 0, wxCENTER ); + wxBitmap bitmap; + switch ( style & wxICON_MASK ) + { + case wxICON_ERROR: + bitmap = wxArtProvider::GetIcon(wxART_ERROR, wxART_MESSAGE_BOX); break; + case wxICON_INFORMATION: + bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX); break; + case wxICON_WARNING: + bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX); break; + case wxICON_QUESTION: + bitmap = wxArtProvider::GetIcon(wxART_QUESTION, wxART_MESSAGE_BOX); break; + default: + wxFAIL_MSG(_T("incorrect log style")); + } + wxStaticBitmap *icon = new wxStaticBitmap(this, -1, bitmap); + icon_text->Add( icon, 0, wxCENTER ); } // 2) text -- 2.45.2