-// Does a physical scroll
-void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
-{
- // cerr << "Scrolling. delta = " << dx << ", " << dy << endl;
- int x, y, w, h;
- if (rect)
- {
- // Use specified rectangle
- x = rect->x; y = rect->y; w = rect->width; h = rect->height;
- }
- else
- {
- // Use whole client area
- x = 0; y = 0;
- GetClientSize(& w, & h);
- }
-
- int x1 = (dx >= 0) ? x : x - dx ;
- int y1 = (dy >= 0) ? y : y - dy;
- int w1 = w - abs(dx);
- int h1 = h - abs(dy);
- int x2 = (dx >= 0) ? x + dx : x;
- int y2 = (dy >= 0) ? y + dy : y;
-
- wxClientDC dc(this);
-
- dc.SetLogicalFunction (wxCOPY);
-
- Widget widget = (Widget) GetMainWidget();
- Window window = XtWindow(widget);
- Display* display = XtDisplay(widget);
-
- XCopyArea(display, window,
- window, (GC) dc.GetGC(),
- x1, y1,
- w1, h1,
- x2, y2);
-
- dc.SetAutoSetting(TRUE);
- wxBrush brush(GetBackgroundColour(), wxSOLID);
- dc.SetBrush(brush); // ??
-
- // We'll add rectangles to the list of update rectangles
- // according to which bits we've exposed.
- wxList updateRects;
-
- if (dx > 0)
- {
- wxRect *rect = new wxRect;
- rect->x = x;
- rect->y = y;
- rect->width = dx;
- rect->height = h;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- else if (dx < 0)
- {
- wxRect *rect = new wxRect;
-
- rect->x = x + w + dx;
- rect->y = y;
- rect->width = -dx;
- rect->height = h;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width,
- rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- if (dy > 0)
- {
- wxRect *rect = new wxRect;
-
- rect->x = x;
- rect->y = y;
- rect->width = w;
- rect->height = dy;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- else if (dy < 0)
- {
- wxRect *rect = new wxRect;
-
- rect->x = x;
- rect->y = y + h + dy;
- rect->width = w;
- rect->height = -dy;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- dc.SetBrush(wxNullBrush);
-
- // Now send expose events
-
- wxNode* node = updateRects.First();
- while (node)
- {
- wxRect* rect = (wxRect*) node->Data();
- XExposeEvent event;
-
- event.type = Expose;
- event.display = display;
- event.send_event = True;
- event.window = window;
-
- event.x = rect->x;
- event.y = rect->y;
- event.width = rect->width;
- event.height = rect->height;
-
- event.count = 0;
-
- XSendEvent(display, window, False, ExposureMask, (XEvent *)&event);
-
- node = node->Next();
-
- }
-
- // Delete the update rects
- node = updateRects.First();
- while (node)
- {
- wxRect* rect = (wxRect*) node->Data();
- delete rect;
- node = node->Next();
- }
-
- XmUpdateDisplay((Widget) GetMainWidget());
-}
-
-void wxWindow::OnChar(wxKeyEvent& event)
-{
- event.Skip();
-/* ??
-if ( event.KeyCode() == WXK_TAB ) {
-// propagate the TABs to the parent - it's up to it to decide what
-// to do with it
-if ( GetParent() ) {
-if ( GetParent()->ProcessEvent(event) )
-return;
-}
-}
- */
-}
-
-void wxWindow::OnKeyDown(wxKeyEvent& event)
-{
- event.Skip();
-}
-
-void wxWindow::OnKeyUp(wxKeyEvent& event)
-{
- event.Skip();
-}
-
-void wxWindow::OnPaint(wxPaintEvent& event)
-{
- Default();
-}
-
-bool wxWindow::IsEnabled() const
-{
- // TODO. Is this right?
- // return XtGetSensitive((Widget) GetMainWidget());
- return FALSE;
-}
-
-// Dialog support: override these and call
-// base class members to add functionality
-// that can't be done using validators.
-// NOTE: these functions assume that controls
-// are direct children of this window, not grandchildren
-// or other levels of descendant.
-
-// Transfer values to controls. If returns FALSE,
-// it's an application error (pops up a dialog)
-bool wxWindow::TransferDataToWindow()
-{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() &&
- !child->GetValidator()->TransferToWindow() )
- {
- wxLogError("Could not transfer data to window.");
- return FALSE;
- }
-
- node = node->Next();
- }
- return TRUE;
-}
-
-// Transfer values from controls. If returns FALSE,
-// validation failed: don't quit
-bool wxWindow::TransferDataFromWindow()
-{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() && !child->GetValidator()->TransferFromWindow() )
- {
- return FALSE;
- }
-
- node = node->Next();
- }
- return TRUE;
-}
-
-bool wxWindow::Validate()
-{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) )
- {
- return FALSE;
- }
-
- node = node->Next();
- }
- return TRUE;
-}
-
-// Get the window with the focus
-wxWindow *wxWindow::FindFocus()
-{
- // TODO
- return NULL;
-}
-
-void wxWindow::AddChild(wxWindow *child)
-{
- GetChildren().Append(child);
- child->m_windowParent = this;
-}
-
-void wxWindow::RemoveChild(wxWindow *child)
-{
- GetChildren().DeleteObject(child);
- child->m_windowParent = NULL;
-}
-
-// Reparents this window to have the new parent.
-bool wxWindow::Reparent(wxWindow* WXUNUSED(parent))
-{
- // For now, we indicate that this isn't implemented.
- return FALSE;
-}
-
-void wxWindow::DestroyChildren()
-{
- wxNode *node = GetChildren().First();
- while (node)
- {
- wxNode* next = node->Next();
- wxWindow* child = (wxWindow*) node->Data();
- delete child;
- node = next;
- }
- GetChildren().Clear();
-#if 0
- wxNode *node;
- while ((node = GetChildren().First()) != (wxNode *)NULL) {
- wxWindow *child;
- if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) {
- delete child;
- if ( GetChildren().Member(child) )
- delete node;
- }
- } /* while */
-#endif
-}
-
-void wxWindow::MakeModal(bool modal)
-{
- // Disable all other windows
- if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
- {
- wxNode *node = wxTopLevelWindows.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (win != this)
- win->Enable(!modal);
-
- node = node->Next();
- }
- }
-}
-
-// If nothing defined for this, try the parent.
-// E.g. we may be a button loaded from a resource, with no callback function
-// defined.
-void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
-{
- if (GetEventHandler()->ProcessEvent(event) )
- return;
- if (m_windowParent)
- m_windowParent->GetEventHandler()->OnCommand(win, event);
-}
-
-void wxWindow::SetConstraints(wxLayoutConstraints *c)