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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [generic/] [tixHLInd.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 *  tixHLInd.c ---
3
 *
4
 *      Implements indicators inside tixHList widgets
5
 *
6
 * Copyright (c) 1994-1995 Ioi Kim Lam. All rights reserved.
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 <tixHList.h>
16
 
17
static TIX_DECLARE_SUBCMD(Tix_HLIndCreate);
18
static TIX_DECLARE_SUBCMD(Tix_HLIndConfig);
19
static TIX_DECLARE_SUBCMD(Tix_HLIndCGet);
20
static TIX_DECLARE_SUBCMD(Tix_HLIndDelete);
21
static TIX_DECLARE_SUBCMD(Tix_HLIndExists);
22
static TIX_DECLARE_SUBCMD(Tix_HLIndSize);
23
 
24
 
25
/*----------------------------------------------------------------------
26
 * "indicator" sub command
27
 *----------------------------------------------------------------------
28
 */
29
int
30
Tix_HLIndicator(clientData, interp, argc, argv)
31
    ClientData clientData;
32
    Tcl_Interp *interp;         /* Current interpreter. */
33
    int argc;                   /* Number of arguments. */
34
    char **argv;                /* Argument strings. */
35
{
36
    static Tix_SubCmdInfo subCmdInfo[] = {
37
        {TIX_DEFAULT_LEN, "cget", 2, 2, Tix_HLIndCGet,
38
           "entryPath option"},
39
        {TIX_DEFAULT_LEN, "configure", 1, TIX_VAR_ARGS, Tix_HLIndConfig,
40
           "entryPath ?option? ?value ...?"},
41
        {TIX_DEFAULT_LEN, "create", 1, TIX_VAR_ARGS, Tix_HLIndCreate,
42
           "entryPath ?option value ...?"},
43
        {TIX_DEFAULT_LEN, "delete", 1, 1, Tix_HLIndDelete,
44
           "entryPath"},
45
        {TIX_DEFAULT_LEN, "exists", 1, 1, Tix_HLIndExists,
46
           "entryPath"},
47
        {TIX_DEFAULT_LEN, "size", 1, 1, Tix_HLIndSize,
48
           "entryPath"},
49
    };
50
    static Tix_CmdInfo cmdInfo = {
51
        Tix_ArraySize(subCmdInfo), 1, TIX_VAR_ARGS, "?option? ?arg ...?",
52
    };
53
 
54
    return Tix_HandleSubCmds(&cmdInfo, subCmdInfo, clientData,
55
        interp, argc+1, argv-1);
56
}
57
 
58
/*----------------------------------------------------------------------
59
 * "indicator cget" sub command
60
 *----------------------------------------------------------------------
61
 */
62
static int
63
Tix_HLIndCGet(clientData, interp, argc, argv)
64
    ClientData clientData;
65
    Tcl_Interp *interp;         /* Current interpreter. */
66
    int argc;                   /* Number of arguments. */
67
    char **argv;                /* Argument strings. */
68
{
69
    WidgetPtr wPtr = (WidgetPtr) clientData;
70
    HListElement * chPtr;
71
 
72
    if ((chPtr = Tix_HLFindElement(interp, wPtr, argv[0])) == NULL) {
73
        return TCL_ERROR;
74
    }
75
    if (chPtr->indicator == NULL) {
76
        Tcl_AppendResult(interp, "entry \"", argv[0],
77
            "\" does not have an indicator", (char*)NULL);
78
        return TCL_ERROR;
79
    }
80
    return Tk_ConfigureValue(interp, wPtr->dispData.tkwin,
81
        chPtr->indicator->base.diTypePtr->itemConfigSpecs,
82
        (char *)chPtr->indicator, argv[1], 0);
83
}
84
 
85
/*----------------------------------------------------------------------
86
 * "indicator configure" sub command
87
 *----------------------------------------------------------------------
88
 */
89
static int
90
Tix_HLIndConfig(clientData, interp, argc, argv)
91
    ClientData clientData;
92
    Tcl_Interp *interp;         /* Current interpreter. */
93
    int argc;                   /* Number of arguments. */
94
    char **argv;                /* Argument strings. */
95
{
96
    WidgetPtr wPtr = (WidgetPtr) clientData;
97
    HListElement * chPtr;
98
 
99
    if ((chPtr = Tix_HLFindElement(interp, wPtr, argv[0])) == NULL) {
100
        return TCL_ERROR;
101
    }
102
    if (chPtr->indicator == NULL) {
103
        Tcl_AppendResult(interp, "entry \"", argv[0],
104
            "\" does not have an indicator", (char*)NULL);
105
        return TCL_ERROR;
106
    }
107
    if (argc == 1) {
108
        return Tk_ConfigureInfo(interp, wPtr->dispData.tkwin,
109
            chPtr->indicator->base.diTypePtr->itemConfigSpecs,
110
            (char *)chPtr->indicator, NULL, 0);
111
    } else if (argc == 2) {
112
        return Tk_ConfigureInfo(interp, wPtr->dispData.tkwin,
113
            chPtr->indicator->base.diTypePtr->itemConfigSpecs,
114
            (char *)chPtr->indicator, argv[1], 0);
115
    } else {
116
        Tix_HLMarkElementDirty(wPtr, chPtr);
117
        Tix_HLResizeWhenIdle(wPtr);
118
 
119
        return Tix_DItemConfigure(chPtr->indicator,
120
            argc-1, argv+1, TK_CONFIG_ARGV_ONLY);
121
    }
122
}
123
 
124
/*----------------------------------------------------------------------
125
 * "indicator create" sub command
126
 *----------------------------------------------------------------------
127
 */
128
static int
129
Tix_HLIndCreate(clientData, interp, argc, argv)
130
    ClientData clientData;
131
    Tcl_Interp *interp;         /* Current interpreter. */
132
    int argc;                   /* Number of arguments. */
133
    char **argv;                /* Argument strings. */
134
{
135
    WidgetPtr wPtr = (WidgetPtr) clientData;
136
    HListElement * chPtr;
137
    int i;
138
    size_t len;
139
    Tix_DItem * iPtr;
140
    char * ditemType = NULL;
141
 
142
    if ((chPtr = Tix_HLFindElement(interp, wPtr, argv[0])) == NULL) {
143
        return TCL_ERROR;
144
    }
145
    if ((argc %2) == 0) {
146
        Tcl_AppendResult(interp, "value for \"", argv[argc-1],
147
            "\" missing", NULL);
148
        return TCL_ERROR;
149
    }
150
    for (i=1; i<argc; i+=2) {
151
        len = strlen(argv[i]);
152
        if (strncmp(argv[i], "-itemtype", len) == 0) {
153
            ditemType = argv[i+1];
154
        }
155
    }
156
    if (ditemType == NULL) {
157
        ditemType = wPtr->diTypePtr->name;
158
    }
159
 
160
    iPtr = Tix_DItemCreate(&wPtr->dispData, ditemType);
161
    if (iPtr == NULL) {
162
        return TCL_ERROR;
163
    }
164
    if (Tix_DItemType(iPtr) == TIX_DITEM_WINDOW) {
165
        wPtr->needToRaise = 1;
166
    }
167
 
168
    iPtr->base.clientData = (ClientData)chPtr;
169
    if (Tix_DItemConfigure(iPtr, argc-1, argv+1, 0) != TCL_OK) {
170
        return TCL_ERROR;
171
    }
172
 
173
    if (chPtr->indicator != NULL) {
174
        if (Tix_DItemType(chPtr->indicator) == TIX_DITEM_WINDOW) {
175
            Tix_WindowItemListRemove(&wPtr->mappedWindows,
176
                chPtr->indicator);
177
        }
178
        Tix_DItemFree(chPtr->indicator);
179
    }
180
    chPtr->indicator = iPtr;
181
    Tix_HLMarkElementDirty(wPtr, chPtr);
182
    Tix_HLResizeWhenIdle(wPtr);
183
 
184
    return TCL_OK;
185
}
186
/*----------------------------------------------------------------------
187
 * "indicator delete" sub command
188
 *----------------------------------------------------------------------
189
 */
190
static int
191
Tix_HLIndDelete(clientData, interp, argc, argv)
192
    ClientData clientData;
193
    Tcl_Interp *interp;         /* Current interpreter. */
194
    int argc;                   /* Number of arguments. */
195
    char **argv;                /* Argument strings. */
196
{
197
    WidgetPtr wPtr = (WidgetPtr) clientData;
198
    HListElement * chPtr;
199
 
200
    if ((chPtr = Tix_HLFindElement(interp, wPtr, argv[0])) == NULL) {
201
        return TCL_ERROR;
202
    }
203
    if (chPtr->indicator == NULL) {
204
        Tcl_AppendResult(interp, "entry \"", argv[0],
205
            "\" does not have an indicator", (char*)NULL);
206
        return TCL_ERROR;
207
    }
208
 
209
    if (Tix_DItemType(chPtr->indicator) == TIX_DITEM_WINDOW) {
210
        Tix_WindowItemListRemove(&wPtr->mappedWindows,
211
            chPtr->indicator);
212
    }
213
 
214
    /* Free the item and leave a blank! */
215
 
216
    Tix_DItemFree(chPtr->indicator);
217
    chPtr->indicator = NULL;
218
 
219
    Tix_HLMarkElementDirty(wPtr, chPtr);
220
    Tix_HLResizeWhenIdle(wPtr);
221
 
222
    return TCL_OK;
223
}
224
/*----------------------------------------------------------------------
225
 * "indicator exists" sub command
226
 *----------------------------------------------------------------------
227
 */
228
static int
229
Tix_HLIndExists(clientData, interp, argc, argv)
230
    ClientData clientData;
231
    Tcl_Interp *interp;         /* Current interpreter. */
232
    int argc;                   /* Number of arguments. */
233
    char **argv;                /* Argument strings. */
234
{
235
    WidgetPtr wPtr = (WidgetPtr) clientData;
236
    HListElement * chPtr;
237
 
238
    if ((chPtr = Tix_HLFindElement(interp, wPtr, argv[0])) == NULL) {
239
        return TCL_ERROR;
240
    }
241
    if (chPtr->indicator == NULL) {
242
        Tcl_AppendResult(interp, "0", NULL);
243
    } else {
244
        Tcl_AppendResult(interp, "1", NULL);
245
    }
246
 
247
    return TCL_OK;
248
}
249
 
250
/*----------------------------------------------------------------------
251
 * "indicator size" sub command
252
 *----------------------------------------------------------------------
253
 */
254
static int
255
Tix_HLIndSize(clientData, interp, argc, argv)
256
    ClientData clientData;
257
    Tcl_Interp *interp;         /* Current interpreter. */
258
    int argc;                   /* Number of arguments. */
259
    char **argv;                /* Argument strings. */
260
{
261
    WidgetPtr wPtr = (WidgetPtr) clientData;
262
    HListElement * chPtr;
263
    char buff[100];
264
 
265
    if ((chPtr = Tix_HLFindElement(interp, wPtr, argv[0])) == NULL) {
266
        return TCL_ERROR;
267
    }
268
    if (chPtr->indicator == NULL) {
269
        Tcl_AppendResult(interp, "entry \"", argv[0],
270
            "\" does not have an indicator", (char*)NULL);
271
        return TCL_ERROR;
272
    }
273
    sprintf(buff, "%d %d",
274
        Tix_DItemWidth(chPtr->indicator),
275
        Tix_DItemHeight(chPtr->indicator));
276
    Tcl_AppendResult(interp, buff, NULL);
277
    return TCL_OK;
278
}

powered by: WebSVN 2.1.0

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