Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19518/source
Modified Files:
flattr.cpp flattr_ed.cpp flext.cpp
Log Message:
""
Index: flattr_ed.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flattr_ed.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** flattr_ed.cpp 21 Jun 2004 13:58:19 -0000 1.21
--- flattr_ed.cpp 9 Sep 2004 04:00:46 -0000 1.22
***************
*** 79,148 ****
sys_gui(
! "proc flext_apply {id alen} {\n"
// strip "." from the TK id to make a variable name suffix
"set vid [string trimleft $id .]\n"
! // make a list of the attribute values (including save flags)
"set lst {}\n"
- "for {set ix 1} {$ix <= $alen} {incr ix} {\n"
- "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n"
- "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n"
- "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n"
- "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n"
- "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n"
! "global $var_attr_name $var_attr_init $var_attr_val $var_attr_save $var_attr_type\n"
!
! "if { [expr $$var_attr_type] != 0 } {\n"
! // attribute is puttable
! "lappend lst [eval concat $$var_attr_name]\n"
! // process current value
! "set tmp [eval concat $$var_attr_val]\n"
! "set len [llength $tmp]\n"
! "if { $len == 1 } {\n"
! // it's an atom
! // if atom starts with $, replace it by # ($ can't be passed by TCL)
! "if { [string index $tmp 0] == \"$\" } {\n"
! "set tmp [string replace $tmp 0 0 #]\n"
! "}\n"
! "lappend lst $tmp\n"
! "} else {\n"
! // it's a list
! "set lst [concat $lst {list} $len $tmp]\n"
! "}\n"
! // process init value
! "set tmp [eval concat $$var_attr_init]\n"
! "set len [llength $tmp]\n"
! "if { $len == 1 } {\n"
! // it's an atom
! // if atom starts with $, replace it by # ($ can't be passed by TCL)
! "if { [string index $tmp 0] == \"$\" } {\n"
! "set tmp [string replace $tmp 0 0 #]\n"
! "}\n"
! "lappend lst $tmp\n"
! "} else {\n"
! // it's a list
! "set lst [concat $lst {list} $len $tmp]\n"
! "}\n"
! "lappend lst [eval concat $$var_attr_save]\n"
! "}\n"
"}\n"
! "set cmd [concat $id attributedialog $lst \\;]\n"
! "pd $cmd\n"
"}\n"
"proc flext_cancel {id} {\n"
! "set cmd [concat $id cancel \\;]\n"
! "pd $cmd\n"
"}\n"
"proc flext_ok {id alen} {\n"
! "flext_apply $id $alen\n"
"flext_cancel $id\n"
"}\n"
--- 79,151 ----
sys_gui(
! "proc flext_escatoms {lst} {\n"
! "set tmp {}\n"
! "foreach a $lst {\n"
! "set a [regsub {\\$} $a \\\\$]\n" // replace $ with \$
! "set a [regsub {,} $a \\\\,]\n" // replace , with \,
! "set a [regsub {;} $a \\\\\\;]\n" // replace ; with \;
! "lappend tmp $a\n"
! "}\n"
! "return $tmp\n"
! "}\n"
!
! "proc flext_makevalue {id ix} {\n"
// strip "." from the TK id to make a variable name suffix
"set vid [string trimleft $id .]\n"
! "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n"
! "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n"
! "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n"
! "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n"
! "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n"
!
! "global $var_attr_name $var_attr_init $var_attr_val $var_attr_save $var_attr_type\n"
"set lst {}\n"
! "if { [expr $$var_attr_type] != 0 } {\n"
! // attribute is puttable
! "lappend lst [eval concat $$var_attr_name]\n"
! // process current value
! "set tmp [flext_escatoms [eval concat $$var_attr_val]]\n"
! "set lst [concat $lst [llength $tmp] $tmp]\n"
! // process init value
! "set tmp [flext_escatoms [eval concat $$var_attr_init]]\n"
! "set lst [concat $lst [llength $tmp] $tmp]\n"
! "lappend lst [eval concat $$var_attr_save]\n"
"}\n"
! // return list
! "return $lst\n"
! "}\n"
!
! "proc flext_apply {id ix} {\n"
! "set lst [flext_makevalue $id $ix]\n"
! "set lst [eval concat $lst]\n" // remove curly braces from character escaping
! "pd [concat $id attributedialog $lst \\;]\n"
! "}\n"
!
! "proc flext_applyall {id alen} {\n"
! // make a list of the attribute values (including save flags)
!
! "set lst {}\n"
! "for {set ix 1} {$ix <= $alen} {incr ix} {\n"
! "set lst [concat $lst [flext_makevalue $id $ix]]\n"
! "}\n"
! "set lst [eval concat $lst]\n" // remove curly braces from character escaping
!
! "pd [concat $id attributedialog $lst \\;]\n"
"}\n"
"proc flext_cancel {id} {\n"
! "pd [concat $id cancel \\;]\n"
"}\n"
"proc flext_ok {id alen} {\n"
! "flext_applyall $id $alen\n"
"flext_cancel $id\n"
"}\n"
***************
*** 182,186 ****
"proc flext_textcopy {id idtxt var} {\n"
"global $var\n"
! "set $var [eval $idtxt get 0.0 end]\n"
"destroy $id\n"
"}\n"
--- 185,193 ----
"proc flext_textcopy {id idtxt var} {\n"
"global $var\n"
! "set txt [eval $idtxt get 0.0 end]\n"
! // strip newline characters
! "set tmp {}\n"
! "foreach t $txt { lappend tmp [string trim $t] }\n"
! "set $var $tmp\n"
"destroy $id\n"
"}\n"
***************
*** 201,205 ****
"pack $id.w.text -expand yes -fill both\n"
! "$id.w.text insert 0.0 [expr $$var]\n"
"$id.w.text mark set insert 0.0\n"
--- 208,220 ----
"pack $id.w.text -expand yes -fill both\n"
! // insert text with newlines
! "set txt [split [expr $$var] ,]\n"
! "set lines [llength $txt]\n"
! "for {set ix 0} {$ix < ($lines-1)} {incr ix} {\n"
! "$id.w.text insert end [string trim [lindex $txt $ix] ]\n"
! "$id.w.text insert end \" ,\\n\"\n"
! "}\n"
! "$id.w.text insert end [string trim [lindex $txt end] ]\n"
!
"$id.w.text mark set insert 0.0\n"
***************
*** 230,234 ****
"grid columnconfigure $id {1 4} -weight 3\n" // value entry
"grid columnconfigure $id {2 3} -weight 0\n" // copy buttons
! "grid columnconfigure $id {5 6 7} -weight 0\n" // radio buttons
// "grid rowconfigure $id {0 1 2} -weight 0\n"
--- 245,250 ----
"grid columnconfigure $id {1 4} -weight 3\n" // value entry
"grid columnconfigure $id {2 3} -weight 0\n" // copy buttons
! "grid columnconfigure $id 5 -weight 1\n" // apply button
! "grid columnconfigure $id {6 7 8} -weight 0\n" // radio buttons
// "grid rowconfigure $id {0 1 2} -weight 0\n"
***************
*** 239,242 ****
--- 255,259 ----
"label $id.copy -text {copy} -height 2 -font {Helvetica 9 bold}\n"
"label $id.val -text {current value} -height 2 -font {Helvetica 9 bold}\n"
+ "label $id.apply -text {} -height 2 -font {Helvetica 9 bold}\n" // why must this be empty?
"foreach {i txt} {0 {don't\rsave} 1 {do\rinit} 2 {always\rsave} } {\n"
"label $id.b$i -text $txt -height 2 -font {Helvetica 9 bold}\n"
***************
*** 248,252 ****
"grid config $id.copy -column 2 -columnspan 2 -row $row \n"
"grid config $id.val -column 4 -row $row \n"
! "foreach i {0 1 2} { grid config $id.b$i -column [expr $i + 5] -row $row }\n"
// "grid config $id.options -column 3 -row 0 \n"
"incr row\n"
--- 265,270 ----
"grid config $id.copy -column 2 -columnspan 2 -row $row \n"
"grid config $id.val -column 4 -row $row \n"
! "grid config $id.apply -column 5 -row $row \n"
! "foreach i {0 1 2} { grid config $id.b$i -column [expr $i + 6] -row $row }\n"
// "grid config $id.options -column 3 -row 0 \n"
"incr row\n"
***************
*** 254,258 ****
// Separator
"frame $id.sep -relief ridge -bd 1 -height 2\n"
! "grid config $id.sep -column 0 -columnspan 8 -row $row -pady 2 -sticky {snew}\n"
"incr row\n"
--- 272,276 ----
// Separator
"frame $id.sep -relief ridge -bd 1 -height 2\n"
! "grid config $id.sep -column 0 -columnspan 9 -row $row -pady 2 -sticky {snew}\n"
"incr row\n"
***************
*** 323,326 ****
--- 341,345 ----
"grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
+ // copy buttons
"button $id.b2i-$ix -text {<-} -height 1 -command \" flext_copyval $var_attr_init $var_attr_val \"\n"
"grid config $id.b2i-$ix -column 2 -row $row -sticky {ew}\n"
***************
*** 328,331 ****
--- 347,354 ----
"grid config $id.b2c-$ix -column 3 -row $row -sticky {ew}\n"
+ // apply button
+ "button $id.apply-$ix -text {Apply} -height 1 -command \" flext_apply $id $ix \"\n"
+ "grid config $id.apply-$ix -column 5 -row $row -sticky {ew}\n"
+
// "tk_optionMenu $id.opt-$ix $var_attr_save {don't save} {initialize} {always save}\n"
// "grid config $id.opt-$ix -column 5 -row $ix \n"
***************
*** 334,338 ****
"foreach {i c} {0 black 1 blue 2 red} {\n"
"radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n"
! "grid config $id.b$i-$ix -column [expr $i + 5] -row $row \n"
"}\n"
"} else {\n"
--- 357,361 ----
"foreach {i c} {0 black 1 blue 2 red} {\n"
"radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n"
! "grid config $id.b$i-$ix -column [expr $i + 6] -row $row \n"
"}\n"
"} else {\n"
***************
*** 362,366 ****
"label $id.readonly-$ix -text \"read-only\"\n"
! "grid config $id.readonly-$ix -column 5 -columnspan 3 -row $row -padx 5 -sticky {ew}\n"
"}\n"
--- 385,389 ----
"label $id.readonly-$ix -text \"read-only\"\n"
! "grid config $id.readonly-$ix -column 6 -columnspan 3 -row $row -padx 5 -sticky {ew}\n"
"}\n"
***************
*** 373,377 ****
"frame $id.sep2 -relief ridge -bd 1 -height 2\n"
// "grid rowconfigure $id $row -weight 0\n"
! "grid config $id.sep2 -column 0 -columnspan 8 -row $row -pady 5 -sticky {snew}\n"
"incr row\n"
--- 396,400 ----
"frame $id.sep2 -relief ridge -bd 1 -height 2\n"
// "grid rowconfigure $id $row -weight 0\n"
! "grid config $id.sep2 -column 0 -columnspan 9 -row $row -pady 5 -sticky {snew}\n"
"incr row\n"
***************
*** 380,386 ****
"pack $id.buttonframe -side bottom -fill x\n"
! "button $id.buttonframe.cancel -text {Cancel} -width 20 -command \" flext_cancel $id \"\n"
! "button $id.buttonframe.apply -text {Apply} -width 20 -command \" flext_apply $id $alen \"\n"
! "button $id.buttonframe.ok -text {OK} -width 20 -command \" flext_ok $id $alen \"\n"
"button $id.buttonframe.help -text {Help} -width 10 -command \" flext_help $id \"\n"
--- 403,409 ----
"pack $id.buttonframe -side bottom -fill x\n"
! "button $id.buttonframe.cancel -text {Leave} -width 20 -command \" flext_cancel $id \"\n"
! "button $id.buttonframe.apply -text {Apply all} -width 20 -command \" flext_applyall $id $alen \"\n"
! "button $id.buttonframe.ok -text {Apply & Leave} -width 20 -command \" flext_ok $id $alen \"\n"
"button $id.buttonframe.help -text {Help} -width 10 -command \" flext_help $id \"\n"
***************
*** 391,400 ****
// "grid rowconfigure $id $row -weight 0\n"
! "grid config $id.buttonframe -column 0 -columnspan 8 -row $row -pady 5 -sticky {ew}\n"
// Key bindings
"bind $id {<KeyPress-Escape>} \" flext_cancel $id \"\n"
"bind $id {<KeyPress-Return>} \" flext_ok $id $alen \"\n"
! "bind $id {<Shift-KeyPress-Return>} \" flext_apply $id $alen \"\n"
"}\n"
);
--- 414,423 ----
// "grid rowconfigure $id $row -weight 0\n"
! "grid config $id.buttonframe -column 0 -columnspan 9 -row $row -pady 5 -sticky {ew}\n"
// Key bindings
"bind $id {<KeyPress-Escape>} \" flext_cancel $id \"\n"
"bind $id {<KeyPress-Return>} \" flext_ok $id $alen \"\n"
! "bind $id {<Shift-KeyPress-Return>} \" flext_applyall $id $alen \"\n"
"}\n"
);
***************
*** 622,629 ****
bool flext_base::cb_AttrDialog(flext_base *th,int argc,const t_atom *argv)
{
! int i = 0;
! if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) ++i;
!
! for(; i < argc; ) {
FLEXT_ASSERT(IsSymbol(argv[i]));
--- 645,649 ----
bool flext_base::cb_AttrDialog(flext_base *th,int argc,const t_atom *argv)
{
! for(int i = 0; i < argc; ) {
FLEXT_ASSERT(IsSymbol(argv[i]));
***************
*** 633,657 ****
// get current value
int ccnt,coffs;
! if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) {
! i++;
! FLEXT_ASSERT(CanbeInt(argv[i]));
! ccnt = GetAInt(argv[i]);
! coffs = ++i;
! }
! else
! coffs = i,ccnt = 1;
i += ccnt;
// get init value
int icnt,ioffs;
! if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) {
! i++;
! FLEXT_ASSERT(CanbeInt(argv[i]));
! icnt = GetAInt(argv[i]);
! ioffs = ++i;
! }
! else
! ioffs = i,icnt = 1;
i += icnt;
--- 653,667 ----
// get current value
+ FLEXT_ASSERT(CanbeInt(argv[i]));
int ccnt,coffs;
! ccnt = GetAInt(argv[i]);
! coffs = ++i;
i += ccnt;
// get init value
+ FLEXT_ASSERT(CanbeInt(argv[i]));
int icnt,ioffs;
! icnt = GetAInt(argv[i]);
! ioffs = ++i;
i += icnt;
Index: flattr.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flattr.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** flattr.cpp 24 Aug 2004 02:34:30 -0000 1.24
--- flattr.cpp 9 Sep 2004 04:00:46 -0000 1.25
***************
*** 49,52 ****
--- 49,54 ----
AttrItem *a,*b;
+ FLEXT_ASSERT(asym != sym__ && asym != sym_list && asym != sym_float && asym != sym_symbol && asym != sym_anything);
+
if(sfun) // if commented out, there will be a warning at run-time (more user-friendly)
{
***************
*** 239,245 ****
case a_symbol:
if(argc == 1 && IsSymbol(argv[0])) {
! // \todo shall we analyze the patcher args????
! // any.st = const_cast<t_symbol *>(GetParamSym(GetSymbol(argv[0]),thisCanvas()));
! any.st = GetSymbol(argv[0]);
((methfun_1)a->fun)(this,any);
}
--- 241,247 ----
case a_symbol:
if(argc == 1 && IsSymbol(argv[0])) {
! t_atom at;
! GetParamSym(at,GetSymbol(argv[0]),thisCanvas());
! any.st = const_cast<t_symbol *>(GetSymbol(at));
((methfun_1)a->fun)(this,any);
}
Index: flext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flext.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** flext.cpp 21 Jun 2004 13:58:19 -0000 1.28
--- flext.cpp 9 Sep 2004 04:00:47 -0000 1.29
***************
*** 55,58 ****
--- 55,63 ----
flext_base::~FLEXT_CLASSDEF(flext_base)()
{
+ #if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT)
+ // attribute editor window may still be open -> close it
+ gfxstub_deleteforkey(thisHdr());
+ #endif
+
#if FLEXT_SYS == FLEXT_SYS_MAX
// according to David Z. one should do that first...