More Motif changes (colour/font stuff)
[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[1];
121 XtSetArg (args[0], XmNdefaultPosition, False);
122 Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 1);
123 m_mainWidget = (WXWidget) dialogShell;
124
125 // We don't want margins, since there is enough elsewhere.
126 XtVaSetValues(dialogShell,
127 XmNmarginHeight, 0,
128 XmNmarginWidth, 0,
129 XmNresizePolicy, XmRESIZE_NONE,
130 NULL) ;
131
132 Widget shell = XtParent(dialogShell) ;
133 if (!title.IsNull())
134 {
135 XmString str = XmStringCreateSimple((char*) (const char*)title);
136 XtVaSetValues(dialogShell,
137 XmNdialogTitle, str,
138 NULL);
139 XmStringFree(str);
140 }
141
142 wxAddWindowToTable(dialogShell, this);
143
144 // Intercept CLOSE messages from the window manager
145 Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
146
147 /* MATTHEW: [8] Remove and add WM_DELETE_WINDOW so ours is only handler */
148 /* Why do we have to do this for wxDialog, but not wxFrame? */
149 XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
150 XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
151 XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
152
153 // Modified Steve Hammes for Motif 2.0
154 #if (XmREVISION > 1 || XmVERSION > 1)
155 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
156 #elif XmREVISION == 1
157 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (caddr_t)this);
158 #else
159 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
160 #endif
161
162 XtTranslations ptr ;
163 XtOverrideTranslations(dialogShell,
164 ptr = XtParseTranslationTable("<Configure>: resize()"));
165 XtFree((char *)ptr);
166
167 // Can't remember what this was about... but I think it's necessary.
168
169 if (wxUSE_INVISIBLE_RESIZE)
170 {
171 if (pos.x > -1)
172 XtVaSetValues(dialogShell, XmNx, pos.x,
173 NULL);
174 if (pos.y > -1)
175 XtVaSetValues(dialogShell, XmNy, pos.y,
176 NULL);
177
178 if (size.x > -1)
179 XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
180 if (size.y > -1)
181 XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
182 }
183
184 // This patch come from Torsten Liermann lier@lier1.muc.de
185 if (XmIsMotifWMRunning(shell))
186 {
187 int decor = 0 ;
188 if (m_windowStyle & wxRESIZE_BORDER)
189 decor |= MWM_DECOR_RESIZEH ;
190 if (m_windowStyle & wxSYSTEM_MENU)
191 decor |= MWM_DECOR_MENU;
192 if ((m_windowStyle & wxCAPTION) ||
193 (m_windowStyle & wxTINY_CAPTION_HORIZ) ||
194 (m_windowStyle & wxTINY_CAPTION_VERT))
195 decor |= MWM_DECOR_TITLE;
196 if (m_windowStyle & wxTHICK_FRAME)
197 decor |= MWM_DECOR_BORDER;
198 if (m_windowStyle & wxMINIMIZE_BOX)
199 decor |= MWM_DECOR_MINIMIZE;
200 if (m_windowStyle & wxMAXIMIZE_BOX)
201 decor |= MWM_DECOR_MAXIMIZE;
202
203 XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
204 }
205 // This allows non-Motif window managers to support at least the
206 // no-decorations case.
207 else
208 {
209 if ((m_windowStyle & wxCAPTION) != wxCAPTION)
210 XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
211 }
212
213 XtRealizeWidget(dialogShell);
214
215 XtAddCallback(dialogShell,XmNunmapCallback,
216 (XtCallbackProc)wxUnmapBulletinBoard,this) ;
217
218 // Positioning of the dialog doesn't work properly unless the dialog
219 // is managed, so we manage without mapping to the screen.
220 // To show, we map the shell (actually it's parent).
221 if (!wxUSE_INVISIBLE_RESIZE)
222 XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL);
223
224 if (!wxUSE_INVISIBLE_RESIZE)
225 {
226 XtManageChild(dialogShell);
227 SetSize(pos.x, pos.y, size.x, size.y);
228 }
229 XtAddEventHandler(dialogShell,ExposureMask,FALSE,
230 wxDialogBoxRepaintProc, (XtPointer) this);
231
232 XtAddEventHandler(dialogShell,
233 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
234 FALSE,
235 wxDialogBoxEventHandler,
236 (XtPointer)this);
237
238 ChangeBackgroundColour();
239 SetFont(* parent->GetFont());
240
241 return TRUE;
242 }
243
244 void wxDialog::SetModal(bool flag)
245 {
246 if ( flag )
247 m_windowStyle |= wxDIALOG_MODAL ;
248 else
249 if ( m_windowStyle & wxDIALOG_MODAL )
250 m_windowStyle -= wxDIALOG_MODAL ;
251
252 wxModelessWindows.DeleteObject(this);
253 if (!flag)
254 wxModelessWindows.Append(this);
255 }
256
257 wxDialog::~wxDialog()
258 {
259 m_modalShowing = FALSE;
260 if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
261 {
262 XtUnmapWidget((Widget) m_mainWidget);
263 }
264
265 wxTopLevelWindows.DeleteObject(this);
266
267 if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
268 wxModelessWindows.DeleteObject(this);
269
270 // If this is the last top-level window, exit.
271 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
272 {
273 wxTheApp->SetTopWindow(NULL);
274
275 if (wxTheApp->GetExitOnFrameDelete())
276 {
277 wxTheApp->ExitMainLoop();
278 }
279 }
280
281 // This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp)
282 // but I think this should work, if we destroy the children first.
283 // Note that this might need to be done for wxFrame also.
284 DestroyChildren();
285
286 // Now process all events, because otherwise
287 // this might remain on the screen.
288 Display* display;
289 if (m_mainWidget)
290 display = XtDisplay((Widget) m_mainWidget);
291 else
292 display = (Display*) wxGetDisplay();
293
294 XSync(display, FALSE);
295 XEvent event;
296 while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
297 XFlush(display);
298 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
299 XtDispatchEvent(&event);
300 }
301 }
302
303 // By default, pressing escape cancels the dialog
304 void wxDialog::OnCharHook(wxKeyEvent& event)
305 {
306 if (event.m_keyCode == WXK_ESCAPE)
307 {
308 // Behaviour changed in 2.0: we'll send a Cancel message
309 // to the dialog instead of Close.
310 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
311 cancelEvent.SetEventObject( this );
312 GetEventHandler()->ProcessEvent(cancelEvent);
313
314 return;
315 }
316 // We didn't process this event.
317 event.Skip();
318 }
319
320 void wxDialog::Iconize(bool WXUNUSED(iconize))
321 {
322 // Can't iconize a dialog in Motif, apparently
323 // TODO: try using the parent of m_mainShell.
324 // XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
325 }
326
327 bool wxDialog::IsIconized() const
328 {
329 /*
330 Boolean iconic;
331 XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
332
333 return iconic;
334 */
335 return FALSE;
336 }
337
338 void wxDialog::SetSize(int x, int y, int width, int height, int sizeFlags)
339 {
340 XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
341 wxWindow::SetSize(x, y, width, height, sizeFlags);
342 XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
343 }
344
345 void wxDialog::SetClientSize(int width, int height)
346 {
347 SetSize(-1, -1, width, height);
348 }
349
350
351 void wxDialog::SetTitle(const wxString& title)
352 {
353 m_dialogTitle = title;
354 if (!title.IsNull())
355 {
356 XmString str = XmStringCreateSimple((char*) (const char*) title);
357 XtVaSetValues((Widget) m_mainWidget,
358 XmNtitle, (char*) (const char*) title,
359 XmNdialogTitle, str, // Roberto Cocchi
360 XmNiconName, (char*) (const char*) title,
361 NULL);
362 XmStringFree(str);
363 }
364 }
365
366 wxString wxDialog::GetTitle() const
367 {
368 return m_dialogTitle;
369 }
370
371 void wxDialog::Centre(int direction)
372 {
373 int x_offset,y_offset ;
374 int display_width, display_height;
375 int width, height, x, y;
376 wxWindow *parent = GetParent();
377 if ((direction & wxCENTER_FRAME) && parent)
378 {
379 parent->GetPosition(&x_offset,&y_offset) ;
380 parent->GetSize(&display_width,&display_height) ;
381 }
382 else
383 {
384 wxDisplaySize(&display_width, &display_height);
385 x_offset = 0 ;
386 y_offset = 0 ;
387 }
388
389 GetSize(&width, &height);
390 GetPosition(&x, &y);
391
392 if (direction & wxHORIZONTAL)
393 x = (int)((display_width - width)/2);
394 if (direction & wxVERTICAL)
395 y = (int)((display_height - height)/2);
396
397 SetSize(x+x_offset, y+y_offset, width, height);
398 }
399
400 void wxDialog::Raise()
401 {
402 Window parent_window = XtWindow((Widget) m_mainWidget),
403 next_parent = XtWindow((Widget) m_mainWidget),
404 root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
405 // search for the parent that is child of ROOT, because the WM may
406 // reparent twice and notify only the next parent (like FVWM)
407 while (next_parent != root) {
408 Window *theChildren; unsigned int n;
409 parent_window = next_parent;
410 XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
411 &next_parent, &theChildren, &n);
412 XFree(theChildren); // not needed
413 }
414 XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
415 }
416
417 void wxDialog::Lower()
418 {
419 Window parent_window = XtWindow((Widget) m_mainWidget),
420 next_parent = XtWindow((Widget) m_mainWidget),
421 root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
422 // search for the parent that is child of ROOT, because the WM may
423 // reparent twice and notify only the next parent (like FVWM)
424 while (next_parent != root) {
425 Window *theChildren; unsigned int n;
426 parent_window = next_parent;
427 XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
428 &next_parent, &theChildren, &n);
429 XFree(theChildren); // not needed
430 }
431 XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
432 }
433
434 bool wxDialog::Show(bool show)
435 {
436 m_isShown = show;
437
438 if (show)
439 {
440 if (!wxUSE_INVISIBLE_RESIZE)
441 XtMapWidget(XtParent((Widget) m_mainWidget));
442 else
443 XtManageChild((Widget) m_mainWidget) ;
444
445 XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget));
446
447 }
448 else
449 {
450 if (!wxUSE_INVISIBLE_RESIZE)
451 XtUnmapWidget(XtParent((Widget) m_mainWidget));
452 else
453 XtUnmanageChild((Widget) m_mainWidget) ;
454
455 XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
456 XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
457 }
458
459 return TRUE;
460 }
461
462 // Shows a dialog modally, returning a return code
463 int wxDialog::ShowModal()
464 {
465 m_windowStyle |= wxDIALOG_MODAL;
466
467 Show(TRUE);
468
469 if (m_modalShowing)
470 return 0;
471
472 wxModalShowingStack.Insert((wxObject *)TRUE);
473
474 m_modalShowing = TRUE;
475 XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
476 XEvent event;
477
478 // Loop until we signal that the dialog should be closed
479 while ((wxModalShowingStack.Number() > 0) && (bool)wxModalShowingStack.First()->Data())
480 {
481 XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
482 }
483
484 // Remove modal dialog flag from stack
485 wxNode *node = wxModalShowingStack.First();
486 if (node)
487 delete node;
488
489 // Now process all events in case they get sent to a destroyed dialog
490 XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
491 while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
492 {
493 XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
494 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
495 XtDispatchEvent(&event);
496 }
497
498 // TODO: is it safe to call this, if the dialog may have been deleted
499 // by now? Probably only if we're using delayed deletion of dialogs.
500 return GetReturnCode();
501 }
502
503 void wxDialog::EndModal(int retCode)
504 {
505 if (!m_modalShowing)
506 return;
507
508 SetReturnCode(retCode);
509
510 XtRemoveGrab((Widget) m_mainWidget);
511
512 Show(FALSE);
513
514 m_modalShowing = FALSE;
515
516 wxNode *node = wxModalShowingStack.First();
517 if (node)
518 node->SetData((wxObject *)FALSE);
519 }
520
521 // Standard buttons
522 void wxDialog::OnOK(wxCommandEvent& event)
523 {
524 if ( Validate() && TransferDataFromWindow() )
525 {
526 if ( IsModal() )
527 EndModal(wxID_OK);
528 else
529 {
530 SetReturnCode(wxID_OK);
531 this->Show(FALSE);
532 }
533 }
534 }
535
536 void wxDialog::OnApply(wxCommandEvent& event)
537 {
538 if (Validate())
539 TransferDataFromWindow();
540 // TODO probably need to disable the Apply button until things change again
541 }
542
543 void wxDialog::OnCancel(wxCommandEvent& event)
544 {
545 if ( IsModal() )
546 EndModal(wxID_CANCEL);
547 else
548 {
549 SetReturnCode(wxID_CANCEL);
550 this->Show(FALSE);
551 }
552 }
553
554 bool wxDialog::OnClose()
555 {
556 // Behaviour changed in 2.0: we'll send a Cancel message by default,
557 // which may close the dialog.
558 // Check for looping if the Cancel event handler calls Close()
559
560 static wxList closing;
561
562 if ( closing.Member(this) )
563 return FALSE;
564
565 closing.Append(this);
566
567 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
568 cancelEvent.SetEventObject( this );
569 GetEventHandler()->ProcessEvent(cancelEvent);
570
571 closing.DeleteObject(this);
572
573 return FALSE;
574 }
575
576 void wxDialog::OnCloseWindow(wxCloseEvent& event)
577 {
578 // Compatibility
579 if ( GetEventHandler()->OnClose() || event.GetForce())
580 {
581 this->Destroy();
582 }
583 }
584
585 // Destroy the window (delayed, if a managed window)
586 bool wxDialog::Destroy()
587 {
588 if (!wxPendingDelete.Member(this))
589 wxPendingDelete.Append(this);
590 return TRUE;
591 }
592
593 void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
594 {
595 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
596 Refresh();
597 }
598
599 void wxDialog::Fit()
600 {
601 }
602
603 // Handle a close event from the window manager
604 static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs)
605 {
606 wxDialog *dialog = (wxDialog *)client_data;
607 wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
608 closeEvent.SetEventObject(dialog);
609
610 // May delete the dialog (with delayed deletion)
611 dialog->GetEventHandler()->ProcessEvent(closeEvent);
612 }
613
614 // TODO: Preferably, we should have a universal repaint proc.
615 // Meanwhile, use a special one for dialogs.
616 static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *)
617 {
618 Window window;
619 static XRectangle *xrect;
620 Display *display;
621 GC gc;
622 int llp = 0;
623 static int last_count = 0;
624 static int draw_count = 0;
625
626 wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
627 if (!win)
628 return;
629
630 switch(event -> type)
631 {
632 case Expose :
633 window = (Window) win -> GetXWindow();
634 display = (Display *) win -> GetXDisplay();
635 /* TODO
636 gc = (GC) panel -> GetDC() -> gc;
637
638 llp = event -> xexpose.count;
639
640 if ((last_count == 0) && (llp == 0))
641 {
642 xrect = new XRectangle[1];
643 xrect[0].x = event -> xexpose.x;
644 xrect[0].y = event -> xexpose.y;
645 xrect[0].width = event -> xexpose.width;
646 xrect[0].height = event -> xexpose.height;
647
648 XSetClipRectangles(display,gc,0,0,xrect,1,Unsorted);
649 // panel->DoPaint(xrect, 1);
650 panel->GetEventHandler()->OnPaint();
651
652 delete xrect;
653 }
654
655 if ((last_count == 0) && (llp != 0))
656 {
657 xrect = new XRectangle[llp + 1];
658 draw_count = llp + 1;
659
660 xrect[draw_count - llp - 1].x = event -> xexpose.x;
661 xrect[draw_count - llp - 1].y = event -> xexpose.y;
662 xrect[draw_count - llp - 1].width = event -> xexpose.width;
663 xrect[draw_count - llp - 1].height = event -> xexpose.height;
664 }
665
666 if ((last_count != 0) && (llp != 0))
667 {
668 xrect[draw_count - llp - 1].x = event -> xexpose.x;
669 xrect[draw_count - llp - 1].y = event -> xexpose.y;
670 xrect[draw_count - llp - 1].width = event -> xexpose.width;
671 xrect[draw_count - llp - 1].height = event -> xexpose.height;
672 }
673
674 if ((last_count != 0) && (llp == 0))
675 {
676 xrect[draw_count - llp - 1].x = event -> xexpose.x;
677 xrect[draw_count - llp - 1].y = event -> xexpose.y;
678 xrect[draw_count - llp - 1].width = event -> xexpose.width;
679 xrect[draw_count - llp - 1].height = event -> xexpose.height;
680
681 XSetClipRectangles(display,gc,0,0,xrect,draw_count,Unsorted);
682 // panel->DoPaint(xrect,draw_count);
683 panel->GetEventHandler()->OnPaint();
684
685 delete xrect;
686 }
687 last_count = event -> xexpose.count;
688 */
689 break;
690 default :
691 cout << "\n\nNew Event ! is = " << event -> type << "\n";
692 break;
693 }
694 }
695
696 static void wxDialogBoxEventHandler (Widget wid,
697 XtPointer client_data,
698 XEvent* event,
699 Boolean *continueToDispatch)
700 {
701 wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
702 if (dialog)
703 {
704 wxMouseEvent wxevent(wxEVT_NULL);
705 if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
706 {
707 wxevent.SetEventObject(dialog);
708 wxevent.SetId(dialog->GetId());
709 dialog->GetEventHandler()->ProcessEvent(wxevent);
710 }
711 else
712 {
713 // An attempt to implement OnCharHook by calling OnCharHook first;
714 // if this returns TRUE, set continueToDispatch to False
715 // (don't continue processing).
716 // Otherwise set it to True and call OnChar.
717 wxKeyEvent keyEvent(wxEVENT_TYPE_CHAR);
718 if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
719 {
720 keyEvent.SetEventObject(dialog);
721 keyEvent.SetId(dialog->GetId());
722 keyEvent.SetEventType(wxEVT_CHAR_HOOK);
723 if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
724 {
725 *continueToDispatch = False;
726 return;
727 }
728 else
729 {
730 keyEvent.SetEventType(wxEVT_CHAR);
731 dialog->GetEventHandler()->ProcessEvent(keyEvent);
732 }
733 }
734 }
735 }
736 *continueToDispatch = True;
737 }
738
739 static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call)
740 {
741 /* This gets called when the dialog is being shown, which
742 * defeats modal showing.
743 client->m_modalShowing = FALSE ;
744 client->m_isShown = FALSE;
745 */
746 }
747
748 void wxDialog::ChangeFont()
749 {
750 // TODO
751 }
752
753 void wxDialog::ChangeBackgroundColour()
754 {
755 // TODO
756 }
757
758 void wxDialog::ChangeForegroundColour()
759 {
760 // TODO
761 }
762