Added some Motif wxGLCanvas support; some more Motif bugs cured; print dialogs
[wxWidgets.git] / src / motif / dialog.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dialog.cpp
3 // Purpose: wxDialog class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "dialog.h"
14 #endif
15
16 #include "wx/dialog.h"
17 #include "wx/utils.h"
18 #include "wx/frame.h"
19 #include "wx/app.h"
20 #include "wx/settings.h"
21
22 #include <Xm/Xm.h>
23
24 #include <X11/Shell.h>
25 #if XmVersion >= 1002
26 #include <Xm/XmAll.h>
27 #endif
28 #include <Xm/MwmUtil.h>
29 #include <Xm/Label.h>
30 #include <Xm/BulletinB.h>
31 #include <Xm/Frame.h>
32 #include <Xm/Text.h>
33 #include <Xm/DialogS.h>
34 #include <Xm/FileSB.h>
35 #include <Xm/RowColumn.h>
36 #include <Xm/LabelG.h>
37 #include <Xm/AtomMgr.h>
38 #if XmVersion > 1000
39 #include <Xm/Protocols.h>
40 #endif
41
42 #include "wx/motif/private.h"
43
44 static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs);
45 static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *);
46 static void wxDialogBoxEventHandler (Widget wid,
47 XtPointer client_data,
48 XEvent* event,
49 Boolean *continueToDispatch);
50
51 static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call);
52
53 // A stack of modal_showing flags, since we can't rely
54 // on accessing wxDialog::m_modalShowing within
55 // wxDialog::Show in case a callback has deleted the wxDialog.
56 static wxList wxModalShowingStack;
57
58 // Lists to keep track of windows, so we can disable/enable them
59 // for modal dialogs
60 wxList wxModalDialogs;
61 wxList wxModelessWindows; // Frames and modeless dialogs
62 extern wxList wxPendingDelete;
63
64 #define wxUSE_INVISIBLE_RESIZE 1
65
66 #if !USE_SHARED_LIBRARY
67 IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
68
69 BEGIN_EVENT_TABLE(wxDialog, wxPanel)
70 EVT_BUTTON(wxID_OK, wxDialog::OnOK)
71 EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
72 EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
73 EVT_CHAR_HOOK(wxDialog::OnCharHook)
74 EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
75 EVT_CLOSE(wxDialog::OnCloseWindow)
76 END_EVENT_TABLE()
77
78 #endif
79
80 wxDialog::wxDialog()
81 {
82 m_modalShowing = FALSE;
83 m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
84 }
85
86 bool wxDialog::Create(wxWindow *parent, wxWindowID id,
87 const wxString& title,
88 const wxPoint& pos,
89 const wxSize& size,
90 long style,
91 const wxString& name)
92 {
93 m_windowStyle = style;
94 m_modalShowing = FALSE;
95 m_dialogTitle = title;
96
97 m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
98 m_foregroundColour = *wxBLACK;
99
100 SetName(name);
101
102 if (!parent)
103 wxTopLevelWindows.Append(this);
104
105 if (parent) parent->AddChild(this);
106
107 if ( id == -1 )
108 m_windowId = (int)NewControlId();
109 else
110 m_windowId = id;
111
112 Widget parentWidget = (Widget) 0;
113 if (parent)
114 parentWidget = (Widget) parent->GetTopWidget();
115 if (!parent)
116 parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
117
118 wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
119
120 Arg args[2];
121 XtSetArg (args[0], XmNdefaultPosition, False);
122 XtSetArg (args[1], XmNautoUnmanage, False);
123 Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
124 m_mainWidget = (WXWidget) dialogShell;
125
126 // We don't want margins, since there is enough elsewhere.
127 XtVaSetValues(dialogShell,
128 XmNmarginHeight, 0,
129 XmNmarginWidth, 0,
130 XmNresizePolicy, XmRESIZE_NONE,
131 NULL) ;
132
133 Widget shell = XtParent(dialogShell) ;
134 if (!title.IsNull())
135 {
136 XmString str = XmStringCreateSimple((char*) (const char*)title);
137 XtVaSetValues(dialogShell,
138 XmNdialogTitle, str,
139 NULL);
140 XmStringFree(str);
141 }
142
143 m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
144 ChangeFont(FALSE);
145
146 wxAddWindowToTable(dialogShell, this);
147
148 // Intercept CLOSE messages from the window manager
149 Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
150
151 /* Remove and add WM_DELETE_WINDOW so ours is only handler */
152 /* Why do we have to do this for wxDialog, but not wxFrame? */
153 XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
154 XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
155 XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
156
157 // Modified Steve Hammes for Motif 2.0
158 #if (XmREVISION > 1 || XmVERSION > 1)
159 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
160 #elif XmREVISION == 1
161 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (caddr_t)this);
162 #else
163 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
164 #endif
165
166 XtTranslations ptr ;
167 XtOverrideTranslations(dialogShell,
168 ptr = XtParseTranslationTable("<Configure>: resize()"));
169 XtFree((char *)ptr);
170
171 // Can't remember what this was about... but I think it's necessary.
172
173 if (wxUSE_INVISIBLE_RESIZE)
174 {
175 if (pos.x > -1)
176 XtVaSetValues(dialogShell, XmNx, pos.x,
177 NULL);
178 if (pos.y > -1)
179 XtVaSetValues(dialogShell, XmNy, pos.y,
180 NULL);
181
182 if (size.x > -1)
183 XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
184 if (size.y > -1)
185 XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
186 }
187
188 // This patch come from Torsten Liermann lier@lier1.muc.de
189 if (XmIsMotifWMRunning(shell))
190 {
191 int decor = 0 ;
192 if (m_windowStyle & wxRESIZE_BORDER)
193 decor |= MWM_DECOR_RESIZEH ;
194 if (m_windowStyle & wxSYSTEM_MENU)
195 decor |= MWM_DECOR_MENU;
196 if ((m_windowStyle & wxCAPTION) ||
197 (m_windowStyle & wxTINY_CAPTION_HORIZ) ||
198 (m_windowStyle & wxTINY_CAPTION_VERT))
199 decor |= MWM_DECOR_TITLE;
200 if (m_windowStyle & wxTHICK_FRAME)
201 decor |= MWM_DECOR_BORDER;
202 if (m_windowStyle & wxMINIMIZE_BOX)
203 decor |= MWM_DECOR_MINIMIZE;
204 if (m_windowStyle & wxMAXIMIZE_BOX)
205 decor |= MWM_DECOR_MAXIMIZE;
206
207 XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
208 }
209 // This allows non-Motif window managers to support at least the
210 // no-decorations case.
211 else
212 {
213 if ((m_windowStyle & wxCAPTION) != wxCAPTION)
214 XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
215 }
216
217 XtRealizeWidget(dialogShell);
218
219 XtAddCallback(dialogShell,XmNunmapCallback,
220 (XtCallbackProc)wxUnmapBulletinBoard,this) ;
221
222 // Positioning of the dialog doesn't work properly unless the dialog
223 // is managed, so we manage without mapping to the screen.
224 // To show, we map the shell (actually it's parent).
225 if (!wxUSE_INVISIBLE_RESIZE)
226 XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL);
227
228 if (!wxUSE_INVISIBLE_RESIZE)
229 {
230 XtManageChild(dialogShell);
231 SetSize(pos.x, pos.y, size.x, size.y);
232 }
233 XtAddEventHandler(dialogShell,ExposureMask,FALSE,
234 wxDialogBoxRepaintProc, (XtPointer) this);
235
236 XtAddEventHandler(dialogShell,
237 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
238 FALSE,
239 wxDialogBoxEventHandler,
240 (XtPointer)this);
241
242 ChangeBackgroundColour();
243
244 return TRUE;
245 }
246
247 void wxDialog::SetModal(bool flag)
248 {
249 if ( flag )
250 m_windowStyle |= wxDIALOG_MODAL ;
251 else
252 if ( m_windowStyle & wxDIALOG_MODAL )
253 m_windowStyle -= wxDIALOG_MODAL ;
254
255 wxModelessWindows.DeleteObject(this);
256 if (!flag)
257 wxModelessWindows.Append(this);
258 }
259
260 wxDialog::~wxDialog()
261 {
262 m_modalShowing = FALSE;
263 if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
264 {
265 XtUnmapWidget((Widget) m_mainWidget);
266 }
267
268 wxTopLevelWindows.DeleteObject(this);
269
270 if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
271 wxModelessWindows.DeleteObject(this);
272
273 // If this is the last top-level window, exit.
274 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
275 {
276 wxTheApp->SetTopWindow(NULL);
277
278 if (wxTheApp->GetExitOnFrameDelete())
279 {
280 wxTheApp->ExitMainLoop();
281 }
282 }
283
284 // This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp)
285 // but I think this should work, if we destroy the children first.
286 // Note that this might need to be done for wxFrame also.
287 DestroyChildren();
288
289 // This causes a crash in e.g. the resource sample when closing
290 // the example dialog. TODO: Probably not necessary (?)
291 #if 0
292 // Now process all events, because otherwise
293 // this might remain on the screen.
294 Display* display;
295 if (m_mainWidget)
296 display = XtDisplay((Widget) m_mainWidget);
297 else
298 display = (Display*) wxGetDisplay();
299
300 XSync(display, FALSE);
301 XEvent event;
302 while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
303 XFlush(display);
304 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
305 XtDispatchEvent(&event);
306 }
307 #endif
308 }
309
310 // By default, pressing escape cancels the dialog
311 void wxDialog::OnCharHook(wxKeyEvent& event)
312 {
313 if (event.m_keyCode == WXK_ESCAPE)
314 {
315 // Behaviour changed in 2.0: we'll send a Cancel message
316 // to the dialog instead of Close.
317 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
318 cancelEvent.SetEventObject( this );
319 GetEventHandler()->ProcessEvent(cancelEvent);
320
321 return;
322 }
323 // We didn't process this event.
324 event.Skip();
325 }
326
327 void wxDialog::Iconize(bool WXUNUSED(iconize))
328 {
329 // Can't iconize a dialog in Motif, apparently
330 // TODO: try using the parent of m_mainShell.
331 // XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
332 }
333
334 bool wxDialog::IsIconized() const
335 {
336 /*
337 Boolean iconic;
338 XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
339
340 return iconic;
341 */
342 return FALSE;
343 }
344
345 void wxDialog::SetSize(int x, int y, int width, int height, int sizeFlags)
346 {
347 XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
348 wxWindow::SetSize(x, y, width, height, sizeFlags);
349 XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
350 }
351
352 void wxDialog::SetClientSize(int width, int height)
353 {
354 SetSize(-1, -1, width, height);
355 }
356
357
358 void wxDialog::SetTitle(const wxString& title)
359 {
360 m_dialogTitle = title;
361 if (!title.IsNull())
362 {
363 XmString str = XmStringCreateSimple((char*) (const char*) title);
364 XtVaSetValues((Widget) m_mainWidget,
365 XmNtitle, (char*) (const char*) title,
366 XmNdialogTitle, str, // Roberto Cocchi
367 XmNiconName, (char*) (const char*) title,
368 NULL);
369 XmStringFree(str);
370 }
371 }
372
373 wxString wxDialog::GetTitle() const
374 {
375 return m_dialogTitle;
376 }
377
378 void wxDialog::Centre(int direction)
379 {
380 int x_offset,y_offset ;
381 int display_width, display_height;
382 int width, height, x, y;
383 wxWindow *parent = GetParent();
384 if ((direction & wxCENTER_FRAME) && parent)
385 {
386 parent->GetPosition(&x_offset,&y_offset) ;
387 parent->GetSize(&display_width,&display_height) ;
388 }
389 else
390 {
391 wxDisplaySize(&display_width, &display_height);
392 x_offset = 0 ;
393 y_offset = 0 ;
394 }
395
396 GetSize(&width, &height);
397 GetPosition(&x, &y);
398
399 if (direction & wxHORIZONTAL)
400 x = (int)((display_width - width)/2);
401 if (direction & wxVERTICAL)
402 y = (int)((display_height - height)/2);
403
404 SetSize(x+x_offset, y+y_offset, width, height);
405 }
406
407 void wxDialog::Raise()
408 {
409 Window parent_window = XtWindow((Widget) m_mainWidget),
410 next_parent = XtWindow((Widget) m_mainWidget),
411 root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
412 // search for the parent that is child of ROOT, because the WM may
413 // reparent twice and notify only the next parent (like FVWM)
414 while (next_parent != root) {
415 Window *theChildren; unsigned int n;
416 parent_window = next_parent;
417 XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
418 &next_parent, &theChildren, &n);
419 XFree(theChildren); // not needed
420 }
421 XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
422 }
423
424 void wxDialog::Lower()
425 {
426 Window parent_window = XtWindow((Widget) m_mainWidget),
427 next_parent = XtWindow((Widget) m_mainWidget),
428 root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
429 // search for the parent that is child of ROOT, because the WM may
430 // reparent twice and notify only the next parent (like FVWM)
431 while (next_parent != root) {
432 Window *theChildren; unsigned int n;
433 parent_window = next_parent;
434 XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
435 &next_parent, &theChildren, &n);
436 XFree(theChildren); // not needed
437 }
438 XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
439 }
440
441 bool wxDialog::Show(bool show)
442 {
443 m_isShown = show;
444
445 if (show)
446 {
447 if (!wxUSE_INVISIBLE_RESIZE)
448 XtMapWidget(XtParent((Widget) m_mainWidget));
449 else
450 XtManageChild((Widget) m_mainWidget) ;
451
452 XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget));
453
454 }
455 else
456 {
457 if (!wxUSE_INVISIBLE_RESIZE)
458 XtUnmapWidget(XtParent((Widget) m_mainWidget));
459 else
460 XtUnmanageChild((Widget) m_mainWidget) ;
461
462 XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
463 XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
464 }
465
466 return TRUE;
467 }
468
469 // Shows a dialog modally, returning a return code
470 int wxDialog::ShowModal()
471 {
472 m_windowStyle |= wxDIALOG_MODAL;
473
474 Show(TRUE);
475
476 if (m_modalShowing)
477 return 0;
478
479 wxModalShowingStack.Insert((wxObject *)TRUE);
480
481 m_modalShowing = TRUE;
482 XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
483
484 XEvent event;
485
486 // Loop until we signal that the dialog should be closed
487 while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0))
488 {
489 // XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
490
491 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
492 wxTheApp->ProcessXEvent((WXEvent*) &event);
493 }
494
495 // Remove modal dialog flag from stack
496 wxNode *node = wxModalShowingStack.First();
497 if (node)
498 delete node;
499
500 // Now process all events in case they get sent to a destroyed dialog
501 XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
502 while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
503 {
504 XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
505 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
506
507 wxTheApp->ProcessXEvent((WXEvent*) &event);
508 }
509
510 // TODO: is it safe to call this, if the dialog may have been deleted
511 // by now? Probably only if we're using delayed deletion of dialogs.
512 return GetReturnCode();
513 }
514
515 void wxDialog::EndModal(int retCode)
516 {
517 if (!m_modalShowing)
518 return;
519
520 SetReturnCode(retCode);
521
522 // Strangely, we don't seem to need this now.
523 // XtRemoveGrab((Widget) m_mainWidget);
524
525 Show(FALSE);
526
527 m_modalShowing = FALSE;
528
529 wxNode *node = wxModalShowingStack.First();
530 if (node)
531 node->SetData((wxObject *)FALSE);
532 }
533
534 // Standard buttons
535 void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
536 {
537 if ( Validate() && TransferDataFromWindow() )
538 {
539 if ( IsModal() )
540 EndModal(wxID_OK);
541 else
542 {
543 SetReturnCode(wxID_OK);
544 this->Show(FALSE);
545 }
546 }
547 }
548
549 void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
550 {
551 if (Validate())
552 TransferDataFromWindow();
553 // TODO probably need to disable the Apply button until things change again
554 }
555
556 void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
557 {
558 if ( IsModal() )
559 EndModal(wxID_CANCEL);
560 else
561 {
562 SetReturnCode(wxID_CANCEL);
563 this->Show(FALSE);
564 }
565 }
566
567 bool wxDialog::OnClose()
568 {
569 // Behaviour changed in 2.0: we'll send a Cancel message by default,
570 // which may close the dialog.
571 // Check for looping if the Cancel event handler calls Close()
572
573 static wxList closing;
574
575 if ( closing.Member(this) )
576 return FALSE;
577
578 closing.Append(this);
579
580 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
581 cancelEvent.SetEventObject( this );
582 GetEventHandler()->ProcessEvent(cancelEvent);
583
584 closing.DeleteObject(this);
585
586 return FALSE;
587 }
588
589 void wxDialog::OnCloseWindow(wxCloseEvent& event)
590 {
591 // Compatibility
592 if ( GetEventHandler()->OnClose() || event.GetForce())
593 {
594 this->Destroy();
595 }
596 }
597
598 // Destroy the window (delayed, if a managed window)
599 bool wxDialog::Destroy()
600 {
601 if (!wxPendingDelete.Member(this))
602 wxPendingDelete.Append(this);
603 return TRUE;
604 }
605
606 void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
607 {
608 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
609 Refresh();
610 }
611
612 void wxDialog::Fit()
613 {
614 wxWindow::Fit();
615 }
616
617 // Handle a close event from the window manager
618 static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data,
619 XmAnyCallbackStruct *WXUNUSED(cbs))
620 {
621 wxDialog *dialog = (wxDialog *)client_data;
622 wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
623 closeEvent.SetEventObject(dialog);
624
625 // May delete the dialog (with delayed deletion)
626 dialog->GetEventHandler()->ProcessEvent(closeEvent);
627 }
628
629 // TODO: Preferably, we should have a universal repaint proc.
630 // Meanwhile, use a special one for dialogs.
631 static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *)
632 {
633 Window window;
634 Display *display;
635
636 wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
637 if (!win)
638 return;
639
640 switch(event -> type)
641 {
642 case Expose :
643 {
644 window = (Window) win -> GetXWindow();
645 display = (Display *) win -> GetXDisplay();
646
647 wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
648 event->xexpose.width, event->xexpose.height);
649 win->m_updateRects.Append((wxObject*) rect);
650
651 if (event -> xexpose.count == 0)
652 {
653 wxPaintEvent event(win->GetId());
654 event.SetEventObject(win);
655 win->GetEventHandler()->ProcessEvent(event);
656
657 win->ClearUpdateRects();
658 }
659 break;
660 }
661 default :
662 {
663 cout << "\n\nNew Event ! is = " << event -> type << "\n";
664 break;
665 }
666 }
667 }
668
669 static void wxDialogBoxEventHandler (Widget wid,
670 XtPointer WXUNUSED(client_data),
671 XEvent* event,
672 Boolean *continueToDispatch)
673 {
674 wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
675 if (dialog)
676 {
677 wxMouseEvent wxevent(wxEVT_NULL);
678 if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
679 {
680 wxevent.SetEventObject(dialog);
681 wxevent.SetId(dialog->GetId());
682 dialog->GetEventHandler()->ProcessEvent(wxevent);
683 }
684 else
685 {
686 // An attempt to implement OnCharHook by calling OnCharHook first;
687 // if this returns TRUE, set continueToDispatch to False
688 // (don't continue processing).
689 // Otherwise set it to True and call OnChar.
690 wxKeyEvent keyEvent(wxEVT_CHAR);
691 if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
692 {
693 keyEvent.SetEventObject(dialog);
694 keyEvent.SetId(dialog->GetId());
695 keyEvent.SetEventType(wxEVT_CHAR_HOOK);
696 if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
697 {
698 *continueToDispatch = False;
699 return;
700 }
701 else
702 {
703 keyEvent.SetEventType(wxEVT_CHAR);
704 dialog->GetEventHandler()->ProcessEvent(keyEvent);
705 }
706 }
707 }
708 }
709 *continueToDispatch = True;
710 }
711
712 static void wxUnmapBulletinBoard(Widget WXUNUSED(dialog), wxDialog *WXUNUSED(client), XtPointer WXUNUSED(call) )
713 {
714 /* This gets called when the dialog is being shown, which
715 * defeats modal showing.
716 client->m_modalShowing = FALSE ;
717 client->m_isShown = FALSE;
718 */
719 }
720
721 void wxDialog::ChangeFont(bool keepOriginalSize)
722 {
723 wxWindow::ChangeFont(keepOriginalSize);
724 }
725
726 void wxDialog::ChangeBackgroundColour()
727 {
728 if (GetMainWidget())
729 DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
730 }
731
732 void wxDialog::ChangeForegroundColour()
733 {
734 if (GetMainWidget())
735 DoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
736 }
737