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