| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "tixPort.h" |
| 17 |
#include "tixInt.h" |
| 18 |
#include "tixDef.h" |
| 19 |
#include "tixGrid.h" |
| 20 |
|
| 21 |
static TIX_DECLARE_SUBCMD(Tix_GrRCSize); |
| 22 |
EXTERN TIX_DECLARE_SUBCMD(Tix_GrSetSize); |
| 23 |
|
| 24 |
int |
| 25 |
Tix_GrSetSize(clientData, interp, argc, argv) |
| 26 |
ClientData clientData; |
| 27 |
Tcl_Interp *interp; |
| 28 |
int argc; |
| 29 |
char **argv; |
| 30 |
{ |
| 31 |
static Tix_SubCmdInfo subCmdInfo[] = { |
| 32 |
{TIX_DEFAULT_LEN, "row", 1, TIX_VAR_ARGS, Tix_GrRCSize, |
| 33 |
"index ?option value ...?"}, |
| 34 |
{TIX_DEFAULT_LEN, "column", 1, TIX_VAR_ARGS, Tix_GrRCSize, |
| 35 |
"index ?option value ...?"}, |
| 36 |
}; |
| 37 |
static Tix_CmdInfo cmdInfo = { |
| 38 |
Tix_ArraySize(subCmdInfo), 1, TIX_VAR_ARGS, "option index ?arg ...?", |
| 39 |
}; |
| 40 |
|
| 41 |
return Tix_HandleSubCmds(&cmdInfo, subCmdInfo, clientData, |
| 42 |
interp, argc+1, argv-1); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
static int |
| 47 |
Tix_GrRCSize(clientData, interp, argc, argv) |
| 48 |
ClientData clientData; |
| 49 |
Tcl_Interp *interp; |
| 50 |
int argc; |
| 51 |
char **argv; |
| 52 |
{ |
| 53 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 54 |
int which, index, code; |
| 55 |
char errorMsg[300]; |
| 56 |
int changed; |
| 57 |
|
| 58 |
if (argv[-1][0] == 'c') { |
| 59 |
which = 0; |
| 60 |
} else { |
| 61 |
which = 1; |
| 62 |
} |
| 63 |
if (Tcl_GetIntFromObj(interp, argv[0], &index) != TCL_OK) { |
| 64 |
size_t len = strlen(argv[0]); |
| 65 |
|
| 66 |
Tcl_ResetResult(interp); |
| 67 |
if (strncmp(argv[0], "default", len)!=0) { |
| 68 |
Tcl_AppendResult(interp, "unknown option \"", argv[0], |
| 69 |
"\"; must be an integer or \"default\"", NULL); |
| 70 |
return TCL_ERROR; |
| 71 |
} else { |
| 72 |
|
| 73 |
sprintf(errorMsg, "%s %s ?option value ...?", argv[-2], argv[-1]); |
| 74 |
|
| 75 |
code = Tix_GrConfigSize(interp, wPtr, argc-1, argv+1, |
| 76 |
&wPtr->defSize[which],errorMsg, &changed); |
| 77 |
|
| 78 |
|
| 79 |
if (code == TCL_OK) { |
| 80 |
switch (wPtr->defSize[which].sizeType) { |
| 81 |
case TIX_GR_DEFAULT: |
| 82 |
wPtr->defSize[which].sizeType = TIX_GR_DEFINED_CHAR; |
| 83 |
if (which == 0) { |
| 84 |
wPtr->defSize[which].charValue = 10.0; |
| 85 |
} else { |
| 86 |
wPtr->defSize[which].charValue = 1.1; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
switch (wPtr->defSize[which].sizeType) { |
| 91 |
case TIX_GR_DEFINED_PIXEL: |
| 92 |
wPtr->defSize[which].pixels=wPtr->defSize[which].sizeValue; |
| 93 |
break; |
| 94 |
|
| 95 |
case TIX_GR_DEFINED_CHAR: |
| 96 |
wPtr->defSize[which].pixels = |
| 97 |
(int)(wPtr->defSize[which].charValue * |
| 98 |
wPtr->fontSize[which]); |
| 99 |
break; |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
} else { |
| 104 |
sprintf(errorMsg, "%s %s ?option value ...?", argv[-2], argv[-1]); |
| 105 |
|
| 106 |
code = TixGridDataConfigRowColSize(interp, wPtr, wPtr->dataSet, |
| 107 |
which, index, argc-1, argv+1, errorMsg, &changed); |
| 108 |
} |
| 109 |
|
| 110 |
if (changed) { |
| 111 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 112 |
} |
| 113 |
|
| 114 |
return code; |
| 115 |
} |