aboutsummaryrefslogtreecommitdiff
path: root/generic/Tabular.c
diff options
context:
space:
mode:
authorlecoanet2000-06-21 14:52:18 +0000
committerlecoanet2000-06-21 14:52:18 +0000
commit43552eb9d326fc58013f72ad7acbdf2de04610e6 (patch)
tree6e7d1e3201b54931527f5bb82b0f1120c8f3aa09 /generic/Tabular.c
parenta5b3e7c2a66c9d2424f9e86a42b6e3a1de4a72ad (diff)
downloadtkzinc-43552eb9d326fc58013f72ad7acbdf2de04610e6.zip
tkzinc-43552eb9d326fc58013f72ad7acbdf2de04610e6.tar.gz
tkzinc-43552eb9d326fc58013f72ad7acbdf2de04610e6.tar.bz2
tkzinc-43552eb9d326fc58013f72ad7acbdf2de04610e6.tar.xz
Implentation de la m�thode Part afin de permettre d'utiliser des
noms symboliques pour associer des bindings aux parties priv�es (connexion, guideur, ...).
Diffstat (limited to 'generic/Tabular.c')
-rw-r--r--generic/Tabular.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/generic/Tabular.c b/generic/Tabular.c
index 00bd019..8f179e0 100644
--- a/generic/Tabular.c
+++ b/generic/Tabular.c
@@ -33,6 +33,9 @@
#include "Geo.h"
#include "tkZinc.h"
+#include <ctype.h>
+#include <stdlib.h>
+
static const char rcsid[] = "$Id$";
static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $";
@@ -495,6 +498,52 @@ Coords(Item item,
/*
**********************************************************************************
*
+ * Part --
+ * Convert a private part from/to symbolic representation.
+ *
+ **********************************************************************************
+ */
+static int
+Part(Item item,
+ Tcl_Obj **part_spec,
+ int *part)
+{
+ char *part_str;
+ char *end;
+
+ if (*part_spec) {
+ part_str = Tcl_GetString(*part_spec);
+ if (strlen(part_str) == 0) {
+ *part = ZN_NO_PART;
+ }
+ else if (isdigit(part_str[0])) {
+ *part = strtol(part_str, &end, 0);
+ if ((*end != 0) || (*part < 0) ||
+ (*part >= ((TabularItem) item)->field_set.num_fields)) {
+ goto part_error;
+ }
+ }
+ else {
+ part_error:
+ Tcl_AppendResult(item->wi->interp, " invalid item part specification", NULL);
+ return ZN_ERROR;
+ }
+ }
+ else {
+ if (*part >= 0) {
+ *part_spec = Tcl_NewIntObj(*part);
+ }
+ else {
+ *part_spec = NewStringObj("");
+ }
+ }
+ return ZN_OK;
+}
+
+
+/*
+ **********************************************************************************
+ *
* Exported functions structs --
*
**********************************************************************************
@@ -502,7 +551,7 @@ Coords(Item item,
static ItemClassStruct TABULAR_ITEM_CLASS = {
sizeof(TabularItemStruct),
True, /* has_fields */
- False, /* has_parts */
+ 0, /* num_parts */
True, /* has_anchors */
"tabular",
tabular_attrs,
@@ -519,6 +568,7 @@ static ItemClassStruct TABULAR_ITEM_CLASS = {
NULL, /* DeleteChars */
NULL, /* Cursor */
NULL, /* Index */
+ Part,
NULL, /* Selection */
NULL, /* Contour */
ComputeCoordinates,