DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2815
Version: 1.3-feature
Hi, I've implemented the backdrop for Fl_Text_Display. It appeared to be
easy change. The diff is applied to request.
Link: http://www.fltk.org/str.php?L2815
Version: 1.3-feature
diff --git a/deps/fltk-1.3.0/FL/Fl_Widget.H b/deps/fltk-1.3.0/FL/Fl_Widget.H
--- a/deps/fltk-1.3.0/FL/Fl_Widget.H
+++ b/deps/fltk-1.3.0/FL/Fl_Widget.H
@@ -188,6 +188,7 @@
void draw_box(Fl_Boxtype t, Fl_Color c) const;
void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
void draw_backdrop() const;
+ void draw_backdrop( int x, int y, int w, int h ) const;
/** draws a focus rectangle around the widget */
void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
diff --git a/deps/fltk-1.3.0/src/Fl_Text_Display.cxx
b/deps/fltk-1.3.0/src/Fl_Text_Display.cxx
--- a/deps/fltk-1.3.0/src/Fl_Text_Display.cxx
+++ b/deps/fltk-1.3.0/src/Fl_Text_Display.cxx
@@ -1963,6 +1963,8 @@
if (!(style & TEXT_ONLY_MASK)) {
fl_color( background );
fl_rectf( X, Y, toX - X, mMaxsize );
+ if( ! (style & PRIMARY_MASK) )
+ draw_backdrop( X, Y, toX - X, mMaxsize );
}
if (!(style & BG_ONLY_MASK)) {
fl_color( foreground );
@@ -2028,6 +2030,8 @@
fl_color( color() );
}
fl_rectf( X, Y, width, height );
+ if( ! (style & PRIMARY_MASK) )
+ draw_backdrop( X, Y, width, height );
}
@@ -3354,7 +3358,7 @@
*/
void Fl_Text_Display::draw(void) {
// don't even try if there is no associated text buffer!
- if (!buffer()) { draw_box(); return; }
+ if (!buffer()) { draw_backdrop(); draw_box(); return; }
fl_push_clip(x(),y(),w(),h()); // prevent drawing outside widget area
diff --git a/deps/fltk-1.3.0/src/fl_boxtype.cxx
b/deps/fltk-1.3.0/src/fl_boxtype.cxx
--- a/deps/fltk-1.3.0/src/fl_boxtype.cxx
+++ b/deps/fltk-1.3.0/src/fl_boxtype.cxx
@@ -413,6 +413,25 @@
((Fl_Image*)img)->draw(x_+(w_-img->w())/2, y_+(h_-img->h())/2);
}
}
+/** draw a segment of the backdrop image */
+void Fl_Widget::draw_backdrop( int X, int Y, int W, int H ) const
+{
+ if (align() & FL_ALIGN_IMAGE_BACKDROP) {
+ const Fl_Image *img = image();
+ // if there is no image, we will not draw the deimage either
+ if (img && deimage() && !active_r())
+ img = deimage();
+ if (img)
+ {
+ int base_x = x_+(w_-img->w())/2;
+ int base_y = y_+(h_-img->h())/2;
+ int cx = X - base_x;
+ int cy = Y - base_y;
+ ((Fl_Image*)img)->draw( X, Y, W, H, cx, cy );
+ }
+ }
+}
+
/** Draws a box of type t, of color c at the widget's position and size. */
void Fl_Widget::draw_box(Fl_Boxtype t, Fl_Color c) const {
draw_box(t, x_, y_, w_, h_, c);
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev