]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixes to wxMotif scrolling and colours (wxTreeCtrl/wxListCtrl now seem to work
authorJulian Smart <julian@anthemion.co.uk>
Mon, 28 Dec 1998 21:32:10 +0000 (21:32 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 28 Dec 1998 21:32:10 +0000 (21:32 +0000)
well, ta-ra!); fixes to thread.cpp since constants were changed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1275 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
distrib/msw/cw.rsp
distrib/msw/vc.rsp
distrib/msw/zipdist.bat
docs/motif/changes.txt
docs/motif/todo.txt
include/wx/motif/window.h
include/wx/string.h
src/common/socket.cpp
src/generic/scrolwin.cpp
src/make_cw.mcp
src/motif/dialog.cpp
src/motif/thread.cpp
src/motif/window.cpp
src/stubs/thread.cpp

index c04d82f724bfabf995c40600708f82a27b73213c..db34f13bbe98767d1479fa5eb27c1538cfdbe781 100644 (file)
@@ -42,7 +42,7 @@ samples/mfc/make_cw.mcp
 
 samples/minimal/make_cw.mcp
 
-samples/minimal/make_cw.mcp
+samples/minifram/make_cw.mcp
 
 samples/nativdlg/make_cw.mcp
 
index e06f706c04ed8643f157537e119c741c5d30fa10..630b084712a1c4ebfca9bb74f4fa26ee3b386da3 100644 (file)
@@ -64,8 +64,8 @@ samples/mfc/MfcVC.dsw
 samples/minimal/MinimalVC.dsp
 samples/minimal/MinimalVC.dsw
 
-samples/minimal/MiniframVC.dsp
-samples/minimal/MiniframVC.dsw
+samples/minifram/MiniframVC.dsp
+samples/minifram/MiniframVC.dsw
 
 samples/nativdlg/NativdlgVC.dsp
 samples/nativdlg/NativdlgVC.dsw
index d345f552a7cfd8bf00126ca1ab4518e11be21135..d8c4e4dedab36d35d9273269c3a055bab87ceb33 100755 (executable)
@@ -14,6 +14,7 @@ erase %dest\wx200*.zip
 
 cd %src
 echo Zipping...
+
 zip32 -@ %dest\wx200gen.zip < %src\distrib\msw\generic.rsp
 zip32 -@ %dest\wx200msw.zip < %src\distrib\msw\msw.rsp
 zip32 -@ %dest\wx200gtk.zip < %src\distrib\msw\gtk.rsp
@@ -28,6 +29,7 @@ zip32 -@ %dest\wx200wrd.zip < %src\distrib\msw\wx_word.rsp
 
 rem VC++ project files
 zip32 -@ %dest\wx200vc.zip < %src\distrib\msw\vc.rsp
+
 rem CodeWarrior project files
 zip32 -@ %dest\wx200cw.zip < %src\distrib\msw\cw.rsp
 
index 0ea25952168c757080952044f4b5feffc57794ab..3c9df41c3f785c1000f5891b9328267201bc6093 100644 (file)
@@ -89,4 +89,14 @@ More recently:
 - Fixed a bug in wxStaticBox.
 - Controls sample runs, though wxRadioBox doesn't appear and
   the notebook flickers for a while.
-- Cured wxTreeCtrl bug: now works pretty well!
\ No newline at end of file
+- Cured wxTreeCtrl bug: now works pretty well!
+
+28/12/98
+--------
+
+- Cured scrolling problem: scrollbars now show/hide themselves
+  without (permanently) resizing the window.
+- Removed some commented-out lines in wxScrolledWindow::AdjustScrollbars
+  that disabled scrollbar paging.
+- Set background colour of drawing area in wxWindow, so e.g. wxListCtrl
+  colours correctly.
\ No newline at end of file
index ee35bec83479c26cd0b26a4d0698cae6b523422b..63254e2da605c920b976e5e21ecb3860d6a5bff6 100644 (file)
@@ -1,7 +1,7 @@
 wxMotif TODO
 ------------
 
-Updated: 12/11/98
+Updated: 28/12/98
 
          -------------------------------o-------------------------
 
@@ -40,33 +40,10 @@ High Priority
 
 - wxSpinButton
 
-- Tidy dialogs such as the colour and font selectors.
-
-- Use generic wxTreeCtrl, wxListCtrl: debug and enhance these.
-  We're close to having these working: mostly scrolling to work out.
-
-- Find out why modal dialogs give a grab warning.
-
-- wxSystemSettings. Eventually, should have control panel-like utility
-  to change colours/fonts but meanwhile should maybe read them
-  from a file.
-
-- wxThread (hopefully, similar to wxGTK)
-
-- wxGrid: scrollbars don't hide; problem with cell selection.
-
-- MDI: seems to be broken for a more complex application I'm testing.
-  Frame decorations don't draw properly, and a child window doesn't
-  process events properly. So probably we should have an alternative
-  implementation that uses tabs, a la wxGTK. The system menu could
-  be implemented using a pop-up menu that applies to the currently
-  active window.
-
-- Controls in a wxToolBar don't work. Probably due to form layout
-  problems; the workaround is to use a separate panel for controls.
-
 - Miscellaneous events.
 
+- Thread classes (copy wxGTK's).
+
 - Write makefiles for all samples and utilities.
 
 - Create some samples for testing.
@@ -75,14 +52,11 @@ Low Priority
 ------------
 
 - Better makefile system that can put objects in different dirs.
-  Use wxGTK config system? It's really complex to debug and
-  doesn't offer a way of compiling apps outside the wxWin
-  hierarchy.
 
 - Extra wxBitmap formats: PNG, BMP. Could use old wxWin 1.68
   wxImage code (derived from XV) for BMP/GIF but it's very bloated. However,
   when implemented as extra bitmap handlers, the code won't be linked
-  unless needed.
+  unless needed. Update: see if wxImage can handle these formats.
 
 - Print/preview framework in print.cpp (see wxGTK).
 
@@ -107,10 +81,6 @@ Low Priority
   - add the driver code to src/motif/helphtml.cpp (a frame, toolbar,
     history list).
 
-- Optimize screen refresh for non-native widgets, e.g. wxWindow
-  created with Create(), using technique in flicker patch for 1.68
-  (see JACS for latest patch).
-
 - Copy and paste, drag and drop. Use a standard X drag
   and drop standard - see http://www.cco.caltech.edu/~jafl/xdnd/
   or use Motif drag and drop as described here:
@@ -130,19 +100,11 @@ Low Priority
 - Reimplement combobox using Lesstif's widget (avoiding GPL'ed
   widget currently used).
 
-- Write generic wxDirDialog (directory selector)
-
-- Use native Motif dialogs for wxMessageBox
-
 - Miscellaneous classes e.g. wxJoystick (identical to GTK's one for
   Linux)
 
 - Blit scaling
 
-- Could eventually alter the MDI widgets to be more Windows-like
-  -- currently it's half-hearted (menus are on children, whereas
-  they should replace the main parent frame menu).
-
 - Get ODBC classes and sample working.
 
 - Work out why wxTextCtrl doesn't work as a stream buffer under
