OSDN Git Service

PATCH: [ 1512708 ] Fix compile with VS2005
authorKimmo Varis <kimmov@gmail.com>
Tue, 27 Jun 2006 17:42:39 +0000 (17:42 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 27 Jun 2006 17:42:39 +0000 (17:42 +0000)
 - also additional cleanup for CCrystalTextView::GetMarginWidth()

Src/Changes.txt
Src/editlib/ccrystaltextview.cpp
Src/editlib/ccrystaltextview.h

index 30758c4..ec73098 100644 (file)
@@ -2,6 +2,11 @@ Src\Changes.txt
 Add new items to top.
 (This summarizes all changes to all files under Src, including Src\Languages.)
 
+2006-06-27 Kimmo
+ PATCH: [ 1512708 ] Fix compile with VS2005
+  Also additional cleanup for CCrystalTextView::GetMarginWidth()
+  Src/editlib: ccrystaltextview.cpp ccrystaltextview.h
+
 2006-06-26 Kimmo
  PATCH: [ 1510596 ] Updated Readme-Swedish.txt
   Submitted by Hans Eriksson
index 5cc6900..6c9eb70 100644 (file)
@@ -5086,24 +5086,34 @@ GetViewLineNumbers () const
   return m_bViewLineNumbers;
 }
 
-int CCrystalTextView::
+/**
+ * @brief Calculate margin area width.
+ * This function calculates needed margin width. Needed width is (approx.)
+ * one char-width for bookmark etc markers and rest to linenumbers (if
+ * visible). If we have linenumbers visible we need to adjust width so that
+ * biggest number fits.
+ * @return Margin area width in pixels.
+ */
+UINT CCrystalTextView::
 GetMarginWidth ()
 {
   int nMarginWidth = 0;
 
   if (m_bSelMargin)
     {
-      nMarginWidth += 12;
+      nMarginWidth += 16;  // Width for markers and some space
       if (m_bViewLineNumbers)
         {
-          int nLines = GetLineCount();
-          for (int n = 0; nLines; n++)
-            nLines /= 10;
-        nMarginWidth += GetCharWidth() * n + 4;
-      }
+          const int nLines = GetLineCount();
+          int nNumbers = 0;
+          int n = 1;
+          for (n = 1; n <= nLines; n *= 10)
+            ++nNumbers;
+          nMarginWidth += GetCharWidth() * nNumbers;
+        }
     }
   else
-    nMarginWidth ++;
+    ++nMarginWidth; // Do we really want one pixel wide margin?
 
   return nMarginWidth;
 }
index 7012c56..6285dca 100644 (file)
@@ -212,7 +212,7 @@ protected :
     CPoint m_ptDraggedTextBegin, m_ptDraggedTextEnd;
     void UpdateCaret ();
     void SetAnchor (const CPoint & ptNewAnchor);
-    int GetMarginWidth ();
+    UINT GetMarginWidth ();
     bool IsValidTextPos (const CPoint &point);
     bool IsValidTextPosX (const CPoint &point);
     bool IsValidTextPosY (const CPoint &point);