// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "window.h"
#endif
BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
- EVT_IDLE(wxWindow::OnIdle)
END_EVENT_TABLE()
// ============================================================================
void wxWindow::Init()
{
- // generic initializations first
- InitBase();
-
// Motif-specific
m_needsRefresh = TRUE;
m_mainWidget = (WXWidget) 0;
m_winCaptured = FALSE;
m_isShown = TRUE;
- m_isBeingDeleted = FALSE;
m_hScrollBar =
m_vScrollBar =
DetachWidget(wMain);
}
- 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 )
// (2) The widget with the focus may not be in the widget table
// depending on which widgets I put in the table
wxWindow *winFocus = (wxWindow *)NULL;
- for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
+ for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
{
wxBrush brush(GetBackgroundColour(), wxSOLID);
dc.SetBrush(brush); // FIXME: needed?
- wxWindowList::Node *cnode = m_children.GetFirst();
+ wxWindowList::compatibility_iterator cnode = m_children.GetFirst();
while (cnode)
{
wxWindow *child = cnode->GetData();
// Now send expose events
- wxList::Node* node = updateRects.GetFirst();
+ wxList::compatibility_iterator node = updateRects.GetFirst();
while (node)
{
wxRect* rect = (wxRect*) node->GetData();
w -= 2 * (thick + margin);
}
+ if( w < 1 ) w = 1;
XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
}
h -= 2 * (thick + margin);
}
+ if( h < 1 ) h = 1;
XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
}
XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent);
}
-void wxWindow::Clear()
-{
- wxClientDC dc(this);
- wxBrush brush(GetBackgroundColour(), wxSOLID);
- dc.SetBackground(brush);
- dc.Clear();
-}
-
void wxWindow::DoPaint()
{
//TODO : make a temporary gc so we can do the XCopyArea below
// Responds to colour changes: passes event on to children.
void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
{
- wxWindowList::Node *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
// Only propagate to non-top-level windows
}
}
-void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
+void wxWindow::OnInternalIdle()
{
// This calls the UI-update mechanism (querying windows for
// menu/toolbar/control state information)
- if (wxUpdateUIEvent::CanUpdate())
- UpdateWindowUI();
+ if (wxUpdateUIEvent::CanUpdate(this))
+ UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}
// ----------------------------------------------------------------------------
// Motif-specific accessors
// ----------------------------------------------------------------------------
+WXWindow wxWindow::GetClientXWindow() const
+{
+ Widget wMain = (Widget)GetClientWidget();
+ if ( wMain )
+ return (WXWindow) XtWindow(wMain);
+ else
+ return (WXWindow) 0;
+}
+
// Get the underlying X window
WXWindow wxWindow::GetXWindow() const
{
XmDrawingAreaCallbackStruct * cbs)
{
wxWindow *canvas = wxGetWindowFromTable(drawingArea);
- XEvent local_event;
+ XEvent* xevent = cbs->event;
if (canvas==NULL)
return;
if (cbs->reason != XmCR_INPUT)
return;
- local_event = *(cbs->event); // We must keep a copy!
-
- switch (local_event.xany.type)
+ switch (xevent->xany.type)
{
case EnterNotify:
case LeaveNotify:
case ButtonPress:
case ButtonRelease:
case MotionNotify:
- {
- wxMouseEvent wxevent;
- if(wxTranslateMouseEvent(wxevent, canvas, drawingArea, &local_event))
{
- canvas->GetEventHandler()->ProcessEvent(wxevent);
+ wxMouseEvent wxevent(0);
+ if (wxTranslateMouseEvent(wxevent, canvas, drawingArea, xevent))
+ {
+ canvas->GetEventHandler()->ProcessEvent(wxevent);
+ }
+ break;
}
- break;
- }
case KeyPress:
{
wxKeyEvent event (wxEVT_CHAR);
- if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event))
+ if (wxTranslateKeyEvent (event, canvas, (Widget) 0, xevent))
{
// Implement wxFrame::OnCharHook by checking ancestor.
wxWindow *parent = canvas;
case KeyRelease:
{
wxKeyEvent event (wxEVT_KEY_UP);
- if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event))
+ if (wxTranslateKeyEvent (event, canvas, (Widget) 0, xevent))
{
canvas->GetEventHandler()->ProcessEvent (event);
}
}
case FocusIn:
{
- if (local_event.xfocus.detail != NotifyPointer)
+ if (xevent->xfocus.detail != NotifyPointer)
{
wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
event.SetEventObject(canvas);
}
case FocusOut:
{
- if (local_event.xfocus.detail != NotifyPointer)
+ if (xevent->xfocus.detail != NotifyPointer)
{
wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
event.SetEventObject(canvas);
// ----------------------------------------------------------------------------
bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
- Widget widget, XEvent *xevent)
+ Widget widget, const XEvent *xevent)
{
switch (xevent->xany.type)
{
case ButtonRelease:
case MotionNotify:
{
+ int eventx = xevent->xbutton.x, eventy = xevent->xbutton.y;
+
wxEventType eventType = wxEVT_NULL;
if (xevent->xany.type == LeaveNotify)
else if (xevent->xany.type == MotionNotify)
{
eventType = wxEVT_MOTION;
+
+ if (xevent->xmotion.is_hint == NotifyHint)
+ {
+ Window root, child;
+ int x_root, y_root;
+ unsigned int state;
+ Display *dpy = XtDisplay (widget);
+
+ XQueryPointer (dpy, XtWindow (widget),
+ &root, &child,
+ &x_root, &y_root, &eventx, &eventy, &state);
+ }
}
else if (xevent->xany.type == ButtonPress)
{
dy = y1;
}
- wxevent.m_x = xevent->xbutton.x + dx;
- wxevent.m_y = xevent->xbutton.y + dy;
+ wxevent.m_x = eventx + dx;
+ wxevent.m_y = eventy + dy;
wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
|| (event_left_is_down (xevent)
}
bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
- Widget WXUNUSED(widget), XEvent *xevent)
+ Widget WXUNUSED(widget), const XEvent *xevent)
{
switch (xevent->xany.type)
{