Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * tixGData.h -- | |
3 | * | |
4 | * Defines portable data structure 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_DATA_H_ | |
14 | #define _TIX_GRID_DATA_H_ | |
15 | ||
16 | /* | |
17 | * Data structure that stored the cells in a Grid widget. It is optimized | |
18 | * for column/row insertion and deletion. | |
19 | * | |
20 | * - A grid is divideded into a set of rows and columns. Each row and column | |
21 | * is divided into a set of cells. | |
22 | * | |
23 | * - The following discusses the structure of a row. The structure of a | |
24 | * column is the reverse of a row. | |
25 | * | |
26 | * Row y is stored in the hash table TixGridDataSet.index[1] with | |
27 | * the index y. Hence, to search for row y, we use the FindHashEntry | |
28 | * operation: | |
29 | * | |
30 | * row_y = TixGridDataSet.index[1].FindHashEntry(y); | |
31 | * | |
32 | * To locate a cell (x,y), we can first find the row y, and then | |
33 | * locate the cell at column x of this row. Note that the cell is | |
34 | * *not* indexed by its column position (y), but rather by the hash | |
35 | * table of the column y. The following example illustrates how cell | |
36 | * (x,y) can be searched: | |
37 | * | |
38 | * row_y = TixGridDataSet.index[1].FindHashEntry(y); | |
39 | * col_x = TixGridDataSet.index[0].FindHashEntry(x); | |
40 | * | |
41 | * cell_xy = row_x.list.FindHashEntry(&col_x); | |
42 | * | |
43 | * The advantage of this arrangement is it is very efficient to | |
44 | * insert a row into into the grid -- we just have to fix the | |
45 | * indices of the rows table. For example, if, after the insertion, | |
46 | * row_y is now moved to the row y1, we change its index from y to | |
47 | * y1. In general, an insertion operation takes log(n) time in a | |
48 | * grid that contains n items. | |
49 | * | |
50 | */ | |
51 | typedef struct TixGridDataSet { | |
52 | Tcl_HashTable index[2]; /* the row and column indices */ | |
53 | /* index[0] holds the columns | |
54 | * (horizontal index) | |
55 | */ | |
56 | int maxIdx[2]; /* the max row/col, or {-1,-1} | |
57 | * if there are no rows/col | |
58 | */ | |
59 | } TixGridDataSet; | |
60 | ||
61 | #define TIX_GR_AUTO 0 | |
62 | #define TIX_GR_DEFAULT 1 | |
63 | #define TIX_GR_DEFINED_PIXEL 2 | |
64 | #define TIX_GR_DEFINED_CHAR 3 | |
65 | ||
66 | typedef struct TixGridSize { | |
67 | int sizeType; | |
68 | int sizeValue; /* width or height */ | |
69 | int pixels; | |
70 | int pad0, pad1; | |
71 | double charValue; | |
72 | } TixGridSize; | |
73 | ||
74 | typedef struct TixGridRowCol { | |
75 | /* private: */ | |
76 | Tcl_HashTable table; | |
77 | ||
78 | /* public: */ | |
79 | int dispIndex; /* the row or column in which | |
80 | * this TixGridRowCol is displayed */ | |
81 | TixGridSize size; | |
82 | } TixGridRowCol; | |
83 | ||
84 | ||
85 | #endif |