X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47d67540a017101b3e46abe9ef0f55914d8de37e..184b5d99a5382cd7a19888c85aff11f8a21af2f6:/src/motif/dialog.cpp?ds=sidebyside diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index ec62649fed..b76fe887a8 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -80,7 +80,7 @@ END_EVENT_TABLE() wxDialog::wxDialog() { m_modalShowing = FALSE; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); } bool wxDialog::Create(wxWindow *parent, wxWindowID id, @@ -94,7 +94,9 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, m_modalShowing = FALSE; m_dialogTitle = title; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); + m_foregroundColour = *wxBLACK; + SetName(name); if (!parent) @@ -137,12 +139,15 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, XmStringFree(str); } + m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + ChangeFont(FALSE); + wxAddWindowToTable(dialogShell, this); // Intercept CLOSE messages from the window manager Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False); - /* MATTHEW: [8] Remove and add WM_DELETE_WINDOW so ours is only handler */ + /* Remove and add WM_DELETE_WINDOW so ours is only handler */ /* Why do we have to do this for wxDialog, but not wxFrame? */ XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1); XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1); @@ -164,7 +169,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, // Can't remember what this was about... but I think it's necessary. - if (USE_INVISIBLE_RESIZE) + if (wxUSE_INVISIBLE_RESIZE) { if (pos.x > -1) XtVaSetValues(dialogShell, XmNx, pos.x, @@ -216,10 +221,10 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, // Positioning of the dialog doesn't work properly unless the dialog // is managed, so we manage without mapping to the screen. // To show, we map the shell (actually it's parent). - if (!USE_INVISIBLE_RESIZE) + if (!wxUSE_INVISIBLE_RESIZE) XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL); - if (!USE_INVISIBLE_RESIZE) + if (!wxUSE_INVISIBLE_RESIZE) { XtManageChild(dialogShell); SetSize(pos.x, pos.y, size.x, size.y); @@ -233,6 +238,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, wxDialogBoxEventHandler, (XtPointer)this); + ChangeBackgroundColour(); + return TRUE; } @@ -252,7 +259,7 @@ void wxDialog::SetModal(bool flag) wxDialog::~wxDialog() { m_modalShowing = FALSE; - if (!USE_INVISIBLE_RESIZE && m_mainWidget) + if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget) { XtUnmapWidget((Widget) m_mainWidget); } @@ -280,10 +287,16 @@ wxDialog::~wxDialog() // Now process all events, because otherwise // this might remain on the screen. - XSync(XtDisplay(XtParent((Widget) m_mainWidget)), FALSE); + Display* display; + if (m_mainWidget) + display = XtDisplay((Widget) m_mainWidget); + else + display = (Display*) wxGetDisplay(); + + XSync(display, FALSE); XEvent event; while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) { - XFlush(XtDisplay((Widget) XtParent((Widget) m_mainWidget))); + XFlush(display); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtDispatchEvent(&event); } @@ -426,7 +439,7 @@ bool wxDialog::Show(bool show) if (show) { - if (!USE_INVISIBLE_RESIZE) + if (!wxUSE_INVISIBLE_RESIZE) XtMapWidget(XtParent((Widget) m_mainWidget)); else XtManageChild((Widget) m_mainWidget) ; @@ -436,7 +449,7 @@ bool wxDialog::Show(bool show) } else { - if (!USE_INVISIBLE_RESIZE) + if (!wxUSE_INVISIBLE_RESIZE) XtUnmapWidget(XtParent((Widget) m_mainWidget)); else XtUnmanageChild((Widget) m_mainWidget) ; @@ -467,7 +480,10 @@ int wxDialog::ShowModal() // Loop until we signal that the dialog should be closed while ((wxModalShowingStack.Number() > 0) && (bool)wxModalShowingStack.First()->Data()) { - 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 @@ -481,7 +497,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 @@ -508,7 +525,7 @@ void wxDialog::EndModal(int retCode) } // Standard buttons -void wxDialog::OnOK(wxCommandEvent& event) +void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { if ( Validate() && TransferDataFromWindow() ) { @@ -522,14 +539,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); @@ -579,7 +596,7 @@ bool wxDialog::Destroy() return TRUE; } -void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) +void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); Refresh(); @@ -590,7 +607,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()); @@ -602,88 +620,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) { @@ -725,7 +701,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. @@ -733,3 +709,19 @@ static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call) client->m_isShown = FALSE; */ } + +void wxDialog::ChangeFont(bool WXUNUSED(keepOriginalSize)) +{ + // TODO +} + +void wxDialog::ChangeBackgroundColour() +{ + // TODO +} + +void wxDialog::ChangeForegroundColour() +{ + // TODO +} +