index f4a6a05f4c587486756787cace3406688be4f837..daa7e42b934a9cd065c7211fefbd52f00ce34823 100644 (file)
@@ -275,6 +275,10 @@ public:
   virtual void SetScrollbar(int orient, int pos, int thumbVisible,
     int range, bool refresh = TRUE);
 
+  // Helper functions for Motif
+  void CreateScrollbar(int orientation);
+  void DestroyScrollbar(int orientation);
+
   virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
   virtual int GetScrollPos(int orient) const;
   virtual int GetScrollRange(int orient) const;
@@ -686,5 +690,19 @@ wxWindow* WXDLLEXPORT wxGetActiveWindow();
 
 WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows;
 
+// A little class to switch off size optimization while an instance of the object
+// exists
+class WXDLLEXPORT wxNoOptimize: public wxObject
+{
+public:
+  wxNoOptimize();
+  ~wxNoOptimize();
+
+  static bool CanOptimize();
+
+protected:
+  static int m_count;
+};
+
 #endif
     // _WX_WINDOW_H_
index ea62d6781b388448dd2bff39a3b0e5fd731f1d44..f9f731380fa5df3ed81d4c9b6f1500b7d6fa5f4b 100644 (file)
@@ -73,6 +73,8 @@
  */
 // ---------------------------------------------------------------------------
 
+WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
+
 /// checks whether the passed in pointer is NULL and if the string is empty
 inline bool WXDLLEXPORT IsEmpty(const char *p) { return !p || !*p; }
 
index 7faaef5d3154404650e6a16694d03fae5dd23a98..277e3e01baf46737bdea36049beadc1b0188dad9 100644 (file)
@@ -469,22 +469,13 @@ void wxSocketBase::Discard()
 bool wxSocketBase::GetPeer(wxSockAddress& addr_man) const
 {
   struct sockaddr my_addr;
-#ifdef __WXMSW__
   int len_addr = sizeof(my_addr);
-#else
-  size_t len_addr = sizeof(my_addr);
-#endif
 
   if (m_fd < 0)
     return FALSE;
 
   if (getpeername(m_fd, (struct sockaddr *)&my_addr,
-#ifdef __WXMSW__
-    &len_addr)
-#else
-    (socklen_t *)&len_addr)
-#endif
-     < 0)
+    &len_addr) < 0)
     return FALSE;
 
   addr_man.Disassemble(&my_addr, len_addr);
@@ -494,22 +485,13 @@ bool wxSocketBase::GetPeer(wxSockAddress& addr_man) const
 bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
 {
   struct sockaddr my_addr;
-#ifdef __WXMSW__
   int len_addr = sizeof(my_addr);
-#else
-  size_t len_addr = sizeof(my_addr);
-#endif
 
   if (m_fd < 0)
     return FALSE;
 
   if (getsockname(m_fd, (struct sockaddr *)&my_addr,
-#ifdef __WXMSW__
-    &len_addr)
-#else
-    (socklen_t *)&len_addr)
-#endif
-     < 0)
+    &len_addr) < 0)
 
     return FALSE;
 
index 4b99809f81ba11584b9e0ebe79025c357e936d8a..4bb0b3a77c716a0cf15dcd4f2af94f806466b552 100644 (file)
@@ -121,7 +121,6 @@ void wxScrolledWindow::OnScroll(wxScrollEvent& event)
     int nScrollInc = CalcScrollInc(event);
     if (nScrollInc == 0) return;
 
-    // TODO: should we store the scroll position here as well as in wxWindow?
     if (orient == wxHORIZONTAL)
     {
         int newPos = m_xScrollPosition + nScrollInc;
@@ -133,19 +132,6 @@ void wxScrolledWindow::OnScroll(wxScrollEvent& event)
         SetScrollPos(wxVERTICAL, newPos, TRUE );
     }
 
-/*
-  // TODO We need to multiply the ScrollWindow amount by the scaling
-  // factor, but how do we know what this is in wxWin 2.0???
-  float scaleX = 1.0;
-  float scaleY = 1.0;
-
-  if ( this->IsKindOf(CLASSINFO(wxCanvas)) )
-  {
-    wxDC* dc = ((wxCanvas *)this)->GetDC();
-    dc->GetUserScale(&scaleX, &scaleY);
-  }
-*/
-
     if (orient == wxHORIZONTAL)
     {
         m_xScrollPosition += nScrollInc;
@@ -234,6 +220,7 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event)
       break;
     }
   }
