Posted to tcl by kevin_walzer at Mon Aug 02 14:29:15 GMT 2010view raw
- int
- TkStateParseProc(clientData, interp, tkwin, value, widgRec, offset)
- ClientData clientData; /* some flags.*/
- Tcl_Interp *interp; /* Used for reporting errors. */
- Tk_Window tkwin; /* Window containing canvas widget. */
- CONST char *value; /* Value of option. */
- char *widgRec; /* Pointer to record for item. */
- int offset; /* Offset into item. */
- {
- int c;
- int flags = (int)clientData;
- size_t length;
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
- if(value == NULL || *value == 0) {
- *statePtr = TK_STATE_NULL;
- return TCL_OK;
- }
- c = value[0];
- length = strlen(value);
- if ((c == 'n') && (strncmp(value, "normal", length) == 0)) {
- *statePtr = TK_STATE_NORMAL;
- return TCL_OK;
- }
- if ((c == 'd') && (strncmp(value, "disabled", length) == 0)) {
- *statePtr = TK_STATE_DISABLED;
- return TCL_OK;
- }
- if ((c == 'a') && (flags&1) && (strncmp(value, "active", length) == 0)) {
- *statePtr = TK_STATE_ACTIVE;
- return TCL_OK;
- }
- if ((c == 'h') && (flags&2) && (strncmp(value, "hidden", length) == 0)) {
- *statePtr = TK_STATE_HIDDEN;
- return TCL_OK;
- }
- Tcl_AppendResult(interp, "bad ", (flags&4)?"-default" : "state",
- " value \"", value, "\": must be normal",
- (char *) NULL);
- if (flags&1) {
- Tcl_AppendResult(interp, ", active",(char *) NULL);
- }
- if (flags&2) {
- Tcl_AppendResult(interp, ", hidden",(char *) NULL);
- }
- if (flags&3) {
- Tcl_AppendResult(interp, ",",(char *) NULL);
- }
- Tcl_AppendResult(interp, " or disabled",(char *) NULL);
- *statePtr = TK_STATE_NORMAL;
- return TCL_ERROR;
- }