OK, I admit that I am nuts. But since the code was mostly there anyways 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
This commit is contained in:
Matthias Melcher 2005-06-01 20:05:49 +00:00
parent daa8f53397
commit 090eb71a26
4 changed files with 62 additions and 15 deletions

View File

@ -2,6 +2,7 @@ CHANGES IN FLTK 1.1.7
- Documentation fixes (STR #648, STR #692, STR #730, STR - Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745) #744, STR #745)
- Added symbols 'refresh', 'reload', 'undo', and 'redo'.
- Fixed focus loss on Fl_Window:resize() - Fixed focus loss on Fl_Window:resize()
- Fl::delete_widget would hang fl_wait after deleting the - Fl::delete_widget would hang fl_wait after deleting the
window (STR #679) window (STR #679)

View File

@ -350,6 +350,8 @@ sign. Figure 3-4 shows the available symbols.</P>
<LI>+[1-9] or -[1-9] tweaks the scaling a little bigger <LI>+[1-9] or -[1-9] tweaks the scaling a little bigger
or smaller.</LI> or smaller.</LI>
<LL>'$' flips the symbol horizontaly, '%' flips it verticaly.
<LI>[1-9] - rotates by a multiple of 45 degrees. '5' and <LI>[1-9] - rotates by a multiple of 45 degrees. '5' and
'6' do no rotation while the others point in the '6' do no rotation while the others point in the
direction of that key on a numeric keypad.</LI> direction of that key on a numeric keypad.</LI>

View File

@ -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 (w < 10) {x -= (10-w)/2; w = 10;}
if (h < 10) {y -= (10-h)/2; h = 10;} if (h < 10) {y -= (10-h)/2; h = 10;}
w = (w-1)|1; h = (h-1)|1; 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; int rotangle;
switch (*p++) { switch (*p++) {
case '0': case '0':
@ -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;} if (equalscale) {if (w<h) h = w; else w = h;}
fl_scale(0.5*w, 0.5*h); fl_scale(0.5*w, 0.5*h);
fl_rotate(rotangle/10.0); 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); (symbols[pos].drawit)(col);
fl_pop_matrix(); fl_pop_matrix();
@ -576,12 +587,11 @@ static void draw_fileprint(Fl_Color c) {
EC; EC;
} }
static void draw_recycle(Fl_Color c) { static void draw_round_arrow(Fl_Color c, float da=5.0) {
double i, r, di=5.0, dr1=0.005, dr2=0.015; double a, r, dr1=0.005, dr2=0.015;
int j; int i, j;
for (j=0; j<4; j++) { for (j=0; j<2; j++) {
fl_rotate(180.0); if (j&1) {
if (j&2) {
fl_color(c); fl_color(c);
set_outline_color(c); set_outline_color(c);
BC; BC;
@ -592,15 +602,15 @@ static void draw_recycle(Fl_Color c) {
vv(-0.1, 0.0); vv(-0.1, 0.0);
vv(-1.0, 0.0); vv(-1.0, 0.0);
vv(-1.0, 0.9); vv(-1.0, 0.9);
for (i=135.0, r=1.0; i>=0.0; i-=di, r-=dr1) { for (i=27, a=140.0, r=1.0; i>0; i--, a-=da, r-=dr1) {
double a = i/180.0 * M_PI; double ar = a/180.0 * M_PI;
vv(cos(a)*r, sin(a)*r); vv(cos(ar)*r, sin(ar)*r);
} }
for (i=0.0; i<=135.0; i+=di, r-=dr2) { for (i=27; i>=0; a+=da, i--, r-=dr2) {
double a = i/180.0 * M_PI; double ar = a/180.0 * M_PI;
vv(cos(a)*r, sin(a)*r); vv(cos(ar)*r, sin(ar)*r);
} }
if (j&2) { if (j&1) {
EC; EC;
} else { } else {
ECP; ECP;
@ -608,6 +618,33 @@ static void draw_recycle(Fl_Color c) {
} }
} }
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 void fl_init_symbols(void) {
static char beenhere; static char beenhere;
if (beenhere) return; if (beenhere) return;
@ -649,7 +686,11 @@ static void fl_init_symbols(void) {
fl_add_symbol("filesave", draw_filesave, 1); fl_add_symbol("filesave", draw_filesave, 1);
fl_add_symbol("filesaveas", draw_filesaveas, 1); fl_add_symbol("filesaveas", draw_filesaveas, 1);
fl_add_symbol("fileprint", draw_fileprint, 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); // fl_add_symbol("file", draw_file, 1);
} }

View File

@ -126,7 +126,10 @@ bt("@fileopen");
bt("@filesave"); bt("@filesave");
bt("@filesaveas"); bt("@filesaveas");
bt("@fileprint"); bt("@fileprint");
bt("@recycle"); bt("@refresh");
bt("@reload");
bt("@undo");
bt("@redo");
orientation = new Fl_Value_Slider( orientation = new Fl_Value_Slider(
(int)(window->w()*.05+.5), window->h()-40, (int)(window->w()*.05+.5), window->h()-40,