+
   if (orient == wxHORIZONTAL)
   {
     if (m_xScrollPixelsPerLine > 0) {
@@ -295,7 +282,8 @@ void wxScrolledWindow::AdjustScrollbars(void)
         m_xScrollPosition = wxMax( 0, m_xScrollPosition );
 
         SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
-//      SetScrollPageSize(wxHORIZONTAL, noPagePositions);
+        // The amount by which we scroll when paging
+        SetScrollPageSize(wxHORIZONTAL, noPagePositions);
     }
     else
     { 
@@ -316,7 +304,8 @@ void wxScrolledWindow::AdjustScrollbars(void)
         m_yScrollPosition = wxMax( 0, m_yScrollPosition );
 
         SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, m_yScrollLines);
-//      SetScrollPageSize(wxVERTICAL, noPagePositions);
+        // The amount by which we scroll when paging
+        SetScrollPageSize(wxVERTICAL, noPagePositions);
     }
     else
     {
index d4a10e5ef138f0984082d50137b9a3dd83e64c0e..66a5ba2c46d54d753d8112a2aa14407742b33e60 100644 (file)
Binary files a/src/make_cw.mcp and b/src/make_cw.mcp differ
index 6862e9a03ad7b48914044f2c319b678e55c31665..84e727db65ef517daa3256716278de72668678ae 100644 (file)
@@ -515,7 +515,8 @@ void wxDialog::EndModal(int retCode)
 
     SetReturnCode(retCode);
 
-    XtRemoveGrab((Widget) m_mainWidget);
+    // Strangely, we don't seem to need this now.
+    //    XtRemoveGrab((Widget) m_mainWidget);
 
     Show(FALSE);
 
index ca3833153ab740fc161123c04b307ae9bdc11906..e12b45e63ba08f60aa98e2a3885774a09091da7d 100644 (file)
@@ -57,14 +57,14 @@ wxMutexError wxMutex::Lock()
 {
     // TODO
     m_locked++;
-    return MUTEX_NO_ERROR;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::TryLock()
 {
     // TODO
     m_locked++;
-    return MUTEX_NO_ERROR;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::Unlock()
@@ -73,7 +73,7 @@ wxMutexError wxMutex::Unlock()
         m_locked--;
 
     // TODO
-    return MUTEX_NO_ERROR;
+    return wxMUTEX_NO_ERROR;
 }
 
 class wxConditionInternal {
@@ -134,25 +134,25 @@ public:
 wxThreadError wxThread::Create()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Destroy()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Pause()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Resume()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 void wxThread::Exit(void *status)
@@ -193,11 +193,13 @@ unsigned long wxThread::GetID() const
     return 0;
 }
 
+/*
 wxThread *wxThread::GetThreadFromID(unsigned long id)
 {
     // TODO
     return NULL;
 }
+*/
 
 bool wxThread::IsAlive() const
 {
index 545f469e13be402a8362daedcf3ebc74d37e5f9e..87495d12b73a19c29ca5bb3d6b13c4f38f71f3ba 100644 (file)
@@ -368,6 +368,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
 
   m_scrolledWindow = (WXWidget) XtVaCreateManagedWidget ("scrolledWindow",
                                            xmScrolledWindowWidgetClass, m_borderWidget ? (Widget) m_borderWidget : parentWidget,
+                                  XmNresizePolicy, XmRESIZE_NONE,
                                   XmNspacing, 0,
                                  XmNscrollingPolicy, XmAPPLICATION_DEFINED,
  //                                  XmNscrollBarDisplayPolicy, XmAS_NEEDED,
@@ -420,8 +421,40 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
   XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
     False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
 
+  // Scrolled widget needs to have its colour changed or we get
+  // a little blue square where the scrollbars abutt
+  wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+  DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE);
+  DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE);
+
+  XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) 0, (Widget) 0, (Widget) m_drawingArea);
+
+  /*
+  if (m_hScrollBar)
+       XtRealizeWidget ((Widget) m_hScrollBar);
+  if (m_vScrollBar)
+       XtRealizeWidget ((Widget) m_vScrollBar);
+       */
+
+  // Without this, the cursor may not be restored properly
+  // (e.g. in splitter sample).
+  SetCursor(*wxSTANDARD_CURSOR);
+  SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+  SetSize(pos.x, pos.y, size.x, size.y);
+
+  return TRUE;
+}
+
+// Helper function
+void wxWindow::CreateScrollbar(int orientation)
+{
+  if (!m_drawingArea)
+    return;
+
+  XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
   // Add scrollbars if required
-  if (m_windowStyle & wxHSCROLL)
+  if (orientation == wxHORIZONTAL)
   {
       Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
                                     xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
@@ -446,9 +479,16 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
       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;
   }
-  if (m_windowStyle & wxVSCROLL)
+
+  if (orientation == wxVERTICAL)
   {
       Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
                                     xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
@@ -472,29 +512,54 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
       wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
       DoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE);
 
+      XtRealizeWidget(vScrollBar);
+
+      XtVaSetValues((Widget) m_scrolledWindow,
+             XmNverticalScrollBar, (Widget) m_vScrollBar,
+             NULL);
+
       m_vScroll = TRUE;
   }
 
