]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/dialog.cpp
wxMSW wxClipboard implementation
[wxWidgets.git] / src / motif / dialog.cpp
index 7edbb5df9132c858f687c4d654d98bca1c6686b4..093cb901fbdfcb8e0fabf901d59e697c32726623 100644 (file)
@@ -117,9 +117,10 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
 
     wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
 
-    Arg args[1];
+    Arg args[2];
     XtSetArg (args[0], XmNdefaultPosition, False);
-    Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 1);
+    XtSetArg (args[1], XmNautoUnmanage, False);
+    Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
     m_mainWidget = (WXWidget) dialogShell;
 
     // We don't want margins, since there is enough elsewhere.
@@ -285,6 +286,9 @@ wxDialog::~wxDialog()
     // Note that this might need to be done for wxFrame also.
     DestroyChildren();
 
+    // This causes a crash in e.g. the resource sample when closing
+    // the example dialog. TODO: Probably not necessary (?)
+#if 0
     // Now process all events, because otherwise
     // this might remain on the screen.
     Display* display;
@@ -300,6 +304,7 @@ wxDialog::~wxDialog()
       XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
       XtDispatchEvent(&event);
     }
+#endif
 }
 
 // By default, pressing escape cancels the dialog
@@ -475,12 +480,16 @@ int wxDialog::ShowModal()
         
     m_modalShowing = TRUE;
     XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
+
     XEvent event;
 
     // Loop until we signal that the dialog should be closed
-    while ((wxModalShowingStack.Number() > 0) && (bool)wxModalShowingStack.First()->Data())
+    while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0))
     {
-        XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+//        XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+
+        XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
+        wxTheApp->ProcessXEvent((WXEvent*) &event);
     }
 
     // Remove modal dialog flag from stack
@@ -494,7 +503,8 @@ int wxDialog::ShowModal()
     {
         XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
         XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
-        XtDispatchEvent(&event);
+
+        wxTheApp->ProcessXEvent((WXEvent*) &event);
     }
 
     // TODO: is it safe to call this, if the dialog may have been deleted
@@ -509,7 +519,8 @@ void wxDialog::EndModal(int retCode)
 
     SetReturnCode(retCode);
 
-    XtRemoveGrab((Widget) m_mainWidget);
+    // Strangely, we don't seem to need this now.
+    //    XtRemoveGrab((Widget) m_mainWidget);
 
     Show(FALSE);
 
@@ -521,7 +532,7 @@ void wxDialog::EndModal(int retCode)
 }
 
 // Standard buttons
-void wxDialog::OnOK(wxCommandEvent& event)
+void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
 {
        if ( Validate() && TransferDataFromWindow() )
        {
@@ -535,14 +546,14 @@ void wxDialog::OnOK(wxCommandEvent& event)
        }
 }
 
-void wxDialog::OnApply(wxCommandEvent& event)
+void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
 {
        if (Validate())
                TransferDataFromWindow();
        // TODO probably need to disable the Apply button until things change again
 }
 
-void wxDialog::OnCancel(wxCommandEvent& event)
+void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
 {
     if ( IsModal() )
         EndModal(wxID_CANCEL);
@@ -592,7 +603,7 @@ bool wxDialog::Destroy()
   return TRUE;
 }
 
-void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
+void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
 {
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
   Refresh();
@@ -603,7 +614,8 @@ void wxDialog::Fit()
 }
 
 // Handle a close event from the window manager
