OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tix/] [generic/] [tixGrRC.c] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tixGrRC.c --
3
 *
4
 *      This module handles "size" sub-commands.
5
 *
6
 * Copyright (c) 1996, Expert Interface Technologies
7
 *
8
 * See the file "license.terms" for information on usage and redistribution
9
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
 *
11
 */
12
 
13
#include <tixPort.h>
14
#include <tixInt.h>
15
#include <tixDef.h>
16
#include <tixGrid.h>
17
 
18
static TIX_DECLARE_SUBCMD(Tix_GrRCSize);
19
EXTERN TIX_DECLARE_SUBCMD(Tix_GrSetSize);
20
 
21
int
22
Tix_GrSetSize(clientData, interp, argc, argv)
23
    ClientData clientData;
24
    Tcl_Interp *interp;         /* Current interpreter. */
25
    int argc;                   /* Number of arguments. */
26
    char **argv;                /* Argument strings. */
27
{
28
    static Tix_SubCmdInfo subCmdInfo[] = {
29
        {TIX_DEFAULT_LEN, "row",    1, TIX_VAR_ARGS, Tix_GrRCSize,
30
           "index ?option value ...?"},
31
        {TIX_DEFAULT_LEN, "column", 1, TIX_VAR_ARGS, Tix_GrRCSize,
32
           "index ?option value ...?"},
33
    };
34
    static Tix_CmdInfo cmdInfo = {
35
        Tix_ArraySize(subCmdInfo), 1, TIX_VAR_ARGS, "option index ?arg ...?",
36
    };
37
 
38
    return Tix_HandleSubCmds(&cmdInfo, subCmdInfo, clientData,
39
        interp, argc+1, argv-1);
40
}
41
 
42
 
43
static int
44
Tix_GrRCSize(clientData, interp, argc, argv)
45
    ClientData clientData;
46
    Tcl_Interp *interp;         /* Current interpreter. */
47
    int argc;                   /* Number of arguments. */
48
    char **argv;                /* Argument strings. */
49
{
50
    WidgetPtr wPtr = (WidgetPtr) clientData;
51
    int which, index, code;
52
    char errorMsg[300];
53
    int changed;
54
 
55
    if (argv[-1][0] == 'c') {
56
        which = 0;
57
    } else {
58
        which = 1;
59
    }
60
    if (Tcl_GetInt(interp, argv[0], &index) != TCL_OK) {
61
        size_t len = strlen(argv[0]);
62
 
63
        Tcl_ResetResult(interp);
64
        if (strncmp(argv[0], "default", len)!=0) {
65
            Tcl_AppendResult(interp, "unknown option \"", argv[0],
66
                "\"; must be an integer or \"default\"", NULL);
67
            return TCL_ERROR;
68
        } else {
69
            /* Setting the default sizes */
70
            sprintf(errorMsg, "%s %s ?option value ...?", argv[-2], argv[-1]);
71
 
72
            code = Tix_GrConfigSize(interp, wPtr, argc-1, argv+1,
73
                &wPtr->defSize[which],errorMsg, &changed);
74
 
75
            /* Handling special cases */
76
            if (code == TCL_OK) {
77
                switch (wPtr->defSize[which].sizeType) {
78
                  case TIX_GR_DEFAULT:
79
                    wPtr->defSize[which].sizeType = TIX_GR_DEFINED_CHAR;
80
                    if (which == 0) {
81
                        wPtr->defSize[which].charValue = 10.0;
82
                    } else {
83
                        wPtr->defSize[which].charValue = 1.1;
84
                    }
85
                }
86
 
87
                switch (wPtr->defSize[which].sizeType) {
88
                  case TIX_GR_DEFINED_PIXEL:
89
                    wPtr->defSize[which].pixels=wPtr->defSize[which].sizeValue;
90
                    break;
91
 
92
                  case TIX_GR_DEFINED_CHAR:
93
                    wPtr->defSize[which].pixels =
94
                       (int)(wPtr->defSize[which].charValue *
95
                             wPtr->fontSize[which]);
96
                    break;
97
                }
98
            }
99
        }
100
    } else {
101
        sprintf(errorMsg, "%s %s ?option value ...?", argv[-2], argv[-1]);
102
 
103
        code = TixGridDataConfigRowColSize(interp, wPtr, wPtr->dataSet,
104
            which, index, argc-1, argv+1, errorMsg, &changed);
105
    }
106
 
107
    if (changed) {
108
        Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE);
109
    }
110
 
111
    return code;
112
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.