Author: fabien
Date: 2009-07-03 17:57:46 -0700 (Fri, 03 Jul 2009)
New Revision: 6823
Log:
UTF8: Fl_Text_Display and related:
  + Constrained many Fl_Text_Display (get and measurement) methods to const.


Modified:
   branches/branch-1.3/CHANGES
   branches/branch-1.3/FL/Fl_Text_Display.H
   branches/branch-1.3/src/Fl_Text_Display.cxx

Modified: branches/branch-1.3/CHANGES
===================================================================
--- branches/branch-1.3/CHANGES 2009-07-04 00:24:26 UTC (rev 6822)
+++ branches/branch-1.3/CHANGES 2009-07-04 00:57:46 UTC (rev 6823)
@@ -1,6 +1,6 @@
 CHANGES IN FLTK 1.3.0
 
-       - Corrected const methods of Fl_Text_Buffer, Fl_Text_Selection
+       - Corrected const methods of Fl_Text_{Buffer|Display|Selection}
          to be declared const, corrected an Fl_Text_Buffer attrib. typo
        - Fixed OpenGL shared context handling (STR #2135)
        - Fixed gray-scale images with alpha channel (STR #2105)

Modified: branches/branch-1.3/FL/Fl_Text_Display.H
===================================================================
--- branches/branch-1.3/FL/Fl_Text_Display.H    2009-07-04 00:24:26 UTC (rev 
6822)
+++ branches/branch-1.3/FL/Fl_Text_Display.H    2009-07-04 00:57:46 UTC (rev 
6823)
@@ -98,23 +98,23 @@
       Gets the current text buffer associated with the text widget.
       Multiple text widgets can be associated with the same text buffer.
     */
-    Fl_Text_Buffer* buffer() { return mBuffer; }
+    Fl_Text_Buffer* buffer() const { return mBuffer; }
     void redisplay_range(int start, int end);
     void scroll(int topLineNum, int horizOffset);
     void insert(const char* text);
     void overstrike(const char* text);
     void insert_position(int newPos);
     /** Gets the position of the text insertion cursor for text display */
-    int insert_position() { return mCursorPos; }
-    int in_selection(int x, int y);
+    int insert_position() const { return mCursorPos; }
+    int in_selection(int x, int y) const;
     void show_insert_position();
     int move_right();
     int move_left();
     int move_up();
     int move_down();
-    int count_lines(int start, int end, bool start_pos_is_line_start);
-    int line_start(int pos);
-    int line_end(int pos, bool start_pos_is_line_start);
+    int count_lines(int start, int end, bool start_pos_is_line_start) const;
+    int line_start(int pos) const;
+    int line_end(int pos, bool start_pos_is_line_start) const;
     int skip_lines(int startPos, int nLines, bool startPosIsLineStart);
     int rewind_lines(int startPos, int nLines);
     void next_word(void);
@@ -128,17 +128,17 @@
     /**    Sets or gets the text cursor color.  */
     void cursor_color(Fl_Color n) {mCursor_color = n;}
     /**    Sets or gets the width/height of the scrollbars.  */
-    int scrollbar_width() { return scrollbar_width_; }
+    int scrollbar_width() const { return scrollbar_width_; }
     /**    Sets or gets the width/height of the scrollbars.  */
     void scrollbar_width(int W) { scrollbar_width_ = W; }
     /**    Gets the scrollbar alignment type */
-    Fl_Align scrollbar_align() { return scrollbar_align_; }
+    Fl_Align scrollbar_align() const { return scrollbar_align_; }
     /**    Sets the scrollbar alignment type */
     void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; }
     /**    Moves the insert position to the beginning of the current word.  */
-    int word_start(int pos) { return buffer()->word_start(pos); }
+    int word_start(int pos) const { return buffer()->word_start(pos); }
     /**    Moves the insert position to the end of the current word.  */
-    int word_end(int pos) { return buffer()->word_end(pos); }
+    int word_end(int pos) const { return buffer()->word_end(pos); }
 
     
     void highlight_data(Fl_Text_Buffer *styleBuffer,
@@ -148,7 +148,7 @@
                         void *cbArg);
 
     int position_style(int lineStartPos, int lineLen, int lineIndex,
-                       int dispIndex);
+                       int dispIndex) const;
     /** \todo FIXME : get set methods pointing on shortcut_ 
      have no effects as shortcut_ is unused in this class and derived! */
     int shortcut() const {return shortcut_;}
@@ -169,8 +169,8 @@
     /**    Sets the default color of text in the widget.  */
     void textcolor(unsigned n) {textcolor_ = n;}
 
-    int wrapped_column(int row, int column);
-    int wrapped_row(int row);
+    int wrapped_column(int row, int column) const;
+    int wrapped_row(int row) const;
     void wrap_mode(int wrap, int wrap_margin);
 
     virtual void resize(int X, int Y, int W, int H);
@@ -206,8 +206,8 @@
 
     void calc_last_char();
 
-    int position_to_line( int pos, int* lineNum );
-    int string_width(const char* string, int length, int style);
+    int position_to_line( int pos, int* lineNum ) const;
+    int string_width(const char* string, int length, int style) const;
 
     static void scroll_timer_cb(void*);
 
@@ -220,22 +220,22 @@
     static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display* d);
     void update_v_scrollbar();
     void update_h_scrollbar();
-    int measure_vline(int visLineNum);
-    int longest_vline();
-    int empty_vlines();
-    int vline_length(int visLineNum);
-    int xy_to_position(int x, int y, int PosType = CHARACTER_POS);
+    int measure_vline(int visLineNum) const;
+    int longest_vline() const;
+    int empty_vlines() const;
+    int vline_length(int visLineNum) const;
+    int xy_to_position(int x, int y, int PosType = CHARACTER_POS) const;
 
     void xy_to_rowcol(int x, int y, int* row, int* column,
-                      int PosType = CHARACTER_POS);
+                      int PosType = CHARACTER_POS) const;
 
-    int position_to_xy(int pos, int* x, int* y);
+    int position_to_xy(int pos, int* x, int* y) const;
     void maintain_absolute_top_line_number(int state);
-    int get_absolute_top_line_number();
+    int get_absolute_top_line_number() const;
     void absolute_top_line_number(int oldFirstChar);
-    int maintaining_absolute_top_line_number();
+    int maintaining_absolute_top_line_number() const;
     void reset_absolute_top_line_number();
-    int position_to_linecol(int pos, int* lineNum, int* column);
+    int position_to_linecol(int pos, int* lineNum, int* column) const;
     void scroll_(int topLineNum, int horizOffset);
 
     void extend_range_for_styles(int* start, int* end);
@@ -248,11 +248,11 @@
                                int maxLines, bool startPosIsLineStart,
                                int styleBufOffset, int *retPos, int *retLines,
                                int *retLineStart, int *retLineEnd,
-                               bool countLastLineMissingNewLine = true);
+                               bool countLastLineMissingNewLine = true) const;
     void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
                          int *nextLineStart);
-    int measure_proportional_character(char c, int colNum, int pos);
-    int wrap_uses_character(int lineEndPos);
+    int measure_proportional_character(char c, int colNum, int pos) const;
+    int wrap_uses_character(int lineEndPos) const;
     int range_touches_selection(const Fl_Text_Selection *sel, int rangeStart,
                                  int rangeEnd) const;
 #ifndef FL_DOXYGEN

Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2009-07-04 00:24:26 UTC (rev 
6822)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2009-07-04 00:57:46 UTC (rev 
6823)
@@ -350,7 +350,7 @@
 }
 #endif
 