-  // Scrolled widget needs to have its colour changed or we get
-  // a little blue square where the scrollbars abutt
-  wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
-  DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE);
+  XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
+}
+void wxWindow::DestroyScrollbar(int orientation)
+{
+  if (!m_drawingArea)
+    return;
 
-  if (m_hScrollBar || m_vScrollBar)
-    XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
+  XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
+  // Add scrollbars if required
+  if (orientation == wxHORIZONTAL)
+  {
+      if (m_hScrollBar)
+      {
+        XtDestroyWidget((Widget) m_hScrollBar);
+      }
+      m_hScrollBar = (WXWidget) 0;
+      m_hScroll = FALSE;
 
-  if (m_hScrollBar)
-       XtRealizeWidget ((Widget) m_hScrollBar);
-  if (m_vScrollBar)
-       XtRealizeWidget ((Widget) m_vScrollBar);
+      XtVaSetValues((Widget) m_scrolledWindow,
+             XmNhorizontalScrollBar, (Widget) 0,
+             NULL);
 
-  // Without this, the cursor may not be restored properly
-  // (e.g. in splitter sample).
-  SetCursor(*wxSTANDARD_CURSOR);
-  SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-  SetSize(pos.x, pos.y, size.x, size.y);
+  }
 
-  return TRUE;
+  if (orientation == wxVERTICAL)
+  {
+      if (m_vScrollBar)
+      {
+        XtDestroyWidget((Widget) m_vScrollBar);
+      }
+      m_vScrollBar = (WXWidget) 0;
+      m_vScroll = TRUE;
+
+      XtVaSetValues((Widget) m_scrolledWindow,
+             XmNverticalScrollBar, (Widget) 0,
+             NULL);
+
+  }
+  XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
 }
 
 void wxWindow::SetFocus()
@@ -693,6 +758,11 @@ void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
   else if (width == oldW && height == oldH)
     useOldSize = TRUE;
 
+  if (!wxNoOptimize::CanOptimize())
+  {
+    useOldSize = FALSE; useOldPos = FALSE;
+  }
+
   if (useOldPos && useOldSize)
     return;
 
@@ -1166,9 +1236,8 @@ void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
 void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
     int range, bool WXUNUSED(refresh))
 {
-    Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
-    if (!scrollBar)
-        return;
+    int oldW, oldH;
+    GetSize(& oldW, & oldH);
 
     if (range == 0)
       range = 1;
@@ -1178,77 +1247,66 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
     if (thumbVisible > range)
       thumbVisible = range;
 
-    XtVaSetValues(scrollBar,
-         XmNvalue, pos,
-         XmNminimum, 0,
-         XmNmaximum, range,
-         XmNsliderSize, thumbVisible,
-         NULL);
+    // Save the old state to see if it changed
+    WXWidget oldScrollBar =  ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
 
     if (orient == wxHORIZONTAL)
-        m_scrollPosX = pos;
-    else
-        m_scrollPosY = pos;
-
-    // See notes below. If the scrollbars didn't leave a ghost presence,
-    // this would be OK.
-#if 0
-    if (range == thumbVisible)
     {
-        XtUnmanageChild(scrollBar);
-        if (orient == wxHORIZONTAL)
-          XtVaSetValues((Widget) m_scrolledWindow,
-             XmNhorizontalScrollBar, (Widget) 0,
-             NULL);
+        if (thumbVisible == range)
+        {
+            if (m_hScrollBar)
+              DestroyScrollbar(wxHORIZONTAL);
+       }
         else
-          XtVaSetValues((Widget) m_scrolledWindow,
-             XmNverticalScrollBar, (Widget) 0,
-             NULL);
+        {
+            if (!m_hScrollBar)
+              CreateScrollbar(wxHORIZONTAL);
+        }
     }
-    else
+    if (orient == wxVERTICAL)
     {
-        XtManageChild(scrollBar);
-        if (orient == wxHORIZONTAL)
-          XtVaSetValues((Widget) m_scrolledWindow,
-             XmNhorizontalScrollBar, (Widget) m_hScrollBar,
-             NULL);
+        if (thumbVisible == range)
+        {
+            if (m_vScrollBar)
+              DestroyScrollbar(wxVERTICAL);
+       }
         else
-          XtVaSetValues((Widget) m_scrolledWindow,
-             XmNverticalScrollBar, (Widget) m_vScrollBar,
-             NULL);
+        {
+            if (!m_vScrollBar)
+              CreateScrollbar(wxVERTICAL);
+        }
     }
-#else
-    // Either both scrollbars are on, or they are off,
-    // otherwise you get a gap where one scrollbar
-    // isn't shown. TODO: try to eliminate this problem.
-    if ((GetScrollThumb(wxHORIZONTAL) >= GetScrollRange(wxHORIZONTAL)) && 
-        (GetScrollThumb(wxVERTICAL) >= GetScrollRange(wxVERTICAL)))
+    WXWidget newScrollBar =  ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
+
+    if (oldScrollBar != newScrollBar)
     {
-        if (m_hScrollBar)
-            XtUnmanageChild((Widget) m_hScrollBar);
-        if (m_vScrollBar)
-            XtUnmanageChild((Widget) m_vScrollBar);
-        XtVaSetValues((Widget) m_scrolledWindow,
-           XmNhorizontalScrollBar, (Widget) 0,
-           XmNverticalScrollBar, (Widget) 0,
-           NULL);
-                     //        XmScrolledWindowSetAreas((Widget) m_scrolledWindow,
-                     //           (Widget) 0, (Widget) 0, (Widget) m_drawingArea);
+      // 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
-    {
-        if (m_hScrollBar)
-            XtManageChild((Widget) m_hScrollBar);
-        if (m_vScrollBar)
-            XtManageChild((Widget) m_vScrollBar);
-        XtVaSetValues((Widget) m_scrolledWindow,
-           XmNhorizontalScrollBar, (Widget) m_hScrollBar,
-           XmNverticalScrollBar, (Widget) m_vScrollBar,
-           NULL);
-       //        XmScrolledWindowSetAreas((Widget) m_scrolledWindow,
-       //           (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
-    }
-#endif
+        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
@@ -2644,6 +2702,11 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
   else if (w == oldW && h == oldH)
     useOldSize = TRUE;
 
+  if (!wxNoOptimize::CanOptimize())
+  {
+    useOldSize = FALSE; useOldPos = FALSE;
+  }
+
   if (useOldPos && useOldSize)
     return;
 
@@ -2704,7 +2767,7 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
 
       w -= (spacing + wsbar);
 
-      XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+      //      XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
     }
   if (h > -1)
     {
@@ -2735,7 +2798,8 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
 
       h -= (spacing + wsbar);
 
-      XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+      //      XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+
     }
   }
 
