X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a91b47e800c78dbf8e91191ce3977d148a13f1fe..031bc97f4629f95d445f9716a9d4d61665a19dc9:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 8ec4c0d3b5..2642297fd9 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -86,6 +86,7 @@ END_EVENT_TABLE() wxWindow::wxWindow() { // Generic + m_isWindow = TRUE; // An optimization m_windowId = 0; m_windowStyle = 0; m_windowParent = NULL; @@ -144,14 +145,6 @@ wxWindow::wxWindow() // Destructor wxWindow::~wxWindow() { - // Remove potential dangling pointer - if (GetParent() && GetParent()->IsKindOf(CLASSINFO(wxPanel))) - { - wxPanel* panel = (wxPanel*) GetParent(); - if (panel->GetLastFocus() == this) - panel->SetLastFocus((wxWindow*) NULL); - } - //// Motif-specific if (GetMainWidget()) @@ -235,7 +228,11 @@ wxWindow::~wxWindow() // Destroy the window if (GetMainWidget()) { - wxDeleteWindowFromTable((Widget) GetMainWidget()); + // If this line (XtDestroyWidget) causes a crash, you may comment it out. + // Child widgets will get destroyed automatically when a frame + // or dialog is destroyed, but before that you may get some memory + // leaks and potential layout problems if you delete and then add + // child windows. XtDestroyWidget((Widget) GetMainWidget()); SetMainWidget((WXWidget) NULL); } @@ -269,6 +266,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, const wxString& name) { // Generic + m_isWindow = TRUE; // An optimization m_windowId = 0; m_windowStyle = 0; m_windowParent = NULL; @@ -751,7 +749,7 @@ void wxWindow::GetClientSize(int *x, int *y) const *x = xx; *y = yy; } -void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) +void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) { // A bit of optimization to help sort out the flickers. int oldX, oldY, oldW, oldH; @@ -823,7 +821,7 @@ void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) */ } -void wxWindow::SetClientSize(int width, int height) +void wxWindow::DoSetClientSize(int width, int height) { if (m_drawingArea) { @@ -1586,8 +1584,30 @@ bool wxWindow::Validate() // Get the window with the focus wxWindow *wxWindow::FindFocus() { - // TODO - return NULL; + // TODO Problems: + // (1) Can there be multiple focussed widgets in an application? + // In which case we need to find the top-level window that's + // currently active. + // (2) The widget with the focus may not be in the widget table + // depending on which widgets I put in the table + + wxNode *node = wxTopLevelWindows.First(); + while (node) + { + wxWindow *win = (wxWindow *)node->Data(); + + Widget w = XmGetFocusWidget ((Widget) win->GetTopWidget()) ; + + if (w != (Widget) NULL) + { + wxWindow* focusWin = wxGetWindowFromTable(w); + if (focusWin) + return focusWin; + } + + node = node->Next(); + } + return (wxWindow*) NULL; } void wxWindow::AddChild(wxWindow *child) @@ -2311,12 +2331,18 @@ void wxDeleteWindowFromTable(Widget w) // Get the underlying X window and display WXWindow wxWindow::GetXWindow() const { - return (WXWindow) XtWindow((Widget) GetMainWidget()); + if (GetMainWidget()) + return (WXWindow) XtWindow((Widget) GetMainWidget()); + else + return (WXWindow) 0; } WXDisplay *wxWindow::GetXDisplay() const { - return (WXDisplay*) XtDisplay((Widget) GetMainWidget()); + if (GetMainWidget()) + return (WXDisplay*) XtDisplay((Widget) GetMainWidget()); + else + return (WXDisplay*) NULL; } WXWidget wxWindow::GetMainWidget() const @@ -3584,3 +3610,40 @@ bool wxNoOptimize::CanOptimize() return (m_count == 0); } +// For repainting arbitrary windows +void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *) +{ + Window window; + Display *display; + + wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w); + if (!win) + return; + + switch(event -> type) + { + case Expose : + { + window = (Window) win -> GetXWindow(); + display = (Display *) win -> GetXDisplay(); + + 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) + { + win->DoPaint(); + + win->ClearUpdateRects(); + } + break; + } + default : + { + cout << "\n\nNew Event ! is = " << event -> type << "\n"; + break; + } + } +} +