📄 flu_tree_browser.h
字号:
//! Find entry \b name in path \b path /*! \return a pointer to the Node of the found entry, or NULL if no matching entry was found */ Node* find( const char *path, const char *name ); //! Find the entry identified by unique id \b id /*! \return a pointer to the Node of the found entry, or NULL if no matching entry was found */ Node* find( unsigned int id ); //! Search for Node \b n in the tree /*! \return a pointer to \b n if it is found, or NULL if it is not in the tree */ inline Node* find( Node *n ) { if( !n ) return NULL; else return find( n->id() ); } //! Find the entry containing the widget \b w /*! \return a pointer to the Node of the found entry, or NULL if no matching entry was found */ Node* find( Fl_Widget *w ); //! Find the next entry identified by \b fullpath after \b startNode /*! \return a pointer to the Node of the found entry, or NULL if no matching entry was found */ Node* find_next( const char *fullpath, Node* startNode = NULL ); //! Find the next entry \b name in path \b path after \b startNode /*! \return a pointer to the Node of the found entry, or NULL if no matching entry was found */ Node* find_next( const char *path, const char *name ); //! \return the number of discovered nodes matching path \b fullpath int find_number( const char *fullpath ); //! \return the number of discovered nodes with name \b name in path \b path int find_number( const char *path, const char *name ); //! \return the full path of the entry identified by unique id \b id, or the empty string if no matching entry was found /*! \note the returned value is only valid until the next time find_path() is called */ const char* find_path( unsigned int id ); //! \return the full path of the entry containing the widget \b w, or the empty string if no matching entry was found /*! \note the returned value is only valid until the next time find_path() is called */ const char* find_path( Fl_Widget *w ); //! \return the full path of Node \b n, or the empty string if \b n is not in the tree /*! \note the returned value is only valid until the next time find_path() is called */ inline const char* find_path( Node *n ) { if( !n ) return ""; else return find_path( n->id() ); } //! \return the first node in the tree (i.e. the root) inline Node* first() { return root.first(); } //! \return the first branch encountered in a depth-first traversal of the tree. NULL means there are no branches inline Node* first_branch() { return root.first_branch(); } //! \return the first leaf encountered in a depth-first traversal of the tree. NULL means there are no leaves inline Node* first_leaf() { return root.first_leaf(); } //! Get the frame rate to use during the open/close animation. Use in conjunction with collapse_time() inline float frame_rate() const { return rdata.fps; } //! Set the frame rate to use during the open/close animation. Use in conjunction with collapse_time(). Default is 100 frames per second inline void frame_rate( float f ) { if( f <= 0.0f ) rdata.fps = 0.001f; else rdata.fps = f; } //! \return a pointer to the root node of the tree inline Node *get_root() { return &root; } //! \return the selected Node that is at \b index among all selected nodes, or \c NULL if no Node is selected /*! For example, \c get_selected(1) will return the first selected node. */ Node* get_selected( int index ); //! Override of Fl_Widget::handle int handle( int event ); //! Set the horizontal icon gap for each entry. Default is 2 inline void horizontal_gap( int g ) { rdata.hGap = g; rdata.forceResize = true; } //! Get the horizontal icon gap for each entry inline int horizontal_gap() const { return rdata.hGap; } //! Set how entries are inserted into the tree. This can be one of FLU_INSERT_FRONT, FLU_INSERT_BACK, FLU_INSERT_SORTED, FLU_INSERT_SORTED_REVERSE. Default is FLU_INSERT_SORTED void insertion_mode( int m ); //! Get how entries are inserted into the tree. inline int insertion_mode() { return rdata.insertionMode; } //! Set the title of the Tree (also the label for the root entry) inline void label( const char *l ) { root.text = l; } //! Get the title of the Tree (also the label for the root entry) inline const char* label() const { return root.text.c_str(); } //! \return the last node in the tree inline Node* last() { return root.last(); } //! \return the last branch encountered in a depth-first traversal of the tree. NULL means there are no branches inline Node* last_branch() { return root.last_branch(); } //! \return the last leaf encountered in a depth-first traversal of the tree. NULL means there are no leaves inline Node* last_leaf() { return root.last_leaf(); } //! Get the default leaf text color inline Fl_Color leaf_color() const { return rdata.defLeafColor; } //! Get the default leaf text font inline Fl_Font leaf_font() const { return rdata.defLeafFont; } //! Get the default leaf text size inline int leaf_size() const { return rdata.defLeafSize; } //! Set the default leaf icon to use for all subsequent leaves added to the tree void leaf_icon( Fl_Image *icon ); //! Set the default color, font and size to use for the text of all subsequent leaves added to the tree, Default is FL_BLACK, FL_HELVETICA, 12 inline void leaf_text( Fl_Color color, Fl_Font font, int size ) { rdata.defLeafColor = color; rdata.defLeafFont = font; rdata.defLeafSize = size; } //! Set whether items can be moved only within their group ( \c true ) or can be moved anywhere in the tree ( \c false ). Default is \c false. Used only when selection_drag_mode() is FLU_DRAG_TO_MOVE. inline void move_only_same_group( bool b ) { rdata.moveOnlySameGroup = b; } //! Get whether items can be moved only within their group ( \c true ) or can be moved anywhere in the tree ( \c false ). Used only when selection_drag_mode() is FLU_DRAG_TO_MOVE. inline bool move_only_same_group() { return rdata.moveOnlySameGroup; } //! \return the number of selected entries int num_selected(); //! Get the color to use for shading odd entries inline Fl_Color odd_shaded_entry_color() const { return rdata.shadedColors[1]; } //! Set whether only a single branch (except the root branch) is allowed open at a time. Default is \c false inline void only_one_open_branch( bool b ) { rdata.singleBranchOpen = b; } //! Get whether only a single branch (except the root branch) is allowed open at a time inline bool only_one_open_branch() { return rdata.singleBranchOpen; } //! Open or close the root node inline void open( bool b ) { root.open( b ); } //! Is the root node open or closed? inline bool open() const { return root.open(); } //! Set whether selecting a branch also opens it. Default is \c false inline void open_on_select( bool b ) { rdata.openOnSelect = b; } //! Get whether selecting a branch also opens it inline bool open_on_select() const { return rdata.openOnSelect; } //! Print the tree to stdout void print(); //! Remove the entry identified by path \b fullpath from the tree /*! \return the unique id of the removed entry, or \c 0 if no matching entry was found */ unsigned int remove( const char *fullpath ); //! Remove entry \b name in path \b path from the tree /*! \return the unique id of the removed entry, or \c 0 if no matching entry was found */ unsigned int remove( const char *path, const char *name ); //! Remove the entry identified by unique id \b id from the tree /*! \return the unique id of the removed entry, or \c 0 if no matching entry was found */ unsigned int remove( unsigned int id ); //! Remove the entry containing the widget \b w from the tree. Note that the widget is automatically destroyed /*! \return the unique id of the removed entry, or \c 0 if no matching entry was found */ unsigned int remove( Fl_Widget *w ); //! Remove Node \b n from the tree /*! \return the id of \b n on successful removal, or \c 0 if \b n is not in the tree */ inline unsigned int remove( Node* n ) { if( !n ) return 0; else return remove( n->id() ); } //! Override of Fl_Widget::resize void resize( int X, int Y, int W, int H ); //! Convenience routine to set the root label color. See Flu_Tree_Browser::Node::label_color() inline void root_color( Fl_Color c ) { get_root()->label_color( c ); } //! Convenience routine to set the root label color. See Flu_Tree_Browser::Node::label_color() inline Fl_Color root_color() { return get_root()->label_color(); } //! Convenience routine to set the root label font. See Flu_Tree_Browser::Node::label_font() inline void root_font( Fl_Font f ) { get_root()->label_font( f ); } //! Convenience routine to set the root label font. See Flu_Tree_Browser::Node::label_font() inline Fl_Font root_font() { return get_root()->label_font(); } //! Convenience routine to set the root label size. See Flu_Tree_Browser::Node::label_size() inline void root_size( unsigned char s ) { get_root()->label_size( s ); } //! Convenience routine to set the root label size. See Flu_Tree_Browser::Node::label_size() inline unsigned char root_size() { return get_root()->label_size(); } //! Select all entries in the tree inline void select_all() { root.select_all(); } //! Get the color to use when hilighting selected entries inline Fl_Color selection_color() const { return rdata.defSelectionColor; } //! Set the color to use when hilighting selected entries. Default is FL_SELECTION_COLOR inline void selection_color( Fl_Color c ) { rdata.defSelectionColor = c; } //! Set the color to use when hilighting selected entries. Default is FL_SELECTION_COLOR inline void selection_color( unsigned c ) { selection_color( (Fl_Color)c ); } //! Set how selection is affected when the mouse is dragged. This can be one of FLU_DRAG_IGNORE, FLU_DRAG_TO_SELECT, FLU_DRAG_TO_MOVE. Default is FLU_DRAG_TO_SELECT. inline void selection_drag_mode( int m ) { rdata.selectionDragMode = m; } //! Get how selection is affected when the mouse is dragged inline int selection_drag_mode() const { return rdata.selectionDragMode; } //! Set how individual entries are selected using the mouse. This can be one of FLU_NO_SELECT, FLU_SINGLE_SELECT, FLU_MULTI_SELECT. Default is FLU_MULTI_SELECT inline void selection_mode( int m ) { rdata.selectionMode = m; root.unselect_all(); } //! Get how individual entries are selected using the mouse inline int selection_mode() const { return rdata.selectionMode; } //! Set which node is hilighted and ready to be selected or unselected. This also scrolls the browser so \b n is visible. void set_hilighted( Node* n ); //! Set the title of the root of the tree to \b label. 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 /*! The root icons, color, font and size are set to the current branch icons and text color, font and size */ Node* set_root( const char *label, Fl_Widget *w = 0, bool showLabel = true ); //! Set the colors to use for shading every other entry. Default is FL_WHITE, FL_WHITE inline void shaded_entry_colors( Fl_Color even, Fl_Color odd ) { rdata.shadedColors[0] = even; rdata.shadedColors[1] = odd; } //! Set whether branch entries are visible. Default is \c true inline void show_branches( bool b ) { rdata.showBranches = b; rdata.forceResize = true; } //! Get whether branch entries are visible inline bool show_branches() const { return rdata.showBranches; } //! Set whether the connectors between entries are visible. Default is \c true inline void show_connectors( bool b ) { rdata.showConnectors = b; } //! Get whether the connectors between entries are visible inline bool show_connectors() const { return rdata.showConnectors; } //! Set whether the root branch (i.e. the name of the tree) is visible. Default is \c true inline void show_root( bool b ) { rdata.showRoot = b; rdata.forceResize = true; } //! Get whether the root branch (i.e. the name of the tree) is visible inline bool show_root() const { return rdata.showRoot; } //! Set whether leaf entries are visible. Default is \c true inline void show_leaves( bool b ) { rdata.showLeaves = b; rdata.forceResize = true; } //! Get whether leaf entries are visible inline bool show_leaves() const { return rdata.showLeaves; } //! Sort the tree according to insertion_mode() inline void sort()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -