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