~ubuntu-branches/ubuntu/maverick/ncbi-tools6/maverick

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*  treeview.h
* ===========================================================================
*
*                            PUBLIC DOMAIN NOTICE                          
*               National Center for Biotechnology Information
*                                                                          
*  This software/database is a "United States Government Work" under the   
*  terms of the United States Copyright Act.  It was written as part of    
*  the author's official duties as a United States Government employee and 
*  thus cannot be copyrighted.  This software/database is freely available 
*  to the public for use. The National Library of Medicine and the U.S.    
*  Government have not placed any restriction on its use or reproduction.  
*                                                                          
*  Although all reasonable efforts have been taken to ensure the accuracy  
*  and reliability of the software and data, the NLM and the U.S.          
*  Government do not and cannot warrant the performance or results that    
*  may be obtained by using this software or data. The NLM and the U.S.    
*  Government disclaim all warranties, express or implied, including       
*  warranties of performance, merchantability or fitness for any particular
*  purpose.                                                                
*                                                                          
*  Please cite the author in any work or product based on this material.   
*
* ===========================================================================
*
* File Name:  treeview.h
*
* Author:  Vladimir Soussov
*   
* File Description:  Data types for treeview
*
*
* $Log: treeview.h,v $
* Revision 1.6  2001/03/28 16:06:10  kans
* added prototype for tview_setPlusColor
*
* Revision 1.5  1998/04/08 16:51:52  soussov
* typo in function name fixed
*
* Revision 1.4  1998/04/01 21:16:46  soussov
* Some prototypes added
*
* Revision 1.3  1998/04/01 20:09:25  soussov
* Some prototypes added
*
* Revision 1.2  1998/04/01 17:44:02  soussov
* changed tp include <>
*
* Revision 1.1  1998/03/31 21:22:28  sirotkin
* With Vladimir - moved from distrib/internal/taxonomy/tree
*
* Revision 6.0  1997/08/25 18:29:56  madden
* Revision changed to 6.0
*
* Revision 1.1  1997/05/30 16:16:23  soussov
* Set of files for ncbitree library
*
* Revision 1.1  1997/05/29 20:44:35  soussov
* Initial version of tree library
*
*
*/

#ifndef TREEVIEW_H_DONE
#define TREEVIEW_H_DONE

#include <ncbi.h>
#include <vibrant.h>
#include <treemgr.h>
#include <treevint.h>

#if 0
typedef enum {
    TVIEW_ON_SELECT = 0,
    TVIEW_ON_OPEN,
    TVIEW_ON_CLOSE
} TViewEvent;
#endif

/***************************************************************
 * Create tree view
 * parent - parent group or window. If parent == NULL then tree view will be
 *          created in a separate resizable window.
 * width, height - size of tree view in pixels
 * tree - tree which has to be shown
 * icon_list - list of icons (if NULL - no icons will be shown
 * scale - scale for distance
 * NodeCmp - node comparison function (NULL if you don't want nodes ordering)
 *
 * If you'd like to display nodes in some particular order,
 * then you have to provide NodeCmp(TreeCursorPtr, TreeCursorPtr)
 * function. For two given nodes, this function should return 
 * negative value if first node should be first, and positive if
 * second node should be first
 *            
 *
 * NOTE!
 * To display tree in tree view you have to provide the getNode function
 * (see tree.h header) and register it using tree_setGetNodeFunc()
 * Tree viewer will run your function to get label, distance and icon id.
 * So it should return CharPtr if format == TREE_NODE_FMT_LABEL
 *                     Int4    if format == TREE_NODE_FMT_ICON || format == TREE_NODE_FMT_DISTANCE
 * If you dont want to paint icon for some node then your function has to return -1 for these nodes
 */
TreeViewPtr tview_create(GrouP parent, Int2 width, Int2 height, 
			 TreePtr tree, _ImageListPtr icon_list, Int2 scale, 
			 TreeNodeCmpFunc NodeCmp);

/***************************************************************
 * The following function works almost like tview_create(NULL, ...),
 * but provide the ability to specify the window position on the screen,
 * window title and add menu to tree viewer's window.
 *
 * Example:
 *
 * static void crtMenu(WindoW m_window)
 * {
 *   MenU m1, m2;
 *
 *   m1= PulldownMenu(m_window, "File");
 *   .....
 *   CommandItem(m1, "Exit", exit_proc);
 *   .....
 *   m2= PulldownMenu(m_window, "Edit");
 *   .....
 * }
 * .....
 * TreeViewPtr tv= tview_createCustom(10, 10, 200, 100, "My favorite tree", crtMenu, 
 *                                    tree, NULL, 30, tview_labelCmp);
 *
 */
TreeViewPtr tview_createCustom(Int2 left, Int2 top, Int2 width, Int2 height,
			       CharPtr title, void (*menuCrtFunc)(WindoW),
			 TreePtr tree, _ImageListPtr il, Int2 l_scale, 
			 TreeNodeCmpFunc NodeCmp);

/***************************************************************
 * Delete tree view
 */
void tview_delete(TreeViewPtr tv, Boolean do_hide);

/***************************************************************
 * Set tree view colors
 * Function returns TRUE on success
 */
Boolean tview_setTextColor(TreeViewPtr tv, Uint4 color);
Boolean tview_setLineColor(TreeViewPtr tv, Uint4 color);
Boolean tview_setPlusColor(TreeViewPtr tv, Uint4 color);
Boolean tview_setSelBGColor(TreeViewPtr tv, Uint4 color);
Boolean tview_setSelFGColor(TreeViewPtr tv, Uint4 color);

/***************************************************************
 * Replace NodeCmp function
 * If you'd like to display nodes in some particular order,
 * then you have to provide NodeCmp(TreeCursorPtr, TreeCursorPtr)
 * function. For two given nodes, this function should return 
 * negative value if first node should be first, and positive if
 * second node should be first
 */

TreeNodeCmpFunc tview_setNodeCmpFunc(TreeViewPtr tv, TreeNodeCmpFunc NodeCmp);

/****************************************************************
 * You can use the following two functions as a NodeCmp functions
 * The first one compares the labels
 * the second one compares the distances
 * To do this just call
 * tview_setNodeCmpFunc(tv, tview_labelCmp);
 * or
 * tview_setNodeCmpFunc(tv, tview_distanceCmp);
 */
Int2 tview_labelCmp(TreeCursorPtr c1, TreeCursorPtr c2);
Int2 tview_distanceCmp(TreeCursorPtr c1, TreeCursorPtr c2);

/*****************************************************************
 * Set event handler function for tree viewer.
 * void HandlerFunc(TreeCursorPtr cursor, TViewEvent evnt)
 * event handler will be called just before any actions
 * regarding this event will be done
 */
TreeViewEventFunc tview_setEventHandler(TreeViewPtr tv, TreeViewEventFunc HandlerFunc);

/*****************************************************************
 * Set double click function.
 * void dblClickFunc(TreeViewPtr tv, TreeNodeId id, Boolean isOverNode)
 * Your function will be called on user double click inside tree viewer panel
 * If user click over tree node, then isOverNode argument will be TRUE
 * and id will be  the id of node under cursor.
 * If there is no nodes under cursor, your function will be called with isOverNode == FALSE
 */
TreeViewClickFunc tview_setDblClickFunc(TreeViewPtr tv, TreeViewClickFunc dblClickFunc);

/*****************************************************************
 * Set shift click function.
 * void shiftClickFunc(TreeViewPtr tv, TreeNodeId id, Boolean isOverNode)
 * Your function will be called on user does shift+click inside tree viewer panel
 * If user click over tree node, then isOverNode argument will be TRUE
 * and id will be  the id of node under cursor.
 * If there is no nodes under cursor, your function will be called with isOverNode == FALSE
 */
TreeViewClickFunc tview_setShiftClickFunc(TreeViewPtr tv, TreeViewClickFunc shiftClickFunc);

/*****************************************************************
 * Set control click function.
 * void ctrlClickFunc(TreeViewPtr tv, TreeNodeId id, Boolean isOverNode)
 * Your function will be called on user does control+click inside tree viewer panel
 * If user click over tree node, then isOverNode argument will be TRUE
 * and id will be  the id of node under cursor.
 * If there is no nodes under cursor, your function will be called with isOverNode == FALSE
 */
TreeViewClickFunc tview_setCtrlClickFunc(TreeViewPtr tv, TreeViewClickFunc ctrlClickFunc);

/*****************************************************************
 * Redraw the tree
 */
void tview_redraw(TreeViewPtr tv);

/*****************************************************************
 * show selected node on the screen
 */
void tview_showSelected(TreeViewPtr tv);

/*****************************************************************
 * select node and show it on the screen
 */
Boolean tview_selectNode(TreeViewPtr tv, TreeNodeId id);

/*****************************************************************
 * open subtree and make it visible
 */
Boolean tview_openSubtree(TreeViewPtr tv, TreeNodeId id);

/*****************************************************************
 * close subtree
 */
Boolean tview_closeSubtree(TreeViewPtr tv, TreeNodeId id);

/*****************************************************************
 * Hide tree view
 */
void tview_hide(TreeViewPtr tv);

/*****************************************************************
 * Show tree view
 */
void tview_show(TreeViewPtr tv);

/*****************************************************************
 * disable tree view
 */
void tview_disable(TreeViewPtr tv);

/*****************************************************************
 * enable tree view
 */
void tview_enable(TreeViewPtr tv);

/*****************************************************************
 * Resize the tree viewer panel
 * You can use this function if you have created tree viewer
 * not as a separate window, but inside some window. 
 * r is a rectangle which describes tree panel coordinates inside
 * window
 */
void tview_resize(TreeViewPtr tv, RectPtr r);

/*****************************************************************
 * Move root of visible tree to node with node_id == id
 * You can use this function if you want to display just
 * subtree from your tree
 */
Boolean tview_moveRoot(TreeViewPtr tv, TreeNodeId id);

/*****************************************************************
 * Get selected node id
 */
TreeNodeId tview_getSelected(TreeViewPtr tv);

/*****************************************************************
 * Get TreePtr 
 */
TreePtr tview_getTreePtr(TreeViewPtr tv);

#endif