From e2e00a0095b57c592d06a5270db10f5fc28067dc Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 2 May 2012 17:05:04 -0700 Subject: [PATCH] Add new boxtypes FL_ASYM_BOX and FL_ASYM_FLAT_BOX. --- FL/Enumerations.H | 6 ++++++ src/fl_boxtype.cxx | 19 ++++++++++++++----- src/fl_rounded_box.cxx | 40 +++++++++++++++++++++++++++++++++------- test/boxtype.cxx | 4 ++-- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/FL/Enumerations.H b/FL/Enumerations.H index 8089097..b86a44b 100644 --- a/FL/Enumerations.H +++ b/FL/Enumerations.H @@ -494,6 +494,8 @@ enum Fl_Boxtype { // boxtypes (if you change these you must fix fl_boxtype.C): _FL_OVAL_FRAME, ///< see figure 1 _FL_OFLAT_BOX, ///< see figure 1 FL_FOCUS_FRAME, + _FL_ASYM_BOX, + _FL_ASYM_FLAT_BOX, FL_FREE_BOXTYPE ///< the first free box type for creation of new box types }; extern FL_EXPORT Fl_Boxtype fl_define_FL_ROUND_UP_BOX(); @@ -518,6 +520,10 @@ extern FL_EXPORT Fl_Boxtype fl_define_FL_OVAL_BOX(); #define FL_OVAL_FRAME (Fl_Boxtype)(fl_define_FL_OVAL_BOX()+2) #define FL_OFLAT_BOX (Fl_Boxtype)(fl_define_FL_OVAL_BOX()+3) +extern FL_EXPORT Fl_Boxtype fl_define_FL_ASYM_BOX(); +#define FL_ASYM_BOX fl_define_FL_ASYM_BOX() +#define FL_ASYM_FLAT_BOX (Fl_Boxtype)(fl_define_FL_ASYM_BOX()+1) + #define FL_PLASTIC_UP_BOX FL_UP_BOX #define FL_PLASTIC_DOWN_BOX FL_DOWN_BOX #define FL_PLASTIC_UP_FRAME FL_UP_FRAME diff --git a/src/fl_boxtype.cxx b/src/fl_boxtype.cxx index 2544589..f118567 100644 --- a/src/fl_boxtype.cxx +++ b/src/fl_boxtype.cxx @@ -1,4 +1,3 @@ -// // "$Id: fl_boxtype.cxx 7903 2010-11-28 21:06:39Z matt $" // // Box drawing code for the Fast Light Tool Kit (FLTK). @@ -316,6 +315,8 @@ static struct { {fl_border_frame, 1,1,2,2,0}, // _FL_OVAL_FRAME {fl_rectf, 0,0,0,0,0}, // _FL_OVAL_FLAT_BOX, {fl_focus_frame, 1,1,1,1,1}, // FL_FOCUS_FRAME + {fl_up_box, 1,1,1,1,0}, + {fl_border_box, 1,1,1,1,0}, {fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+0 {fl_down_box, 3,3,6,6,0}, // FL_FREE_BOX+1 {fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+2 @@ -414,18 +415,22 @@ void fl_draw_box(Fl_Boxtype t, int x, int y, int w, int h, Fl_Color c) { /** Draws the widget box according its box style */ void Fl_Widget::draw_box() const { if (box_) draw_box((Fl_Boxtype)box_, x_, y_, w_, h_, color_); - draw_backdrop(); } + /** If FL_ALIGN_IMAGE_BACKDROP is set, the image or deimage will be drawn */ void Fl_Widget::draw_backdrop() const { - if (align() & FL_ALIGN_IMAGE_BACKDROP) { + + if (align() & FL_ALIGN_IMAGE_BACKDROP || + type() >= FL_WINDOW ) { 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) - ((Fl_Image*)img)->draw(x_+(w_-img->w())/2, y_+(h_-img->h())/2); - } + { + ((Fl_Image*)img)->draw(x_+(w_-img->w())/2, y_+(h_-img->h())/2); + } + } } /** 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 { @@ -433,8 +438,12 @@ void Fl_Widget::draw_box(Fl_Boxtype t, Fl_Color c) const { } /** Draws a box of type t, of color c at the position X,Y and size W,H. */ void Fl_Widget::draw_box(Fl_Boxtype t, int X, int Y, int W, int H, Fl_Color c) const { + + if ( type() >= FL_WINDOW ) + printf( "NTK: drawing window box\n" ); draw_it_active = active_r(); fl_box_table[t].f(X, Y, W, H, c); + draw_backdrop(); draw_it_active = 1; } diff --git a/src/fl_rounded_box.cxx b/src/fl_rounded_box.cxx index ca7f009..b4dece3 100644 --- a/src/fl_rounded_box.cxx +++ b/src/fl_rounded_box.cxx @@ -34,7 +34,7 @@ static double offset[RN] = { 0.0, 0.07612, 0.29289, 0.61732, 1.0}; -static void rbox(int fill, int x, int y, int w, int h) { +static void rbox(int fill, int x, int y, int w, int h, int asym = 0 ) { int i; int rsx ,rsy, rs; rsx = w*2/5; rsy = h*2/5; @@ -43,14 +43,25 @@ static void rbox(int fill, int x, int y, int w, int h) { rsx = rs; rsy = rs; if (fill) fl_begin_polygon(); else fl_begin_loop(); + for (i=0; i