-int Fl_Text_Display::longest_vline() {
+int Fl_Text_Display::longest_vline() const {
   int longest = 0;
   for (int i = 0; i < mNVisibleLines; i++)
     longest = max(longest, measure_vline(i));
@@ -798,7 +798,7 @@
    X coordinate where the position would be if it were visible.
 */
 
-int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) {
+int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const {
   int charIndex, lineStartPos, fontHeight, lineLen;
   int visLineNum, charLen, outIndex, xStep, charStyle;
   char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
@@ -876,7 +876,7 @@
    If continuous wrap mode is on, returns the absolute line number (as opposed
    to the wrapped line number which is used for scrolling).
 */
-int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) 
{
+int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) 
const {
   int retVal;
     
     /* In continuous wrap mode, the absolute (non-wrapped) line count is
@@ -904,7 +904,7 @@
 /**
    Return 1 if position (X, Y) is inside of the primary Fl_Text_Selection
 */
-int Fl_Text_Display::in_selection( int X, int Y ) {
+int Fl_Text_Display::in_selection( int X, int Y ) const {
   int row, column, pos = xy_to_position( X, Y, CHARACTER_POS );
   Fl_Text_Buffer *buf = mBuffer;
   int ok = 0;
@@ -933,7 +933,7 @@
    from the last newline.  Obviously this is time consuming, because it
    invloves character re-counting.
 */
-int Fl_Text_Display::wrapped_column(int row, int column) {
+int Fl_Text_Display::wrapped_column(int row, int column) const {
     int lineStart, dispLineStart;
     
     if (!mContinuousWrap || row < 0 || row > mNVisibleLines)
@@ -953,7 +953,7 @@
    newlines, rather than display wrapping, and anywhere a rectangular selection
    needs a row, it needs it in terms of un-wrapped lines.
 */
-int Fl_Text_Display::wrapped_row(int row) {
+int Fl_Text_Display::wrapped_row(int row) const{
     if (!mContinuousWrap || row < 0 || row > mNVisibleLines)
        return row;
     return buffer()->count_lines(mFirstChar, mLineStarts[row]);
@@ -1131,7 +1131,7 @@
    by avoiding the additional step of scanning back to the last newline.
 */
 int Fl_Text_Display::count_lines(int startPos, int endPos,
-       bool startPosIsLineStart) {
+       bool startPosIsLineStart) const {
     int retLines, retPos, retLineStart, retLineEnd;
 
 #ifdef DEBUG
@@ -1196,7 +1196,7 @@
    the start of the next line.  This is also consistent with the model used by
    visLineLength.
 */
-int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) {
+int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) const {
     int retLines, retPos, retLineStart, retLineEnd;
     
     /* If we're not wrapping use more efficien BufEndOfLine */
@@ -1215,7 +1215,7 @@
    Same as BufStartOfLine, but returns the character after last wrap point
    rather than the last newline.
 */
-int Fl_Text_Display::line_start(int pos) {
+int Fl_Text_Display::line_start(int pos) const {
     int retLines, retPos, retLineStart, retLineEnd;
     
     /* If we're not wrapping, use the more efficient BufStartOfLine */
@@ -1448,7 +1448,7 @@
    Returns the absolute (non-wrapped) line number of the first line displayed.
    Returns 0 if the absolute top line number is not being maintained.
 */
-int Fl_Text_Display::get_absolute_top_line_number() {
+int Fl_Text_Display::get_absolute_top_line_number() const {
     if (!mContinuousWrap)
        return mTopLineNum;
     if (maintaining_absolute_top_line_number())
@@ -1472,7 +1472,7 @@
    Return true if a separate absolute top line number is being maintained
    (for displaying line numbers or showing in the statistics line).
 */
-int Fl_Text_Display::maintaining_absolute_top_line_number() {
+int Fl_Text_Display::maintaining_absolute_top_line_number() const {
     return mContinuousWrap &&
            (mLineNumWidth != 0 || mNeedAbsTopLineNum);
 }
@@ -1491,7 +1491,7 @@
    Find the line number of position "pos" relative to the first line of
    displayed text. Returns 0 if the line is not displayed.
 */
-int Fl_Text_Display::position_to_line( int pos, int *lineNum ) {
+int Fl_Text_Display::position_to_line( int pos, int *lineNum ) const {
   int i;
 
   *lineNum = 0;
@@ -1957,7 +1957,7 @@
    be more appropriate.
 */
 int Fl_Text_Display::position_style( int lineStartPos,
-                                     int lineLen, int lineIndex, int dispIndex 
) {
+                                     int lineLen, int lineIndex, int dispIndex 
) const {
   Fl_Text_Buffer * buf = mBuffer;
   Fl_Text_Buffer *styleBuf = mStyleBuffer;
   int pos, style = 0;
@@ -1989,7 +1989,7 @@
 /**
    Find the width of a string in the font of a particular style
 */
-int Fl_Text_Display::string_width( const char *string, int length, int style ) 
{
+int Fl_Text_Display::string_width( const char *string, int length, int style ) 
const {
   Fl_Font font;
   int fsize;
 
@@ -2016,7 +2016,7 @@
    position, and CHARACTER_POS means return the position of the character
    closest to (X, Y).
 */
-int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) {
+int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
   int charIndex, lineStart, lineLen, fontHeight;
   int charWidth, charLen, charStyle, visLineNum, xStep, outIndex;
   char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
@@ -2082,7 +2082,7 @@
    means translate the position to the nearest character cell.
 */
 void Fl_Text_Display::xy_to_rowcol( int X, int Y, int *row,
-                                    int *column, int posType ) {
+                                    int *column, int posType ) const {
   int fontHeight = mMaxsize;
   int fontWidth = TMPFONTWIDTH;   //mFontStruct->max_bounds.width;
 
@@ -2479,7 +2479,7 @@
 /**
    Return the width in pixels of the displayed line pointed to by "visLineNum"
 */
-int Fl_Text_Display::measure_vline( int visLineNum ) {
+int Fl_Text_Display::measure_vline( int visLineNum ) const {
   int i, width = 0, len, style, lineLen = vline_length( visLineNum );
   int charCount = 0, lineStartPos = mLineStarts[ visLineNum ];
   char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
@@ -2519,7 +2519,7 @@
 /**
    Return true if there are lines visible with no corresponding buffer text
 */
-int Fl_Text_Display::empty_vlines() {
+int Fl_Text_Display::empty_vlines() const {
   return mNVisibleLines > 0 &&
          mLineStarts[ mNVisibleLines - 1 ] == -1;
 }
@@ -2528,7 +2528,7 @@
    Return the length of a line (number of displayable characters) by examining
    entries in the line starts array rather than by scanning for newlines
 */
-int Fl_Text_Display::vline_length( int visLineNum ) {
+int Fl_Text_Display::vline_length( int visLineNum ) const {
   int nextLineStart, lineStartPos;
 
   if (visLineNum < 0 || visLineNum >= mNVisibleLines)
@@ -2794,7 +2794,7 @@
 void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
        int maxPos, int maxLines, bool startPosIsLineStart, int styleBufOffset,
        int *retPos, int *retLines, int *retLineStart, int *retLineEnd,
-       bool countLastLineMissingNewLine) {
+       bool countLastLineMissingNewLine) const {
     int lineStart, newLineStart = 0, b, p, colNum, wrapMargin;
     int maxWidth, i, foundBreak, width;
         bool countPixels;
@@ -2932,7 +2932,7 @@
    insertion/deletion, though static display and wrapping and resizing
    should now be solid because they are now used for online help display.
 */
-int Fl_Text_Display::measure_proportional_character(char c, int colNum, int 
pos) {
+int Fl_Text_Display::measure_proportional_character(char c, int colNum, int 
pos) const {
     int charLen, style;
     char expChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
     Fl_Text_Buffer *styleBuf = mStyleBuffer;
@@ -2996,7 +2996,7 @@
    used as a wrap point, and just guesses that it wasn't.  So if an exact
    accounting is necessary, don't use this function.
 */ 
-int Fl_Text_Display::wrap_uses_character(int lineEndPos) {
+int Fl_Text_Display::wrap_uses_character(int lineEndPos) const {
     char c;
     
     if (!mContinuousWrap || lineEndPos == buffer()->length())

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to