Browse Source

Add FL_FOCUS_FRAME boxtype so that programs can easily override the visual focus style.

tags/v1.3.1000
Jonathan Moore Liles 13 years ago
parent
commit
0296a95ce4
3 changed files with 38 additions and 36 deletions
  1. +1
    -0
      FL/Enumerations.H
  2. +5
    -36
      src/Fl_Widget.cxx
  3. +32
    -0
      src/fl_boxtype.cxx

+ 1
- 0
FL/Enumerations.H View File

@@ -493,6 +493,7 @@ enum Fl_Boxtype { // boxtypes (if you change these you must fix fl_boxtype.C):
_FL_OSHADOW_BOX, ///< see figure 1
_FL_OVAL_FRAME, ///< see figure 1
_FL_OFLAT_BOX, ///< see figure 1
FL_FOCUS_FRAME,
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();


+ 5
- 36
src/Fl_Widget.cxx View File

@@ -186,45 +186,14 @@ Fl_Widget::~Fl_Widget() {
void
Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
if (!Fl::visible_focus()) return;
switch (B) {
case FL_DOWN_BOX:
case FL_DOWN_FRAME:
case FL_THIN_DOWN_BOX:
case FL_THIN_DOWN_FRAME:
X ++;
Y ++;
default:
break;
}

fl_color(fl_contrast(FL_BLACK, color()));

#if defined(USE_X11) || defined(__APPLE_QUARTZ__)
fl_line_style(FL_DOT);
fl_rect(X + Fl::box_dx(B), Y + Fl::box_dy(B),
W - Fl::box_dw(B) - 1, H - Fl::box_dh(B) - 1);
fl_line_style(FL_SOLID);
#elif defined(WIN32)
// Windows 95/98/ME do not implement the dotted line style, so draw
// every other pixel around the focus area...
//
// Also, QuickDraw (MacOS) does not support line styles specifically,
// and the hack we use in fl_line_style() will not draw horizontal lines
// on odd-numbered rows...
int i, xx, yy;

X += Fl::box_dx(B);
Y += Fl::box_dy(B);
W -= Fl::box_dw(B) + 2;
H -= Fl::box_dh(B) + 2;

for (xx = 0, i = 1; xx < W; xx ++, i ++) if (i & 1) fl_point(X + xx, Y);
for (yy = 0; yy < H; yy ++, i ++) if (i & 1) fl_point(X + W, Y + yy);
for (xx = W; xx > 0; xx --, i ++) if (i & 1) fl_point(X + xx, Y + H);
for (yy = H; yy > 0; yy --, i ++) if (i & 1) fl_point(X, Y + yy);
#else
# error unsupported platform
#endif // WIN32
fl_draw_box( FL_FOCUS_FRAME,
X + Fl::box_dx(B),
Y + Fl::box_dy(B),
W - Fl::box_dw(B) - 1,
H - Fl::box_dh(B) - 1, fl_color() );
}




+ 32
- 0
src/fl_boxtype.cxx View File

@@ -246,6 +246,37 @@ void fl_border_frame(int x, int y, int w, int h, Fl_Color c) {
fl_rect(x, y, w, h);
}


void fl_focus_color();

void fl_focus_frame (int X, int Y, int W, int H, Fl_Color c )
{
fl_color(c);

#if defined(USE_X11) || defined(__APPLE_QUARTZ__)
fl_line_style(FL_DOT);
fl_rect(X, Y, W, H );
fl_line_style(FL_SOLID);
#elif defined(WIN32)
// Windows 95/98/ME do not implement the dotted line style, so draw
// every other pixel around the focus area...
//
// Also, QuickDraw (MacOS) does not support line styles specifically,
// and the hack we use in fl_line_style() will not draw horizontal lines
// on odd-numbered rows...
int i, xx, yy;

for (xx = 0, i = 1; xx < W; xx ++, i ++) if (i & 1) fl_point(X + xx, Y);
for (yy = 0; yy < H; yy ++, i ++) if (i & 1) fl_point(X + W, Y + yy);
for (xx = W; xx > 0; xx --, i ++) if (i & 1) fl_point(X + xx, Y + H);
for (yy = H; yy > 0; yy --, i ++) if (i & 1) fl_point(X, Y + yy);
#else
# error unsupported platform
#endif // WIN32
}



////////////////////////////////////////////////////////////////

static struct {
@@ -284,6 +315,7 @@ static struct {
{fl_border_box, 1,1,2,2,0}, // _FL_OVAL_SHADOW_BOX,
{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, 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


Loading…
Cancel
Save