source: trunk/kitgen/8.x/blt/generic/bltTreeView.h@ 176

Last change on this file since 176 was 175, checked in by demin, 12 years ago

initial commit

File size: 36.5 KB
RevLine 
[175]1
2/*
3 * bltTreeView.h --
4 *
5 * This module implements an hierarchy widget for the BLT toolkit.
6 *
7 * Copyright 1998-1999 Lucent Technologies, Inc.
8 *
9 * Permission to use, copy, modify, and distribute this software and
10 * its documentation for any purpose and without fee is hereby
11 * granted, provided that the above copyright notice appear in all
12 * copies and that both that the copyright notice and warranty
13 * disclaimer appear in supporting documentation, and that the names
14 * of Lucent Technologies or any of their entities not be used in
15 * advertising or publicity pertaining to distribution of the software
16 * without specific, written prior permission.
17 *
18 * Lucent Technologies disclaims all warranties with regard to this
19 * software, including all implied warranties of merchantability and
20 * fitness. In no event shall Lucent Technologies be liable for any
21 * special, indirect or consequential damages or any damages
22 * whatsoever resulting from loss of use, data or profits, whether in
23 * an action of contract, negligence or other tortuous action, arising
24 * out of or in connection with the use or performance of this
25 * software.
26 *
27 * The "treeview" widget was created by George A. Howlett.
28 */
29
30/*
31 * TODO:
32 *
33 * BUGS:
34 * 1. "open" operation should change scroll offset so that as many
35 * new entries (up to half a screen) can be seen.
36 * 2. "open" needs to adjust the scrolloffset so that the same entry
37 * is seen at the same place.
38 */
39
40#ifndef BLT_TREEVIEW_H
41#define BLT_TREEVIEW_H
42
43#include "bltImage.h"
44#include "bltHash.h"
45#include "bltChain.h"
46#include "bltTree.h"
47#include "bltTile.h"
48#include "bltBind.h"
49#include "bltObjConfig.h"
50
51#define ITEM_ENTRY (ClientData)0
52#define ITEM_ENTRY_BUTTON (ClientData)1
53#define ITEM_COLUMN_TITLE (ClientData)2
54#define ITEM_COLUMN_RULE (ClientData)3
55#define ITEM_STYLE (ClientData)0x10004
56
57#if HAVE_UTF
58#else
59#define Tcl_NumUtfChars(s,n) (((n) == -1) ? strlen((s)) : (n))
60#define Tcl_UtfAtIndex(s,i) ((s) + (i))
61#endif
62
63#define ODD(x) ((x) | 0x01)
64
65#define END (-1)
66#define SEPARATOR_LIST ((char *)NULL)
67#define SEPARATOR_NONE ((char *)-1)
68
69#define SEARCH_Y 1
70
71typedef char *UID;
72
73/*
74 * The macro below is used to modify a "char" value (e.g. by casting
75 * it to an unsigned character) so that it can be used safely with
76 * macros such as isspace.
77 */
78#define UCHAR(c) ((unsigned char) (c))
79
80#define TOGGLE(x, mask) (((x) & (mask)) ? ((x) & ~(mask)) : ((x) | (mask)))
81
82
83#define SCREENX(h, wx) ((wx) - (h)->xOffset + (h)->inset)
84#define SCREENY(h, wy) ((wy) - (h)->yOffset + (h)->inset + (h)->titleHeight)
85
86#define WORLDX(h, sx) ((sx) - (h)->inset + (h)->xOffset)
87#define WORLDY(h, sy) ((sy) - ((h)->inset + (h)->titleHeight) + (h)->yOffset)
88
89#define VPORTWIDTH(h) (Tk_Width((h)->tkwin) - 2 * (h)->inset)
90#define VPORTHEIGHT(h) \
91 (Tk_Height((h)->tkwin) - (h)->titleHeight - 2 * (h)->inset)
92
93#define ICONWIDTH(d) (tvPtr->levelInfo[(d)].iconWidth)
94#define LEVELX(d) (tvPtr->levelInfo[(d)].x)
95
96#define DEPTH(h, n) \
97 (((h)->flatView) ? 0 : Blt_TreeNodeDepth((h)->tree, (n)))
98
99#define SELECT_FG(t) \
100 (((((t)->flags & TV_FOCUS)) || ((t)->selOutFocusFgColor == NULL)) \
101 ? (t)->selInFocusFgColor : (t)->selOutFocusFgColor)
102#define SELECT_BORDER(t) \
103 (((((t)->flags & TV_FOCUS)) || ((t)->selOutFocusBorder == NULL)) \
104 ? (t)->selInFocusBorder : (t)->selOutFocusBorder)
105
106#define SELECT_MODE_SINGLE (1<<0)
107#define SELECT_MODE_MULTIPLE (1<<1)
108
109/*
110 * ----------------------------------------------------------------------------
111 *
112 * Internal treeview widget flags:
113 *
114 * TV_LAYOUT The layout of the hierarchy needs to be recomputed.
115 *
116 * TV_REDRAW A redraw request is pending for the widget.
117 *
118 * TV_XSCROLL X-scroll request is pending.
119 *
120 * TV_YSCROLL Y-scroll request is pending.
121 *
122 * TV_SCROLL Both X-scroll and Y-scroll requests are pending.
123 *
124 * TV_FOCUS The widget is receiving keyboard events.
125 * Draw the focus highlight border around the widget.
126 *
127 * TV_DIRTY The hierarchy has changed. It may invalidate
128 * the locations and pointers to entries. The widget
129 * will need to recompute its layout.
130 *
131 * TV_RESORT The tree has changed such that the view needs to
132 * be resorted. This can happen when an entry is
133 * open or closed, it's label changes, a column value
134 * changes, etc.
135 *
136 * TV_BORDERS The borders of the widget (highlight ring and
137 * 3-D border) need to be redrawn.
138 *
139 * TV_VIEWPORT Indicates that the viewport has changed in some
140 * way: the size of the viewport, the location of
141 * the viewport, or the contents of the viewport.
142 *
143 */
144
145#define TV_LAYOUT (1<<0)
146#define TV_REDRAW (1<<1)
147#define TV_XSCROLL (1<<2)
148#define TV_YSCROLL (1<<3)
149#define TV_SCROLL (TV_XSCROLL | TV_YSCROLL)
150#define TV_FOCUS (1<<4)
151#define TV_DIRTY (1<<5)
152#define TV_UPDATE (1<<6)
153#define TV_RESORT (1<<7)
154#define TV_SORTED (1<<8)
155#define TV_SORT_PENDING (1<<9)
156#define TV_BORDERS (1<<10)
157#define TV_VIEWPORT (1<<11)
158
159/*
160 * Rule related flags: Rules are XOR-ed lines. We need to track whether
161 * they have been drawn or not.
162 *
163 * TV_RULE_ACTIVE Indicates that a rule is currently being drawn
164 * for a column.
165 *
166 *
167 * TV_RULE_NEEDED Indicates that a rule is needed (but not yet
168 * drawn) for a column.
169 */
170
171#define TV_RULE_ACTIVE (1<<15)
172#define TV_RULE_NEEDED (1<<16)
173
174/*
175 * Selection related flags:
176 *
177 * TV_SELECT_EXPORT Export the selection to X11.
178 *
179 * TV_SELECT_PENDING A "selection" command idle task is pending.
180 *
181 * TV_SELECT_CLEAR Clear selection flag of entry.
182 *
183 * TV_SELECT_SET Set selection flag of entry.
184 *
185 * TV_SELECT_TOGGLE Toggle selection flag of entry.
186 *
187 * TV_SELECT_MASK Mask of selection set/clear/toggle flags.
188 *
189 * TV_SELECT_SORTED Indicates if the entries in the selection
190 * should be sorted or displayed in the order
191 * they were selected.
192 *
193 */
194#define TV_SELECT_CLEAR (1<<16)
195#define TV_SELECT_EXPORT (1<<17)
196#define TV_SELECT_PENDING (1<<18)
197#define TV_SELECT_SET (1<<19)
198#define TV_SELECT_TOGGLE (TV_SELECT_SET | TV_SELECT_CLEAR)
199#define TV_SELECT_MASK (TV_SELECT_SET | TV_SELECT_CLEAR)
200#define TV_SELECT_SORTED (1<<20)
201
202/*
203 * Miscellaneous flags:
204 *
205 * TV_ALLOW_DUPLICATES When inserting new entries, create
206 * duplicate entries.
207 *
208 * TV_FILL_ANCESTORS Automatically create ancestor entries
209 * as needed when inserting a new entry.
210 *
211 * TV_HIDE_ROOT Don't display the root entry.
212 *
213 * TV_HIDE_LEAVES Don't display entries that are leaves.
214 *
215 * TV_SHOW_COLUMN_TITLES Indicates whether to draw titles over each
216 * column.
217 *
218 */
219#define TV_ALLOW_DUPLICATES (1<<21)
220#define TV_FILL_ANCESTORS (1<<22)
221#define TV_HIDE_ROOT (1<<23)
222#define TV_HIDE_LEAVES (1<<24)
223#define TV_SHOW_COLUMN_TITLES (1<<25)
224#define TV_SORT_AUTO (1<<26)
225#define TV_NEW_TAGS (1<<27)
226#define TV_HIGHLIGHT_CELLS (1<<28)
227
228#define TV_ITEM_COLUMN 1
229#define TV_ITEM_RULE 2
230
231/*
232 * -------------------------------------------------------------------------
233 *
234 * Internal entry flags:
235 *
236 * ENTRY_HAS_BUTTON Indicates that a button needs to be
237 * drawn for this entry.
238 *
239 * ENTRY_CLOSED Indicates that the entry is closed and
240 * its subentries are not displayed.
241 *
242 * ENTRY_HIDDEN Indicates that the entry is hidden (i.e.
243 * can not be viewed by opening or scrolling).
244 *
245 * BUTTON_AUTO
246 * BUTTON_SHOW
247 * BUTTON_MASK
248 *
249 * -------------------------------------------------------------------------
250 */
251#define ENTRY_CLOSED (1<<0)
252#define ENTRY_HIDDEN (1<<1)
253#define ENTRY_NOT_LEAF (1<<2)
254#define ENTRY_MASK (ENTRY_CLOSED | ENTRY_HIDDEN)
255
256#define ENTRY_HAS_BUTTON (1<<3)
257#define ENTRY_ICON (1<<4)
258#define ENTRY_REDRAW (1<<5)
259#define ENTRY_LAYOUT_PENDING (1<<6)
260#define ENTRY_DATA_CHANGED (1<<7)
261#define ENTRY_DIRTY (ENTRY_DATA_CHANGED | ENTRY_LAYOUT_PENDING)
262
263#define BUTTON_AUTO (1<<8)
264#define BUTTON_SHOW (1<<9)
265#define BUTTON_MASK (BUTTON_AUTO | BUTTON_SHOW)
266
267#define COLUMN_RULE_PICKED (1<<1)
268#define COLUMN_DIRTY (1<<2)
269
270#define STYLE_TEXTBOX (0)
271#define STYLE_COMBOBOX (1)
272#define STYLE_CHECKBOX (2)
273#define STYLE_TYPE 0x3
274
275#define STYLE_LAYOUT (1<<3)
276#define STYLE_DIRTY (1<<4)
277#define STYLE_HIGHLIGHT (1<<5)
278#define STYLE_USER (1<<6)
279
280typedef struct TreeViewColumnStruct TreeViewColumn;
281typedef struct TreeViewComboboxStruct TreeViewCombobox;
282typedef struct TreeViewEntryStruct TreeViewEntry;
283typedef struct TreeViewStruct TreeView;
284typedef struct TreeViewStyleClassStruct TreeViewStyleClass;
285typedef struct TreeViewStyleStruct TreeViewStyle;
286
287typedef int (TreeViewCompareProc) _ANSI_ARGS_((Tcl_Interp *interp, char *name,
288 char *pattern));
289
290typedef TreeViewEntry *(TreeViewIterProc) _ANSI_ARGS_((TreeViewEntry *entryPtr,
291 unsigned int mask));
292
293typedef struct {
294 int tagType;
295 TreeView *tvPtr;
296 Blt_HashSearch cursor;
297 TreeViewEntry *entryPtr;
298} TreeViewTagInfo;
299
300/*
301 * TreeViewIcon --
302 *
303 * Since instances of the same Tk image can be displayed in
304 * different windows with possibly different color palettes, Tk
305 * internally stores each instance in a linked list. But if
306 * the instances are used in the same widget and therefore use
307 * the same color palette, this adds a lot of overhead,
308 * especially when deleting instances from the linked list.
309 *
310 * For the treeview widget, we never need more than a single
311 * instance of an image, regardless of how many times it's used.
312 * Cache the image, maintaining a reference count for each
313 * image used in the widget. It's likely that the treeview
314 * widget will use many instances of the same image (for example
315 * the open/close icons).
316 */
317
318typedef struct TreeViewIconStruct {
319 Tk_Image tkImage; /* The Tk image being cached. */
320
321 int refCount; /* Reference count for this image. */
322
323 short int width, height; /* Dimensions of the cached image. */
324
325 Blt_HashEntry *hashPtr; /* Hash table pointer to the image. */
326
327} *TreeViewIcon;
328
329#define TreeViewIconHeight(icon) ((icon)->height)
330#define TreeViewIconWidth(icon) ((icon)->width)
331#define TreeViewIconBits(icon) ((icon)->tkImage)
332
333/*
334 * TreeViewColumn --
335 *
336 * A column describes how to display a field of data in the tree.
337 * It may display a title that you can bind to. It may display a
338 * rule for resizing the column. Columns may be hidden, and have
339 * attributes (foreground color, background color, font, etc)
340 * that override those designated globally for the treeview
341 * widget.
342 */
343struct TreeViewColumnStruct {
344 int type; /* Always TV_COLUMN */
345 Blt_TreeKey key; /* Data cell identifier for current tree. */
346 int position; /* Position of column in list. Used
347 * to indicate the first and last
348 * columns. */
349 UID tagsUid; /* List of binding tags for this
350 * entry. UID, not a string, because
351 * in the typical case most columns
352 * will have the same bindtags. */
353
354 TreeView *tvPtr;
355 unsigned int flags;
356
357 /* Title-related information */
358 char *title; /* Text displayed in column heading as its
359 * title. By default, this is the same as
360 * the data cell name. */
361 Tk_Font titleFont; /* Font to draw title in. */
362 Shadow titleShadow;
363
364 XColor *titleFgColor; /* Foreground color of text displayed in
365 * the heading */
366 Tk_3DBorder titleBorder; /* Background color of the column's heading. */
367
368 GC titleGC;
369
370 XColor *activeTitleFgColor; /* Foreground color of text heading when
371 * the column is activated.*/
372 Tk_3DBorder activeTitleBorder;
373
374 int titleBorderWidth;
375 int titleRelief;
376
377 GC activeTitleGC;
378
379 TextLayout *titleTextPtr;
380 short int titleWidth, titleHeight;
381
382 TreeViewIcon titleIcon; /* Icon displayed in column heading */
383 char *titleCmd; /* Tcl script to be executed by the
384 * column's "invoke" operation. */
385
386 char *sortCmd; /* Tcl script used to compare two
387 * columns. */
388
389 /* General information. */
390 int hidden; /* Indicates if the column is
391 * displayed */
392 int state; /* Indicates if column title can
393 * invoked. */
394 int editable; /* Indicates if column can be
395 * edited. */
396
397 int max; /* Maximum space allowed for column. */
398 int reqMin, reqMax; /* Requested bounds on the width of
399 * column. Does not include any
400 * padding or the borderwidth of
401 * column. If non-zero, overrides the
402 * computed width of the column. */
403
404 int reqWidth; /* User-requested width of
405 * column. Does not include any
406 * padding or the borderwidth of
407 * column. If non-zero, overrides the
408 * computed column width. */
409
410 int maxWidth; /* Width of the widest entry in the
411 * column. */
412
413 int worldX; /* Starting world x-coordinate of the
414 * column. */
415
416 double weight; /* Growth factor for column. Zero
417 * indicates that the column can not
418 * be resized. */
419
420 int width; /* Computed width of column. */
421
422 TreeViewStyle *stylePtr; /* Default style for column. */
423
424 Tk_3DBorder border; /* Background color of column. */
425 int borderWidth; /* Border width of the column. */
426 int relief; /* Relief of the column. */
427 Blt_Pad pad; /* Horizontal padding on either side
428 * of the column. */
429
430 Tk_Justify justify; /* Indicates how the text or icon is
431 * justified within the column. */
432
433 Blt_ChainLink *linkPtr;
434
435 int ruleLineWidth;
436 Blt_Dashes ruleDashes;
437 GC ruleGC;
438};
439
440
441struct TreeViewStyleStruct {
442 int refCount; /* Usage reference count. A reference
443 * count of zero indicates that the
444 * style may be freed. */
445 unsigned int flags; /* Bit field containing both the style
446 * type and various flags. */
447 char *name; /* Instance name. */
448 TreeViewStyleClass *classPtr;
449 /* Contains class-specific information such
450 * as configuration specifications and
451 * configure, draw, etc. routines. */
452 Blt_HashEntry *hashPtr; /* If non-NULL, points to the hash
453 * table entry for the style. A style
454 * that's been deleted, but still in
455 * use (non-zero reference count) will
456 * have no hash table entry.
457 */
458 /* General style fields. */
459 Tk_Cursor cursor; /* X Cursor */
460
461 TreeViewIcon icon; /* If non-NULL, is a Tk_Image to be drawn
462 * in the cell. */
463 int gap; /* # pixels gap between icon and text. */
464 Tk_Font font;
465 XColor *fgColor; /* Normal foreground color of cell. */
466 Tk_3DBorder border; /* Normal background color of cell. */
467 XColor *highlightFgColor; /* Foreground color of cell when
468 * highlighted. */
469 Tk_3DBorder highlightBorder;/* Background color of cell when
470 * highlighted. */
471 XColor *activeFgColor; /* Foreground color of cell when active. */
472 Tk_3DBorder activeBorder; /* Background color of cell when active. */
473
474};
475
476typedef struct TreeViewValueStruct {
477 TreeViewColumn *columnPtr; /* Column in which the value is located. */
478 short int width, height; /* Dimensions of value. */
479 TreeViewStyle *stylePtr; /* Style information for cell
480 * displaying value. */
481 char *string; /* Raw text string. */
482 TextLayout *textPtr; /* Processes string to be displayed .*/
483 struct TreeViewValueStruct *nextPtr;
484} TreeViewValue;
485
486typedef void (StyleConfigProc) _ANSI_ARGS_((TreeView *tvPtr,
487 TreeViewStyle *stylePtr));
488typedef void (StyleDrawProc) _ANSI_ARGS_((TreeView *tvPtr, Drawable drawable,
489 TreeViewEntry *entryPtr, TreeViewValue *valuePtr,
490 TreeViewStyle *stylePtr, int x, int y));
491typedef int (StyleEditProc) _ANSI_ARGS_((TreeView *tvPtr,
492 TreeViewEntry *entryPtr, TreeViewValue *valuePtr,
493 TreeViewStyle *stylePtr));
494typedef void (StyleFreeProc) _ANSI_ARGS_((TreeView *tvPtr,
495 TreeViewStyle *stylePtr));
496typedef void (StyleMeasureProc) _ANSI_ARGS_((TreeView *tvPtr,
497 TreeViewStyle *stylePtr, TreeViewValue *valuePtr));
498typedef int (StylePickProc) _ANSI_ARGS_((TreeViewEntry *entryPtr,
499 TreeViewValue *valuePtr, TreeViewStyle *stylePtr, int worldX,
500 int worldY));
501
502struct TreeViewStyleClassStruct {
503 char *className; /* Class name of the style */
504 Blt_ConfigSpec *specsPtr; /* Style configuration specifications */
505 StyleConfigProc *configProc;/* Sets the GCs for style. */
506 StyleMeasureProc *measProc; /* Measures the area needed for the value
507 * with this style. */
508 StyleDrawProc *drawProc; /* Draw the value in it's style. */
509 StylePickProc *pickProc; /* Routine to pick the style's button.
510 * Indicates if the mouse pointer is over
511 * the style's button (if it has one). */
512 StyleEditProc *editProc; /* Routine to edit the style's value. */
513 StyleFreeProc *freeProc; /* Routine to free the style's resources. */
514};
515
516/*
517 * TreeViewEntry --
518 *
519 * Contains data-specific information how to represent the data
520 * of a node of the hierarchy.
521 *
522 */
523struct TreeViewEntryStruct {
524 Blt_TreeNode node; /* Node containing entry */
525 int worldX, worldY; /* X-Y position in world coordinates
526 * where the entry is positioned. */
527
528 short int width, height; /* Dimensions of the entry. This
529 * includes the size of its
530 * columns. */
531
532 int reqHeight; /* Requested height of the entry.
533 * Overrides computed height. */
534
535 int vertLineLength; /* Length of the vertical line
536 * segment. */
537
538 int lineHeight; /* Height of first line of text. */
539 unsigned int flags; /* Flags for this entry. For the
540 * definitions of the various bit
541 * fields see below. */
542
543 UID tagsUid; /* List of binding tags for this
544 * entry. UID, not a string, because
545 * in the typical case most entries
546 * will have the same bindtags. */
547 TreeView *tvPtr;
548
549 UID openCmd, closeCmd; /* Tcl commands to invoke when entries
550 * are opened or closed. They override
551 * those specified globally. */
552 /*
553 * Button information:
554 */
555 short int buttonX, buttonY; /* X-Y coordinate offsets from to
556 * upper left corner of the entry to
557 * the upper-left corner of the
558 * button. Used to pick the
559 * button quickly */
560
561 TreeViewIcon *icons; /* Tk images displayed for the entry.
562 * The first image is the icon
563 * displayed to the left of the
564 * entry's label. The second is icon
565 * displayed when entry is "open". */
566
567 TreeViewIcon *activeIcons; /* Tk images displayed for the entry.
568 * The first image is the icon
569 * displayed to the left of the
570 * entry's label. The second is icon
571 * displayed when entry is "open". */
572
573 short int iconWidth;
574 short int iconHeight; /* Maximum dimensions for icons and
575 * buttons for this entry. This is
576 * used to align the button, icon, and
577 * text. */
578 /*
579 * Label information:
580 */
581 TextLayout *textPtr;
582
583 short int labelWidth;
584 short int labelHeight;
585
586 UID labelUid; /* Text displayed right of the icon. */
587
588 Tk_Font font; /* Font of label. Overrides global
589 * font specification. */
590 char *fullName;
591
592 int flatIndex;
593
594 Tcl_Obj *dataObjPtr; /* pre-fetched data for sorting */
595
596 XColor *color; /* Color of label. Overrides default
597 * text color specification. */
598 GC gc;
599
600 Shadow shadow;
601
602 TreeViewValue *values; /* List of column-related information
603 * for each data value in the node.
604 * Non-NULL only if there are value
605 * entries. */
606};
607
608/*
609 * TreeViewButton --
610 *
611 * A button is the open/close indicator at the far left of the
612 * entry. It is displayed as a plus or minus in a solid
613 * colored box with optionally an border. It has both "active"
614 * and "normal" colors.
615 */
616typedef struct {
617 XColor *fgColor; /* Foreground color. */
618
619 Tk_3DBorder border; /* Background color. */
620
621 XColor *activeFgColor; /* Active foreground color. */
622
623 Tk_3DBorder activeBorder; /* Active background color. */
624
625 GC normalGC;
626 GC activeGC;
627
628 int reqSize;
629
630 int borderWidth;
631
632 int openRelief, closeRelief;
633
634 int width, height;
635
636 TreeViewIcon *icons;
637
638} TreeViewButton;
639
640/*
641 * LevelInfo --
642 *
643 */
644typedef struct {
645 int x;
646 int iconWidth;
647 int labelWidth;
648} LevelInfo;
649
650/*
651 * TreeView --
652 *
653 * A TreeView is a widget that displays an hierarchical table
654 * of one or more entries.
655 *
656 * Entries are positioned in "world" coordinates, referring to
657 * the virtual treeview. Coordinate 0,0 is the upper-left corner
658 * of the root entry and the bottom is the end of the last entry.
659 * The widget's Tk window acts as view port into this virtual
660 * space. The treeview's xOffset and yOffset fields specify the
661 * location of the view port in the virtual world. Scrolling the
662 * viewport is therefore simply changing the xOffset and/or
663 * yOffset fields and redrawing.
664 *
665 * Note that world coordinates are integers, not signed short
666 * integers like X11 screen coordinates. It's very easy to
667 * create a hierarchy taller than 0x7FFF pixels.
668 */
669struct TreeViewStruct {
670 Tcl_Interp *interp;
671
672 Tcl_Command cmdToken; /* Token for widget's Tcl command. */
673
674 Blt_Tree tree; /* Token holding internal tree. */
675
676 Blt_HashEntry *hashPtr;
677
678 /* TreeView specific fields. */
679
680 Tk_Window tkwin; /* Window that embodies the widget.
681 * NULL means that the window has been
682 * destroyed but the data structures
683 * haven't yet been cleaned up.*/
684
685 Display *display; /* Display containing widget; needed,
686 * among other things, to release
687 * resources after tkwin has already
688 * gone away. */
689
690 Blt_HashTable entryTable; /* Table of entry information, keyed by
691 * the node pointer. */
692
693 Blt_HashTable columnTable; /* Table of column information. */
694 Blt_Chain *colChainPtr; /* Chain of columns. Same as the hash
695 * table above but maintains the order
696 * in which columns are displayed. */
697
698 unsigned int flags; /* For bitfield definitions, see below */
699
700 int inset; /* Total width of all borders,
701 * including traversal highlight and
702 * 3-D border. Indicates how much
703 * interior stuff must be offset from
704 * outside edges to leave room for
705 * borders. */
706
707 Tk_Font font;
708 XColor *fgColor;
709
710 Tk_3DBorder border; /* 3D border surrounding the window
711 * (viewport). */
712
713 int borderWidth; /* Width of 3D border. */
714
715 int relief; /* 3D border relief. */
716
717
718 int highlightWidth; /* Width in pixels of highlight to
719 * draw around widget when it has the
720 * focus. <= 0 means don't draw a
721 * highlight. */
722
723 XColor *highlightBgColor; /* Color for drawing traversal
724 * highlight area when highlight is
725 * off. */
726
727 XColor *highlightColor; /* Color for drawing traversal highlight. */
728
729 char *pathSep; /* Pathname separators */
730
731 char *trimLeft; /* Leading characters to trim from
732 * pathnames */
733
734 /*
735 * Entries are connected by horizontal and vertical lines. They
736 * may be drawn dashed or solid.
737 */
738 int lineWidth; /* Width of lines connecting entries */
739
740 int dashes; /* Dash on-off value. */
741
742 XColor *lineColor; /* Color of connecting lines. */
743
744 /*
745 * Button Information:
746 *
747 * The button is the open/close indicator at the far left of the
748 * entry. It is usually displayed as a plus or minus in a solid
749 * colored box with optionally an border. It has both "active" and
750 * "normal" colors.
751 */
752 TreeViewButton button;
753
754 /*
755 * Selection Information:
756 *
757 * The selection is the rectangle that contains a selected entry.
758 * There may be many selected entries. It is displayed as a solid
759 * colored box with optionally a 3D border.
760 */
761 int selRelief; /* Relief of selected items. Currently
762 * is always raised. */
763
764 int selBorderWidth; /* Border width of a selected entry.*/
765
766 XColor *selInFocusFgColor; /* Text color of a selected entry. */
767 XColor *selOutFocusFgColor;
768
769 Tk_3DBorder selInFocusBorder;
770 Tk_3DBorder selOutFocusBorder;
771
772
773 TreeViewEntry *selAnchorPtr; /* Fixed end of selection (i.e. entry
774 * at which selection was started.) */
775 TreeViewEntry *selMarkPtr;
776
777 int selectMode; /* Selection style: "single" or
778 * "multiple". */
779
780 char *selectCmd; /* Tcl script that's invoked whenever
781 * the selection changes. */
782
783 Blt_HashTable selectTable; /* Hash table of currently selected
784 * entries. */
785
786 Blt_Chain *selChainPtr; /* Chain of currently selected
787 * entries. Contains the same
788 * information as the above hash
789 * table, but maintains the order in
790 * which entries are selected.
791 */
792
793 int leader; /* Number of pixels padding between
794 * entries. */
795
796 Tk_Cursor cursor; /* X Cursor */
797
798 Tk_Cursor resizeCursor; /* Resize Cursor */
799
800 int reqWidth, reqHeight; /* Requested dimensions of the
801 * treeview widget's window. */
802
803 GC lineGC; /* GC for drawing dotted line between
804 * entries. */
805
806 XColor *focusColor;
807
808 Blt_Dashes focusDashes; /* Dash on-off value. */
809
810 GC focusGC; /* Graphics context for the active
811 * label. */
812
813 Tk_Window comboWin;
814
815 TreeViewEntry *activePtr; /* Last active entry. */
816
817 TreeViewEntry *focusPtr; /* Entry that currently has focus. */
818
819 TreeViewEntry *activeButtonPtr; /* Pointer to last active button */
820
821 TreeViewEntry *fromPtr;
822
823 TreeViewValue *activeValuePtr;/* Last active value. */
824
825 int xScrollUnits, yScrollUnits; /* # of pixels per scroll unit. */
826
827 /* Command strings to control horizontal and vertical
828 * scrollbars. */
829 char *xScrollCmdPrefix, *yScrollCmdPrefix;
830
831 int scrollMode; /* Selects mode of scrolling: either
832 * BLT_SCROLL_MODE_HIERBOX,
833 * BLT_SCROLL_MODE_LISTBOX,
834 * or BLT_SCROLL_MODE_CANVAS. */
835 /*
836 * Total size of all "open" entries. This represents the range of
837 * world coordinates.
838 */
839 int worldWidth, worldHeight;
840
841 int xOffset, yOffset; /* Translation between view port and
842 * world origin. */
843
844 short int minHeight; /* Minimum entry height. Used to to
845 * compute what the y-scroll unit
846 * should be. */
847 short int titleHeight; /* Height of column titles. */
848
849 LevelInfo *levelInfo;
850
851 /*
852 * Scanning information:
853 */
854 int scanAnchorX, scanAnchorY;
855 /* Scan anchor in screen coordinates. */
856 int scanX, scanY; /* X-Y world coordinate where the scan
857 * started. */
858
859 Blt_HashTable iconTable; /* Table of Tk images */
860
861 Blt_HashTable uidTable; /* Table of strings. */
862
863 Blt_HashTable styleTable; /* Table of cell styles. */
864
865 TreeViewEntry *rootPtr; /* Root entry of tree. */
866
867 TreeViewEntry **visibleArr; /* Array of visible entries */
868
869 int nVisible; /* Number of entries in the above array */
870
871 int nEntries; /* Number of entries in tree. */
872 int treeWidth; /* Computed width of the tree. */
873
874 int buttonFlags; /* Global button indicator for all
875 * entries. This may be overridden by
876 * the entry's -button option. */
877
878 char *openCmd, *closeCmd; /* Tcl commands to invoke when entries
879 * are opened or closed. */
880
881 TreeViewIcon *icons; /* Tk images displayed for the entry.
882 * The first image is the icon
883 * displayed to the left of the
884 * entry's label. The second is icon
885 * displayed when entry is "open". */
886 TreeViewIcon *activeIcons; /* Tk images displayed for the entry.
887 * The first image is the icon
888 * displayed to the left of the
889 * entry's label. The second is icon
890 * displayed when entry is "open". */
891 char *takeFocus;
892
893 ClientData clientData;
894
895 Blt_BindTable bindTable; /* Binding information for entries. */
896
897 Blt_HashTable entryTagTable;
898 Blt_HashTable buttonTagTable;
899 Blt_HashTable columnTagTable;
900 Blt_HashTable styleTagTable;
901
902 TreeViewStyle *stylePtr; /* Default style for text cells */
903
904 TreeViewColumn treeColumn;
905
906 TreeViewColumn *activeColumnPtr;
907 TreeViewColumn *activeTitleColumnPtr;
908 /* Column title currently active. */
909
910 TreeViewColumn *resizeColumnPtr;
911 /* Column that is being resized. */
912
913 int depth;
914
915 int flatView; /* Indicates if the view of the tree
916 * has been flattened. */
917
918 TreeViewEntry **flatArr; /* Flattened array of entries. */
919
920 char *sortField; /* Field to be sorted. */
921
922 int sortType; /* Type of sorting to be performed. See
923 * below for valid values. */
924
925 char *sortCmd; /* Sort command. */
926
927 int sortDecreasing; /* Indicates entries should be sorted
928 * in decreasing order. */
929
930 int viewIsDecreasing; /* Current sorting direction */
931
932 TreeViewColumn *sortColumnPtr;/* Column to use for sorting criteria. */
933
934#ifdef notdef
935 Pixmap drawable; /* Pixmap used to cache the entries
936 * displayed. The pixmap is saved so
937 * that only selected elements can be
938 * drawn quicky. */
939
940 short int drawWidth, drawHeight;
941#endif
942 short int ruleAnchor, ruleMark;
943
944 Blt_Pool entryPool;
945 Blt_Pool valuePool;
946};
947
948
949extern UID Blt_TreeViewGetUid _ANSI_ARGS_((TreeView *tvPtr,
950 CONST char *string));
951extern void Blt_TreeViewFreeUid _ANSI_ARGS_((TreeView *tvPtr, UID uid));
952
953extern void Blt_TreeViewEventuallyRedraw _ANSI_ARGS_((TreeView *tvPtr));
954extern Tcl_ObjCmdProc Blt_TreeViewWidgetInstCmd;
955extern TreeViewEntry *Blt_TreeViewNearestEntry _ANSI_ARGS_((TreeView *tvPtr,
956 int x, int y, int flags));
957extern char *Blt_TreeViewGetFullName _ANSI_ARGS_((TreeView *tvPtr,
958 TreeViewEntry *entryPtr, int checkEntryLabel, Tcl_DString *dsPtr));
959extern void Blt_TreeViewSelectCmdProc _ANSI_ARGS_((ClientData clientData));
960extern void Blt_TreeViewInsertText _ANSI_ARGS_((TreeView *tvPtr,
961 TreeViewEntry *entryPtr, char *string, int extra, int insertPos));
962extern void Blt_TreeViewComputeLayout _ANSI_ARGS_((TreeView *tvPtr));
963extern void Blt_TreeViewPercentSubst _ANSI_ARGS_((TreeView *tvPtr,
964 TreeViewEntry *entryPtr, char *command, Tcl_DString *resultPtr));
965extern void Blt_TreeViewDrawButton _ANSI_ARGS_((TreeView *tvPtr,
966 TreeViewEntry *entryPtr, Drawable drawable, int x, int y));
967extern void Blt_TreeViewDrawValue _ANSI_ARGS_((TreeView *tvPtr,
968 TreeViewEntry *entryPtr, TreeViewValue *valuePtr, Drawable drawable,
969 int x, int y));
970extern void Blt_TreeViewDrawOuterBorders _ANSI_ARGS_((TreeView *tvPtr,
971 Drawable drawable));
972extern int Blt_TreeViewDrawIcon _ANSI_ARGS_((TreeView *tvPtr,
973 TreeViewEntry *entryPtr, Drawable drawable, int x, int y));
974extern void Blt_TreeViewDrawHeadings _ANSI_ARGS_((TreeView *tvPtr,
975 Drawable drawable));
976extern void Blt_TreeViewDrawRule _ANSI_ARGS_((TreeView *tvPtr,
977 TreeViewColumn *columnPtr, Drawable drawable));
978
979extern void Blt_TreeViewConfigureButtons _ANSI_ARGS_((TreeView *tvPtr));
980extern int Blt_TreeViewUpdateWidget _ANSI_ARGS_((Tcl_Interp *interp,
981 TreeView *tvPtr));
982extern int Blt_TreeViewScreenToIndex _ANSI_ARGS_((TreeView *tvPtr,
983 int x, int y));
984
985extern void Blt_TreeViewFreeIcon _ANSI_ARGS_((TreeView *tvPtr,
986 TreeViewIcon icon));
987extern TreeViewIcon Blt_TreeViewGetIcon _ANSI_ARGS_((TreeView *tvPtr,
988 CONST char *iconName));
989extern void Blt_TreeViewAddValue _ANSI_ARGS_((TreeViewEntry *entryPtr,
990 TreeViewColumn *columnPtr));
991extern int Blt_TreeViewCreateColumn _ANSI_ARGS_((TreeView *tvPtr,
992 TreeViewColumn *columnPtr, char *name, char *defaultLabel));
993extern void Blt_TreeViewDestroyValue _ANSI_ARGS_((TreeView *tvPtr,
994 TreeViewValue *valuePtr));
995extern TreeViewValue *Blt_TreeViewFindValue _ANSI_ARGS_((
996 TreeViewEntry *entryPtr, TreeViewColumn *columnPtr));
997extern void Blt_TreeViewDestroyColumns _ANSI_ARGS_((TreeView *tvPtr));
998extern void Blt_TreeViewAllocateColumnUids _ANSI_ARGS_((TreeView *tvPtr));
999extern void Blt_TreeViewFreeColumnUids _ANSI_ARGS_((TreeView *tvPtr));
1000extern void Blt_TreeViewUpdateColumnGCs _ANSI_ARGS_((TreeView *tvPtr,
1001 TreeViewColumn *columnPtr));
1002extern TreeViewColumn *Blt_TreeViewNearestColumn _ANSI_ARGS_((TreeView *tvPtr,
1003 int x, int y, ClientData *contextPtr));
1004
1005extern void Blt_TreeViewDrawRule _ANSI_ARGS_((TreeView *tvPtr,
1006 TreeViewColumn *columnPtr, Drawable drawable));
1007extern int Blt_TreeViewTextOp _ANSI_ARGS_((TreeView *tvPtr, Tcl_Interp *interp,
1008 int objc, Tcl_Obj *CONST *objv));
1009extern int Blt_TreeViewCombobox _ANSI_ARGS_((TreeView *tvPtr,
1010 TreeViewEntry *entryPtr, TreeViewColumn *columnPtr));
1011extern int Blt_TreeViewCreateEntry _ANSI_ARGS_((TreeView *tvPtr,
1012 Blt_TreeNode node, int objc, Tcl_Obj *CONST *objv, int flags));
1013extern int Blt_TreeViewConfigureEntry _ANSI_ARGS_((TreeView *tvPtr,
1014 TreeViewEntry *entryPtr, int objc, Tcl_Obj *CONST *objv, int flags));
1015extern int Blt_TreeViewOpenEntry _ANSI_ARGS_((TreeView *tvPtr,
1016 TreeViewEntry *entryPtr));
1017extern int Blt_TreeViewCloseEntry _ANSI_ARGS_((TreeView *tvPtr,
1018 TreeViewEntry *entryPtr));
1019extern TreeViewEntry *Blt_TreeViewNextEntry _ANSI_ARGS_((
1020 TreeViewEntry *entryPtr, unsigned int mask));
1021extern TreeViewEntry *Blt_TreeViewPrevEntry _ANSI_ARGS_((
1022 TreeViewEntry *entryPtr, unsigned int mask));
1023extern int Blt_TreeViewGetEntry _ANSI_ARGS_((TreeView *tvPtr, Tcl_Obj *objPtr,
1024 TreeViewEntry **entryPtrPtr));
1025extern int Blt_TreeViewEntryIsHidden _ANSI_ARGS_((TreeViewEntry *entryPtr));
1026extern TreeViewEntry *Blt_TreeViewNextSibling _ANSI_ARGS_((
1027 TreeViewEntry *entryPtr, unsigned int mask));
1028extern TreeViewEntry *Blt_TreeViewPrevSibling _ANSI_ARGS_((
1029 TreeViewEntry *entryPtr, unsigned int mask));
1030extern TreeViewEntry *Blt_TreeViewFirstChild _ANSI_ARGS_((
1031 TreeViewEntry *parentPtr, unsigned int mask));
1032extern TreeViewEntry *Blt_TreeViewLastChild _ANSI_ARGS_((
1033 TreeViewEntry *entryPtr, unsigned int mask));
1034extern TreeViewEntry *Blt_TreeViewParentEntry _ANSI_ARGS_((
1035 TreeViewEntry *entryPtr));
1036
1037typedef int (TreeViewApplyProc) _ANSI_ARGS_((TreeView *tvPtr,
1038 TreeViewEntry *entryPtr));
1039
1040extern int Blt_TreeViewApply _ANSI_ARGS_((TreeView *tvPtr,
1041 TreeViewEntry *entryPtr, TreeViewApplyProc *proc, unsigned int mask));
1042
1043extern int Blt_TreeViewColumnOp _ANSI_ARGS_((TreeView *tvPtr,
1044 Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv));
1045extern int Blt_TreeViewSortOp _ANSI_ARGS_((TreeView *tvPtr, Tcl_Interp *interp,
1046 int objc, Tcl_Obj *CONST *objv));
1047extern int Blt_TreeViewGetColumn _ANSI_ARGS_((Tcl_Interp *interp,
1048 TreeView *tvPtr, Tcl_Obj *objPtr, TreeViewColumn **columnPtrPtr));
1049
1050extern void Blt_TreeViewSortFlatView _ANSI_ARGS_((TreeView *tvPtr));
1051extern void Blt_TreeViewSortTreeView _ANSI_ARGS_((TreeView *tvPtr));
1052
1053extern int Blt_TreeViewEntryIsSelected _ANSI_ARGS_((TreeView *tvPtr,
1054 TreeViewEntry *entryPtr));
1055extern void Blt_TreeViewSelectEntry _ANSI_ARGS_((TreeView *tvPtr,
1056 TreeViewEntry *entryPtr));
1057extern void Blt_TreeViewDeselectEntry _ANSI_ARGS_((TreeView *tvPtr,
1058 TreeViewEntry *entryPtr));
1059extern void Blt_TreeViewPruneSelection _ANSI_ARGS_((TreeView *tvPtr,
1060 TreeViewEntry *entryPtr));
1061extern void Blt_TreeViewClearSelection _ANSI_ARGS_((TreeView *tvPtr));
1062extern void Blt_TreeViewClearTags _ANSI_ARGS_((TreeView *tvPtr,
1063 TreeViewEntry *entryPtr));
1064extern int Blt_TreeViewFindTaggedEntries _ANSI_ARGS_((TreeView *tvPtr,
1065 Tcl_Obj *objPtr, TreeViewTagInfo *infoPtr));
1066extern TreeViewEntry *Blt_TreeViewFirstTaggedEntry _ANSI_ARGS_((
1067 TreeViewTagInfo *infoPtr));
1068extern TreeViewEntry *Blt_TreeViewNextTaggedEntry _ANSI_ARGS_((
1069 TreeViewTagInfo *infoPtr));
1070extern ClientData Blt_TreeViewButtonTag _ANSI_ARGS_((TreeView *tvPtr,
1071 CONST char *string));
1072extern ClientData Blt_TreeViewEntryTag _ANSI_ARGS_((TreeView *tvPtr,
1073 CONST char *string));
1074extern ClientData Blt_TreeViewColumnTag _ANSI_ARGS_((TreeView *tvPtr,
1075 CONST char *string));
1076extern void Blt_TreeViewGetTags _ANSI_ARGS_((Tcl_Interp *interp,
1077 TreeView *tvPtr, TreeViewEntry *entryPtr, Blt_List list));
1078extern void Blt_TreeViewTraceColumn _ANSI_ARGS_((TreeView *tvPtr,
1079 TreeViewColumn *columnPtr));
1080extern TreeViewIcon Blt_TreeViewGetEntryIcon _ANSI_ARGS_((TreeView *tvPtr,
1081 TreeViewEntry *entryPtr));
1082extern void Blt_TreeViewSetStyleIcon _ANSI_ARGS_((TreeView *tvPtr,
1083 TreeViewStyle *stylePtr, TreeViewIcon icon));
1084extern int Blt_TreeViewGetStyle _ANSI_ARGS_((Tcl_Interp *interp,
1085 TreeView *tvPtr, char *styleName, TreeViewStyle **stylePtrPtr));
1086extern void Blt_TreeViewFreeStyle _ANSI_ARGS_((TreeView *tvPtr,
1087 TreeViewStyle *stylePtr));
1088extern TreeViewStyle *Blt_TreeViewCreateStyle _ANSI_ARGS_((Tcl_Interp *interp,
1089 TreeView *tvPtr, int type, char *styleName));
1090extern void Blt_TreeViewUpdateStyleGCs _ANSI_ARGS_((TreeView *tvPtr,
1091 TreeViewStyle *stylePtr));
1092extern Tk_3DBorder Blt_TreeViewGetStyleBorder _ANSI_ARGS_((TreeView *tvPtr,
1093 TreeViewStyle *stylePtr));
1094extern GC Blt_TreeViewGetStyleGC _ANSI_ARGS_((TreeViewStyle *stylePtr));
1095extern Tk_Font Blt_TreeViewGetStyleFont _ANSI_ARGS_((TreeView *tvPtr,
1096 TreeViewStyle *stylePtr));
1097extern XColor *Blt_TreeViewGetStyleFg _ANSI_ARGS_((TreeView *tvPtr,
1098 TreeViewStyle *stylePtr));
1099extern TreeViewEntry *Blt_NodeToEntry _ANSI_ARGS_((TreeView *tvPtr,
1100 Blt_TreeNode node));
1101extern int Blt_TreeViewStyleOp _ANSI_ARGS_((TreeView *tvPtr, Tcl_Interp *interp,
1102 int objc, Tcl_Obj *CONST *objv));
1103
1104#define CHOOSE(default, override) \
1105 (((override) == NULL) ? (default) : (override))
1106
1107#define GETLABEL(e) \
1108 (((e)->labelUid != NULL) ? (e)->labelUid : Blt_TreeNodeLabel((e)->node))
1109
1110#define Blt_TreeViewGetData(entryPtr, key, objPtrPtr) \
1111 Blt_TreeGetValueByKey((Tcl_Interp *)NULL, (entryPtr)->tvPtr->tree, \
1112 (entryPtr)->node, key, objPtrPtr)
1113
1114#endif /* BLT_TREEVIEW_H */
Note: See TracBrowser for help on using the repository browser.