Author: pbartok
Date: 2005-06-22 14:03:03 -0400 (Wed, 22 Jun 2005)
New Revision: 46375

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
Log:
2005-06-22  Peter Bartok  <[EMAIL PROTECTED]> 

        * TextControl.cs: Added sanity check
        * TextBoxBase.cs: 
          - Fixed wrapping behaviour, don't set wrap on single line controls
            (this fixes the breakage of colordialog introduced in an earlier
             checkin)
          - Added rudimentary support for autoscrolling right-aligned controls
            (still needs fixing, also, center alignment scroll is missing)



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-06-22 17:05:52 UTC (rev 46374)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-06-22 18:03:03 UTC (rev 46375)
@@ -1,3 +1,13 @@
+2005-06-22  Peter Bartok  <[EMAIL PROTECTED]> 
+
+       * TextControl.cs: Added sanity check
+       * TextBoxBase.cs: 
+         - Fixed wrapping behaviour, don't set wrap on single line controls
+           (this fixes the breakage of colordialog introduced in an earlier
+            checkin)
+         - Added rudimentary support for autoscrolling right-aligned controls
+           (still needs fixing, also, center alignment scroll is missing)
+
 2005-06-22  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
        
        * ScrollBar.cs: Fixes thumbpos on Maximum values

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2005-06-22 17:05:52 UTC (rev 46374)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2005-06-22 18:03:03 UTC (rev 46375)
@@ -84,12 +84,12 @@
                        modified = false;
                        multiline = false;
                        read_only = false;
-                       word_wrap = true;
+                       word_wrap = false;
                        richtext = false;
                        document = new Document(this);
                        document.WidthChanged += new 
EventHandler(document_WidthChanged);
                        //document.CaretMoved += new EventHandler(CaretMoved);
-                       document.Wrap = true;
+                       document.Wrap = false;
                        requested_height = -1;
 
                        MouseDown += new 
MouseEventHandler(TextBoxBase_MouseDown);
@@ -328,7 +328,6 @@
                        set {
                                if (value != multiline) {
                                        multiline = value;
-
                                        // Make sure we update our size; the 
user may have already set the size before going to multiline
                                        if (multiline && requested_height != 
-1) {
                                                Height = requested_height;
@@ -339,6 +338,12 @@
                                }
 
                                document.multiline = multiline;
+
+                               if (multiline) {
+                                       document.wrap = word_wrap;
+                               } else {
+                                       document.wrap = false;
+                               }
                        }
                }
 
@@ -521,8 +526,10 @@
 
                        set {
                                if (value != word_wrap) {
-                                       word_wrap = value;
-                                       document.Wrap = value;
+                                       if (multiline) {
+                                               word_wrap = value;
+                                               document.Wrap = value;
+                                       }
                                }
                        }
                }
@@ -898,6 +905,7 @@
                                                
document.DeleteChar(document.CaretTag, document.CaretPosition, true);
                                                OnTextChanged(EventArgs.Empty);
                                        }
+                                       document.UpdateCaret();
                                        CaretMoved(this, null);
                                        return true;
                                }
@@ -917,8 +925,8 @@
                                }
                        }
 
-                       document.ViewPortWidth = this.Width;
-                       document.ViewPortHeight = this.Height;
+                       document.ViewPortWidth = width;
+                       document.ViewPortHeight = height;
 
                        CalculateDocument();
 
@@ -1167,12 +1175,14 @@
                }
 
                protected void CalculateScrollBars() {
+                       // FIXME - need separate calculations for center and 
right alignment
                        // No scrollbars for a single line
                        if (document.Width >= this.Width) {
                                hscroll.Enabled = true;
                                hscroll.Minimum = 0;
                                hscroll.Maximum = document.Width - this.Width;
                        } else {
+                               hscroll.Maximum = document.ViewPortWidth;
                                hscroll.Enabled = false;
                        }
 
@@ -1181,6 +1191,7 @@
                                vscroll.Minimum = 0;
                                vscroll.Maximum = document.Height - this.Height;
                        } else {
+                               vscroll.Maximum = document.ViewPortHeight;
                                vscroll.Enabled = false;
                        }
 
