Author: matt
Date: 2010-11-27 12:49:27 -0800 (Sat, 27 Nov 2010)
New Revision: 7896
Log:
Tab is now alway 8 characters wide.
Modified:
branches/branch-1.3/FL/Fl_Text_Display.H
branches/branch-1.3/src/Fl_Text_Display.cxx
branches/branch-1.3/test/editor.cxx
Modified: branches/branch-1.3/FL/Fl_Text_Display.H
===================================================================
--- branches/branch-1.3/FL/Fl_Text_Display.H 2010-11-27 20:13:10 UTC (rev
7895)
+++ branches/branch-1.3/FL/Fl_Text_Display.H 2010-11-27 20:49:27 UTC (rev
7896)
@@ -287,7 +287,7 @@
\param x number of pixels form the left margin
\return an approximate column number based on the main font
*/
- double x_to_col(double y);
+ double x_to_col(double y) const;
/**
Convert a column number into an x pixel position.
@@ -295,7 +295,7 @@
\return number of pixels form the left margin to the left of an average
sized character
*/
- double col_to_x(double col);
+ double col_to_x(double col) const;
protected:
// Most (all?) of this stuff should only be called from resize() or
@@ -445,7 +445,10 @@
int mModifyingTabDistance; /* Whether tab distance is being
modified */
- double mColumnScale; /* Width in pixels of an average character */
+ mutable double mColumnScale; /* Width in pixels of an average character. This
+ value is calculated as needed (lazy eval); it
+ needs to be mutable so that it can be
calculated
+ within a method marked as "const" */
Fl_Color mCursor_color;
Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2010-11-27 20:13:10 UTC (rev
7895)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2010-11-27 20:49:27 UTC (rev
7896)
@@ -1750,8 +1750,9 @@
int w = 0;
if (prevChar=='\t') {
// draw a single Tab space
+ int tab = col_to_x(8);
int xAbs = (mode==GET_WIDTH) ? startX :
startX+mHorizOffset-text_area.x;
- w = (((xAbs/100)+1)*100) - xAbs;
+ w = (((xAbs/tab)+1)*tab) - xAbs;
if (mode==DRAW_LINE)
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 );
if (mode==FIND_INDEX && startX+w>rightClip) {
@@ -1782,8 +1783,9 @@
int w = 0;
if (currChar=='\t') {
// draw a single Tab space
+ int tab = col_to_x(8);
int xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x;
- w = (((xAbs/100)+1)*100) - xAbs;
+ w = (((xAbs/tab)+1)*tab) - xAbs;
if (mode==DRAW_LINE)
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 );
if (mode==FIND_INDEX) {
@@ -3759,7 +3761,7 @@
/*
Convert an x pixel position into a column number.
*/
-double Fl_Text_Display::x_to_col(double y)
+double Fl_Text_Display::x_to_col(double y) const
{
if (!mColumnScale) {
mColumnScale = string_width("Mitg", 4, 'A') / 4.0;
@@ -3769,9 +3771,9 @@
/**
- Convert a column number into an y pixel position.
+ Convert a column number into an x pixel position.
*/
-double Fl_Text_Display::col_to_x(double col)
+double Fl_Text_Display::col_to_x(double col) const
{
if (!mColumnScale) {
// recalculate column scale value
Modified: branches/branch-1.3/test/editor.cxx
===================================================================
--- branches/branch-1.3/test/editor.cxx 2010-11-27 20:13:10 UTC (rev 7895)
+++ branches/branch-1.3/test/editor.cxx 2010-11-27 20:49:27 UTC (rev 7896)
@@ -775,7 +775,7 @@
w->editor = new Fl_Text_Editor(0, 30, 660, 370);
w->editor->textfont(FL_COURIER);
w->editor->textsize(TS);
- //w->editor->wrap_mode(Fl_Text_Editor::WRAP_AT_BOUNDS, 100);
+ w->editor->wrap_mode(Fl_Text_Editor::WRAP_AT_BOUNDS, 250);
w->editor->buffer(textbuf);
w->editor->textfont(FL_HELVETICA);
textbuf->text(
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit