diff options
-rw-r--r-- | generic/Attrs.c | 115 | ||||
-rw-r--r-- | generic/Attrs.h | 9 |
2 files changed, 123 insertions, 1 deletions
diff --git a/generic/Attrs.c b/generic/Attrs.c index 45d7dc8..c3e48ad 100644 --- a/generic/Attrs.c +++ b/generic/Attrs.c @@ -31,6 +31,7 @@ #include "Item.h" #include "List.h" #include "Geo.h" +#include "WidgetInfo.h" #include <memory.h> #include <malloc.h> @@ -124,6 +125,120 @@ CharToDim(char dim) } /* + **************************************************************** + * + * Code for reliefs. + * + **************************************************************** + */ +#define RELIEF_FLAT_SPEC "flat" +#define RELIEF_RAISED_SPEC "raised" +#define RELIEF_SUNKEN_SPEC "sunken" +#define RELIEF_GROOVE_SPEC "groove" +#define RELIEF_RIDGE_SPEC "ridge" +#define RELIEF_ROUND_RAISED_SPEC "roundraised" +#define RELIEF_ROUND_SUNKEN_SPEC "roundsunken" +#define RELIEF_ROUND_GROOVE_SPEC "roundgroove" +#define RELIEF_ROUND_RIDGE_SPEC "roundridge" +#define RELIEF_SUNKEN_RULE_SPEC "sunkenrule" +#define RELIEF_RAISED_RULE_SPEC "raisedrule" + +int +ZnGetRelief(WidgetInfo *wi, + char *name, + ReliefStyle *relief) +{ + size_t length; + + length = strlen(name); + if (strncasecmp(name, RELIEF_FLAT_SPEC, length) == 0) { + *relief = RELIEF_FLAT; + } + else if (strncasecmp(name, RELIEF_SUNKEN_SPEC, length) == 0) { + *relief = RELIEF_SUNKEN; + } + else if ((strncasecmp(name, RELIEF_RAISED_SPEC, length) == 0) && (length >= 2)) { + *relief = RELIEF_RAISED; + } + else if ((strncasecmp(name, RELIEF_RIDGE_SPEC, length) == 0) && (length >= 2)) { + *relief = RELIEF_RIDGE; + } + else if (strncasecmp(name, RELIEF_GROOVE_SPEC, length) == 0) { + *relief = RELIEF_GROOVE; + } + else if ((strncasecmp(name, RELIEF_ROUND_SUNKEN_SPEC, length) == 0) && (length >= 6)) { + *relief = RELIEF_ROUND_SUNKEN; + } + else if ((strncasecmp(name, RELIEF_ROUND_RAISED_SPEC, length) == 0) && (length >= 7)) { + *relief = RELIEF_ROUND_RAISED; + } + else if ((strncasecmp(name, RELIEF_ROUND_RIDGE_SPEC, length) == 0) && (length >= 7)) { + *relief = RELIEF_ROUND_RIDGE; + } + else if ((strncasecmp(name, RELIEF_ROUND_GROOVE_SPEC, length) == 0) && (length >= 6)) { + *relief = RELIEF_ROUND_GROOVE; + } + else if ((strncasecmp(name, RELIEF_SUNKEN_RULE_SPEC, length) == 0) && (length >= 7)) { + *relief = RELIEF_SUNKEN_RULE; + } + else if ((strncasecmp(name, RELIEF_RAISED_RULE_SPEC, length) == 0) && (length >= 7)) { + *relief = RELIEF_RAISED_RULE; + } + else { + Tcl_AppendResult(wi->interp, "bad relief type \"", name, "\": must be ", + RELIEF_FLAT_SPEC, ", ", + RELIEF_RAISED_SPEC, ", ", + RELIEF_SUNKEN_SPEC, ", ", + RELIEF_GROOVE_SPEC, ", ", + RELIEF_RIDGE_SPEC, ", ", + RELIEF_ROUND_RAISED_SPEC, ", ", + RELIEF_ROUND_SUNKEN_SPEC, ", ", + RELIEF_ROUND_GROOVE_SPEC, ", ", + RELIEF_ROUND_RIDGE_SPEC, ", ", + RELIEF_SUNKEN_RULE_SPEC, ", ", + RELIEF_RAISED_RULE_SPEC, + NULL); + return ZN_ERROR; + } + if (!wi->render) { + *relief = *relief & ~(RELIEF_ROUND|RELIEF_RULE); + } + + return ZN_OK; +} + +char * +ZnNameOfRelief(ReliefStyle relief) +{ + switch (relief) { + case RELIEF_FLAT: + return RELIEF_FLAT_SPEC; + case RELIEF_SUNKEN: + return RELIEF_SUNKEN_SPEC; + case RELIEF_RAISED: + return RELIEF_RAISED_SPEC; + case RELIEF_GROOVE: + return RELIEF_GROOVE_SPEC; + case RELIEF_RIDGE: + return RELIEF_RIDGE_SPEC; + case RELIEF_ROUND_SUNKEN: + return RELIEF_ROUND_SUNKEN_SPEC; + case RELIEF_ROUND_RAISED: + return RELIEF_ROUND_RAISED_SPEC; + case RELIEF_ROUND_GROOVE: + return RELIEF_ROUND_GROOVE_SPEC; + case RELIEF_ROUND_RIDGE: + return RELIEF_ROUND_RIDGE_SPEC; + case RELIEF_SUNKEN_RULE: + return RELIEF_SUNKEN_RULE_SPEC; + case RELIEF_RAISED_RULE: + return RELIEF_RAISED_RULE_SPEC; + default: + return "unknown relief"; + } +} + +/* * The new format is as follow. Parameters between [] are * optional and take default values when omitted. The spaces can appear * between blocks but not inside. diff --git a/generic/Attrs.h b/generic/Attrs.h index 85583fd..25d377d 100644 --- a/generic/Attrs.h +++ b/generic/Attrs.h @@ -38,6 +38,8 @@ extern "C" { #include <Types.h> +struct _WidgetInfo; + /* * Label Formats. */ @@ -76,7 +78,7 @@ typedef struct { int ref_count; ZnFieldFormatStruct fields[1]; } ZnLabelFormatStruct, *ZnLabelFormat; - + ZnLabelFormat LabelFormatCreate(Tcl_Interp * /* interp */, @@ -126,6 +128,11 @@ LineEndDelete(ZnLineEnd le); char * LineEndGetString(ZnLineEnd le); +int +ZnGetRelief(struct _WidgetInfo *wi, char *name, ReliefStyle *relief); +char * +ZnNameOfRelief(ReliefStyle relief); + #ifdef __CPLUSPLUS__ } |