]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed problems with wxFrame::SetIcons
authorMattia Barbon <mbarbon@cpan.org>
Thu, 28 Mar 2002 20:51:55 +0000 (20:51 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Thu, 28 Mar 2002 20:51:55 +0000 (20:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/iconbndl.cpp
src/gtk/toplevel.cpp
src/gtk1/toplevel.cpp
src/unix/utilsx11.cpp

index 479c5dd27ccf08b3788221879a7c860970fc5dc9..ef64f80fae6d7299a178a87f962199c70788f8dc 100644 (file)
@@ -83,6 +83,8 @@ const wxIcon& wxIconBundle::GetIcon( const wxSize& size ) const
 
     for( i = 0; i < max; ++i )
     {
+        if( !m_icons[i].Ok() )
+            continue;
         wxCoord sx = m_icons[i].GetWidth(), sy = m_icons[i].GetHeight();
         // requested size
         if( sx == size.x && sy == size.y )
@@ -105,7 +107,7 @@ void wxIconBundle::AddIcon( const wxIcon& icon )
     for( i = 0; i < max; ++i )
     {
         wxIcon& tmp = m_icons[i];
-        if( tmp.GetWidth() == icon.GetWidth() &&
+        if( tmp.Ok() && tmp.GetWidth() == icon.GetWidth() &&
             tmp.GetHeight() == icon.GetHeight() )
         {
             tmp = icon;
index 6484fa7f0090a0df223237b5ec2a98600be66ca5..f94dbeab591a24c6a1f19f2ed64ff8392007d3ad 100644 (file)
@@ -191,12 +191,13 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *
         gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
 
     // reset the icon
-    wxIcon iconOld = win->GetIcon();
-    if ( iconOld != wxNullIcon )
+    wxIconBundle iconsOld = win->GetIcons();
+    wxIcon tmp = iconsOld.GetIcon( -1 ); // operator != is not-const
+    if ( tmp != wxNullIcon )
     {
-        wxIcon icon( iconOld );
+        // wxIconBundle icon( iconOld );
         win->SetIcon( wxNullIcon );
-        win->SetIcon( icon );
+        win->SetIcons( iconsOld );
     }
 
     // we set the focus to the child that accepts the focus. this
@@ -840,13 +841,13 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
     GdkWindow* window = m_widget->window;
-    wxCHECK_RET( window, _T("window not created yet - can't set icon") );
 
     wxTopLevelWindowBase::SetIcons( icons );
 
     DoSetIcon( icons.GetIcon( -1 ) );
-    wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
-                   (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
+    if( window )
+        wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
+                       (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
 }
 
 // ----------------------------------------------------------------------------
index 6484fa7f0090a0df223237b5ec2a98600be66ca5..f94dbeab591a24c6a1f19f2ed64ff8392007d3ad 100644 (file)
@@ -191,12 +191,13 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *
         gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
 
     // reset the icon
-    wxIcon iconOld = win->GetIcon();
-    if ( iconOld != wxNullIcon )
+    wxIconBundle iconsOld = win->GetIcons();
+    wxIcon tmp = iconsOld.GetIcon( -1 ); // operator != is not-const
+    if ( tmp != wxNullIcon )
     {
-        wxIcon icon( iconOld );
+        // wxIconBundle icon( iconOld );
         win->SetIcon( wxNullIcon );
-        win->SetIcon( icon );
+        win->SetIcons( iconsOld );
     }
 
     // we set the focus to the child that accepts the focus. this
@@ -840,13 +841,13 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
     GdkWindow* window = m_widget->window;
-    wxCHECK_RET( window, _T("window not created yet - can't set icon") );
 
     wxTopLevelWindowBase::SetIcons( icons );
 
     DoSetIcon( icons.GetIcon( -1 ) );
-    wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
-                   (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
+    if( window )
+        wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
+                       (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
 }
 
 // ----------------------------------------------------------------------------
index 778447cea1ca661a325ad8572e41c8e05ffe364f..d09ae2499268987d980d7276fa6872b84acf0711 100644 (file)
@@ -32,7 +32,8 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window,
     size_t i, max = ib.m_icons.GetCount();
 
     for( i = 0; i < max; ++i )
-        size += 2 + ib.m_icons[i].GetWidth() * ib.m_icons[i].GetHeight();
+        if( ib.m_icons[i].Ok() )
+            size += 2 + ib.m_icons[i].GetWidth() * ib.m_icons[i].GetHeight();
 
     Atom net_wm_icon = XInternAtom( (Display*)display, "_NET_WM_ICON", 0 );