@@ -1263,24 +1274,39 @@
                        //Console.WriteLine("Caret now at {0} (Thumb: {1}x{2}, 
Canvas: {3}x{4}, Document {5}x{6})", pos, hscroll.Value, vscroll.Value, 
canvas_width, canvas_height, document.Width, document.Height);
 
                        // Handle horizontal scrolling
-                       if (pos.X < (document.ViewPortX + track_width)) {
-                               do {
-                                       if ((hscroll.Value - track_width) >= 
hscroll.Minimum) {
-                                               hscroll.Value -= track_width;
+                       if (document.CaretLine.alignment == 
HorizontalAlignment.Left) {
+                               if (pos.X < (document.ViewPortX + track_width)) 
{
+                                       do {
+                                               if ((hscroll.Value - 
track_width) >= hscroll.Minimum) {
+                                                       hscroll.Value -= 
track_width;
+                                               } else {
+                                                       hscroll.Value = 
hscroll.Minimum;
+                                               }
+                                       } while (hscroll.Value > pos.X);
+                               }
+
+                               if ((pos.X > (this.canvas_width + 
document.ViewPortX - track_width)) && (hscroll.Value != hscroll.Maximum)) {
+                                       do {
+                                               if ((hscroll.Value + 
track_width) <= hscroll.Maximum) {
+                                                       hscroll.Value += 
track_width;
+                                               } else {
+                                                       hscroll.Value = 
hscroll.Maximum;
+                                               }
+                                       } while (pos.X > (hscroll.Value + 
this.canvas_width));
+                               }
+                       } else if (document.CaretLine.alignment == 
HorizontalAlignment.Right) {
+                               if (pos.X < document.ViewPortX) {
+                                       if (pos.X > hscroll.Minimum) {
+                                               hscroll.Value = pos.X;
                                        } else {
                                                hscroll.Value = hscroll.Minimum;
                                        }
-                               } while (hscroll.Value > pos.X);
-                       }
+                               }
 
-                       if ((pos.X > (this.canvas_width + document.ViewPortX - 
track_width)) && (hscroll.Value != hscroll.Maximum)) {
-                               do {
-                                       if ((hscroll.Value + track_width) <= 
hscroll.Maximum) {
-                                               hscroll.Value += track_width;
-                                       } else {
-                                               hscroll.Value = hscroll.Maximum;
-                                       }
-                               } while (pos.X > (hscroll.Value + 
this.canvas_width));
+                               if ((pos.X > (this.canvas_width + 
document.ViewPortX)) && (hscroll.Value != hscroll.Maximum)) {
+                                       hscroll.Value = hscroll.Maximum;
+                               }
+                       } else {
                        }
 
                        if (!multiline) {

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs   
2005-06-22 17:05:52 UTC (rev 46374)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs   
2005-06-22 18:03:03 UTC (rev 46375)
@@ -31,7 +31,6 @@
 // Stuff missing (in no particular order):
 // - Align text after RecalculateLine
 // - Implement tag types to support wrapping (ie have a 'newline' tag), for 
images, etc.
-// - Wrap and recalculate lines
 // - Implement CaretPgUp/PgDown
 // - Finish selection calculations (invalidate only changed, more ways to 
select)
 // - Implement C&P
@@ -568,7 +567,7 @@
                        selection_end.line = this.document;
                        selection_end.pos = 0;
 
-                       viewport_x = -2;
+                       viewport_x = 0;
                        viewport_y = -2;
 
                        // Default selection is empty
@@ -2514,7 +2513,7 @@
                        while (line_no <= lines) {
                                line = GetLine(line_no);
 
-                               if (line.alignment != HorizontalAlignment.Left) 
{
+                               if (line != null && line.alignment != 
HorizontalAlignment.Left) {
                                        if (line.alignment == 
HorizontalAlignment.Center) {
                                                line.align_shift = 
(viewport_width - (int)line.widths[line.text.Length]) / 2;
                                        } else {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to