#include "wx/module.h"
#include "wx/menuitem.h"
#include "wx/log.h"
+#include "wx/evtloop.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
}
}
-bool wxWindow::MapOrUnmap(WXWidget widget, bool map)
+bool wxWindow::MapOrUnmap(WXWidget widget, bool domap)
{
Widget w = (Widget)widget;
if ( !w )
return FALSE;
- if ( map )
+ if ( domap )
XtMapWidget(w);
else
XtUnmapWidget(w);
+ // Rationale: a lot of common operations (including but not
+ // limited to moving, resizing and appending items to a listbox)
+ // unmamange the widget, do their work, then manage it again.
+ // This means that, for example adding an item to a listbox will show it,
+ // or that most controls are shown every time they are moved or resized!
+ XtSetMappedWhenManaged( w, domap );
+
return TRUE;
}
GetClientSize(& w, & h);
}
- wxNode *cnode = m_children.First();
+ wxWindowList::Node *cnode = m_children.GetFirst();
while (cnode)
{
- wxWindow *child = (wxWindow*) cnode->Data();
+ wxWindow *child = cnode->GetData();
int sx = 0;
int sy = 0;
child->GetSize( &sx, &sy );
wxPoint pos( child->GetPosition() );
child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE );
- cnode = cnode->Next();
+ cnode = cnode->GetNext();
}
int x1 = (dx >= 0) ? x : x - dx;
// Now send expose events
- wxNode* node = updateRects.First();
+ wxList::Node* node = updateRects.GetFirst();
while (node)
{
- wxRect* rect = (wxRect*) node->Data();
+ wxRect* rect = (wxRect*) node->GetData();
XExposeEvent event;
event.type = Expose;
XSendEvent(display, window, False, ExposureMask, (XEvent *)&event);
- node = node->Next();
+ node = node->GetNext();
}
// Delete the update rects
- node = updateRects.First();
+ node = updateRects.GetFirst();
while (node)
{
- wxRect* rect = (wxRect*) node->Data();
+ wxRect* rect = (wxRect*) node->GetData();
delete rect;
- node = node->Next();
+ node = node->GetNext();
}
XmUpdateDisplay((Widget) GetMainWidget());
// popup menus
// ----------------------------------------------------------------------------
+#if wxUSE_MENUS
+
bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
{
Widget widget = (Widget) GetMainWidget();
if (menu->GetParent() && (menu->GetId() != -1))
return FALSE;
- if (menu->GetMainWidget()) {
+ if (menu->GetMainWidget())
+ {
menu->DestroyMenu(TRUE);
}
XmMenuPosition (menuWidget, &event);
XtManageChild (menuWidget);
- XEvent x_event;
// The ID of a pop-up menu is 1 when active, and is set to 0 by the
// idle-time destroy routine.
// Waiting until this ID changes causes this function to block until
// In other words, once this routine returns, it is safe to delete
// the menu object.
// Ian Brown <ian.brown@printsoft.de>
- while (menu->GetId() == 1)
- {
- XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &x_event);
- wxTheApp->ProcessXEvent((WXEvent*) & x_event);
+ wxEventLoop evtLoop;
- if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
- {
- if (!wxTheApp->ProcessIdle())
- {
-#if wxUSE_THREADS
- // leave the main loop to give other threads a chance to
- // perform their GUI work
- wxMutexGuiLeave();
- wxUsleep(20);
- wxMutexGuiEnter();
-#endif
- }
- }
+ while (menu->GetId() == 1)
+ {
+ wxDoEventLoopIteration( evtLoop );
}
+
return TRUE;
}
+#endif
+
// ---------------------------------------------------------------------------
// moving and resizing
// ---------------------------------------------------------------------------
y = oldY;
}
- if ( width == -1 )
+ if ( width <= 0 )
width = oldW;
- if ( height == -1 )
+ if ( height <= 0 )
height = oldH;
bool nothingChanged = (x == oldX) && (y == oldY) &&
if (managed)
XtManageChild(widget);
-
- // How about this bit. Maybe we don't need to generate size events
- // all the time -- they'll be generated when the window is sized anyway.
-#if 0
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
-#endif // 0
}
}
bool wxWindow::ProcessAccelerator(wxKeyEvent& event)
{
+#if wxUSE_ACCEL
if (!m_acceleratorTable.Ok())
return FALSE;
wxFrame* frame = wxDynamicCast(parent, wxFrame);
if ( frame )
{
+#if wxUSE_MENUS
// Try for a menu command
if (frame->GetMenuBar())
{
return frame->GetEventHandler()->ProcessEvent(commandEvent);
}
}
+#endif
}
// Find a child matching the command id
return FALSE;
} // matches event
}// for
+#endif
// We didn't match the key event against an accelerator.
return FALSE;
wxWidgetHashTable->Put((long) w, win);
- wxLogTrace("widget", "Widget 0x%08x <-> window %p (%s)",
- w, win, win->GetClassInfo()->GetClassName());
+ wxLogTrace("widget", "Widget 0x%p <-> window %p (%s)",
+ (WXWidget)w, win, win->GetClassInfo()->GetClassName());
return TRUE;
}
int width, height, width1, height1;
GetSize(& width, & height);
- // lesstif 0.87 hangs here
-#ifndef LESSTIF_VERSION
+ // lesstif 0.87 hangs here, but 0.93 does not
+#if !defined(LESSTIF_VERSION) \
+ || (defined(LesstifVersion) && LesstifVersion >= 93)
XtVaSetValues (w,
XmNfontList, (XmFontList) m_font.GetFontList(1.0, XtDisplay(w)),
NULL);