|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/vibrant/treeview.h |
source navigation diff markup identifier search freetext search file search |
1 /* treeview.h
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: treeview.h
27 *
28 * Author: Vladimir Soussov
29 *
30 * File Description: Data types for treeview
31 *
32 *
33 * $Log: treeview.h,v $
34 * Revision 1.6 2001/03/28 16:06:10 kans
35 * added prototype for tview_setPlusColor
36 *
37 * Revision 1.5 1998/04/08 16:51:52 soussov
38 * typo in function name fixed
39 *
40 * Revision 1.4 1998/04/01 21:16:46 soussov
41 * Some prototypes added
42 *
43 * Revision 1.3 1998/04/01 20:09:25 soussov
44 * Some prototypes added
45 *
46 * Revision 1.2 1998/04/01 17:44:02 soussov
47 * changed tp include <>
48 *
49 * Revision 1.1 1998/03/31 21:22:28 sirotkin
50 * With Vladimir - moved from distrib/internal/taxonomy/tree
51 *
52 * Revision 6.0 1997/08/25 18:29:56 madden
53 * Revision changed to 6.0
54 *
55 * Revision 1.1 1997/05/30 16:16:23 soussov
56 * Set of files for ncbitree library
57 *
58 * Revision 1.1 1997/05/29 20:44:35 soussov
59 * Initial version of tree library
60 *
61 *
62 */
63
64 #ifndef TREEVIEW_H_DONE
65 #define TREEVIEW_H_DONE
66
67 #include <ncbi.h>
68 #include <vibrant.h>
69 #include <treemgr.h>
70 #include <treevint.h>
71
72 #if 0
73 typedef enum {
74 TVIEW_ON_SELECT = 0,
75 TVIEW_ON_OPEN,
76 TVIEW_ON_CLOSE
77 } TViewEvent;
78 #endif
79
80 /***************************************************************
81 * Create tree view
82 * parent - parent group or window. If parent == NULL then tree view will be
83 * created in a separate resizable window.
84 * width, height - size of tree view in pixels
85 * tree - tree which has to be shown
86 * icon_list - list of icons (if NULL - no icons will be shown
87 * scale - scale for distance
88 * NodeCmp - node comparison function (NULL if you don't want nodes ordering)
89 *
90 * If you'd like to display nodes in some particular order,
91 * then you have to provide NodeCmp(TreeCursorPtr, TreeCursorPtr)
92 * function. For two given nodes, this function should return
93 * negative value if first node should be first, and positive if
94 * second node should be first
95 *
96 *
97 * NOTE!
98 * To display tree in tree view you have to provide the getNode function
99 * (see tree.h header) and register it using tree_setGetNodeFunc()
100 * Tree viewer will run your function to get label, distance and icon id.
101 * So it should return CharPtr if format == TREE_NODE_FMT_LABEL
102 * Int4 if format == TREE_NODE_FMT_ICON || format == TREE_NODE_FMT_DISTANCE
103 * If you dont want to paint icon for some node then your function has to return -1 for these nodes
104 */
105 TreeViewPtr tview_create(GrouP parent, Int2 width, Int2 height,
106 TreePtr tree, _ImageListPtr icon_list, Int2 scale,
107 TreeNodeCmpFunc NodeCmp);
108
109 /***************************************************************
110 * The following function works almost like tview_create(NULL, ...),
111 * but provide the ability to specify the window position on the screen,
112 * window title and add menu to tree viewer's window.
113 *
114 * Example:
115 *
116 * static void crtMenu(WindoW m_window)
117 * {
118 * MenU m1, m2;
119 *
120 * m1= PulldownMenu(m_window, "File");
121 * .....
122 * CommandItem(m1, "Exit", exit_proc);
123 * .....
124 * m2= PulldownMenu(m_window, "Edit");
125 * .....
126 * }
127 * .....
128 * TreeViewPtr tv= tview_createCustom(10, 10, 200, 100, "My favorite tree", crtMenu,
129 * tree, NULL, 30, tview_labelCmp);
130 *
131 */
132 TreeViewPtr tview_createCustom(Int2 left, Int2 top, Int2 width, Int2 height,
133 CharPtr title, void (*menuCrtFunc)(WindoW),
134 TreePtr tree, _ImageListPtr il, Int2 l_scale,
135 TreeNodeCmpFunc NodeCmp);
136
137 /***************************************************************
138 * Delete tree view
139 */
140 void tview_delete(TreeViewPtr tv, Boolean do_hide);
141
142 /***************************************************************
143 * Set tree view colors
144 * Function returns TRUE on success
145 */
146 Boolean tview_setTextColor(TreeViewPtr tv, Uint4 color);
147 Boolean tview_setLineColor(TreeViewPtr tv, Uint4 color);
148 Boolean tview_setPlusColor(TreeViewPtr tv, Uint4 color);
149 Boolean tview_setSelBGColor(TreeViewPtr tv, Uint4 color);
150 Boolean tview_setSelFGColor(TreeViewPtr tv, Uint4 color);
151
152 /***************************************************************
153 * Replace NodeCmp function
154 * If you'd like to display nodes in some particular order,
155 * then you have to provide NodeCmp(TreeCursorPtr, TreeCursorPtr)
156 * function. For two given nodes, this function should return
157 * negative value if first node should be first, and positive if
158 * second node should be first
159 */
160
161 TreeNodeCmpFunc tview_setNodeCmpFunc(TreeViewPtr tv, TreeNodeCmpFunc NodeCmp);
162
163 /****************************************************************
164 * You can use the following two functions as a NodeCmp functions
165 * The first one compares the labels
166 * the second one compares the distances
167 * To do this just call
168 * tview_setNodeCmpFunc(tv, tview_labelCmp);
169 * or
170 * tview_setNodeCmpFunc(tv, tview_distanceCmp);
171 */
172 Int2 tview_labelCmp(TreeCursorPtr c1, TreeCursorPtr c2);
173 Int2 tview_distanceCmp(TreeCursorPtr c1, TreeCursorPtr c2);
174
175 /*****************************************************************
176 * Set event handler function for tree viewer.
177 * void HandlerFunc(TreeCursorPtr cursor, TViewEvent evnt)
178 * event handler will be called just before any actions
179 * regarding this event will be done
180 */
181 TreeViewEventFunc tview_setEventHandler(TreeViewPtr tv, TreeViewEventFunc HandlerFunc);
182
183 /*****************************************************************
184 * Set double click function.
185 * void dblClickFunc(TreeViewPtr tv, TreeNodeId id, Boolean isOverNode)
186 * Your function will be called on user double click inside tree viewer panel
187 * If user click over tree node, then isOverNode argument will be TRUE
188 * and id will be the id of node under cursor.
189 * If there is no nodes under cursor, your function will be called with isOverNode == FALSE
190 */
191 TreeViewClickFunc tview_setDblClickFunc(TreeViewPtr tv, TreeViewClickFunc dblClickFunc);
192
193 /*****************************************************************
194 * Set shift click function.
195 * void shiftClickFunc(TreeViewPtr tv, TreeNodeId id, Boolean isOverNode)
196 * Your function will be called on user does shift+click inside tree viewer panel
197 * If user click over tree node, then isOverNode argument will be TRUE
198 * and id will be the id of node under cursor.
199 * If there is no nodes under cursor, your function will be called with isOverNode == FALSE
200 */
201 TreeViewClickFunc tview_setShiftClickFunc(TreeViewPtr tv, TreeViewClickFunc shiftClickFunc);
202
203 /*****************************************************************
204 * Set control click function.
205 * void ctrlClickFunc(TreeViewPtr tv, TreeNodeId id, Boolean isOverNode)
206 * Your function will be called on user does control+click inside tree viewer panel
207 * If user click over tree node, then isOverNode argument will be TRUE
208 * and id will be the id of node under cursor.
209 * If there is no nodes under cursor, your function will be called with isOverNode == FALSE
210 */
211 TreeViewClickFunc tview_setCtrlClickFunc(TreeViewPtr tv, TreeViewClickFunc ctrlClickFunc);
212
213 /*****************************************************************
214 * Redraw the tree
215 */
216 void tview_redraw(TreeViewPtr tv);
217
218 /*****************************************************************
219 * show selected node on the screen
220 */
221 void tview_showSelected(TreeViewPtr tv);
222
223 /*****************************************************************
224 * select node and show it on the screen
225 */
226 Boolean tview_selectNode(TreeViewPtr tv, TreeNodeId id);
227
228 /*****************************************************************
229 * open subtree and make it visible
230 */
231 Boolean tview_openSubtree(TreeViewPtr tv, TreeNodeId id);
232
233 /*****************************************************************
234 * close subtree
235 */
236 Boolean tview_closeSubtree(TreeViewPtr tv, TreeNodeId id);
237
238 /*****************************************************************
239 * Hide tree view
240 */
241 void tview_hide(TreeViewPtr tv);
242
243 /*****************************************************************
244 * Show tree view
245 */
246 void tview_show(TreeViewPtr tv);
247
248 /*****************************************************************
249 * disable tree view
250 */
251 void tview_disable(TreeViewPtr tv);
252
253 /*****************************************************************
254 * enable tree view
255 */
256 void tview_enable(TreeViewPtr tv);
257
258 /*****************************************************************
259 * Resize the tree viewer panel
260 * You can use this function if you have created tree viewer
261 * not as a separate window, but inside some window.
262 * r is a rectangle which describes tree panel coordinates inside
263 * window
264 */
265 void tview_resize(TreeViewPtr tv, RectPtr r);
266
267 /*****************************************************************
268 * Move root of visible tree to node with node_id == id
269 * You can use this function if you want to display just
270 * subtree from your tree
271 */
272 Boolean tview_moveRoot(TreeViewPtr tv, TreeNodeId id);
273
274 /*****************************************************************
275 * Get selected node id
276 */
277 TreeNodeId tview_getSelected(TreeViewPtr tv);
278
279 /*****************************************************************
280 * Get TreePtr
281 */
282 TreePtr tview_getTreePtr(TreeViewPtr tv);
283
284 #endif
285 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |