Skip to content

Commit

Permalink
OK, I admit that I am nuts. But since the code was mostly there anywa…
Browse files Browse the repository at this point in the history
…ys adding only a few bytes to the library in total, I added the symbols 'refresh' (formerly known as 'recycle'), 'reload', 'undo', and 'redo', and flags to flip symbols horizontaly '$', and verticaly '%'.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4391 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Jun 1, 2005
1 parent daa8f53 commit 090eb71
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -2,6 +2,7 @@ CHANGES IN FLTK 1.1.7

- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
- Added symbols 'refresh', 'reload', 'undo', and 'redo'.
- Fixed focus loss on Fl_Window:resize()
- Fl::delete_widget would hang fl_wait after deleting the
window (STR #679)
Expand Down
2 changes: 2 additions & 0 deletions documentation/common.html
Expand Up @@ -350,6 +350,8 @@ <H3>label()</H3>
<LI>+[1-9] or -[1-9] tweaks the scaling a little bigger
or smaller.</LI>

<LL>'$' flips the symbol horizontaly, '%' flips it verticaly.

<LI>[1-9] - rotates by a multiple of 45 degrees. '5' and
'6' do no rotation while the others point in the
direction of that key on a numeric keypad.</LI>
Expand Down
69 changes: 55 additions & 14 deletions src/fl_symbols.cxx
Expand Up @@ -113,6 +113,15 @@ int fl_draw_symbol(const char *label,int x,int y,int w,int h,Fl_Color col) {
if (w < 10) {x -= (10-w)/2; w = 10;}
if (h < 10) {y -= (10-h)/2; h = 10;}
w = (w-1)|1; h = (h-1)|1;
char flip_x = 0, flip_y = 0;
if (*p=='$') {
flip_x = 1;
p++;
}
if (*p=='%') {
flip_y = 1;
p++;
}
int rotangle;
switch (*p++) {
case '0':
Expand Down Expand Up @@ -142,6 +151,8 @@ int fl_draw_symbol(const char *label,int x,int y,int w,int h,Fl_Color col) {
if (equalscale) {if (w<h) h = w; else w = h;}
fl_scale(0.5*w, 0.5*h);
fl_rotate(rotangle/10.0);
if (flip_x) fl_scale(-1.0, 1.0);
if (flip_y) fl_scale(1.0, -1.0);
}
(symbols[pos].drawit)(col);
fl_pop_matrix();
Expand Down Expand Up @@ -576,12 +587,11 @@ static void draw_fileprint(Fl_Color c) {
EC;
}

static void draw_recycle(Fl_Color c) {
double i, r, di=5.0, dr1=0.005, dr2=0.015;
int j;
for (j=0; j<4; j++) {
fl_rotate(180.0);
if (j&2) {
static void draw_round_arrow(Fl_Color c, float da=5.0) {
double a, r, dr1=0.005, dr2=0.015;
int i, j;
for (j=0; j<2; j++) {
if (j&1) {
fl_color(c);
set_outline_color(c);
BC;
Expand All @@ -592,22 +602,49 @@ static void draw_recycle(Fl_Color c) {
vv(-0.1, 0.0);
vv(-1.0, 0.0);
vv(-1.0, 0.9);
for (i=135.0, r=1.0; i>=0.0; i-=di, r-=dr1) {
double a = i/180.0 * M_PI;
vv(cos(a)*r, sin(a)*r);
for (i=27, a=140.0, r=1.0; i>0; i--, a-=da, r-=dr1) {
double ar = a/180.0 * M_PI;
vv(cos(ar)*r, sin(ar)*r);
}
for (i=0.0; i<=135.0; i+=di, r-=dr2) {
double a = i/180.0 * M_PI;
vv(cos(a)*r, sin(a)*r);
for (i=27; i>=0; a+=da, i--, r-=dr2) {
double ar = a/180.0 * M_PI;
vv(cos(ar)*r, sin(ar)*r);
}
if (j&2) {
if (j&1) {
EC;
} else {
ECP;
}
}
}

static void draw_refresh(Fl_Color c) {
draw_round_arrow(c);
fl_rotate(180.0);
draw_round_arrow(c);
fl_rotate(-180.0);
}

static void draw_reload(Fl_Color c) {
fl_rotate(-135.0);
draw_round_arrow(c, 10);
fl_rotate(135.0);
}

static void draw_undo(Fl_Color c) {
fl_translate(0.0, 0.2);
fl_scale(1.0, -1.0);
draw_round_arrow(c, 6);
fl_scale(1.0, -1.0);
fl_translate(0.0, -0.2);
}

static void draw_redo(Fl_Color c) {
fl_scale(-1.0, 1.0);
draw_undo(c);
fl_scale(-1.0, 1.0);
}

static void fl_init_symbols(void) {
static char beenhere;
if (beenhere) return;
Expand Down Expand Up @@ -649,7 +686,11 @@ static void fl_init_symbols(void) {
fl_add_symbol("filesave", draw_filesave, 1);
fl_add_symbol("filesaveas", draw_filesaveas, 1);
fl_add_symbol("fileprint", draw_fileprint, 1);
fl_add_symbol("recycle", draw_recycle, 1);

fl_add_symbol("refresh", draw_refresh, 1);
fl_add_symbol("reload", draw_reload, 1);
fl_add_symbol("undo", draw_undo, 1);
fl_add_symbol("redo", draw_redo, 1);

// fl_add_symbol("file", draw_file, 1);
}
Expand Down
5 changes: 4 additions & 1 deletion test/symbols.cxx
Expand Up @@ -126,7 +126,10 @@ bt("@fileopen");
bt("@filesave");
bt("@filesaveas");
bt("@fileprint");
bt("@recycle");
bt("@refresh");
bt("@reload");
bt("@undo");
bt("@redo");

orientation = new Fl_Value_Slider(
(int)(window->w()*.05+.5), window->h()-40,
Expand Down

0 comments on commit 090eb71

Please sign in to comment.