@@ -3202,12 +3266,16 @@ void wxWindow::ChangeBackgroundColour()
 {
     if (GetMainWidget())
         DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
+    if (m_scrolledWindow && (GetMainWidget() != m_scrolledWindow))
+        DoChangeBackgroundColour(m_scrolledWindow, m_backgroundColour);
 }
 
 void wxWindow::ChangeForegroundColour()
 {
     if (GetMainWidget())
         DoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
+    if (m_scrolledWindow && (GetMainWidget() != m_scrolledWindow))
+        DoChangeForegroundColour(m_scrolledWindow, m_foregroundColour);
 }
 
 // Change a widget's foreground and background colours.
@@ -3370,3 +3438,24 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event)
     return FALSE;
 }
 
+/*
+ * wxNoOptimize: switch off size optimization
+ */
+
+int wxNoOptimize::m_count = 0;
+
+wxNoOptimize::wxNoOptimize()
+{
+  m_count ++;
+}
+
+wxNoOptimize::~wxNoOptimize()
+{
+  m_count --;
+}
+
+bool wxNoOptimize::CanOptimize()
+{
+  return (m_count == 0);
+}
+
index ca3833153ab740fc161123c04b307ae9bdc11906..e12b45e63ba08f60aa98e2a3885774a09091da7d 100644 (file)
@@ -57,14 +57,14 @@ wxMutexError wxMutex::Lock()
 {
     // TODO
     m_locked++;
-    return MUTEX_NO_ERROR;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::TryLock()
 {
     // TODO
     m_locked++;
-    return MUTEX_NO_ERROR;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::Unlock()
@@ -73,7 +73,7 @@ wxMutexError wxMutex::Unlock()
         m_locked--;
 
     // TODO
-    return MUTEX_NO_ERROR;
+    return wxMUTEX_NO_ERROR;
 }
 
 class wxConditionInternal {
@@ -134,25 +134,25 @@ public:
 wxThreadError wxThread::Create()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Destroy()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Pause()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Resume()
 {
     // TODO
-    return THREAD_NO_ERROR;
+    return wxTHREAD_NO_ERROR;
 }
 
 void wxThread::Exit(void *status)
@@ -193,11 +193,13 @@ unsigned long wxThread::GetID() const
     return 0;
 }
 
+/*
 wxThread *wxThread::GetThreadFromID(unsigned long id)
 {
     // TODO
     return NULL;
 }
+*/
 
 bool wxThread::IsAlive() const
 {