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