More Motif stuff incl. beginnings of wxToolBar
[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
240 return TRUE;
241 }
242
243 void wxDialog::SetModal(bool flag)
244 {
245 if ( flag )
246 m_windowStyle |= wxDIALOG_MODAL ;
247 else
248 if ( m_windowStyle & wxDIALOG_MODAL )
249 m_windowStyle -= wxDIALOG_MODAL ;
250
251 wxModelessWindows.DeleteObject(this);
252 if (!flag)
253 wxModelessWindows.Append(this);
254 }
255
256 wxDialog::~wxDialog()
257 {
258 m_modalShowing = FALSE;
259 if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
260 {
261 XtUnmapWidget((Widget) m_mainWidget);
262 }
263
264 wxTopLevelWindows.DeleteObject(this);
265
266 if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
267 wxModelessWindows.DeleteObject(this);
268
269 // If this is the last top-level window, exit.
270 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
271 {
272 wxTheApp->SetTopWindow(NULL);
273
274 if (wxTheApp->GetExitOnFrameDelete())
275 {
276 wxTheApp->ExitMainLoop();
277 }
278 }
279
280 // This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp)
281 // but I think this should work, if we destroy the children first.
282 // Note that this might need to be done for wxFrame also.
283 DestroyChildren();
284
285 // Now process all events, because otherwise
286 // this might remain on the screen.
287 Display* display;
288 if (m_mainWidget)
289 display = XtDisplay((Widget) m_mainWidget);
290 else
291 display = (Display*) wxGetDisplay();
292
293 XSync(display, FALSE);
294 XEvent event;
295 while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
296 XFlush(display);
297 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
298 XtDispatchEvent(&event);
299 }
300 }
301
302 // By default, pressing escape cancels the dialog
303 void wxDialog::OnCharHook(wxKeyEvent& event)
304 {
305 if (event.m_keyCode == WXK_ESCAPE)
306 {
307 // Behaviour changed in 2.0: we'll send a Cancel message
308 // to the dialog instead of Close.
309 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
310 cancelEvent.SetEventObject( this );
311 GetEventHandler()->ProcessEvent(cancelEvent);
312
313 return;
314 }
315 // We didn't process this event.
316 event.Skip();
317 }
318
319 void wxDialog::Iconize(bool WXUNUSED(iconize))
320 {
321 // Can't iconize a dialog in Motif, apparently
322 // TODO: try using the parent of m_mainShell.
323 // XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
324 }
325
326 bool wxDialog::IsIconized() const
327 {
328 /*
329 Boolean iconic;
330 XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
331
332 return iconic;
333 */
334 return FALSE;
335 }
336
337 void wxDialog::SetSize(int x, int y, int width, int height, int sizeFlags)
338 {
339 XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
340 wxWindow::SetSize(x, y, width, height, sizeFlags);
341 XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
342 }
343
344 void wxDialog::SetClientSize(int width, int height)
345 {
346 SetSize(-1, -1, width, height);
347 }
348
349
350 void wxDialog::SetTitle(const wxString& title)
351 {
352 m_dialogTitle = title;
353 if (!title.IsNull())
354 {
355 XmString str = XmStringCreateSimple((char*) (const char*) title);
356 XtVaSetValues((Widget) m_mainWidget,
357 XmNtitle, (char*) (const char*) title,
358 XmNdialogTitle, str, // Roberto Cocchi
359 XmNiconName, (char*) (const char*) title,
360 NULL);
361 XmStringFree(str);
362 }
363 }
364
365 wxString wxDialog::GetTitle() const
366 {
367 return m_dialogTitle;
368 }
369
370 void wxDialog::Centre(int direction)
371 {
372 int x_offset,y_offset ;
373 int display_width, display_height;
374 int width, height, x, y;
375 wxWindow *parent = GetParent();
376 if ((direction & wxCENTER_FRAME) && parent)
377 {
378 parent->GetPosition(&x_offset,&y_offset) ;
379 parent->GetSize(&display_width,&display_height) ;
380 }
381 else
382 {
383 wxDisplaySize(&display_width, &display_height);
384 x_offset = 0 ;
385 y_offset = 0 ;
386 }
387
388 GetSize(&width, &height);
389 GetPosition(&x, &y);
390
391 if (direction & wxHORIZONTAL)
392 x = (int)((display_width - width)/2);
393 if (direction & wxVERTICAL)
394 y = (int)((display_height - height)/2);
395
396 SetSize(x+x_offset, y+y_offset, width, height);
397 }
398
399 void wxDialog::Raise()
400 {
401 Window parent_window = XtWindow((Widget) m_mainWidget),
402 next_parent = XtWindow((Widget) m_mainWidget),
403 root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
404 // search for the parent that is child of ROOT, because the WM may
405 // reparent twice and notify only the next parent (like FVWM)
406 while (next_parent != root) {
407 Window *theChildren; unsigned int n;
408 parent_window = next_parent;
409 XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
410 &next_parent, &theChildren, &n);
411 XFree(theChildren); // not needed
412 }
413 XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
414 }
415
416 void wxDialog::Lower()
417 {
418 Window parent_window = XtWindow((Widget) m_mainWidget),
419 next_parent = XtWindow((Widget) m_mainWidget),
420 root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
421 // search for the parent that is child of ROOT, because the WM may
422 // reparent twice and notify only the next parent (like FVWM)
423 while (next_parent != root) {
424 Window *theChildren; unsigned int n;
425 parent_window = next_parent;
426 XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
427 &next_parent, &theChildren, &n);
428 XFree(theChildren); // not needed
429 }
430 XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
431 }
432
433 bool wxDialog::Show(bool show)
434 {
435 m_isShown = show;
436
437 if (show)
438 {
439 if (!wxUSE_INVISIBLE_RESIZE)
440 XtMapWidget(XtParent((Widget) m_mainWidget));
441 else
442 XtManageChild((Widget) m_mainWidget) ;
443
444 XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget));
445
446 }
447 else
448 {
449 if (!wxUSE_INVISIBLE_RESIZE)
450 XtUnmapWidget(XtParent((Widget) m_mainWidget));
451 else
452 XtUnmanageChild((Widget) m_mainWidget) ;
453
454 XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
455 XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
456 }
457
458 return TRUE;
459 }
460
461 // Shows a dialog modally, returning a return code
462 int wxDialog::ShowModal()
463 {
464 m_windowStyle |= wxDIALOG_MODAL;
465
466 Show(TRUE);
467
468 if (m_modalShowing)
469 return 0;
470
471 wxModalShowingStack.Insert((wxObject *)TRUE);
472
473 m_modalShowing = TRUE;
474 XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
475 XEvent event;
476
477 // Loop until we signal that the dialog should be closed
478 while ((wxModalShowingStack.Number() > 0) && (bool)wxModalShowingStack.First()->Data())
479 {
480 XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
481 }
482
483 // Remove modal dialog flag from stack
484 wxNode *node = wxModalShowingStack.First();
485 if (node)
486 delete node;
487
488 // Now process all events in case they get sent to a destroyed dialog
489 XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
490 while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
491 {
492 XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
493 XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
494 XtDispatchEvent(&event);
495 }
496
497 // TODO: is it safe to call this, if the dialog may have been deleted
498 // by now? Probably only if we're using delayed deletion of dialogs.
499 return GetReturnCode();
500 }
501
502 void wxDialog::EndModal(int retCode)
503 {
504 if (!m_modalShowing)
505 return;
506
507 SetReturnCode(retCode);
508
509 XtRemoveGrab((Widget) m_mainWidget);
510
511 Show(FALSE);
512
513 m_modalShowing = FALSE;
514
515 wxNode *node = wxModalShowingStack.First();
516 if (node)
517 node->SetData((wxObject *)FALSE);
518 }
519
520 // Standard buttons
521 void wxDialog::OnOK(wxCommandEvent& event)
522 {
523 if ( Validate() && TransferDataFromWindow() )
524 {
525 if ( IsModal() )
526 EndModal(wxID_OK);
527 else
528 {
529 SetReturnCode(wxID_OK);
530 this->Show(FALSE);
531 }
532 }
533 }
534
535 void wxDialog::OnApply(wxCommandEvent& event)
536 {
537 if (Validate())
538 TransferDataFromWindow();
539 // TODO probably need to disable the Apply button until things change again
540 }
541
542 void wxDialog::OnCancel(wxCommandEvent& event)
543 {
544 if ( IsModal() )
545 EndModal(wxID_CANCEL);
546 else
547 {
548 SetReturnCode(wxID_CANCEL);
549 this->Show(FALSE);
550 }
551 }
552
553 bool wxDialog::OnClose()
554 {
555 // Behaviour changed in 2.0: we'll send a Cancel message by default,
556 // which may close the dialog.
557 // Check for looping if the Cancel event handler calls Close()
558
559 static wxList closing;
560
561 if ( closing.Member(this) )
562 return FALSE;
563
564 closing.Append(this);
565
566 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
567 cancelEvent.SetEventObject( this );
568 GetEventHandler()->ProcessEvent(cancelEvent);
569
570 closing.DeleteObject(this);
571
572 return FALSE;
573 }
574
575 void wxDialog::OnCloseWindow(wxCloseEvent& event)
576 {
577 // Compatibility
578 if ( GetEventHandler()->OnClose() || event.GetForce())
579 {
580 this->Destroy();
581 }
582 }
583
584 // Destroy the window (delayed, if a managed window)
585 bool wxDialog::Destroy()
586 {
587 if (!wxPendingDelete.Member(this))
588 wxPendingDelete.Append(this);
589 return TRUE;
590 }
591
592 void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
593 {
594 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
595 Refresh();
596 }
597
598 void wxDialog::Fit()
599 {
600 }
601
602 // Handle a close event from the window manager
603 static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs)
604 {
605 wxDialog *dialog = (wxDialog *)client_data;
606 wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
607 closeEvent.SetEventObject(dialog);
608
609 // May delete the dialog (with delayed deletion)
610 dialog->GetEventHandler()->ProcessEvent(closeEvent);
611 }
612
613 // TODO: Preferably, we should have a universal repaint proc.
614 // Meanwhile, use a special one for dialogs.
615 static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *)
616 {
617 Window window;
618 static XRectangle *xrect;
619 Display *display;
620 GC gc;
621 int llp = 0;
622 static int last_count = 0;
623 static int draw_count = 0;
624
625 wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
626 if (!win)
627 return;
628
629 switch(event -> type)
630 {
631 case Expose :
632 window = (Window) win -> GetXWindow();
633 display = (Display *) win -> GetXDisplay();
634 /* TODO
635 gc = (GC) panel -> GetDC() -> gc;
636
637 llp = event -> xexpose.count;
638
639 if ((last_count == 0) && (llp == 0))
640 {
641 xrect = new XRectangle[1];
642 xrect[0].x = event -> xexpose.x;
643 xrect[0].y = event -> xexpose.y;
644 xrect[0].width = event -> xexpose.width;
645 xrect[0].height = event -> xexpose.height;
646
647 XSetClipRectangles(display,gc,0,0,xrect,1,Unsorted);
648 // panel->DoPaint(xrect, 1);
649 panel->GetEventHandler()->OnPaint();
650
651 delete xrect;
652 }
653
654 if ((last_count == 0) && (llp != 0))
655 {
656 xrect = new XRectangle[llp + 1];
657 draw_count = llp + 1;
658
659 xrect[draw_count - llp - 1].x = event -> xexpose.x;
660 xrect[draw_count - llp - 1].y = event -> xexpose.y;
661 xrect[draw_count - llp - 1].width = event -> xexpose.width;
662 xrect[draw_count - llp - 1].height = event -> xexpose.height;
663 }
664
665 if ((last_count != 0) && (llp != 0))
666 {
667 xrect[draw_count - llp - 1].x = event -> xexpose.x;
668 xrect[draw_count - llp - 1].y = event -> xexpose.y;
669 xrect[draw_count - llp - 1].width = event -> xexpose.width;
670 xrect[draw_count - llp - 1].height = event -> xexpose.height;
671 }
672
673 if ((last_count != 0) && (llp == 0))
674 {
675 xrect[draw_count - llp - 1].x = event -> xexpose.x;
676 xrect[draw_count - llp - 1].y = event -> xexpose.y;
677 xrect[draw_count - llp - 1].width = event -> xexpose.width;
678 xrect[draw_count - llp - 1].height = event -> xexpose.height;
679
680 XSetClipRectangles(display,gc,0,0,xrect,draw_count,Unsorted);
681 // panel->DoPaint(xrect,draw_count);
682 panel->GetEventHandler()->OnPaint();
683
684 delete xrect;
685 }
686 last_count = event -> xexpose.count;
687 */
688 break;
689 default :
690 cout << "\n\nNew Event ! is = " << event -> type << "\n";
691 break;
692 }
693 }
694
695 static void wxDialogBoxEventHandler (Widget wid,
696 XtPointer client_data,
697 XEvent* event,
698 Boolean *continueToDispatch)
699 {
700 wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
701 if (dialog)
702 {
703 wxMouseEvent wxevent(wxEVT_NULL);
704 if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
705 {
706 wxevent.SetEventObject(dialog);
707 wxevent.SetId(dialog->GetId());
708 dialog->GetEventHandler()->ProcessEvent(wxevent);
709 }
710 else
711 {
712 // An attempt to implement OnCharHook by calling OnCharHook first;
713 // if this returns TRUE, set continueToDispatch to False
714 // (don't continue processing).
715 // Otherwise set it to True and call OnChar.
716 wxKeyEvent keyEvent(wxEVENT_TYPE_CHAR);
717 if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
718 {
719 keyEvent.SetEventObject(dialog);
720 keyEvent.SetId(dialog->GetId());
721 keyEvent.SetEventType(wxEVT_CHAR_HOOK);
722 if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
723 {
724 *continueToDispatch = False;
725 return;
726 }
727 else
728 {
729 keyEvent.SetEventType(wxEVT_CHAR);
730 dialog->GetEventHandler()->ProcessEvent(keyEvent);
731 }
732 }
733 }
734 }
735 *continueToDispatch = True;
736 }
737
738 static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call)
739 {
740 /* This gets called when the dialog is being shown, which
741 * defeats modal showing.
742 client->m_modalShowing = FALSE ;
743 client->m_isShown = FALSE;
744 */
745 }
746
747 void wxDialog::ChangeFont()
748 {
749 // TODO
750 }
751
752 void wxDialog::ChangeBackgroundColour()
753 {
754 // TODO
755 }
756
757 void wxDialog::ChangeForegroundColour()
758 {
759 // TODO
760 }
761