From: Vadim Zeitlin Date: Sat, 7 Apr 2007 23:40:55 +0000 (+0000) Subject: made wxTLW::SetIcon() non-virtual, it was already implemented in terms of X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ea098413d0e9c3f794f43826137a636e229f26f9?ds=inline made wxTLW::SetIcon() non-virtual, it was already implemented in terms of SetIcons() in most of the ports, now do it in all of them git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45322 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/cocoa/toplevel.h b/include/wx/cocoa/toplevel.h index 5ac33f1a77..775c8db9c9 100644 --- a/include/wx/cocoa/toplevel.h +++ b/include/wx/cocoa/toplevel.h @@ -108,8 +108,7 @@ public: // Things I may/may not do -// virtual void SetIcon(const wxIcon& icon); -// virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); } +// virtual void SetIcons(const wxIconBundle& icons); // virtual void Clear() ; // virtual void Raise(); // virtual void Lower(); diff --git a/include/wx/generic/mdig.h b/include/wx/generic/mdig.h index 4ca3ba2625..bd0f0a39f0 100644 --- a/include/wx/generic/mdig.h +++ b/include/wx/generic/mdig.h @@ -170,8 +170,7 @@ public: #endif // no icon - void SetIcon( const wxIcon& WXUNUSED(icon) ) { } - void SetIcons( const wxIconBundle& WXUNUSED(icons) ) { } + virtual void SetIcons( const wxIconBundle& WXUNUSED(icons) ) { } // no maximize etc virtual void Maximize( bool WXUNUSED(maximize) = true) { /* Has no effect */ } diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index 051987ad7e..5ce91c006e 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -133,8 +133,6 @@ public: #endif // wxUSE_TOOLBAR // no icon - virtual void SetIcon(const wxIcon& icon) - { wxTopLevelWindowBase::SetIcon(icon); } virtual void SetIcons(const wxIconBundle& icons ) { wxTopLevelWindowBase::SetIcons(icons); } diff --git a/include/wx/gtk/toplevel.h b/include/wx/gtk/toplevel.h index 7e0a51d981..fcc7ff9871 100644 --- a/include/wx/gtk/toplevel.h +++ b/include/wx/gtk/toplevel.h @@ -47,7 +47,6 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index 3ccf1b4d7f..cec5798bab 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -155,8 +155,6 @@ public: #endif // wxUSE_TOOLBAR // no icon - virtual void SetIcon(const wxIcon& icon) - { wxTopLevelWindowBase::SetIcon(icon); } virtual void SetIcons(const wxIconBundle& icons ) { wxTopLevelWindowBase::SetIcons(icons); } diff --git a/include/wx/gtk1/toplevel.h b/include/wx/gtk1/toplevel.h index beeb8635f7..3a3042dc97 100644 --- a/include/wx/gtk1/toplevel.h +++ b/include/wx/gtk1/toplevel.h @@ -47,7 +47,6 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); diff --git a/include/wx/mac/carbon/toplevel.h b/include/wx/mac/carbon/toplevel.h index b50b7160b6..f66ada9000 100644 --- a/include/wx/mac/carbon/toplevel.h +++ b/include/wx/mac/carbon/toplevel.h @@ -60,8 +60,6 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); - virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); } virtual void Restore(); virtual bool SetShape(const wxRegion& region); diff --git a/include/wx/motif/frame.h b/include/wx/motif/frame.h index a5cf199637..7e52ecd467 100644 --- a/include/wx/motif/frame.h +++ b/include/wx/motif/frame.h @@ -48,7 +48,6 @@ public: void SetTitle(const wxString& title); // Set icon - virtual void SetIcon(const wxIcon& icon); virtual void SetIcons(const wxIconBundle& icons); #if wxUSE_STATUSBAR diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index fdca302814..48e7e512e4 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -52,7 +52,6 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); virtual void SetIcons(const wxIconBundle& icons ); virtual void Restore(); diff --git a/include/wx/os2/toplevel.h b/include/wx/os2/toplevel.h index a251addfe7..e5fa3c0723 100644 --- a/include/wx/os2/toplevel.h +++ b/include/wx/os2/toplevel.h @@ -67,7 +67,6 @@ public: virtual void Maximize(bool bMaximize = true); virtual void Restore(void); virtual void SendSizeEvent(void); - virtual void SetIcon(const wxIcon& rIcon); virtual void SetIcons(const wxIconBundle& rIcons); virtual bool Show(bool bShow = true); diff --git a/include/wx/palmos/toplevel.h b/include/wx/palmos/toplevel.h index 08954715af..a931c9e3b9 100644 --- a/include/wx/palmos/toplevel.h +++ b/include/wx/palmos/toplevel.h @@ -54,8 +54,7 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); - virtual void SetIcons(const wxIconBundle& icons ); + virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); #ifndef __WXWINCE__ diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index 3814678337..268ecbd4ad 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -145,16 +145,16 @@ public: virtual bool IsIconized() const = 0; // get the frame icon - wxIcon GetIcon() const { return m_icons.GetIcon( -1 ); } + wxIcon GetIcon() const; // get the frame icons const wxIconBundle& GetIcons() const { return m_icons; } - // set the frame icon - virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); } + // set the frame icon: implemented in terms of SetIcons() + void SetIcon(const wxIcon& icon); // set the frame icons - virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; } + virtual void SetIcons(const wxIconBundle& icons) { m_icons = icons; } // maximize the window to cover entire screen virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0; diff --git a/include/wx/univ/toplevel.h b/include/wx/univ/toplevel.h index 3ab4c58d32..aace185fbd 100644 --- a/include/wx/univ/toplevel.h +++ b/include/wx/univ/toplevel.h @@ -130,7 +130,6 @@ public: // implement base class pure virtuals virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual wxPoint GetClientAreaOrigin() const; - virtual void SetIcon(const wxIcon& icon) { SetIcons( wxIconBundle( icon ) ); } virtual void SetIcons(const wxIconBundle& icons); // implementation from now on diff --git a/include/wx/x11/toplevel.h b/include/wx/x11/toplevel.h index 675fc4ad08..ae820864c2 100644 --- a/include/wx/x11/toplevel.h +++ b/include/wx/x11/toplevel.h @@ -50,7 +50,6 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = true); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon) { SetIcons( wxIconBundle( icon ) ); } virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 433e3a6aae..c1645bd9be 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -315,6 +315,26 @@ bool wxTopLevelWindowBase::IsAlwaysMaximized() const #endif } +// ---------------------------------------------------------------------------- +// icons +// ---------------------------------------------------------------------------- + +wxIcon wxTopLevelWindowBase::GetIcon() const +{ + return m_icons.IsEmpty() ? wxIcon() : m_icons.GetIcon( -1 ); +} + +void wxTopLevelWindowBase::SetIcon(const wxIcon& icon) +{ + // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't + // have any icon), but adding an invalid icon to wxIconBundle is not + wxIconBundle icons; + if ( icon.Ok() ) + icons.AddIcon(icon); + + SetIcons(icons); +} + // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index b53b2b681a..66c6dfa436 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -1173,17 +1173,6 @@ void wxTopLevelWindowGTK::SetTitle( const wxString &title ) gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); } -void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) -{ - // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't - // have any icon), but adding an invalid icon to wxIconBundle is not - wxIconBundle icons; - if ( icon.Ok() ) - icons.AddIcon(icon); - - SetIcons(icons); -} - void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); diff --git a/src/gtk1/toplevel.cpp b/src/gtk1/toplevel.cpp index 97c4fc09c6..ba996a4a9d 100644 --- a/src/gtk1/toplevel.cpp +++ b/src/gtk1/toplevel.cpp @@ -1086,17 +1086,6 @@ void wxTopLevelWindowGTK::SetTitle( const wxString &title ) gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); } -void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) -{ - // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't - // have any icon), but adding an invalid icon to wxIconBundle is not - wxIconBundle icons; - if ( icon.Ok() ) - icons.AddIcon(icon); - - SetIcons(icons); -} - void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index d29746a500..f3f0878937 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -1031,12 +1031,6 @@ wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const return wxPoint(0, 0) ; } -void wxTopLevelWindowMac::SetIcon(const wxIcon& icon) -{ - // this sets m_icon - wxTopLevelWindowBase::SetIcon(icon); -} - void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush ) { wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ; diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index 6870ed2bc2..c4555bb150 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -470,11 +470,6 @@ void wxFrame::DoSetIcon(const wxIcon& icon) NULL); } -void wxFrame::SetIcon(const wxIcon& icon) -{ - SetIcons( wxIconBundle( icon ) ); -} - void wxFrame::SetIcons(const wxIconBundle& icons) { wxFrameBase::SetIcons( icons ); diff --git a/src/motif/toplevel.cpp b/src/motif/toplevel.cpp index aaa53556da..35af4ecfe6 100644 --- a/src/motif/toplevel.cpp +++ b/src/motif/toplevel.cpp @@ -72,8 +72,6 @@ void wxTopLevelWindowMotif::PreDestroy() { wxModelessWindows.DeleteObject(this); - m_icons.m_icons.Empty(); - DestroyChildren(); // MessageDialog and FileDialog do not have a client widget diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index fae5b35149..3704dcf8a8 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -977,24 +977,19 @@ wxString wxTopLevelWindowMSW::GetTitle() const return GetLabel(); } -void wxTopLevelWindowMSW::SetIcon(const wxIcon& icon) -{ - SetIcons( wxIconBundle( icon ) ); -} - void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons) { wxTopLevelWindowBase::SetIcons(icons); #if !defined(__WXMICROWIN__) - const wxIcon& sml = icons.GetIcon( wxSize( 16, 16 ) ); + const wxIcon& sml = icons.GetIcon(16); if( sml.Ok() && sml.GetWidth() == 16 && sml.GetHeight() == 16 ) { ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_SMALL, (LPARAM)GetHiconOf(sml) ); } - const wxIcon& big = icons.GetIcon( wxSize( 32, 32 ) ); + const wxIcon& big = icons.GetIcon(32); if( big.Ok() && big.GetWidth() == 32 && big.GetHeight() == 32 ) { ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_BIG, diff --git a/src/os2/toplevel.cpp b/src/os2/toplevel.cpp index 8b467cc7c7..b231df5bff 100644 --- a/src/os2/toplevel.cpp +++ b/src/os2/toplevel.cpp @@ -995,13 +995,6 @@ bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow, // wxTopLevelWindowOS2 misc // ---------------------------------------------------------------------------- -void wxTopLevelWindowOS2::SetIcon( - const wxIcon& rIcon -) -{ - SetIcons(wxIconBundle(rIcon)); -} // end of wxTopLevelWindowOS2::SetIcon - void wxTopLevelWindowOS2::SetIcons( const wxIconBundle& rIcons ) @@ -1011,7 +1004,7 @@ void wxTopLevelWindowOS2::SetIcons( // wxTopLevelWindowBase::SetIcons(rIcons); - const wxIcon& vIcon = rIcons.GetIcon(wxSize(32, 32)); + const wxIcon& vIcon = rIcons.GetIcon(32); if (vIcon.Ok() && vIcon.GetWidth() == 32 && vIcon.GetHeight() == 32) { diff --git a/src/palmos/toplevel.cpp b/src/palmos/toplevel.cpp index 0b1105aafc..2093565f33 100644 --- a/src/palmos/toplevel.cpp +++ b/src/palmos/toplevel.cpp @@ -234,10 +234,6 @@ wxString wxTopLevelWindowPalm::GetTitle() const return wxEmptyString; } -void wxTopLevelWindowPalm::SetIcon(const wxIcon& icon) -{ -} - void wxTopLevelWindowPalm::SetIcons(const wxIconBundle& icons) { } diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index 58248bf16f..0f7e4a9b4d 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -373,8 +373,7 @@ void wxTopLevelWindowX11::DoSetIcon(const wxIcon& icon) { if (icon.Ok() && GetMainWindow()) { -#if wxUSE_NANOX -#else +#if !wxUSE_NANOX XWMHints *wmHints = XAllocWMHints(); wmHints->icon_pixmap = (Pixmap) icon.GetPixmap();