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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tix/] [generic/] [tixGrid.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tixGrid.h --
3
 *
4
 *      Defines main data structures for tixGrid
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
#ifndef _TIX_GRID_H_
14
#define _TIX_GRID_H_
15
 
16
#ifndef _TIX_GRID_DATA_H_
17
#include "tixGrData.h"
18
#endif
19
 
20
#ifdef BUILD_tix
21
# undef TCL_STORAGE_CLASS
22
# define TCL_STORAGE_CLASS DLLEXPORT
23
#endif
24
 
25
#define TIX_X 0
26
#define TIX_Y 1
27
 
28
 
29
#define TIX_S_MARGIN 0
30
#define TIX_X_MARGIN 1
31
#define TIX_Y_MARGIN 2
32
#define TIX_MAIN     3
33
 
34
#define TIX_SITE_NONE -1
35
 
36
typedef struct TixGrEntry {
37
    Tix_DItem * iPtr;
38
    Tcl_HashEntry * entryPtr[2];        /* The index of this entry in the
39
                                         * row/col tables */
40
} TixGrEntry;
41
 
42
/*----------------------------------------------------------------------
43
 *                      Render Block
44
 *
45
 * Before the Grid is rendered, information is filled into a pseudo 2D
46
 * array of RenderBlockElem's:
47
 *
48
 *      (1) entries are placed in the appropriate (x,y) locations
49
 *      (2) background and borders are formatted according
50
 *      (3) highlights are formatted.
51
 *
52
 * The widget is redrawn using the render-block. This saves reformatting
53
 * the next time the widget is exposed.
54
 *----------------------------------------------------------------------
55
 */
56
typedef struct RenderBlockElem {
57
    TixGrEntry * chPtr;         /* not allocated, don't need to free */
58
    int borderW[2][2];
59
    int index[2];
60
 
61
    unsigned int selected : 1;
62
    unsigned int filled : 1;
63
} RenderBlockElem;
64
 
65
 
66
/* ElmDispSize --
67
 *
68
 *      This structure stores the size information of the visible
69
 *      rows (RenderBlock.dispSize[0][...]) and columns
70
 *      (RenderBlock.dispSize[1][...])
71
 */
72
typedef struct ElmDispSize {
73
    int preBorder;
74
    int size;
75
    int postBorder;
76
 
77
    int total;          /* simple the sum of the above */
78
} ElmDispSize;
79
 
80
typedef struct RenderBlock {
81
    int size[2];                /* num of rows and cols in the render block */
82
 
83
    RenderBlockElem **elms;     /* An Malloc'ed pseudo 2D array (you can do
84
                                 * things like elms[0][0]), Used for the
85
                                 * main body of the Grid.
86
                                 */
87
    ElmDispSize *dispSize[2];   /* (dispSizes[0][x], dispSizes[1][y])
88
                                 * will be the dimension of the element (x,y)
89
                                 * displayed on the screen (may be bigger
90
                                 * or smaller than its desired size). */
91
    int visArea[2];             /* visible area (width times height) of
92
                                 * the visible cells on the screen */
93
}  RenderBlock;
94
 
95
/*----------------------------------------------------------------------
96
 *                      RenderInfo
97
 *
98
 * This stores information for rendering from the RB into an X drawable.
99
 *
100
 *----------------------------------------------------------------------
101
 */
102
typedef struct RenderInfo {
103
    Drawable drawable;
104
    int origin[2];
105
    int offset[2];
106
    int size[2];                /* width and height of the area to draw
107
                                 * (number of pixels starting from the offset)
108
                                 * if offset = (2,2) and size = (5,5) we have
109
                                 * to draw the rectangle ((2,2), (6,6));
110
                                 */
111
    struct {                    /* the current valid grid area for the */
112
        int x1, x2, y1, y2;     /* "format" command */
113
        int whichArea;
114
    } fmt;
115
} RenderInfo;
116
 
117
typedef struct ExposedArea {
118
    int x1, y1, x2, y2;
119
} ExposedArea, Rect;
120
 
121
/*----------------------------------------------------------------------
122
 *                      ColorInfo
123
 *
124
 * These colors are used by the format commands. They must be saved
125
 * or otherwise the colormap may be changed ..
126
 *----------------------------------------------------------------------
127
 */
128
typedef struct ColorInfo {
129
    struct ColorInfo * next;
130
    int counter;
131
    int type;                   /* TK_CONFIG_BORDER or TK_CONFIG_COLOR */
132
    long pixel;
133
    Tk_3DBorder border;
134
    XColor * color;
135
} ColorInfo;
136
 
137
/*----------------------------------------------------------------------
138
 *                      SelectBlock
139
 *
140
 * These structures are arranged in a list and are used to determine
141
 * where a cell is selected.
142
 *----------------------------------------------------------------------
143
 */
144
#define TIX_GR_CLEAR            1
145
#define TIX_GR_SET              2
146
#define TIX_GR_TOGGLE           3
147
 
148
#define TIX_GR_MAX              0x7fffffff
149
 
150
#define TIX_GR_RESIZE           1
151
#define TIX_GR_REDRAW           2
152
 
153
 
154
typedef struct SelectBlock {
155
    struct SelectBlock * next;
156
    int range[2][2];            /* the top left and bottom right corners */
157
    int type;                   /* TIX_GR_CLEAR, TIX_GR_SET,
158
                                 * TIX_GR_TOGGLE
159
                                 *
160
                                 * If several SelectBlock covers the same
161
                                 * cell, the last block in the wPtr->selList
162
                                 * determines whether this cell is selected
163
                                 * or not */
164
} SelectBlock;
165
 
166
/*----------------------------------------------------------------------
167
 *                      GrSortItem
168
 *
169
 * Used to sort the items in the grid
170
 *----------------------------------------------------------------------
171
 */
172
typedef struct Tix_GrSortItem {
173
    char * data;                        /* is usually a string, but
174
                                         * can be a pointer to an
175
                                         * arbitrary data in C API */
176
    int index;                          /* row or column */
177
} Tix_GrSortItem;
178
 
179
/*----------------------------------------------------------------------
180
 * Data structure for iterating the cells inside the grid.
181
 *
182
 *----------------------------------------------------------------------
183
 */
184
 
185
typedef struct Tix_GrDataRowSearch {
186
    struct TixGridRowCol * row;
187
    Tcl_HashSearch hashSearch;
188
    Tcl_HashEntry *hashPtr;
189
} Tix_GrDataRowSearch;
190
 
191
typedef struct Tix_GrDataCellSearch {
192
    char * data;
193
    Tcl_HashSearch hashSearch;
194
    Tcl_HashEntry *hashPtr;
195
} Tix_GrDataCellSearch;
196
 
197
/*----------------------------------------------------------------------
198
 *
199
 *              Main data structure of the grid widget.
200
 *
201
 *----------------------------------------------------------------------
202
 */
203
typedef struct Tix_GridScrollInfo {
204
    char * command;
205
 
206
    int max;            /* total size (width or height) of the widget*/
207
    int offset;         /* The top/left side of the scrolled widget */
208
    int unit;           /* How much should we scroll when the user */
209
 
210
    double window;      /* visible size, percentage of the total */
211
}Tix_GridScrollInfo;
212
 
213
 
214
typedef struct GridStruct {
215
    Tix_DispData dispData;
216
 
217
    Tcl_Command widgetCmd;      /* Token for button's widget command. */
218
 
219
    /*
220
     * Information used when displaying widget:
221
     */
222
    int reqSize[2];             /* For app programmer to request size */
223
 
224
    /*
225
     * Information used when displaying widget:
226
     */
227
 
228
    /* Border and general drawing */
229
    int borderWidth;            /* Width of 3-D borders. */
230
    int selBorderWidth;         /* Width of 3-D borders for selected items */
231
    int relief;                 /* Indicates whether window as a whole is
232
                                 * raised, sunken, or flat. */
233
    Tk_3DBorder border;         /* Used for drawing the 3d border. */
234
    Tk_3DBorder selectBorder;   /* Used for selected background. */
235
    XColor *normalFg;           /* Normal foreground for text. */
236
    XColor *normalBg;           /* Normal background for  text. */
237
    XColor *selectFg;           /* Color for drawing selected text. */
238
 
239
    Tk_Uid state;               /* State can only be normal or disabled. */
240
 
241
       /* GC and stuff */
242
    GC backgroundGC;            /* GC for drawing background. */
243
    GC selectGC;                /* GC for drawing selected background. */
244
    GC anchorGC;                /* GC for drawing dotted anchor highlight. */
245
    TixFont font;               /* Default font used by the DItems. */
246
 
247
    /* Text drawing */
248
    Cursor cursor;              /* Current cursor for window, or None. */
249
 
250
    /* For highlights */
251
    int highlightWidth;         /* Width in pixels of highlight to draw
252
                                 * around widget when it has the focus.
253
                                 * <= 0 means don't draw a highlight. */
254
    int bdPad;                  /* = highlightWidth + borderWidth */
255
    XColor *highlightColorPtr;  /* Color for drawing traversal highlight. */
256
    GC highlightGC;             /* For drawing traversal highlight. */
257
 
258
    /*
259
     * default pad and gap values
260
     */
261
    int padX, padY;
262
 
263
    Tk_Uid selectMode;          /* Selection style: single, browse, multiple,
264
                                 * or extended.  This value isn't used in C
265
                                 * code, but the Tcl bindings use it. */
266
    Tk_Uid selectUnit;          /* Selection unit: cell, row or column.
267
                                 * This value isn't used in C
268
                                 * code, but the Tcl bindings use it. */
269
 
270
    /*
271
     * The following three sites are used according to the -selectunit.
272
     * if selectunit is: "cell", [0] and [1] are used; "row", only [0]
273
     * is used; "column", only [1] is used
274
     */
275
    int anchor[2];              /* The current anchor unit */
276
    int dropSite[2];            /* The current drop site */
277
    int dragSite[2];            /* The current drop site */
278
 
279
    /*
280
     * Callback commands.
281
     */
282
    char *command;              /* The command when user double-clicks */
283
    char *browseCmd;            /* The command to call when the selection
284
                                 * changes. */
285
    char *editNotifyCmd;        /* The command to call to determine whether
286
                                 * a cell is editable. */
287
    char *editDoneCmd;          /* The command to call when an entry has
288
                                 * been edited by the user.*/
289
    char *formatCmd;            /* The command to call when the Grid widget
290
                                 * needs to be reformatted (e.g, Exposure
291
                                 * events or when contents have been
292
                                 * changed). */
293
    char *sizeCmd;              /* The command to call when the size of
294
                                 * the listbox changes. E.g., when the user
295
                                 * add/deletes elements. Useful for auto-
296
                                 * scrollbar geometry managers */
297
 
298
    /*
299
     * Info for lay-out
300
     */
301
    char *takeFocus;            /* Value of -takefocus option;  not used in
302
                                 * the C code, but used by keyboard traversal
303
                                 * scripts.  Malloc'ed, but may be NULL. */
304
 
305
    int serial;                 /* this number is incremented before each time
306
                                 * the widget is redisplayed */
307
 
308
    TixGridDataSet * dataSet;
309
    RenderBlock * mainRB;       /* Malloc'ed */
310
 
311
    int hdrSize[2];             /* number of rows (height of x header, index
312
                                 * [0]) and columns (width of y header, index
313
                                 * [1]) */
314
    int floatRange[2];          /* Are the num of columns and rows floated?
315
                                 * (if floated, you can scroll past the max
316
                                 * element).*/
317
    int gridSize[2];            /* the size of the grid where there is data */
318
    Tix_DItemInfo * diTypePtr;  /* Default item type */
319
    ExposedArea expArea;
320
 
321
    RenderInfo * renderInfo;    /* only points to stuff in stack */
322
    Tix_GridScrollInfo scrollInfo[2];
323
    int fontSize[2];            /* size of the "0" char of the -font option
324
                                 */
325
    TixGridSize defSize[2];
326
    Tix_LinkList colorInfo;
327
    Tix_LinkList selList;
328
    Tix_LinkList mappedWindows;
329
    int colorInfoCounter;
330
 
331
    unsigned int hasFocus  : 1;
332
 
333
    unsigned int idleEvent : 1;
334
    unsigned int toResize  : 1;         /* idle event */
335
    unsigned int toRedraw : 1;          /* idle event */
336
 
337
    unsigned int toResetRB  : 1; /* Do we need to reset the render block */
338
    unsigned int toComputeSel  : 1;
339
    unsigned int toRedrawHighlight : 1;
340
} Grid;
341
 
342
typedef Grid   WidgetRecord;
343
typedef Grid * WidgetPtr;
344
 
345
#define DEF_GRID_BG_COLOR               NORMAL_BG
346
#define DEF_GRID_BG_MONO                WHITE
347
#define DEF_GRID_BORDER_WIDTH           "2"
348
#define DEF_GRID_BROWSE_COMMAND         ""
349
#define DEF_GRID_COMMAND                ""
350
#define DEF_GRID_CURSOR                 ""
351
#define DEF_GRID_DEFAULT_WIDTH          "40"
352
#define DEF_GRID_DEFAULT_HEIGHT         "20"
353
#define DEF_GRID_EDITDONE_COMMAND       ""
354
#define DEF_GRID_EDITNOTIFY_COMMAND     ""
355
#define DEF_GRID_FLOATING_ROWS          "0"
356
#define DEF_GRID_FLOATING_COLS          "0"
357
#define DEF_GRID_FONT           CTL_FONT
358
#define DEF_GRID_FG_COLOR               BLACK
359
#define DEF_GRID_FG_MONO                BLACK
360
#define DEF_GRID_FORMAT_COMMAND         ""
361
#define DEF_GRID_HEIGHT                 "10"
362
#define DEF_GRID_HIGHLIGHT_COLOR        BLACK
363
#define DEF_GRID_HIGHLIGHT_MONO         BLACK
364
#define DEF_GRID_HIGHLIGHT_WIDTH        "2"
365
#define DEF_GRID_LEFT_MARGIN            "1"
366
#define DEF_GRID_ITEM_TYPE              "text"
367
#define DEF_GRID_RELIEF                 "sunken"
368
#define DEF_GRID_PADX                   "2"
369
#define DEF_GRID_PADY                   "2"
370
#define DEF_GRID_SELECT_BG_COLOR        ACTIVE_BG
371
#define DEF_GRID_SELECT_FG_COLOR        BLACK
372
#define DEF_GRID_SELECT_BG_MONO         BLACK
373
#define DEF_GRID_SELECT_FG_MONO         WHITE
374
#define DEF_GRID_SELECT_MODE            "single"
375
#define DEF_GRID_SELECT_UNIT            "row"
376
#define DEF_GRID_SELECT_BORDERWIDTH     "1"
377
#define DEF_GRID_STATE                  "normal"
378
#define DEF_GRID_SIZE_COMMAND           ""
379
#define DEF_GRID_TAKE_FOCUS             "1"
380
#define DEF_GRID_TOP_MARGIN             "1"
381
#define DEF_GRID_WIDTH                  "4"
382
#define DEF_GRID_Y_SCROLL_COMMAND       ""
383
#define DEF_GRID_X_SCROLL_COMMAND       ""
384
 
385
/*
386
 * common functions
387
 */
388
 
389
EXTERN void             Tix_GrAddChangedRect _ANSI_ARGS_((
390
                            WidgetPtr wPtr, int changedRect[2][2],
391
                            int isSite));
392
EXTERN int              Tix_GrConfigSize _ANSI_ARGS_((Tcl_Interp *interp,
393
                            WidgetPtr wPtr, int argc, char **argv,
394
                            TixGridSize *sizePtr, char * argcErrorMsg,
395
                            int *changed_ret));
396
EXTERN void             Tix_GrDoWhenIdle _ANSI_ARGS_((WidgetPtr wPtr,
397
                            int type));
398
EXTERN void             Tix_GrCancelDoWhenIdle _ANSI_ARGS_((WidgetPtr wPtr));
399
EXTERN void             Tix_GrFreeElem _ANSI_ARGS_((TixGrEntry * chPtr));
400
EXTERN void             Tix_GrFreeUnusedColors _ANSI_ARGS_((WidgetPtr wPtr,
401
                            int freeAll));
402
EXTERN void             Tix_GrScrollPage _ANSI_ARGS_((WidgetPtr wPtr,
403
                            int count, int axis));
404
 
405
/*
406
 * The dataset functions
407
 */
408
 
409
EXTERN int              TixGridDataConfigRowColSize _ANSI_ARGS_((
410
                            Tcl_Interp * interp, WidgetPtr wPtr,
411
                            TixGridDataSet * dataSet, int which, int index,
412
                            int argc, char ** argv, char * argcErrorMsg,
413
                            int *changed_ret));
414
EXTERN char *           TixGridDataCreateEntry _ANSI_ARGS_((
415
                            TixGridDataSet * dataSet, int x, int y,
416
                            char * defaultEntry));
417
EXTERN int              TixGridDataDeleteEntry _ANSI_ARGS_((
418
                            TixGridDataSet * dataSet, int x, int y));
419
EXTERN void             TixGridDataDeleteRange _ANSI_ARGS_((WidgetPtr wPtr,
420
                            TixGridDataSet * dataSet, int which,
421
                            int from, int to));
422
EXTERN void             TixGridDataDeleteSearchedEntry _ANSI_ARGS_((
423
                            Tix_GrDataCellSearch * cellSearchPtr));
424
EXTERN char *           TixGridDataFindEntry _ANSI_ARGS_((
425
                            TixGridDataSet * dataSet, int x, int y));
426
EXTERN int              TixGrDataFirstCell _ANSI_ARGS_((
427
                            Tix_GrDataRowSearch * rowSearchPtr,
428
                            Tix_GrDataCellSearch * cellSearchPtr));
429
EXTERN int              TixGrDataFirstRow _ANSI_ARGS_((
430
                            TixGridDataSet* dataSet,
431
                            Tix_GrDataRowSearch * rowSearchPtr));
432
EXTERN int              TixGridDataGetRowColSize _ANSI_ARGS_((
433
                            WidgetPtr wPtr, TixGridDataSet * dataSet,
434
                            int which, int index, TixGridSize * defSize,
435
                            int *pad0, int * pad1));
436
EXTERN void             TixGridDataGetGridSize _ANSI_ARGS_((
437
                            TixGridDataSet * dataSet, int *width_ret,
438
                            int *height_ret));
439
EXTERN int              TixGridDataGetIndex _ANSI_ARGS_((
440
                            Tcl_Interp * interp, WidgetPtr wPtr,
441
                            char * xStr, char * yStr, int * xPtr, int * yPtr));
442
EXTERN void             TixGridDataInsert _ANSI_ARGS_((
443
                            TixGridDataSet * dataSet,
444
                            int x, int y, ClientData data));
445
EXTERN void             TixGridDataMoveRange _ANSI_ARGS_((WidgetPtr wPtr,
446
                            TixGridDataSet * dataSet, int which,
447
                            int from, int to, int by));
448
EXTERN int              TixGrDataNextCell _ANSI_ARGS_((
449
                            Tix_GrDataCellSearch * cellSearchPtr));
450
EXTERN int              TixGrDataNextRow _ANSI_ARGS_((
451
                            Tix_GrDataRowSearch * rowSearchPtr));
452
EXTERN TixGridDataSet*  TixGridDataSetInit _ANSI_ARGS_((void));
453
EXTERN void             TixGridDataSetFree _ANSI_ARGS_((
454
                            TixGridDataSet* dataSet));
455
EXTERN int              TixGridDataUpdateSort _ANSI_ARGS_((
456
                            TixGridDataSet * dataSet, int axis,
457
                            int start, int end, Tix_GrSortItem *items));
458
 
459
#undef TCL_STORAGE_CLASS
460
#define TCL_STORAGE_CLASS DLLIMPORT
461
 
462
#endif /*_TIX_GRID_H_*/

powered by: WebSVN 2.1.0

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