]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dialog.cpp
MSW compilation fixes
[wxWidgets.git] / src / gtk1 / dialog.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dialog.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
2b854a32 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "dialog.h"
12#endif
13
14#include "wx/dialog.h"
15#include "wx/frame.h"
16#include "wx/app.h"
83624f79
RR
17
18#include "gdk/gdk.h"
19#include "gtk/gtk.h"
c801d85f
KB
20#include "wx/gtk/win_gtk.h"
21
acfd422a
RR
22//-----------------------------------------------------------------------------
23// idle system
24//-----------------------------------------------------------------------------
25
26extern void wxapp_install_idle_handler();
27extern bool g_isIdle;
28
29//-----------------------------------------------------------------------------
30// data
e2414cbe
RR
31//-----------------------------------------------------------------------------
32
33extern wxList wxPendingDelete;
34
c801d85f 35//-----------------------------------------------------------------------------
e1e955e1
RR
36// "delete_event"
37//-----------------------------------------------------------------------------
c801d85f
KB
38
39bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
2b854a32 40{
121a3581
RR
41 if (g_isIdle)
42 wxapp_install_idle_handler();
2b854a32 43
fb1585ae 44 win->Close();
c801d85f 45
fb1585ae 46 return TRUE;
c33c4050 47}
c801d85f 48
e52f60e6
RR
49//-----------------------------------------------------------------------------
50// "size_allocate"
51//-----------------------------------------------------------------------------
52
53static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win )
54{
121a3581
RR
55 if (g_isIdle)
56 wxapp_install_idle_handler();
acfd422a 57
a2053b27 58 if (!win->m_hasVMT) return;
e52f60e6 59
121a3581
RR
60 if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
61 {
62 win->m_width = alloc->width;
63 win->m_height = alloc->height;
64 win->UpdateSize();
65 }
e52f60e6
RR
66}
67
36b3b54a
RR
68//-----------------------------------------------------------------------------
69// "configure_event"
70//-----------------------------------------------------------------------------
71
72static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
73{
121a3581
RR
74 if (g_isIdle)
75 wxapp_install_idle_handler();
acfd422a 76
a2053b27 77 if (!win->m_hasVMT) return FALSE;
36b3b54a 78
121a3581
RR
79 win->m_x = event->x;
80 win->m_y = event->y;
36b3b54a 81
a2053b27 82 wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
36b3b54a
RR
83 mevent.SetEventObject( win );
84 win->GetEventHandler()->ProcessEvent( mevent );
85
86 return FALSE;
87}
88
2b07d713
RR
89//-----------------------------------------------------------------------------
90// "realize" from m_widget
91//-----------------------------------------------------------------------------
92
58dea4b0 93/* we cannot MWM hints and icons before the widget has been realized,
2b07d713
RR
94 so we do this directly after realization */
95
96static gint
58dea4b0 97gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
2b07d713 98{
acfd422a
RR
99 if (g_isIdle) wxapp_install_idle_handler();
100
15b24b14
RR
101 /* reset the icon */
102 if (win->m_icon != wxNullIcon)
103 {
104 wxIcon icon( win->m_icon );
105 win->m_icon = wxNullIcon;
f03fc89f 106 win->SetIcon( icon );
15b24b14
RR
107 }
108
109 return FALSE;
110}
111
112//-----------------------------------------------------------------------------
113// "map" from m_widget
114//-----------------------------------------------------------------------------
115
116static gint
117gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
118{
119 /* I haven''t been able to set the position of
120 the dialog before it is shown, so I do it here */
a2053b27 121 gtk_widget_set_uposition( widget, win->m_x, win->m_y );
15b24b14 122
2b07d713
RR
123 /* all this is for Motif Window Manager "hints" and is supposed to be
124 recognized by other WM as well. not tested. */
051b55ad 125 long decor = (long) GDK_DECOR_BORDER;
aa64626e 126 long func = (long) GDK_FUNC_MOVE ;
2b07d713 127
f03fc89f
VZ
128 if ((win->GetWindowStyle() & wxCAPTION) != 0)
129 decor |= GDK_DECOR_TITLE;
130 if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
aa64626e
KB
131 {
132 decor |= GDK_DECOR_MENU;
133 func |= GDK_FUNC_CLOSE;
134 }
f03fc89f 135 if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
15b24b14 136 {
f03fc89f
VZ
137 func |= GDK_FUNC_MINIMIZE;
138 decor |= GDK_DECOR_MINIMIZE;
15b24b14 139 }
f03fc89f 140 if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
15b24b14 141 {
f03fc89f
VZ
142 decor |= GDK_DECOR_MAXIMIZE;
143 func |= GDK_FUNC_MAXIMIZE;
15b24b14 144 }
f03fc89f 145 if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
aa64626e
KB
146 {
147 func |= GDK_FUNC_RESIZE;
148 decor |= GDK_DECOR_RESIZEH;
149 }
a2053b27
RR
150 gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
151 gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
2b07d713
RR
152
153 /* GTK's shrinking/growing policy */
f03fc89f 154 if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
a2053b27 155 gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
2b07d713 156 else
a2053b27 157 gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
2b07d713 158
227e5e99
RR
159 return FALSE;
160}
161
c801d85f
KB
162//-----------------------------------------------------------------------------
163// wxDialog
164//-----------------------------------------------------------------------------
165
a60c99e6 166BEGIN_EVENT_TABLE(wxDialog,wxPanel)
fb1585ae
RR
167 EVT_BUTTON (wxID_OK, wxDialog::OnOK)
168 EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
169 EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
e52f60e6 170 EVT_SIZE (wxDialog::OnSize)
fb1585ae 171 EVT_CLOSE (wxDialog::OnCloseWindow)
c801d85f
KB
172END_EVENT_TABLE()
173
a60c99e6 174IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
c801d85f 175
68995f26 176void wxDialog::Init()
c801d85f 177{
f03fc89f 178 m_returnCode = 0;
de8113d9 179 m_sizeSet = FALSE;
fb1585ae 180 m_modalShowing = FALSE;
c33c4050 181}
c801d85f 182
2b854a32 183wxDialog::wxDialog( wxWindow *parent,
fb1585ae 184 wxWindowID id, const wxString &title,
2b854a32 185 const wxPoint &pos, const wxSize &size,
fb1585ae 186 long style, const wxString &name )
c801d85f 187{
68995f26
VZ
188 Init();
189
fb1585ae 190 Create( parent, id, title, pos, size, style, name );
c33c4050 191}
c801d85f
KB
192
193bool wxDialog::Create( wxWindow *parent,
fb1585ae 194 wxWindowID id, const wxString &title,
2b854a32 195 const wxPoint &pos, const wxSize &size,
fb1585ae 196 long style, const wxString &name )
c801d85f 197{
a802c3a1 198 wxTopLevelWindows.Append( this );
2b854a32 199
fb1585ae 200 m_needParent = FALSE;
2b854a32 201
fb1585ae 202 PreCreation( parent, id, pos, size, style, name );
2b854a32 203
fb1585ae 204 m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );
de1c750f
RR
205
206 if (!name.IsEmpty())
207 gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
208
fb1585ae 209 GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
2b854a32 210
2b854a32 211 gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
fb1585ae 212 GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
2b854a32 213
fb1585ae
RR
214 m_wxwindow = gtk_myfixed_new();
215 gtk_widget_show( m_wxwindow );
216 GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
2b854a32 217
fb1585ae 218 gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
2b854a32 219
fb1585ae 220 SetTitle( title );
2b854a32 221
de8113d9 222 if (m_parent) m_parent->AddChild( this );
2b854a32 223
de8113d9 224 PostCreation();
e146b8c8 225
2b07d713
RR
226 /* we cannot set MWM hints before the widget has
227 been realized, so we do this directly after realization */
228 gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
f03fc89f 229 GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
227e5e99
RR
230
231 /* we set the position of the window after the map event. setting it
232 before has no effect (with KWM) */
233 gtk_signal_connect( GTK_OBJECT(m_widget), "map",
f03fc89f 234 GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
227e5e99 235
2b07d713 236 /* the user resized the frame by dragging etc. */
2b854a32 237 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
36b3b54a 238 GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
2b854a32 239
36b3b54a
RR
240 gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
241 GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this );
242
fb1585ae 243 return TRUE;
c33c4050 244}
c801d85f 245
43a18898 246wxDialog::~wxDialog()
c801d85f 247{
fb1585ae 248 wxTopLevelWindows.DeleteObject( this );
2b854a32 249
0d2a2b60
RR
250 if (wxTheApp->GetTopWindow() == this)
251 {
252 wxTheApp->SetTopWindow( (wxWindow*) NULL );
253 }
2b854a32 254
0d2a2b60 255 if (wxTopLevelWindows.Number() == 0)
2b854a32 256 {
0d2a2b60
RR
257 wxTheApp->ExitMainLoop();
258 }
c33c4050 259}
c801d85f 260
43a18898 261void wxDialog::SetTitle( const wxString& title )
c801d85f 262{
fb1585ae 263 m_title = title;
ed9b9841
OK
264 if (m_title.IsNull()) m_title = _T("");
265 gtk_window_set_title( GTK_WINDOW(m_widget), m_title.mbc_str() );
c33c4050 266}
c801d85f 267
43a18898 268wxString wxDialog::GetTitle() const
c801d85f 269{
fb1585ae 270 return (wxString&)m_title;
c33c4050 271}
c801d85f
KB
272
273void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
274{
fb1585ae 275 if (Validate()) TransferDataFromWindow();
c33c4050 276}
c801d85f
KB
277
278void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
279{
fb1585ae
RR
280 if (IsModal())
281 {
282 EndModal(wxID_CANCEL);
283 }
284 else
285 {
286 SetReturnCode(wxID_CANCEL);
739730ca 287 Show(FALSE);
fb1585ae 288 }
c33c4050 289}
c801d85f 290
903f689b 291void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
c801d85f 292{
32ac755d
RR
293 printf( "OnOK 1.\n" );
294 if (Validate() && TransferDataFromWindow())
1a6944fd 295 {
32ac755d 296 printf( "OnOK 2.\n" );
2b854a32 297 if (IsModal())
fb1585ae 298 {
739730ca 299 printf( "OnOK: modal.\n" );
fb1585ae
RR
300 EndModal(wxID_OK);
301 }
302 else
303 {
739730ca 304 printf( "OnOK: non-modal.\n" );
fb1585ae
RR
305 SetReturnCode(wxID_OK);
306 this->Show(FALSE);
307 }
1a6944fd 308 }
c33c4050 309}
c801d85f
KB
310
311void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
312{
2b854a32 313 // yes
c33c4050 314}
c801d85f 315
2b854a32 316void wxDialog::OnCloseWindow(wxCloseEvent& event)
c801d85f 317{
e3065973
JS
318 // We'll send a Cancel message by default,
319 // which may close the dialog.
320 // Check for looping if the Cancel event handler calls Close().
321
322 // Note that if a cancel button and handler aren't present in the dialog,
323 // nothing will happen when you close the dialog via the window manager, or
324 // via Close().
325 // We wouldn't want to destroy the dialog by default, since the dialog may have been
326 // created on the stack.
327 // However, this does mean that calling dialog->Close() won't delete the dialog
328 // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
329 // sure to destroy the dialog.
330 // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
331
ab2b3dd4 332 static wxList s_closing;
c801d85f 333
ab2b3dd4 334 if (s_closing.Member(this))
2b854a32
VZ
335 return; // no loops
336
ab2b3dd4 337 s_closing.Append(this);
c801d85f 338
fb1585ae
RR
339 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
340 cancelEvent.SetEventObject( this );
341 GetEventHandler()->ProcessEvent(cancelEvent);
ab2b3dd4 342 s_closing.DeleteObject(this);
c801d85f
KB
343}
344
43a18898 345bool wxDialog::Destroy()
e2414cbe 346{
fb1585ae 347 if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
e2414cbe 348
fb1585ae 349 return TRUE;
e2414cbe
RR
350}
351
e52f60e6
RR
352void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
353{
ed9b9841 354 wxASSERT_MSG( (m_widget != NULL), _T("invalid dialog") );
2b854a32 355
e52f60e6
RR
356 if (GetAutoLayout())
357 {
358 Layout();
359 }
2b854a32 360 else
e52f60e6 361 {
de8113d9 362 /* no child: go out ! */
db1b4961 363 if (!GetChildren().First()) return;
2b854a32 364
de8113d9 365 /* do we have exactly one child? */
e52f60e6 366 wxWindow *child = (wxWindow *) NULL;
db1b4961 367 for(wxNode *node = GetChildren().First(); node; node = node->Next())
e52f60e6
RR
368 {
369 wxWindow *win = (wxWindow *)node->Data();
de135918 370 if (!wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog))
e52f60e6 371 {
de8113d9 372 /* it's the second one: do nothing */
e52f60e6
RR
373 if (child) return;
374 child = win;
375 }
376 }
377
de8113d9 378 /* yes: set it's size to fill all the frame */
e52f60e6
RR
379 int client_x, client_y;
380 GetClientSize( &client_x, &client_y );
381 child->SetSize( 1, 1, client_x-2, client_y);
382 }
383}
384
bfc6fde4 385void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
903f689b 386{
ed9b9841
OK
387 wxASSERT_MSG( (m_widget != NULL), _T("invalid dialog") );
388 wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid dialog") );
fb1585ae 389
de8113d9 390 if (m_resizing) return; /* I don't like recursions */
fb1585ae
RR
391 m_resizing = TRUE;
392
393 int old_x = m_x;
394 int old_y = m_y;
395 int old_width = m_width;
396 int old_height = m_height;
2b854a32 397
fb1585ae
RR
398 if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
399 {
400 if (x != -1) m_x = x;
401 if (y != -1) m_y = y;
402 if (width != -1) m_width = width;
403 if (height != -1) m_height = height;
404 }
405 else
406 {
407 m_x = x;
408 m_y = y;
409 m_width = width;
410 m_height = height;
411 }
412
413 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
414 {
415 if (width == -1) m_width = 80;
416 }
417
418 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
419 {
420 if (height == -1) m_height = 26;
421 }
2b854a32 422
fb1585ae
RR
423 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
424 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
0c77152e
RR
425 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
426 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
fb1585ae
RR
427
428 if ((m_x != -1) || (m_y != -1))
429 {
2b854a32 430 if ((m_x != old_x) || (m_y != old_y))
f03fc89f
VZ
431 {
432 /* we set the position here and when showing the dialog
433 for the first time in idle time */
e146b8c8 434 gtk_widget_set_uposition( m_widget, m_x, m_y );
f03fc89f 435 }
fb1585ae 436 }
2b854a32 437
fb1585ae
RR
438 if ((m_width != old_width) || (m_height != old_height))
439 {
227e5e99 440 /* actual resizing is deferred to GtkOnSize in idle time and
f03fc89f 441 when showing the dialog */
de8113d9 442 m_sizeSet = FALSE;
fb1585ae 443 }
2b854a32 444
fb1585ae 445 m_resizing = FALSE;
903f689b
RR
446}
447
de8113d9
RR
448void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
449{
450 // due to a bug in gtk, x,y are always 0
451 // m_x = x;
452 // m_y = y;
453
454 if ((m_height == height) && (m_width == width) && (m_sizeSet)) return;
455 if (!m_wxwindow) return;
456
457 m_width = width;
458 m_height = height;
459
460 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
461 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
462 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
463 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
464
465 /* we actually set the size of a frame here and no-where else */
466 gtk_widget_set_usize( m_widget, m_width, m_height );
467
468 m_sizeSet = TRUE;
469
470 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
471 event.SetEventObject( this );
472 GetEventHandler()->ProcessEvent( event );
473}
474
903f689b
RR
475void wxDialog::Centre( int direction )
476{
ed9b9841 477 wxASSERT_MSG( (m_widget != NULL), _T("invalid dialog") );
2b854a32 478
43a18898
RR
479 int x = 0;
480 int y = 0;
2b854a32 481
f5eafd0e
RR
482 if ((direction & wxHORIZONTAL) == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
483 if ((direction & wxVERTICAL) == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
2b854a32 484
fb1585ae 485 Move( x, y );
903f689b
RR
486}
487
de8113d9
RR
488void wxDialog::OnInternalIdle()
489{
1b3667ab 490 if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
de8113d9
RR
491 GtkOnSize( m_x, m_y, m_width, m_height );
492}
493
debe6624 494bool wxDialog::Show( bool show )
c801d85f 495{
fb1585ae
RR
496 if (!show && IsModal())
497 {
de8113d9 498 EndModal( wxID_CANCEL );
fb1585ae 499 }
c801d85f 500
de8113d9
RR
501 if (show && !m_sizeSet)
502 {
503 /* by calling GtkOnSize here, we don't have to call
504 either after showing the frame, which would entail
505 much ugly flicker nor from within the size_allocate
506 handler, because GTK 1.1.X forbids that. */
507
508 GtkOnSize( m_x, m_y, m_width, m_height );
509 }
2b854a32 510
739730ca 511 bool ret = wxWindow::Show( show );
e146b8c8 512
fb1585ae 513 if (show) InitDialog();
2b854a32 514
739730ca 515 return ret;
c33c4050
RR
516}
517
43a18898 518bool wxDialog::IsModal() const
e1e955e1 519{
fb1585ae 520 return m_modalShowing;
e1e955e1
RR
521}
522
523void wxDialog::SetModal( bool WXUNUSED(flag) )
c33c4050 524{
e1e955e1 525/*
c33c4050
RR
526 if (flag)
527 m_windowStyle |= wxDIALOG_MODAL;
528 else
529 if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL;
e1e955e1 530*/
ed9b9841 531 wxFAIL_MSG( _T("wxDialog:SetModal obsolete now") );
c33c4050 532}
c801d85f 533
43a18898 534int wxDialog::ShowModal()
c801d85f 535{
fb1585ae
RR
536 if (IsModal())
537 {
ed9b9841 538 wxFAIL_MSG( _T("wxDialog:ShowModal called twice") );
fb1585ae
RR
539 return GetReturnCode();
540 }
e146b8c8 541
fb1585ae 542 Show( TRUE );
2b854a32 543
fb1585ae 544 m_modalShowing = TRUE;
2b854a32 545
fb1585ae
RR
546 gtk_grab_add( m_widget );
547 gtk_main();
548 gtk_grab_remove( m_widget );
2b854a32 549
fb1585ae 550 return GetReturnCode();
c33c4050 551}
c801d85f
KB
552
553void wxDialog::EndModal( int retCode )
554{
fb1585ae 555 SetReturnCode( retCode );
2b854a32 556
fb1585ae
RR
557 if (!IsModal())
558 {
ed9b9841 559 wxFAIL_MSG( _T("wxDialog:EndModal called twice") );
fb1585ae
RR
560 return;
561 }
2b854a32 562
fb1585ae 563 m_modalShowing = FALSE;
2b854a32 564
fb1585ae 565 gtk_main_quit();
2b854a32 566
fb1585ae 567 Show( FALSE );
c33c4050 568}
c801d85f 569
43a18898 570void wxDialog::InitDialog()
c801d85f 571{
fb1585ae 572 wxWindow::InitDialog();
c33c4050
RR
573}
574
c33c4050
RR
575void wxDialog::SetIcon( const wxIcon &icon )
576{
fb1585ae
RR
577 m_icon = icon;
578 if (!icon.Ok()) return;
2b854a32 579
fb1585ae
RR
580 wxMask *mask = icon.GetMask();
581 GdkBitmap *bm = (GdkBitmap *) NULL;
582 if (mask) bm = mask->GetBitmap();
2b854a32 583
fb1585ae 584 gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
c33c4050 585}