Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17582
Modified Files: Tag: impd_0_37 g_numbox.c Log Message: deleting 90 lines
Index: g_numbox.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_numbox.c,v retrieving revision 1.1.1.4.2.2.2.19 retrieving revision 1.1.1.4.2.2.2.20 diff -C2 -d -r1.1.1.4.2.2.2.19 -r1.1.1.4.2.2.2.20 *** g_numbox.c 6 May 2004 07:12:26 -0000 1.1.1.4.2.2.2.19 --- g_numbox.c 8 May 2004 21:10:43 -0000 1.1.1.4.2.2.2.20 *************** *** 23,27 **** #define CH post("%d: change=%d", __LINE__, (int)x->x_gui.x_change);
- static void my_numbox_key(void *z, t_floatarg fkey); static t_class *my_numbox_class;
--- 23,26 ---- *************** *** 33,41 **** x->x_gui.x_change = 0; CH glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); ! x->x_gui.x_draw(x, x->x_gui.x_glist, 0); }
static void my_numbox_tick_wait(t_my_numbox *x) ! {x->x_gui.x_draw(x, x->x_gui.x_glist, 0);}
void my_numbox_clip(t_my_numbox *x) --- 32,40 ---- x->x_gui.x_change = 0; CH glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); ! iemgui_dodraw((t_iemgui *)x); }
static void my_numbox_tick_wait(t_my_numbox *x) ! {iemgui_dodraw((t_iemgui *)x);}
void my_numbox_clip(t_my_numbox *x) *************** *** 49,119 **** }
- void my_numbox_ftoa(t_my_numbox *x) - { - double f=x->x_val; - int bufsize, is_exp=0, i, idecimal; - - sprintf(x->x_buf, "%g", f); - bufsize = strlen(x->x_buf); - if(bufsize >= 5)/* if it is in exponential mode */ - { - i = bufsize - 4; - if((x->x_buf[i] == 'e') || (x->x_buf[i] == 'E')) - is_exp = 1; - } - if(bufsize > x->x_gui.x_w)/* if to reduce */ - { - if(is_exp) - { - if(x->x_gui.x_w <= 5) - { - x->x_buf[0] = (f < 0.0 ? '-' : '+'); - x->x_buf[1] = 0; - } - i = bufsize - 4; - for(idecimal=0; idecimal < i; idecimal++) - if(x->x_buf[idecimal] == '.') - break; - if(idecimal > (x->x_gui.x_w - 4)) - { - x->x_buf[0] = (f < 0.0 ? '-' : '+'); - x->x_buf[1] = 0; - } - else - { - int new_exp_index=x->x_gui.x_w-4, old_exp_index=bufsize-4; - for(i=0; i < 4; i++, new_exp_index++, old_exp_index++) - x->x_buf[new_exp_index] = x->x_buf[old_exp_index]; - x->x_buf[x->x_gui.x_w] = 0; - } - } - else - { - for(idecimal=0; idecimal < bufsize; idecimal++) - if(x->x_buf[idecimal] == '.') - break; - if(idecimal > x->x_gui.x_w) {x->x_buf[0] = (f < 0.0 ? '-' : '+'); - x->x_buf[1] = 0; - } - else - x->x_buf[x->x_gui.x_w] = 0; - } - } - } - - void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode) { - if (mode==IEM_GUI_DRAW_MODE_ERASE) - sys_mgui((t_iemgui *)x,"numbox","erase",""); - else if (mode==IEM_GUI_DRAW_MODE_SELECT) - sys_mgui((t_iemgui *)x,"numbox","select","i", - (int)x->x_gui.x_selected + 2*(int)x->x_gui.x_change); - else { - pd_upload((t_gobj *)x,glist); - my_numbox_ftoa(x); - sys_mgui((t_iemgui *)x,"numbox","draw",""); - sys_mgui((t_iemgui *)x,"numbox","select","i", - (int)x->x_gui.x_selected + 2*(int)x->x_gui.x_change);} - } - /* ------------------------ nbx widgetbehaviour----------------------------- */
--- 48,51 ---- *************** *** 145,150 **** }
! int my_numbox_check_minmax(t_my_numbox *x, double min, double max) { int val=x->x_val; if(x->x_gui.x_lin0_log1) { --- 77,83 ---- }
! int my_numbox_check_minmax(t_my_numbox *x) { + double min=x->x_min, max=x->x_max; int val=x->x_val; if(x->x_gui.x_lin0_log1) { *************** *** 178,208 **** x->x_val -= k2*dy; my_numbox_clip(x); ! x->x_gui.x_draw(x, x->x_gui.x_glist, 0); my_numbox_bang(x); clock_unset(x->x_clock_reset); }
- static int my_numbox_newclick(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) - { - t_my_numbox* x = (t_my_numbox *)z; - if(!doit) return 1; - x->x_gui.x_finemoved = !! shift; - return 1; - } - static void my_numbox_set(t_my_numbox *x, t_floatarg f) ! { ! x->x_val = f; ! my_numbox_clip(x); ! x->x_gui.x_draw(x, x->x_gui.x_glist, 0); ! }
static void my_numbox_log_height(t_my_numbox *x, t_floatarg lh) { ! if(lh < 10.0) lh = 10.0; ! x->x_log_height = (int)lh; x->x_k = x->x_gui.x_lin0_log1 ? exp(log(x->x_max/x->x_min)/(double)(x->x_log_height)) : 1.0; - }
--- 111,126 ---- x->x_val -= k2*dy; my_numbox_clip(x); ! iemgui_dodraw((t_iemgui *)x); my_numbox_bang(x); clock_unset(x->x_clock_reset); }
static void my_numbox_set(t_my_numbox *x, t_floatarg f) ! {x->x_val=f; my_numbox_clip(x); iemgui_dodraw((t_iemgui *)x);}
static void my_numbox_log_height(t_my_numbox *x, t_floatarg lh) { ! x->x_log_height = MAX(10.0,(int)lh); x->x_k = x->x_gui.x_lin0_log1 ? exp(log(x->x_max/x->x_min)/(double)(x->x_log_height)) : 1.0; }
*************** *** 221,245 **** }
! static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) ! { ! if(my_numbox_check_minmax(x, ! (double)atom_getfloatarg(0, ac, av), ! (double)atom_getfloatarg(1, ac, av))) ! x->x_gui.x_draw(x, x->x_gui.x_glist, 0); ! }
static void my_numbox_lin(t_my_numbox *x) {x->x_gui.x_lin0_log1 = 0;} static void my_numbox_log(t_my_numbox *x) {x->x_gui.x_lin0_log1 = 1; ! if(my_numbox_check_minmax(x, x->x_min, x->x_max)) x->x_gui.x_draw(x, x->x_gui.x_glist, 0); ! }
- static void my_numbox_init(t_my_numbox *x, t_floatarg f) {x->x_gui.x_loadinit = !!f;} static void my_numbox_loadbang(t_my_numbox *x) { if(!sys_noloadbang && x->x_gui.x_loadinit) ! { ! x->x_gui.x_draw(x, x->x_gui.x_glist, 0); ! my_numbox_bang(x); ! } }
--- 139,154 ---- }
! static void my_numbox_range(t_my_numbox *x, t_float min, t_float max) ! {x->x_min=min; x->x_max=max; ! if(my_numbox_check_minmax(x)) iemgui_dodraw((t_iemgui *)x);}
static void my_numbox_lin(t_my_numbox *x) {x->x_gui.x_lin0_log1 = 0;} static void my_numbox_log(t_my_numbox *x) {x->x_gui.x_lin0_log1 = 1; ! if(my_numbox_check_minmax(x)) iemgui_dodraw((t_iemgui *)x);}
static void my_numbox_loadbang(t_my_numbox *x) { if(!sys_noloadbang && x->x_gui.x_loadinit) ! {iemgui_dodraw((t_iemgui *)x); my_numbox_bang(x);} }
*************** *** 266,275 **** y->x_w=MAX(w,1); my_numbox_calc_fontwidth(x); ! my_numbox_check_minmax(x, x->x_min, x->x_max); y->x_w = MAX(y->x_w,1); y->x_snd_able = y->x_snd!=sym_empty; y->x_rcv_able = y->x_rcv!=sym_empty; if (y->x_rcv_able) pd_bind((t_pd *)x, y->x_rcv); ! if (glist_isvisible(glist_getcanvas(y->x_glist))) x->x_gui.x_draw(x, y->x_glist, 0); }
--- 175,184 ---- y->x_w=MAX(w,1); my_numbox_calc_fontwidth(x); ! my_numbox_check_minmax(x); y->x_w = MAX(y->x_w,1); y->x_snd_able = y->x_snd!=sym_empty; y->x_rcv_able = y->x_rcv!=sym_empty; if (y->x_rcv_able) pd_bind((t_pd *)x, y->x_rcv); ! if (glist_isvisible(glist_getcanvas(y->x_glist))) iemgui_dodraw((t_iemgui *)x); }
*************** *** 278,282 **** t_iemgui *y = iemgui_new(my_numbox_class); t_my_numbox *x = (t_my_numbox *)y; - y->x_draw = (t_iemfunptr)my_numbox_draw; x->x_log_height = 256; y->x_w=5; --- 187,190 ---- *************** *** 317,324 **** class_addmethod(c, (t_method)my_numbox_set, gensym("set"), A_FLOAT, 0); class_addmethod(c, (t_method)my_numbox_size, gensym("size"), A_GIMME, 0); /* !@#$ actually overrode label_font to do stuff related to width */ class_addmethod(c, (t_method)my_numbox_log, gensym("log"), 0); class_addmethod(c, (t_method)my_numbox_lin, gensym("lin"), 0); ! class_addmethod(c, (t_method)my_numbox_init, gensym("init"), A_FLOAT, 0); class_addmethod(c, (t_method)my_numbox_log_height, gensym("log_height"), A_FLOAT, 0); wb.w_getrectfn = my_numbox_getrect; --- 225,233 ---- class_addmethod(c, (t_method)my_numbox_set, gensym("set"), A_FLOAT, 0); class_addmethod(c, (t_method)my_numbox_size, gensym("size"), A_GIMME, 0); + class_addmethod(c, (t_method)my_numbox_range, gensym("range"), A_GIMME, 0); /* !@#$ actually overrode label_font to do stuff related to width */ class_addmethod(c, (t_method)my_numbox_log, gensym("log"), 0); class_addmethod(c, (t_method)my_numbox_lin, gensym("lin"), 0); ! class_addmethod(c, (t_method)iemgui_init, gensym("init"), A_FLOAT, 0); class_addmethod(c, (t_method)my_numbox_log_height, gensym("log_height"), A_FLOAT, 0); wb.w_getrectfn = my_numbox_getrect;