📄 flu_tree_browser.h
字号:
/* * =========================================================================== * PRODUCTION $Log: Flu_Tree_Browser.h,v $ * PRODUCTION Revision 1000.0 2004/04/12 18:22:29 gouriano * PRODUCTION PRODUCTION: IMPORTED [CATCHUP_003] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//* * These files were imported into NCBI's CVS directly from FLU version 2.9.1. * Modifications to the source are listed below. * * ========================================================================== * $Log: Flu_Tree_Browser.h,v $ * Revision 1000.0 2004/04/12 18:22:29 gouriano * PRODUCTION: IMPORTED [CATCHUP_003] Dev-tree R1.7 * * Revision 1.7 2004/04/07 12:41:18 dicuccio * Fixed compiler warning on MSVC - unsighed char -> bool conversion * * Revision 1.6 2004/03/25 17:13:45 ivanov * Introduced FLU_DND_BASE macro to make DOC++ happy * * Revision 1.5 2004/03/11 14:10:41 dicuccio * Fixes for 64-bit compilation * * Revision 1.4 2004/03/11 13:51:55 dicuccio * Imported FLU version 2.9.1. Altered export specifiers to match NCBI layout. * Altered include paths to match NCBI toolkit layout. * * ========================================================================== */// $Id: Flu_Tree_Browser.h,v 1000.0 2004/04/12 18:22:29 gouriano Exp $/*************************************************************** * FLU - FLTK Utility Widgets * Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University * * This file and its content is protected by a software license. * You should have received a copy of this license with this file. * If not, please contact the Ohio Supercomputer Center immediately: * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212 * ***************************************************************/#ifndef _FLU_TREE_BROWSER_H#define _FLU_TREE_BROWSER_H#include <stdio.h>#include <string.h>#include <stdlib.h>#define USE_FLU_DND/* fltk includes */#include <FL/Fl.H>#include <FL/Fl_Box.H>#include <FL/Fl_Pixmap.H>#include <FL/Fl_Image.H>#include <FL/Fl_Scrollbar.H>#include <FL/Fl_Group.H>#include <FL/Fl_Menu_Button.H>/* flu includes */#include <gui/widgets/FLU/Flu_Enumerations.h>#include <gui/widgets/FLU/FluSimpleString.h>#ifdef USE_FLU_DND#include <gui/widgets/FLU/Flu_DND.h>#elsetypedef struct { bool dummy; } Flu_DND_Event; // for compatibilty when not compiling DND support#endif//! This class provides a browser for hierarchical data representation (i.e. a "tree")#ifdef USE_FLU_DND# define FLU_DND_BASE , public Flu_DND#else# define FLU_DND_BASE#endifclass NCBI_GUIWIDGETS_FLU_EXPORT Flu_Tree_Browser : public Fl_Group FLU_DND_BASE{ public: class Node; friend class Node; //! Normal FLTK widget constructor Flu_Tree_Browser( int x, int y, int w, int h, const char *label = 0 ); //! Default destructor virtual ~Flu_Tree_Browser(); //! Add the entry specified by \b fullpath to the tree. If \b w is not \c NULL then that widget is the entry and its label is visible depending on the value of \b showLabel. Note that the widget is destroyed by the tree/node on clear() or the destructor /*! If \b fullpath ends in a slash ("/"), then the entry is added as a branch, else it is added as a leaf \return a pointer to the Node of the added entry or NULL if the add failed */ Node* add( const char* fullpath, Fl_Widget *w = 0, bool showLabel = true ); //! Add entry \b name in path \b path to the tree. If \b w is not \c NULL then that widget is the entry and its label is visible depending on the value of \b showLabel. Note that the widget is destroyed by the tree/node on clear() or the destructor /*! If \b name ends in a slash ("/"), then the entry is added as a branch, else it is added as a leaf \return a pointer to the Node of the added entry or NULL if the add failed */ Node* add( const char* path, const char* name, Fl_Widget *w = 0, bool showLabel = true ); //! Add entry \b name to node \b n. If \b w is not \c NULL then that widget is the entry and its label is visible depending on the value of \b showLabel. Note that the widget is destroyed by the tree/node on clear() or the destructor /*! If \b name ends in a slash ("/"), then the entry is added as a branch, else it is added as a leaf \return a pointer to the Node of the added entry or NULL if the add failed */ inline Node* add( Node* n, const char* name, Fl_Widget *w = 0, bool showLabel = true ) { return n->add( name, w, showLabel ); } //! Convenience function that is the same as add() except it appends a '/' to \b fullpath if one does not exist Node* add_branch( const char* fullpath, Fl_Widget *w = 0, bool showLabel = true ); //! Convenience function that is the same as add() except it appends a '/' to \b name if one does not exist Node* add_branch( const char* path, const char* name, Fl_Widget *w = 0, bool showLabel = true ); //! Convenience function that is the same as add() except it appends a '/' to \b name if one does not exist inline Node* add_branch( Node* n, const char* name, Fl_Widget *w = 0, bool showLabel = true ) { return n->add_branch( name, w, showLabel ); } //! Convenience function that is the same as add() except it removes any '/' at the end of \b fullpath Node* add_leaf( const char* fullpath, Fl_Widget *w = 0, bool showLabel = true ); //! Convenience function that is the same as add() except it removes any '/' at the end of \b fullpath Node* add_leaf( const char* path, const char* name, Fl_Widget *w = 0, bool showLabel = true ); //! Convenience function that is the same as add() except it removes any '/' at the end of \b fullpath inline Node* add_leaf( Node* n, const char* name, Fl_Widget *w = 0, bool showLabel = true ) { return n->add_leaf( name, w, showLabel ); } //! Set whether all branches are always open. Default value is \c false inline void all_branches_always_open( bool b ) { rdata.allBranchesAlwaysOpen = b; } //! Get whether all branches are always open. Default value is \c false inline bool all_branches_always_open() { return rdata.allBranchesAlwaysOpen; } //! Set whether multiple leaves with the same path are allowed. Default value is \c true inline void allow_leaf_duplication( bool b ) { rdata.allowDuplication = b; } //! Get whether multiple leaves with the same path are allowed. inline bool allow_leaf_duplication() { return rdata.allowDuplication; } //! \return \c true if drag and drop support has been compiled in, \c false otherwise inline bool have_dnd() {#ifdef USE_FLU_DND return true;#else return false;#endif } //! Set whether drag and drop processing is enabled for the browser. Default is \c false /*! If DND is enabled, either text or instances of Flu_Tree_Browser::DND_Object from outside the tree can be dragged and dropped onto the tree to create a new node. Nodes within the tree can be dragged and dropped (only within the same tree) according to the value of selection_drag_mode(). */ inline void allow_dnd( bool b ) { rdata.dnd = b; } //! Get whether drag and drop processing is enabled for the browser. inline bool allow_dnd() { return rdata.dnd; } //! Set whether the root node is always open. Shortcut for \c get_root()->always_open(b). Default is \c false inline void always_open( bool b ) { root.always_open( b ); } //! Get whether the root node is always open inline bool always_open() { return root.always_open(); } //! Set whether animations of opening/closing branches are enabled. Default is \c false inline void animate( bool b ) { rdata.animate = b; } //! Get whether animations of opening/closing branches are enabled inline bool animate() { return rdata.animate; } //! Set whether the tree automatically determines whether a node is a branch or a leaf based on whether it has any children. Default is \c false void auto_branches( bool b ); //! Get whether the tree automatically determines whether a node is a branch or a leaf based on whether it has any children inline bool auto_branches() const { return rdata.autoBranches; } //! Get the default branch text color inline Fl_Color branch_color() const { return rdata.defBranchColor; } //! Get the default branch text font inline Fl_Font branch_font() const { return rdata.defBranchFont; } //! Get the default branch text size inline int branch_size() const { return rdata.defBranchSize; } //! Set the default color, font and size to use for the text of all subsequent branches added to the tree inline void branch_text( Fl_Color color, Fl_Font font, int size ) { rdata.defBranchColor = color; rdata.defBranchFont = font; rdata.defBranchSize = size; } //! Set the default branch icons to use for all subsequent branches added to the tree void branch_icons( Fl_Image *closed, Fl_Image *open ); //! Get the type of box to draw the browser in inline Fl_Boxtype box() const { return _box->box(); } //! Set the type of box to draw the browser in. Default is FL_NO_BOX inline void box( Fl_Boxtype b ) { _box->box( b ); } //! Override of Fl_Widget::callback inline void callback( Fl_Callback *c, void *user_data = 0 ) { rdata.cb = c; rdata.cbd = user_data; } //! Get the reason why the last callback happened. This can be one of FLU_UNHILIGHTED, FLU_HILIGHTED, FLU_SELECTED, FLU_UNSELECTED, FLU_OPENED, FLU_CLOSED, FLU_DOUBLE_CLICK, FLU_WIDGET_CALLBACK, FLU_MOVED_CALLBACK, FLU_NEW_NODE_CALLBACK inline int callback_reason() const { return rdata.cbReason; } //! Get the node on which the last callback happened. /*! \note this node is only guaranteed to be in the tree \b during the callback. If the callback adds/removes nodes, then this node may have changed. In general, do not use the node returned by this method outside of the tree callback. */ inline Node* callback_node() const { return rdata.cbNode; } //! Clear all entries from the tree void clear(); //! Set the default collapse icons to use for all subsequent branches added to the tree void collapse_icons( Fl_Image *closed, Fl_Image *open ); //! Get the amount of time to take when animating an open/close. Use in conjunction with frame_rate() inline float collapse_time() const { return rdata.collapseTime; } //! Set the amount of time to take when animating an open/close. Use in conjunction with frame_rate(). Default is 0.1 seconds inline void collapse_time( float t ) { rdata.collapseTime = t; } //! Get the background color of the browser inline Fl_Color color() const { return _box->color(); } //! Set the background color of the browser. Default is FL_WHITE inline void color( Fl_Color c ) { _box->color( c ); } //! Set the background color of the browser. Default is FL_WHITE inline void color( unsigned c ) { _box->color( (Fl_Color)c ); } //! Set the color, style, and width of the connector lines. Default is FL_DARK2, FL_DOT, 1 inline void connector_style( Fl_Color color, int style, int width = 1 ) { rdata.defLineColor = color; rdata.lineStyle = style; rdata.lineWidth = width; } //! Get the color of the connector lines inline Fl_Color connector_color() const { return rdata.defLineColor; } //! Get the style of the connector lines inline int connector_style() const { return rdata.lineStyle; } //! Get the width of the connector lines inline int connector_width() const { return rdata.lineWidth; } //! Set whether double-clicking a branch opens/closes it inline void double_click_opens( bool b ) { rdata.doubleClickToOpen = b; } //! Get whether double-clicking a branch opens/closes it inline bool double_click_opens() { return rdata.doubleClickToOpen; } //! Get the color to use for shading even entries inline Fl_Color even_shaded_entry_color() const { return rdata.shadedColors[0]; } //! Find the entry identified by \b fullpath /*! \return a pointer to the Node of the found entry, or NULL if no matching entry was found */ inline Node* find( const char *fullpath ) { return find_next( fullpath ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -