aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flattr_ed.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-08-03 02:36:46 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-08-03 02:36:46 +0000
commit810a63a522ec5c3f05df5b2bc1cf35306bf4accb (patch)
treedd716016194e96185e27f1d565e001d8cdb2391e /externals/grill/flext/source/flattr_ed.cpp
parent0dcdd827ba312d0624c9eb169d3970dd4386a4f6 (diff)
""
svn path=/trunk/; revision=819
Diffstat (limited to 'externals/grill/flext/source/flattr_ed.cpp')
-rw-r--r--externals/grill/flext/source/flattr_ed.cpp126
1 files changed, 104 insertions, 22 deletions
diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp
index 0722ea10..a52de29f 100644
--- a/externals/grill/flext/source/flattr_ed.cpp
+++ b/externals/grill/flext/source/flattr_ed.cpp
@@ -16,35 +16,54 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT)
+#ifdef PD_DEVEL_VERSION
+#define FLEXT_CLONEWIDGET
+#endif
+
#ifdef _MSC_VER
#pragma warning( disable : 4091 )
#endif
+#ifndef FLEXT_CLONEWIDGET
// This is problematic... non-public headers!
-// compilation may be specific for one version of PD!!
+// compilation is specific for a compiled version!!
#include <m_imp.h>
+#endif
+
#include <g_canvas.h>
#include <string.h>
#include <stdio.h>
static t_widgetbehavior widgetbehavior;
+
+#ifndef FLEXT_CLONEWIDGET
static void (*ori_vis)(t_gobj *c, t_glist *, int vis) = NULL;
+#endif
void flext_base::SetAttrEditor(t_classid c)
{
// widgetbehavior struct MUST be resident... (static is just ok here)
- widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn;
+#ifndef FLEXT_CLONEWIDGET
+ ori_vis = c->c_wb->w_visfn;
+ widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn;
widgetbehavior.w_displacefn = c->c_wb->w_displacefn;
widgetbehavior.w_selectfn = c->c_wb->w_selectfn;
widgetbehavior.w_activatefn = c->c_wb->w_activatefn;
widgetbehavior.w_deletefn = c->c_wb->w_deletefn;
- ori_vis = c->c_wb->w_visfn;
- widgetbehavior.w_visfn = cb_GfxVis;
widgetbehavior.w_clickfn = c->c_wb->w_clickfn;
+#else
+ widgetbehavior.w_getrectfn = text_widgetbehavior.w_getrectfn;
+ widgetbehavior.w_displacefn = text_widgetbehavior.w_displacefn;
+ widgetbehavior.w_selectfn = text_widgetbehavior.w_selectfn;
+ widgetbehavior.w_activatefn = text_widgetbehavior.w_activatefn;
+ widgetbehavior.w_deletefn = text_widgetbehavior.w_deletefn;
+ widgetbehavior.w_clickfn = text_widgetbehavior.w_clickfn;
+#endif
widgetbehavior.w_propertiesfn = cb_GfxProperties;
widgetbehavior.w_savefn = cb_GfxSave;
+ widgetbehavior.w_visfn = cb_GfxVis;
class_setwidget(c, &widgetbehavior);
@@ -120,7 +139,7 @@ void flext_base::SetAttrEditor(t_classid c)
"proc pdtk_flext_dialog {id title attrlist} {\n"
"set vid [string trimleft $id .]\n"
- "set alen [expr [llength $attrlist] / 5 ]\n"
+ "set alen [expr [llength $attrlist] / 6 ]\n"
"toplevel $id\n"
"wm title $id $title\n"
@@ -152,7 +171,7 @@ void flext_base::SetAttrEditor(t_classid c)
"incr row\n"
"set ix 1\n"
- "foreach {an av ai asv afl} $attrlist {\n"
+ "foreach {an av ai atp asv afl} $attrlist {\n"
// get attribute name
"set var_attr_name [concat [concat var_name_$ix]_$vid ]\n"
"global $var_attr_name\n"
@@ -187,13 +206,31 @@ void flext_base::SetAttrEditor(t_classid c)
"if { $afl != 0 } {\n"
// attribute is puttable
+ // entry field for initial value
// entry field for current value
- "entry $id.val-$ix -textvariable $var_attr_val\n"
- "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
- // entry field for initial value
- "entry $id.init-$ix -textvariable $var_attr_init\n"
+ // choose entry field type
+ "switch $atp {\n"
+ "0 - 1 {\n" // int or float
+ "entry $id.init-$ix -textvariable $var_attr_init\n"
+ "entry $id.val-$ix -textvariable $var_attr_val\n"
+ "}\n"
+ "2 {\n" // boolean
+ "checkbutton $id.init-$ix -variable $var_attr_init\n"
+ "checkbutton $id.val-$ix -variable $var_attr_val\n"
+ "}\n"
+ "3 {\n" // symbol
+ "entry $id.init-$ix -textvariable $var_attr_init\n"
+ "entry $id.val-$ix -textvariable $var_attr_val\n"
+ "}\n"
+ "4 - 5 {\n" // list or unknown
+ "entry $id.init-$ix -textvariable $var_attr_init\n"
+ "entry $id.val-$ix -textvariable $var_attr_val\n"
+ "}\n"
+ "}\n"
+
"grid config $id.init-$ix -column 1 -row $row -padx 5 -sticky {ew}\n"
+ "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
"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"
@@ -212,7 +249,24 @@ void flext_base::SetAttrEditor(t_classid c)
// attribute is gettable only
// entry field for current value (read-only)
- "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n"
+
+ // choose display field type
+ "switch $atp {\n"
+ "0 - 1 {\n" // int or float
+ "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n"
+ "}\n"
+ "2 {\n" // boolean
+ "checkbutton $id.val-$ix -variable $var_attr_val -state disabled\n"
+ "}\n"
+ "3 {\n" // symbol
+ "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n"
+ "}\n"
+ "4 - 5 {\n" // list or unknown
+ "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n"
+ "}\n"
+ "}\n"
+
+// "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n"
"grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
"label $id.readonly-$ix -text \"read-only\"\n"
@@ -293,6 +347,12 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
for(int i = 0; i < cnt; ++i) {
const t_symbol *sym = GetSymbol(la[i]);
+ const char *bcur = b;
+
+ // get attribute
+ AttrItem *gattr = th->FindAttrib(sym,true);
+ // get puttable attribute
+ AttrItem *pattr = gattr?gattr->Counterpart():th->FindAttrib(sym,false);
// get flags
int sv;
@@ -308,14 +368,25 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
sv = 1;
else
sv = 0;
-
initdata = a.IsInitValue()?&a.GetInitValue():NULL;
}
- STD::sprintf(b,"%s {",GetString(sym)); b += strlen(b);
+ // get attribute type
+ int tp;
+ bool list;
+ switch((gattr?gattr:pattr)->argtp) {
+ case a_int: tp = 0; list = false; break;
+ case a_float: tp = 1; list = false; break;
+ case a_bool: tp = 2; list = false; break;
+ case a_symbol: tp = 3; list = true; break;
+ case a_list:
+ case a_LIST: tp = 4; list = true; break;
+ default:
+ tp = 5; list = true;
+ FLEXT_ASSERT(false);
+ }
- // get attribute
- AttrItem *gattr = th->FindAttrib(sym,true);
+ STD::sprintf(b,list?"%s {":"%s ",GetString(sym)); b += strlen(b);
AtomList lv;
if(gattr) { // gettable attribute is present
@@ -324,11 +395,11 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
b += PrintList(b,lv.Count(),lv.Atoms());
}
+ else {
+ strcpy(b,"{}"); b += strlen(b);
+ }
- STD::sprintf(b, "} {"); b += strlen(b);
-
- // get puttable attribute
- AttrItem *pattr = gattr->Counterpart();
+ strcpy(b, list?"} {":" "); b += strlen(b);
if(pattr) {
// if there is initialization data take this, otherwise take the current data
@@ -336,8 +407,12 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
b += PrintList(b,lp.Count(),lp.Atoms());
}
+ else {
+ strcpy(b,"{}"); b += strlen(b);
+ }
+
- STD::sprintf(b, "} %i %i ", sv,pattr?(pattr->BothExist()?2:1):0); b += strlen(b);
+ STD::sprintf(b, list?"} %i %i %i ":" %i %i %i ",tp,sv,pattr?(pattr->BothExist()?2:1):0); b += strlen(b);
}
strcpy(b, " }\n");
@@ -348,8 +423,8 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
//! Strip the attributes off the object command line
void flext_base::cb_GfxVis(t_gobj *c, t_glist *gl, int vis)
{
- flext_base *th = thisObject(c);
- t_text *x = (t_text *)th->thisHdr();
+ t_text *x = (t_text *)c;
+
FLEXT_ASSERT(x->te_binbuf);
int argc = binbuf_getnatom(x->te_binbuf);
@@ -363,7 +438,14 @@ void flext_base::cb_GfxVis(t_gobj *c, t_glist *gl, int vis)
x->te_binbuf = nb;
}
+ t_rtext *rt = glist_findrtext(gl,x);
+ rtext_retext(rt);
+
+#ifdef FLEXT_CLONEWIDGET
+ text_widgetbehavior.w_visfn(c,gl,vis);
+#else
ori_vis(c,gl,vis);
+#endif
}
static void BinbufAdd(t_binbuf *b,const t_atom &at)