X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/105fbe1ffa8968cb85fd2cac7192957e522d17ba..a766986f6d443ba1d50e3af25f3306fa56e4518e:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 9a7d7eb156..17634160d4 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -20,12 +20,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __VMS -#define XtDisplay XTDISPLAY -#define XtWindow XTWINDOW -#define XtScreen XTSCREEN -#endif - #ifndef WX_PRECOMP #include "wx/hash.h" #include "wx/log.h" @@ -80,6 +74,7 @@ #endif #include "wx/motif/private.h" +#include "wx/motif/dcclient.h" #include @@ -230,6 +225,11 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { + // Get default border + wxBorder border = GetBorder(style); + style &= ~wxBORDER_MASK; + style |= border; + wxCHECK_MSG( parent, false, "can't create wxWindow without parent" ); CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); @@ -629,12 +629,13 @@ void wxWindow::Lower() void wxWindow::SetLabel(const wxString& label) { - XtVaSetValues((Widget)GetMainWidget(), XmNtitle, label.mb_str(), NULL); + XtVaSetValues((Widget)GetMainWidget(), XmNtitle, + (const char*)label.mb_str(), NULL); } wxString wxWindow::GetLabel() const { - char *label; + char *label = NULL; XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &label, NULL); return wxString(label); @@ -874,6 +875,9 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) int y2 = (dy >= 0) ? y + dy : y; wxClientDC dc(this); + wxClientDCImpl * const + dcimpl = static_cast(dc.GetImpl()); + GC const gc = (GC) dcimpl->GetGC(); dc.SetLogicalFunction (wxCOPY); @@ -881,10 +885,9 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) Window window = XtWindow(widget); Display* display = XtDisplay(widget); - XCopyArea(display, window, window, (GC) dc.GetGC(), - x1, y1, w1, h1, x2, y2); + XCopyArea(display, window, window, gc, x1, y1, w1, h1, x2, y2); - dc.SetAutoSetting(true); + dcimpl->SetAutoSetting(true); wxBrush brush(GetBackgroundColour(), wxSOLID); dc.SetBrush(brush); // FIXME: needed? @@ -912,8 +915,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) rect->width = dx; rect->height = h; - XFillRectangle(display, window, - (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); + XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height); rect->x = rect->x; rect->y = rect->y; @@ -931,9 +933,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) rect->width = -dx; rect->height = h; - XFillRectangle(display, window, - (GC) dc.GetGC(), rect->x, rect->y, rect->width, - rect->height); + XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height); rect->x = rect->x; rect->y = rect->y; @@ -951,8 +951,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) rect->width = w; rect->height = dy; - XFillRectangle(display, window, - (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); + XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height); rect->x = rect->x; rect->y = rect->y; @@ -970,8 +969,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) rect->width = w; rect->height = -dy; - XFillRectangle(display, window, - (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); + XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height); rect->x = rect->x; rect->y = rect->y; @@ -1171,7 +1169,7 @@ void wxWindow::DoGetSize(int *x, int *y) const XmNwidth, &xx, XmNheight, &yy, NULL ); - if(x) *x = widget ? xx : -1; + if(x) *x = widget ? xx : -1; if(y) *y = widget ? yy : -1; } @@ -1543,10 +1541,13 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) wxClientDC dc(this); wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID); dc.SetBackground(backgroundBrush); + + wxClientDCImpl * const + dcimpl = static_cast(dc.GetImpl()); if (rect) - dc.Clear(*rect); + dcimpl->Clear(*rect); else - dc.Clear(); + dcimpl->Clear(); } XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent); @@ -1559,7 +1560,10 @@ void wxWindow::DoPaint() { wxPaintDC dc(this); - GC tempGC = (GC) dc.GetBackingGC(); + wxPaintDCImpl * const + dcimpl = static_cast(dc.GetImpl()); + + GC tempGC = (GC) dcimpl->GetBackingGC(); Widget widget = (Widget) GetMainWidget(); @@ -1616,11 +1620,11 @@ void wxWindow::DoPaint() // Set an erase event first wxEraseEvent eraseEvent(GetId(), &dc); eraseEvent.SetEventObject(this); - GetEventHandler()->ProcessEvent(eraseEvent); + HandleWindowEvent(eraseEvent); wxPaintEvent event(GetId()); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); m_needsRefresh = false; } @@ -1642,7 +1646,7 @@ void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) { wxSysColourChangedEvent event2; event.SetEventObject(win); - win->GetEventHandler()->ProcessEvent(event2); + win->HandleWindowEvent(event2); } node = node->GetNext(); @@ -1653,7 +1657,7 @@ void wxWindow::OnInternalIdle() { // This calls the UI-update mechanism (querying windows for // menu/toolbar/control state information) - if (wxUpdateUIEvent::CanUpdate(this)) + if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen()) UpdateWindowUI(wxUPDATE_UI_FROMIDLE); } @@ -1702,7 +1706,7 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event) // If ProcessEvent returns true (it was handled), then // the calling code will skip the event handling. - return frame->GetEventHandler()->ProcessEvent(commandEvent); + return frame->HandleWindowEvent(commandEvent); } } #endif @@ -1721,7 +1725,7 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event) { wxCommandEvent commandEvent (wxEVT_COMMAND_BUTTON_CLICKED, child->GetId()); commandEvent.SetEventObject(child); - return child->GetEventHandler()->ProcessEvent(commandEvent); + return child->HandleWindowEvent(commandEvent); } return false; @@ -1907,7 +1911,7 @@ void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), wxSize newSize(win->GetSize()); wxSizeEvent sizeEvent(newSize, win->GetId()); sizeEvent.SetEventObject(win); - win->GetEventHandler()->ProcessEvent(sizeEvent); + win->HandleWindowEvent(sizeEvent); } } @@ -1993,7 +1997,7 @@ static void wxCanvasInputEvent(Widget drawingArea, wxMouseEvent wxevent(0); if (wxTranslateMouseEvent(wxevent, canvas, drawingArea, xevent)) { - canvas->GetEventHandler()->ProcessEvent(wxevent); + canvas->HandleWindowEvent(wxevent); } break; } @@ -2010,7 +2014,7 @@ static void wxCanvasInputEvent(Widget drawingArea, if (parent) { event.SetEventType(wxEVT_CHAR_HOOK); - if (parent->GetEventHandler()->ProcessEvent(event)) + if (parent->HandleWindowEvent(event)) return; } @@ -2019,10 +2023,10 @@ static void wxCanvasInputEvent(Widget drawingArea, event.SetEventType(wxEVT_KEY_DOWN); // Only process OnChar if OnKeyDown didn't swallow it - if (!canvas->GetEventHandler()->ProcessEvent (event)) + if (!canvas->HandleWindowEvent (event)) { event.SetEventType(wxEVT_CHAR); - canvas->GetEventHandler()->ProcessEvent (event); + canvas->HandleWindowEvent (event); } } break; @@ -2032,7 +2036,7 @@ static void wxCanvasInputEvent(Widget drawingArea, wxKeyEvent event (wxEVT_KEY_UP); if (wxTranslateKeyEvent (event, canvas, (Widget) 0, xevent)) { - canvas->GetEventHandler()->ProcessEvent (event); + canvas->HandleWindowEvent (event); } break; } @@ -2042,7 +2046,7 @@ static void wxCanvasInputEvent(Widget drawingArea, { wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId()); event.SetEventObject(canvas); - canvas->GetEventHandler()->ProcessEvent(event); + canvas->HandleWindowEvent(event); } break; } @@ -2052,7 +2056,7 @@ static void wxCanvasInputEvent(Widget drawingArea, { wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId()); event.SetEventObject(canvas); - canvas->GetEventHandler()->ProcessEvent(event); + canvas->HandleWindowEvent(event); } break; } @@ -2074,7 +2078,7 @@ static void wxPanelItemEventHandler(Widget wid, wxMouseEvent wxevent(0); if (wxTranslateMouseEvent(wxevent, window, wid, event)) { - window->GetEventHandler()->ProcessEvent(wxevent); + window->HandleWindowEvent(wxevent); } } @@ -2152,7 +2156,7 @@ static void wxScrollBarCallback(Widget scrollbar, cbs->value, orientation); event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent(event); + win->HandleWindowEvent(event); } // For repainting arbitrary windows @@ -2623,14 +2627,14 @@ void wxGetTextExtent(const wxWindow* window, const wxString& str, { XRectangle ink, logical; WXFontSet fset = (WXFontSet) args[0].value; - + XmbTextExtents( (XFontSet)fset, str.c_str(), str.length(), &ink, &logical); if( width ) *width = logical.width; if( height ) *height = logical.height; - if( ascent ) *ascent = -logical.y; - if( descent ) *descent = logical.height + logical.y; + if( ascent ) *ascent = -logical.y; + if( descent ) *descent = logical.height + logical.y; } else { @@ -2669,14 +2673,14 @@ void wxGetTextExtent(const wxWindow* window, const wxString& str, if (type == XmFONT_IS_FONTSET) { XRectangle ink, logical; - + XmbTextExtents( (XFontSet)thing, str.c_str(), str.length(), &ink, &logical); if( width ) *width = logical.width; if( height ) *height = logical.height; - if( ascent ) *ascent = -logical.y; - if( descent ) *descent = logical.height + logical.y; + if( ascent ) *ascent = -logical.y; + if( descent ) *descent = logical.height + logical.y; } else {