-// Responds to colour changes: passes event on to children.
-void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
-{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- // Only propagate to non-top-level windows
- wxWindow *win = (wxWindow *)node->Data();
- if ( win->GetParent() )
- {
- wxSysColourChangedEvent event2;
- event.m_eventObject = win;
- win->GetEventHandler()->ProcessEvent(event2);
- }
-
- node = node->Next();
- }
-}
-
-// This can be called by the app (or wxWindows) to do default processing for the current
-// event. Save message/event info in wxWindow so they can be used in this function.
-long wxWindow::Default()
-{
- // TODO
- return 0;
-}
-
-void wxWindow::InitDialog()
-{
- wxInitDialogEvent event(GetId());
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
-}
-
-// Default init dialog behaviour is to transfer data to window
-void wxWindow::OnInitDialog(wxInitDialogEvent& event)
-{
- TransferDataToWindow();
-}
-
-// Caret manipulation
-void wxWindow::CreateCaret(int w, int h)
-{
- m_caretWidth = w;
- m_caretHeight = h;
- m_caretEnabled = TRUE;
-}
-
-void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
-{
- // TODO
-}
-
-void wxWindow::ShowCaret(bool show)
-{
- // TODO
-}
-
-void wxWindow::DestroyCaret()
-{
- // TODO
- m_caretEnabled = FALSE;
-}
-
-void wxWindow::SetCaretPos(int x, int y)
-{
- // TODO
-}
-
-void wxWindow::GetCaretPos(int *x, int *y) const
-{
- // TODO
-}
-
-wxWindow *wxGetActiveWindow()
-{
- // TODO
- return NULL;
-}
-
-void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH)
-{
- m_minSizeX = minW;
- m_minSizeY = minH;
- m_maxSizeX = maxW;
- m_maxSizeY = maxH;
-
- if (!this->IsKindOf(CLASSINFO(wxFrame)))
- return;
-
- wxFrame *frame = (wxFrame *)this;
- Widget widget = (Widget) frame->GetShellWidget();
-
- if (minW > -1)
- XtVaSetValues(widget, XmNminWidth, minW, NULL);
- if (minH > -1)
- XtVaSetValues(widget, XmNminHeight, minH, NULL);
- if (maxW > -1)
- XtVaSetValues(widget, XmNmaxWidth, maxW, NULL);
- if (maxH > -1)
- XtVaSetValues(widget, XmNmaxHeight, maxH, NULL);
- if (incW > -1)
- XtVaSetValues(widget, XmNwidthInc, incW, NULL);
- if (incH > -1)
- XtVaSetValues(widget, XmNheightInc, incH, NULL);
-}
-
-void wxWindow::Centre(int direction)
-{
- int x, y, width, height, panel_width, panel_height, new_x, new_y;
-
- wxWindow *father = (wxWindow *)GetParent();
- if (!father)
- return;
-
- father->GetClientSize(&panel_width, &panel_height);
- GetSize(&width, &height);
- GetPosition(&x, &y);
-
- new_x = -1;
- new_y = -1;
-
- if (direction & wxHORIZONTAL)
- new_x = (int)((panel_width - width)/2);
-
- if (direction & wxVERTICAL)
- new_y = (int)((panel_height - height)/2);
-
- SetSize(new_x, new_y, -1, -1);
-
-}
-
-// Coordinates relative to the window
-void wxWindow::WarpPointer (int x, int y)
-{
- XWarpPointer (XtDisplay((Widget) GetClientWidget()), None, XtWindow((Widget) GetClientWidget()), 0, 0, 0, 0, x, y);
-}
-
-void wxWindow::OnEraseBackground(wxEraseEvent& event)
-{
- // TODO
- Default();
-}
-
-int wxWindow::GetScrollPos(int orient) const
-{
- if (orient == wxHORIZONTAL)
- return m_scrollPosX;
- else
- return m_scrollPosY;
- /*
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
- int pos;
- XtVaGetValues(scrollBar,
- XmNvalue, &pos, NULL);
- return pos;
- }
- else
- return 0;
- */
-}
-
-// This now returns the whole range, not just the number
-// of positions that we can scroll.
-int wxWindow::GetScrollRange(int orient) const
-{
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
- int range;
- XtVaGetValues(scrollBar,
- XmNmaximum, &range, NULL);
- return range;
- }
- else
- return 0;
-}
-
-int wxWindow::GetScrollThumb(int orient) const
-{
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
- int thumb;
- XtVaGetValues(scrollBar,
- XmNsliderSize, &thumb, NULL);
- return thumb;
- }
- else
- return 0;
-}
-
-void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
-{
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
- XtVaSetValues (scrollBar,
- XmNvalue, pos,
- NULL);
- }
- if (orient == wxHORIZONTAL)
- m_scrollPosX = pos;
- else
- m_scrollPosY = pos;
-
-}
-
-// New function that will replace some of the above.
-void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
- int range, bool WXUNUSED(refresh))
-{
- int oldW, oldH;
- GetSize(& oldW, & oldH);
-
- if (range == 0)
- range = 1;
- if (thumbVisible == 0)
- thumbVisible = 1;
-
- if (thumbVisible > range)
- thumbVisible = range;
-
- // Save the old state to see if it changed
- WXWidget oldScrollBar = ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
-
- if (orient == wxHORIZONTAL)
- {
- if (thumbVisible == range)
- {
- if (m_hScrollBar)
- DestroyScrollbar(wxHORIZONTAL);
- }
- else
- {
- if (!m_hScrollBar)
- CreateScrollbar(wxHORIZONTAL);
- }
- }
- if (orient == wxVERTICAL)
- {
- if (thumbVisible == range)
- {
- if (m_vScrollBar)
- DestroyScrollbar(wxVERTICAL);
- }
- else
- {
- if (!m_vScrollBar)
- CreateScrollbar(wxVERTICAL);
- }
- }
- WXWidget newScrollBar = ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
-
- if (oldScrollBar != newScrollBar)
- {
- // This is important! Without it, scrollbars misbehave
- // badly.
- XtUnrealizeWidget((Widget) m_scrolledWindow);
- XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
- XtRealizeWidget((Widget) m_scrolledWindow);
- XtManageChild((Widget) m_scrolledWindow);
- }
-
- if (newScrollBar)
- XtVaSetValues((Widget) newScrollBar,
- XmNvalue, pos,
- XmNminimum, 0,
- XmNmaximum, range,
- XmNsliderSize, thumbVisible,
- NULL);
-
- if (orient == wxHORIZONTAL)
- m_scrollPosX = pos;
- else
- m_scrollPosY = pos;
-
- int newW, newH;
- GetSize(& newW, & newH);
-
- // Adjusting scrollbars can resize the canvas accidentally
- if (newW != oldW || newH != oldH)
- SetSize(-1, -1, oldW, oldH);
-}
-
-// 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 ;