]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
clipboard update and latest module definition file of .dll build
[wxWidgets.git] / src / generic / listctrl.cpp
index 5e7ce897adeb7f15ee9e0929f6c8b48534ce777e..9f32c43da4a62f9874dc4951df0b30b68383a783 100644 (file)
@@ -3920,10 +3920,26 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
     else
         iconSpacing = 0;
 
+    // Note that we do not call GetClientSize() here but
+    // GetSize() and substract the border size for sunken
+    // borders manually. This is technically incorrect,
+    // but we need to know the client area's size WITHOUT
+    // scrollbars here. Since we don't know if there are
+    // any scrollbars, we use GetSize() instead. Another
+    // solution would be to call SetScrollbars() here to
+    // remove the scrollbars and call GetClientSize() then,
+    // but this might result in flicker and - worse - will
+    // reset the scrollbars to 0 which is not good at all
+    // if you resize a dialog/window, but don't want to
+    // reset the window scrolling. RR.
+    // Furthermore, we actually do NOT subtract the border
+    // width as 2 pixels is just the extra space which we
+    // need around the actual content in the window. Other-
+    // wise the text would e.g. touch the upper border. RR.
     int clientWidth,
         clientHeight;
-    GetClientSize( &clientWidth, &clientHeight );
-
+    GetSize( &clientWidth, &clientHeight );
+    
     if ( HasFlag(wxLC_REPORT) )
     {
         // all lines have the same height
@@ -3952,13 +3968,26 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
         // fit into the window, we recalculate after subtracting an
         // approximated 15 pt for the horizontal scrollbar
 
-        clientHeight -= 4;  // sunken frame
-
         int entireWidth = 0;
 
         for (int tries = 0; tries < 2; tries++)
         {
-            entireWidth = 0;
+            // We start with 4 for the border around all items
+            entireWidth = 4;
+                
+            if (tries == 1)
+            {
+                // Now we have decided that the items do not fit into the
+                // client area. Unfortunately, wxWindows sometimes thinks
+                // that it does fit and therefore NO horizontal scrollbar
+                // is inserted. This looks ugly, so we fudge here and make
+                // the calculated width bigger than was actually has been
+                // calculated. This ensures that wxScrolledWindows puts
+                // a scrollbar at the bottom of its client area.
+                entireWidth += SCROLL_UNIT_X;
+            }
+            
+            // Start at 2,2 so the text does not touch the border
             int x = 2;
             int y = 2;
             int maxWidth = 0;
@@ -3971,7 +4000,7 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
                 currentlyVisibleLines++;
                 wxListLineData *line = GetLine(i);
                 line->CalculateSize( &dc, iconSpacing );
-                line->SetPosition( x, y, clientWidth, iconSpacing );
+                line->SetPosition( x, y, clientWidth, iconSpacing );  // Why clientWidth? (FIXME)
 
                 wxSize sizeLine = GetLineSize(i);
 
@@ -3982,8 +4011,8 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
                 if (currentlyVisibleLines > m_linesPerPage)
                     m_linesPerPage = currentlyVisibleLines;
 
-                // assume that the size of the next one is the same... (FIXME)
-                if ( y + sizeLine.y - 6 >= clientHeight )
+                // Assume that the size of the next one is the same... (FIXME)
+                if ( y + sizeLine.y >= clientHeight )
                 {
                     currentlyVisibleLines = 0;
                     y = 2;
@@ -3991,17 +4020,21 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
                     entireWidth += maxWidth+6;
                     maxWidth = 0;
                 }
+                
+                // We have reached the last item.
                 if ( i == count - 1 )
                     entireWidth += maxWidth;
-                if ((tries == 0) && (entireWidth > clientWidth))
+                    
+                if ( (tries == 0) && (entireWidth+SCROLL_UNIT_X > clientWidth) )
                 {
-                    clientHeight -= 15; // scrollbar height
+                    clientHeight -= 15; // We guess the scrollbar height. (FIXME)
                     m_linesPerPage = 0;
                     currentlyVisibleLines = 0;
                     break;
                 }
+                
                 if ( i == count - 1 )
-                    tries = 1;  // everything fits, no second try required
+                    tries = 1;  // Everything fits, no second try required.
             }
         }