X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/33caefb37762ff21b139ef943d1b614dc3b237db..71f21f464f52ff7292ccefaf0d425ac9f2068f78:/src/motif/window.cpp?ds=sidebyside diff --git a/src/motif/window.cpp b/src/motif/window.cpp index c8537834bf..f7ed6cb2bb 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -53,6 +53,7 @@ #include #include #include +#include // for XmMenuPosition #include "wx/motif/private.h" @@ -182,7 +183,8 @@ void wxWindow::Init() m_winCaptured = FALSE; m_isShown = TRUE; - + m_isBeingDeleted = FALSE; + m_hScrollBar = m_vScrollBar = m_borderWidget = @@ -216,7 +218,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, { wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" ); - CreateBase(parent, id, pos, size, style, name); + CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); parent->AddChild(this); @@ -359,6 +361,8 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, // Destructor wxWindow::~wxWindow() { + m_isBeingDeleted = TRUE; + // Motif-specific actions first WXWidget wMain = GetMainWidget(); if ( wMain ) @@ -369,6 +373,9 @@ wxWindow::~wxWindow() ClearUpdateRects(); + if ( m_parent ) + m_parent->RemoveChild( this ); + // If m_drawingArea, we're a fully-fledged window with drawing area, // scrollbars etc. (what wxCanvas used to be) if ( m_drawingArea ) @@ -1040,6 +1047,76 @@ void wxWindow::DoSetToolTip(wxToolTip * WXUNUSED(tooltip)) #endif // wxUSE_TOOLTIPS +// ---------------------------------------------------------------------------- +// popup menus +// ---------------------------------------------------------------------------- + +bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) +{ + Widget widget = (Widget) GetMainWidget(); + + /* The menuId field seems to be usused, so we'll use it to + indicate whether a menu is popped up or not: + 0: Not currently created as a popup + -1: Created as a popup, but not active + 1: Active popup. + */ + + if (menu->GetParent() && (menu->GetId() != -1)) + return FALSE; + + if (menu->GetMainWidget()) { + menu->DestroyMenu(TRUE); + } + + menu->SetId(1); /* Mark as popped-up */ + menu->CreateMenu(NULL, widget, menu); + menu->SetInvokingWindow(this); + + menu->UpdateUI(); + + // menu->SetParent(parent); + // parent->children->Append(menu); // Store menu for later deletion + + Widget menuWidget = (Widget) menu->GetMainWidget(); + + int rootX = 0; + int rootY = 0; + + int deviceX = x; + int deviceY = y; + /* + if (this->IsKindOf(CLASSINFO(wxCanvas))) + { + wxCanvas *canvas = (wxCanvas *) this; + deviceX = canvas->GetDC ()->LogicalToDeviceX (x); + deviceY = canvas->GetDC ()->LogicalToDeviceY (y); + } + */ + + Display *display = XtDisplay (widget); + Window rootWindow = RootWindowOfScreen (XtScreen((Widget)widget)); + Window thisWindow = XtWindow (widget); + Window childWindow; + XTranslateCoordinates (display, thisWindow, rootWindow, (int) deviceX, (int) deviceY, + &rootX, &rootY, &childWindow); + + XButtonPressedEvent event; + event.type = ButtonPress; + event.button = 1; + + event.x = deviceX; + event.y = deviceY; + + event.x_root = rootX; + event.y_root = rootY; + + XmMenuPosition (menuWidget, &event); + XtManageChild (menuWidget); + + return TRUE; +} + // --------------------------------------------------------------------------- // moving and resizing // --------------------------------------------------------------------------- @@ -1597,6 +1674,9 @@ bool wxAddWindowToTable(Widget w, wxWindow *win) wxWidgetHashTable->Put((long) w, win); + wxLogDebug("Widget 0x%08x <-> window %p (%s)", + w, win, win->GetClassInfo()->GetClassName()); + return TRUE; } @@ -2560,6 +2640,7 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEve switch (xevent->xany.type) { case KeyPress: + case KeyRelease: { char buf[20];