From 903bd3ddf614fe4b6e1fd716635b40e895d5779f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 25 Oct 2007 17:07:35 +0000 Subject: updated help patch and added rudimentary size message svn path=/trunk/externals/bbogart/; revision=8882 --- entry/entry-help.pd | 49 +++++++++++++++++++++++++++++--------------- entry/entry.c | 58 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 73 insertions(+), 34 deletions(-) diff --git a/entry/entry-help.pd b/entry/entry-help.pd index e5ff1a5..f528915 100644 --- a/entry/entry-help.pd +++ b/entry/entry-help.pd @@ -1,24 +1,41 @@ -#N canvas 200 48 434 445 10; -#X obj 73 132 entry 150 100 grey95 black; +#N canvas 200 48 472 591 10; +#X obj 73 212 entry 150 100 grey black; #X obj 11 84 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; -#X obj 32 266 print; -#X msg 137 75 clear; -#X msg 141 107 set one two three four five six; -#X msg 88 274 Can you see what I am; -#X msg 88 250 set \$1 \$2 \$3 \$4 \$5 \$6; -#X msg 86 51 fgcolour yellow; +#X obj 32 346 print; +#X msg 150 95 clear; +#X msg 159 117 set one two three four five six; +#X msg 72 50 fgcolour yellow; #X msg 50 23 bgcolour purple; -#X obj 128 363 entry 150 50 grey70 purple; -#X text 11 336 The one was created with: entry 150 50 grey70 purple -; -#X text 8 305 Creation arguments are: width height bgcolor fgcolor. +#X obj 128 473 entry 100 100 grey70 purple; +#X text 8 365 Creation arguments are: width height bgcolor fgcolor. The width and height are in pixels.; +#X obj 261 234 select return; +#X obj 79 347 pddp/print; +#X obj 176 143 trigger bang bang; +#X msg 176 164 clear; +#X symbolatom 216 319 10 0 0 1 last_key_typed - -; +#X text 266 262 ^-- hit return to output; +#X msg 132 430 size 100 100; +#X msg 219 430 size 400 200; +#X msg 29 4 bgcolour grey; +#X msg 84 71 fgcolour black; +#X text 13 404 The size message currently only takes affect after a +save and reopen.; #X connect 0 0 2 0; -#X connect 0 0 6 0; +#X connect 0 0 10 0; +#X connect 0 1 9 0; +#X connect 0 1 13 0; #X connect 1 0 0 0; #X connect 3 0 0 0; #X connect 4 0 0 0; -#X connect 6 0 5 0; -#X connect 7 0 0 0; -#X connect 8 0 0 0; +#X connect 5 0 0 0; +#X connect 6 0 0 0; +#X connect 9 0 11 0; +#X connect 11 0 12 0; +#X connect 11 1 0 0; +#X connect 12 0 0 0; +#X connect 15 0 7 0; +#X connect 16 0 7 0; +#X connect 17 0 0 0; +#X connect 18 0 0 0; diff --git a/entry/entry.c b/entry/entry.c index 78a8e9d..1e31022 100644 --- a/entry/entry.c +++ b/entry/entry.c @@ -38,6 +38,8 @@ #define BACKGROUNDCOLOR "grey70" +#define DEBUG(x) + typedef struct _entry { t_object x_obj; @@ -86,9 +88,28 @@ static t_symbol *right_symbol; static t_symbol *up_symbol; static t_symbol *down_symbol; -/* widget helper functions */ +/* function prototypes */ + +static void entry_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2); +static void entry_displace(t_gobj *z, t_glist *glist, int dx, int dy); +static void entry_select(t_gobj *z, t_glist *glist, int state); +static void entry_activate(t_gobj *z, t_glist *glist, int state); +static void entry_delete(t_gobj *z, t_glist *glist); +static void entry_vis(t_gobj *z, t_glist *glist, int vis); +static void entry_save(t_gobj *z, t_binbuf *b); + + +t_widgetbehavior entry_widgetbehavior = { +w_getrectfn: entry_getrect, +w_displacefn: entry_displace, +w_selectfn: entry_select, +w_activatefn: entry_activate, +w_deletefn: entry_delete, +w_visfn: entry_vis, +w_clickfn: NULL, +}; -#define DEBUG(x) x +/* widget helper functions */ static int calculate_onset(t_entry *x, t_glist *glist, int i, int nplus) { @@ -356,18 +377,6 @@ static void entry_vis(t_gobj *z, t_glist *glist, int vis) } } -static void entry_save(t_gobj *z, t_binbuf *b); - -t_widgetbehavior entry_widgetbehavior = { -w_getrectfn: entry_getrect, -w_displacefn: entry_displace, -w_selectfn: entry_select, -w_activatefn: entry_activate, -w_deletefn: entry_delete, -w_visfn: entry_vis, -w_clickfn: NULL, -}; - /* Function to reset the contents of the entry box */ static void entry_set(t_entry* x, t_symbol *s, int argc, t_atom *argv) { @@ -375,7 +384,7 @@ static void entry_set(t_entry* x, t_symbol *s, int argc, t_atom *argv) int i; t_symbol *tmp; - tmp = s; /* this gets rid of the unused variable warning */ + tmp = s; /* <-- this gets rid of the unused variable warning */ DEBUG(post("%s delete 0.0 end \n", x->x_widget_name);); sys_vgui("%s delete 0.0 end \n", x->x_widget_name); for(i=0; ix_status_outlet, output_symbol); @@ -495,6 +504,13 @@ void entry_fgcolour(t_entry* x, t_symbol* fgcol) sys_vgui("%s configure -foreground \"%s\" \n", x->x_widget_name, x->x_fgcolour->s_name); } +static void entry_size(t_entry *x, t_float width, t_float height) +{ + DEBUG(post("entry_size");); + x->x_height = height; + x->x_width = width; +} + static void entry_free(t_entry *x) { pd_unbind(&x->x_obj.ob_pd, x->x_receive_name); @@ -552,6 +568,12 @@ void entry_setup(void) { gensym("keyup"), A_DEFFLOAT, 0); + + class_addmethod(entry_class, (t_method)entry_size, + gensym("size"), + A_DEFFLOAT, + A_DEFFLOAT, + 0); class_addmethod(entry_class, (t_method)entry_output, gensym("output"), @@ -590,7 +612,7 @@ void entry_setup(void) { up_symbol = gensym("up"); down_symbol = gensym("down"); - post("Text v0.1 Ben Bogart.\nCVS: $Revision: 1.12 $ $Date: 2007-10-25 16:39:13 $"); + post("Text v0.1 Ben Bogart.\nCVS: $Revision: 1.13 $ $Date: 2007-10-25 17:07:35 $"); } -- cgit v1.2.1