-static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs)
+static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data, 
+                                   XmAnyCallbackStruct *WXUNUSED(cbs))
 {
   wxDialog *dialog = (wxDialog *)client_data;
   wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
@@ -615,88 +627,46 @@ static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCal
 
 // TODO: Preferably, we should have a universal repaint proc.
 // Meanwhile, use a special one for dialogs.
-static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *)
-   {
+static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *)
+{
      Window window;
-     static XRectangle *xrect;
      Display *display;
-     GC gc;
-     int llp = 0;
-     static int last_count = 0;
-     static int draw_count = 0;
 
      wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
      if (!win)
        return;
 
      switch(event -> type)
-        {
+     {
           case Expose :
+          {
                window = (Window) win -> GetXWindow();
                display = (Display *) win -> GetXDisplay();
-              /* TODO
-               gc = (GC) panel -> GetDC() -> gc;
-               
-               llp = event -> xexpose.count;
-               
-               if ((last_count == 0) && (llp == 0))
-                  {
-                    xrect = new XRectangle[1];
-                    xrect[0].x = event -> xexpose.x;
-                    xrect[0].y = event -> xexpose.y;
-                    xrect[0].width = event -> xexpose.width;
-                    xrect[0].height = event -> xexpose.height;
-                    
-                    XSetClipRectangles(display,gc,0,0,xrect,1,Unsorted);
-//                    panel->DoPaint(xrect, 1);
-                    panel->GetEventHandler()->OnPaint();
-
-                    delete xrect;
-                  }
-
-               if ((last_count == 0) && (llp != 0))
-                  {
-                    xrect = new XRectangle[llp + 1];
-                    draw_count = llp + 1;
-                    
-                    xrect[draw_count - llp - 1].x = event -> xexpose.x;
-                    xrect[draw_count - llp - 1].y = event -> xexpose.y;
-                    xrect[draw_count - llp - 1].width = event -> xexpose.width;
-                    xrect[draw_count - llp - 1].height = event -> xexpose.height;
-                  }
-
-               if ((last_count != 0) && (llp != 0))
-                  {
-                    xrect[draw_count - llp - 1].x = event -> xexpose.x;
-                    xrect[draw_count - llp - 1].y = event -> xexpose.y;
-                    xrect[draw_count - llp - 1].width = event -> xexpose.width;
-                    xrect[draw_count - llp - 1].height = event -> xexpose.height;
-                  }
-               
-               if ((last_count != 0) && (llp == 0))
-                  {
-                    xrect[draw_count - llp - 1].x = event -> xexpose.x;
-                    xrect[draw_count - llp - 1].y = event -> xexpose.y;
-                    xrect[draw_count - llp - 1].width = event -> xexpose.width;
-                    xrect[draw_count - llp - 1].height = event -> xexpose.height;
-
-                    XSetClipRectangles(display,gc,0,0,xrect,draw_count,Unsorted);
-//                    panel->DoPaint(xrect,draw_count);
-                    panel->GetEventHandler()->OnPaint();
-
-                    delete xrect;
-                  }
-               last_count = event -> xexpose.count;
-              */
+
+               wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
+                                       event->xexpose.width, event->xexpose.height);
+               win->m_updateRects.Append((wxObject*) rect);
+
+               if (event -> xexpose.count == 0)
+               {
+                    wxPaintEvent event(win->GetId());
+                    event.SetEventObject(win);
+                    win->GetEventHandler()->ProcessEvent(event);
+
+                    win->ClearUpdateRects();
+               }
                break;
-          default :
+         }
+        default :
+         {
                cout << "\n\nNew Event ! is = " << event -> type << "\n";
                break;
-        }
-   }
+         }
+     }
+}
 
 static void wxDialogBoxEventHandler (Widget    wid,
-                              XtPointer client_data,
+                              XtPointer WXUNUSED(client_data),
                               XEvent*   event,
                               Boolean *continueToDispatch)
 {
@@ -738,7 +708,7 @@ static void wxDialogBoxEventHandler (Widget    wid,
   *continueToDispatch = True;
 }
 
-static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call)
+static void wxUnmapBulletinBoard(Widget WXUNUSED(dialog), wxDialog *WXUNUSED(client), XtPointer WXUNUSED(call) )
 {
   /* This gets called when the dialog is being shown, which
    * defeats modal showing.
@@ -749,16 +719,18 @@ static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call)
 
 void wxDialog::ChangeFont(bool keepOriginalSize)
 {
-    // TODO
+    wxWindow::ChangeFont(keepOriginalSize);
 }
 
 void wxDialog::ChangeBackgroundColour()
 {
-    // TODO
+    if (GetMainWidget())
+        DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
 }
 
 void wxDialog::ChangeForegroundColour()
 {
-    // TODO
+    if (GetMainWidget())
+        DoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
 }