- Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
- xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
- XmNorientation, XmVERTICAL,
- NULL);
- // XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
-
- XtVaSetValues (vScrollBar,
- XmNincrement, 1,
- XmNvalue, 0,
+ // Destroy children before destroying self
+ DestroyChildren();
+
+ if (m_backingPixmap)
+ XFreePixmap (XtDisplay ((Widget) GetMainWidget()), (Pixmap) m_backingPixmap);
+
+ Widget w = (Widget) m_drawingArea;
+ wxDeleteWindowFromTable(w);
+
+ if (w)
+ {
+ XtDestroyWidget(w);
+ m_drawingArea = (WXWidget) 0;
+ }
+
+ // Only if we're _really_ a canvas (not a dialog box/panel)
+ if (m_scrolledWindow)
+ {
+ wxDeleteWindowFromTable((Widget) m_scrolledWindow);
+ }
+
+ if (m_hScrollBar)
+ {
+ wxDeleteWindowFromTable((Widget) m_hScrollBar);
+ XtUnmanageChild((Widget) m_hScrollBar);
+ }
+ if (m_vScrollBar)
+ {
+ wxDeleteWindowFromTable((Widget) m_vScrollBar);
+ XtUnmanageChild((Widget) m_vScrollBar);
+ }
+
+ if (m_hScrollBar)
+ XtDestroyWidget((Widget) m_hScrollBar);
+ if (m_vScrollBar)
+ XtDestroyWidget((Widget) m_vScrollBar);
+
+ UnmanageAndDestroy(m_scrolledWindow);
+
+ if (m_borderWidget)
+ {
+ XtDestroyWidget ((Widget) m_borderWidget);
+ m_borderWidget = (WXWidget) 0;
+ }
+ }
+ else // Why wasn't this here before? JACS 8/3/2000
+ DestroyChildren();
+
+
+ // Destroy the window
+ if (GetMainWidget())
+ {
+ // If this line (XtDestroyWidget) causes a crash, you may comment it out.
+ // Child widgets will get destroyed automatically when a frame
+ // or dialog is destroyed, but before that you may get some memory
+ // leaks and potential layout problems if you delete and then add
+ // child windows.
+
+ // GRG, Feb/2000: commented this out when adding support for
+ // wxSCROLL[WIN]_THUMBRELEASE events. Also it was reported
+ // that this call crashed wxMotif under OS/2, so it seems
+ // that leaving it out is the right thing to do.
+ // SN, Feb/2000: newgrid/griddemo shows why it is needed :-(
+ XtDestroyWidget((Widget) GetMainWidget());
+ SetMainWidget((WXWidget) NULL);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// scrollbar management
+// ----------------------------------------------------------------------------
+
+// Helper function
+void wxWindow::CreateScrollbar(wxOrientation orientation)
+{
+ wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" );
+
+ XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
+ // Add scrollbars if required
+ if (orientation == wxHORIZONTAL)
+ {
+ Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
+ xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
+ XmNorientation, XmHORIZONTAL,
+ NULL);
+ XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+
+ XtVaSetValues (hScrollBar,
+ XmNincrement, 1,
+ XmNvalue, 0,
+ NULL);
+
+ m_hScrollBar = (WXWidget) hScrollBar;
+
+ wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ DoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE);
+
+ XtRealizeWidget(hScrollBar);
+
+ XtVaSetValues((Widget) m_scrolledWindow,
+ XmNhorizontalScrollBar, (Widget) m_hScrollBar,
+ NULL);
+
+ m_hScroll = TRUE;
+
+ wxAddWindowToTable( hScrollBar, this );
+ }
+
+ if (orientation == wxVERTICAL)
+ {
+ Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
+ xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
+ XmNorientation, XmVERTICAL,
+ NULL);
+ XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+
+ XtVaSetValues (vScrollBar,
+ XmNincrement, 1,
+ XmNvalue, 0,