Skip to content

Commit

Permalink
Solves STR#3395.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12529 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
erco77 committed Oct 26, 2017
1 parent 6774852 commit a27da5e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions FL/Fl_Text_Display.H
Expand Up @@ -293,7 +293,7 @@ public:
Sets the default font used when drawing text in the widget.
\param s default text font face
*/
void textfont(Fl_Font s) {textfont_ = s; mColumnScale = 0;}
void textfont(Fl_Font s) {textfont_ = s; mColumnScale = 0; recalc_display(); }

/**
Gets the default size of text in the widget.
Expand All @@ -305,7 +305,7 @@ public:
Sets the default size of text in the widget.
\param s new text size
*/
void textsize(Fl_Fontsize s) {textsize_ = s; mColumnScale = 0;}
void textsize(Fl_Fontsize s) {textsize_ = s; mColumnScale = 0; recalc_display(); }

/**
Gets the default color of text in the widget.
Expand All @@ -323,6 +323,7 @@ public:
int wrapped_row(int row) const;
void wrap_mode(int wrap, int wrap_margin);

virtual void recalc_display();
virtual void resize(int X, int Y, int W, int H);

/**
Expand Down
28 changes: 16 additions & 12 deletions src/Fl_Text_Display.cxx
Expand Up @@ -212,7 +212,7 @@ Fl_Text_Display::~Fl_Text_Display() {
void Fl_Text_Display::linenumber_width(int width) {
if (width < 0) return;
mLineNumWidth = width;
resize(x(), y(), w(), h()); // triggers code to recalculate line#s
recalc_display(); // recalc line#s // resize(x(), y(), w(), h());
}

/**
Expand Down Expand Up @@ -365,7 +365,7 @@ void Fl_Text_Display::buffer( Fl_Text_Buffer *buf ) {
}

/* Resize the widget to update the screen... */
resize(x(), y(), w(), h());
recalc_display(); // resize(x(), y(), w(), h());
}


Expand Down Expand Up @@ -431,8 +431,6 @@ int Fl_Text_Display::longest_vline() const {
return longest;
}



/**
\brief Change the size of the displayed text area.
Expand All @@ -456,6 +454,13 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
#endif // DEBUG2

Fl_Widget::resize(X,Y,W,H);
recalc_display();
}

/**
Recalculate the display's visible lines and scrollbar sizes.
*/
void Fl_Text_Display::recalc_display() {
if (!buffer()) return;

// did we have scrollbars initially?
Expand All @@ -464,10 +469,10 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {

int oldTAWidth = text_area.w;

X += Fl::box_dx(box());
Y += Fl::box_dy(box());
W -= Fl::box_dw(box());
H -= Fl::box_dh(box());
int X = x() + Fl::box_dx(box());
int Y = y() + Fl::box_dy(box());
int W = w() - Fl::box_dw(box());
int H = h() - Fl::box_dh(box());

text_area.x = X + LEFT_MARGIN + mLineNumWidth;
text_area.y = Y + TOP_MARGIN;
Expand Down Expand Up @@ -680,7 +685,6 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
}



/**
\brief Refresh a rectangle of the text display.
\param left, top are in coordinates of the text drawing window.
Expand Down Expand Up @@ -941,7 +945,7 @@ void Fl_Text_Display::wrap_mode(int wrap, int wrapMargin) {
mAbsTopLineNum = 1; // changed from 0 to 1 -- LZA / STR#2621
}

resize(x(), y(), w(), h());
recalc_display(); // resize(x(), y(), w(), h());
}


Expand Down Expand Up @@ -1250,7 +1254,7 @@ void Fl_Text_Display::display_insert() {
*/
void Fl_Text_Display::show_insert_position() {
display_insert_position_hint = 1;
resize(x(), y(), w(), h());
recalc_display(); // resize(x(), y(), w(), h());
}


Expand Down Expand Up @@ -2817,7 +2821,7 @@ void Fl_Text_Display::calc_last_char() {
void Fl_Text_Display::scroll(int topLineNum, int horizOffset) {
mTopLineNumHint = topLineNum;
mHorizOffsetHint = horizOffset;
resize(x(), y(), w(), h());
recalc_display(); // resize(x(), y(), w(), h());
}


Expand Down

0 comments on commit a27da5e

Please sign in to comment.