2009-11-18 15:22:51 +03:00
|
|
|
//
|
|
|
|
// "$Id$"
|
|
|
|
//
|
|
|
|
|
2009-11-14 18:49:12 +03:00
|
|
|
#ifndef FL_TREE_ITEM_H
|
|
|
|
#define FL_TREE_ITEM_H
|
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Widget.H>
|
2009-12-08 11:06:44 +03:00
|
|
|
#include <FL/Fl_Image.H>
|
2009-11-14 18:49:12 +03:00
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
|
|
|
#include <FL/Fl_Tree_Item_Array.H>
|
|
|
|
#include <FL/Fl_Tree_Prefs.H>
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// FL/Fl_Tree_Item.H
|
|
|
|
//////////////////////
|
|
|
|
//
|
|
|
|
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
|
2010-11-29 00:06:39 +03:00
|
|
|
// Copyright (C) 2009-2010 by Greg Ercolano.
|
2009-11-14 18:49:12 +03:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
|
|
|
//
|
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2009-11-14 18:49:12 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief This file contains the definitions for Fl_Tree_Item
|
|
|
|
///
|
|
|
|
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
/// \class Fl_Tree_Item
|
|
|
|
/// \brief Tree widget item.
|
2009-11-14 18:49:12 +03:00
|
|
|
///
|
|
|
|
/// This class is a single tree item, and manages all of the item's attributes.
|
|
|
|
/// Fl_Tree_Item is used by Fl_Tree, which is comprised of many instances of Fl_Tree_Item.
|
|
|
|
///
|
|
|
|
/// Fl_Tree_Item is hierarchical; it dynamically manages an Fl_Tree_Item_Array of children
|
|
|
|
/// that are themselves instances of Fl_Tree_Item. Each item can have zero or more children.
|
|
|
|
/// When an item has children, close() and open() can be used to hide or show them.
|
|
|
|
///
|
|
|
|
/// Items have their own attributes; font size, face, color.
|
|
|
|
/// Items maintain their own hierarchy of children.
|
|
|
|
///
|
|
|
|
/// When you make changes to items, you'll need to tell the tree to redraw()
|
|
|
|
/// for the changes to show up.
|
|
|
|
///
|
2014-01-21 01:23:24 +04:00
|
|
|
/// New 1.3.3 ABI feature:
|
|
|
|
/// You can define custom items by either adding a custom widget to the item
|
|
|
|
/// with Fl_Tree_Item::widget(), or override the draw_item_content() method
|
|
|
|
/// if you want to just redefine how the label is drawn.
|
|
|
|
///
|
|
|
|
/// The following shows the Fl_Tree_Item's dimensions, useful when overriding
|
|
|
|
/// the draw_item_content() method:
|
|
|
|
///
|
2014-11-11 01:29:49 +03:00
|
|
|
/// \image html Fl_Tree_Item-dimensions.png "Fl_Tree_Item's internal dimensions." width=6cm
|
|
|
|
/// \image latex Fl_Tree_Item-dimensions.png "Fl_Tree_Item's internal dimensions." width=6cm
|
2014-01-21 01:23:24 +04:00
|
|
|
///
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
class Fl_Tree;
|
2010-09-02 23:38:08 +04:00
|
|
|
class FL_EXPORT Fl_Tree_Item {
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
Fl_Tree *_tree; // parent tree
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
const char *_label; // label (memory managed)
|
2011-01-30 23:22:06 +03:00
|
|
|
Fl_Font _labelfont; // label's font face
|
|
|
|
Fl_Fontsize _labelsize; // label's font size
|
2009-11-14 18:49:12 +03:00
|
|
|
Fl_Color _labelfgcolor; // label's fg color
|
2012-05-10 01:26:32 +04:00
|
|
|
Fl_Color _labelbgcolor; // label's bg color (0xffffffff is 'transparent')
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
/// \enum Fl_Tree_Item_Flags
|
|
|
|
enum Fl_Tree_Item_Flags {
|
|
|
|
#else
|
|
|
|
/// \enum
|
2012-05-10 01:26:32 +04:00
|
|
|
enum {
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#endif
|
2012-05-10 01:26:32 +04:00
|
|
|
OPEN = 1<<0, ///> item is open
|
|
|
|
VISIBLE = 1<<1, ///> item is visible
|
|
|
|
ACTIVE = 1<<2, ///> item is active
|
2013-09-17 00:25:14 +04:00
|
|
|
SELECTED = 1<<3 ///> item is selected
|
2012-05-10 01:26:32 +04:00
|
|
|
};
|
2012-11-07 00:46:14 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10301
|
2012-05-10 01:26:32 +04:00
|
|
|
// NEW
|
|
|
|
unsigned short _flags; // misc flags
|
|
|
|
#else /*FLTK_ABI_VERSION*/
|
|
|
|
// OLD: this will go away after 1.3.x
|
2009-11-14 18:49:12 +03:00
|
|
|
char _open; // item is open?
|
|
|
|
char _visible; // item is visible?
|
|
|
|
char _active; // item activated?
|
|
|
|
char _selected; // item selected?
|
2012-05-10 01:26:32 +04:00
|
|
|
#endif /*FLTK_ABI_VERSION*/
|
2009-11-14 18:49:12 +03:00
|
|
|
int _xywh[4]; // xywh of this widget (if visible)
|
2012-04-22 17:40:02 +04:00
|
|
|
int _collapse_xywh[4]; // xywh of collapse icon (if visible)
|
2009-11-14 18:49:12 +03:00
|
|
|
int _label_xywh[4]; // xywh of label
|
|
|
|
Fl_Widget *_widget; // item's label widget (optional)
|
2009-12-08 11:06:44 +03:00
|
|
|
Fl_Image *_usericon; // item's user-specific icon (optional)
|
2015-04-28 22:39:53 +03:00
|
|
|
#if FLTK_ABI_VERSION >= 10304
|
|
|
|
Fl_Image *_userdeicon; // deactivated usericon
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
Fl_Tree_Item_Array _children; // array of child items
|
|
|
|
Fl_Tree_Item *_parent; // parent item (=0 if root)
|
2009-12-08 11:06:44 +03:00
|
|
|
void *_userdata; // user data that can be associated with an item
|
2012-11-07 00:46:14 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10301
|
2012-01-19 16:44:26 +04:00
|
|
|
Fl_Tree_Item *_prev_sibling; // previous sibling (same level)
|
|
|
|
Fl_Tree_Item *_next_sibling; // next sibling (same level)
|
|
|
|
#endif /*FLTK_ABI_VERSION*/
|
2014-01-21 01:23:24 +04:00
|
|
|
// Protected methods
|
2009-11-14 18:49:12 +03:00
|
|
|
protected:
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
void _Init(const Fl_Tree_Prefs &prefs, Fl_Tree *tree);
|
2009-11-14 18:49:12 +03:00
|
|
|
void show_widgets();
|
|
|
|
void hide_widgets();
|
|
|
|
void draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_Prefs &prefs);
|
|
|
|
void draw_horizontal_connector(int x1, int x2, int y, const Fl_Tree_Prefs &prefs);
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
void recalc_tree();
|
2014-01-21 01:23:24 +04:00
|
|
|
int calc_item_height(const Fl_Tree_Prefs &prefs) const;
|
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
Fl_Color drawfgcolor() const;
|
|
|
|
Fl_Color drawbgcolor() const;
|
|
|
|
#endif
|
|
|
|
|
2009-11-14 18:49:12 +03:00
|
|
|
public:
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR -- backwards compatible
|
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
Fl_Tree_Item(Fl_Tree *tree); // CTOR -- ABI 1.3.3+
|
2014-05-22 19:38:27 +04:00
|
|
|
virtual ~Fl_Tree_Item(); // DTOR -- ABI 1.3.3+
|
|
|
|
#else
|
|
|
|
~Fl_Tree_Item(); // DTOR -- backwards compatible
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#endif
|
2009-12-08 11:06:44 +03:00
|
|
|
Fl_Tree_Item(const Fl_Tree_Item *o); // COPY CTOR
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's x position relative to the window
|
2010-08-26 17:32:30 +04:00
|
|
|
int x() const { return(_xywh[0]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's y position relative to the window
|
2010-08-26 17:32:30 +04:00
|
|
|
int y() const { return(_xywh[1]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The entire item's width to right edge of Fl_Tree's inner width
|
|
|
|
/// within scrollbars.
|
2010-08-26 17:32:30 +04:00
|
|
|
int w() const { return(_xywh[2]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's height
|
2010-08-26 17:32:30 +04:00
|
|
|
int h() const { return(_xywh[3]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's label x position relative to the window
|
|
|
|
/// \version 1.3.3
|
2013-11-10 08:33:44 +04:00
|
|
|
int label_x() const { return(_label_xywh[0]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's label y position relative to the window
|
|
|
|
/// \version 1.3.3
|
2013-11-10 08:33:44 +04:00
|
|
|
int label_y() const { return(_label_xywh[1]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's maximum label width to right edge of Fl_Tree's inner width
|
|
|
|
/// within scrollbars.
|
|
|
|
/// \version 1.3.3
|
2013-11-10 08:33:44 +04:00
|
|
|
int label_w() const { return(_label_xywh[2]); }
|
2014-01-21 01:23:24 +04:00
|
|
|
/// The item's label height
|
|
|
|
/// \version 1.3.3
|
2013-11-10 08:33:44 +04:00
|
|
|
int label_h() const { return(_label_xywh[3]); }
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
2014-01-21 01:23:24 +04:00
|
|
|
virtual int draw_item_content(int render);
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
void draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
|
2014-01-21 01:23:24 +04:00
|
|
|
int &tree_item_xmax, int lastchild=1, int render=1);
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#else
|
2014-01-21 01:23:24 +04:00
|
|
|
void draw(int X, int &Y, int W, Fl_Widget *tree,
|
|
|
|
Fl_Tree_Item *itemfocus, const Fl_Tree_Prefs &prefs, int lastchild=1);
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
void show_self(const char *indent = "") const;
|
|
|
|
void label(const char *val);
|
|
|
|
const char *label() const;
|
2009-12-08 11:06:44 +03:00
|
|
|
|
|
|
|
/// Set a user-data value for the item.
|
|
|
|
inline void user_data( void* data ) { _userdata = data; }
|
|
|
|
|
|
|
|
/// Retrieve the user-data value that has been assigned to the item.
|
|
|
|
inline void* user_data() const { return _userdata; }
|
2009-11-14 18:49:12 +03:00
|
|
|
|
|
|
|
/// Set item's label font face.
|
2011-01-30 23:22:06 +03:00
|
|
|
void labelfont(Fl_Font val) {
|
2009-11-14 18:49:12 +03:00
|
|
|
_labelfont = val;
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
recalc_tree(); // may change tree geometry
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Get item's label font face.
|
2011-01-30 23:22:06 +03:00
|
|
|
Fl_Font labelfont() const {
|
2009-11-14 18:49:12 +03:00
|
|
|
return(_labelfont);
|
|
|
|
}
|
|
|
|
/// Set item's label font size.
|
2011-01-30 23:22:06 +03:00
|
|
|
void labelsize(Fl_Fontsize val) {
|
2009-11-14 18:49:12 +03:00
|
|
|
_labelsize = val;
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
recalc_tree(); // may change tree geometry
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Get item's label font size.
|
2011-01-30 23:22:06 +03:00
|
|
|
Fl_Fontsize labelsize() const {
|
2009-11-14 18:49:12 +03:00
|
|
|
return(_labelsize);
|
|
|
|
}
|
|
|
|
/// Set item's label foreground text color.
|
|
|
|
void labelfgcolor(Fl_Color val) {
|
|
|
|
_labelfgcolor = val;
|
|
|
|
}
|
|
|
|
/// Return item's label foreground text color.
|
|
|
|
Fl_Color labelfgcolor() const {
|
|
|
|
return(_labelfgcolor);
|
|
|
|
}
|
2014-01-21 01:23:24 +04:00
|
|
|
/// Set item's label text color. Alias for labelfgcolor(Fl_Color)).
|
|
|
|
void labelcolor(Fl_Color val) {
|
|
|
|
labelfgcolor(val);
|
|
|
|
}
|
|
|
|
/// Return item's label text color. Alias for labelfgcolor() const).
|
|
|
|
Fl_Color labelcolor() const {
|
|
|
|
return labelfgcolor();
|
|
|
|
}
|
2009-11-14 18:49:12 +03:00
|
|
|
/// Set item's label background color.
|
2014-01-21 01:23:24 +04:00
|
|
|
/// A special case is made for color 0xffffffff which uses the parent tree's bg color.
|
2009-11-14 18:49:12 +03:00
|
|
|
void labelbgcolor(Fl_Color val) {
|
|
|
|
_labelbgcolor = val;
|
|
|
|
}
|
2014-01-21 01:23:24 +04:00
|
|
|
/// Return item's label background text color.
|
|
|
|
/// If the color is 0xffffffff, the default behavior is the parent tree's
|
|
|
|
/// bg color will be used. (An overloaded draw_item_content() can override
|
|
|
|
/// this behavior.)
|
2009-11-14 18:49:12 +03:00
|
|
|
Fl_Color labelbgcolor() const {
|
|
|
|
return(_labelbgcolor);
|
|
|
|
}
|
|
|
|
/// Assign an FLTK widget to this item.
|
|
|
|
void widget(Fl_Widget *val) {
|
|
|
|
_widget = val;
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
recalc_tree(); // may change tree geometry
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Return FLTK widget assigned to this item.
|
|
|
|
Fl_Widget *widget() const {
|
|
|
|
return(_widget);
|
|
|
|
}
|
|
|
|
/// Return the number of children this item has.
|
|
|
|
int children() const {
|
|
|
|
return(_children.total());
|
|
|
|
}
|
|
|
|
/// Return the child item for the given 'index'.
|
|
|
|
Fl_Tree_Item *child(int index) {
|
|
|
|
return(_children[index]);
|
|
|
|
}
|
|
|
|
/// Return the const child item for the given 'index'.
|
|
|
|
const Fl_Tree_Item *child(int t) const;
|
|
|
|
/// See if this item has children.
|
|
|
|
int has_children() const {
|
|
|
|
return(children());
|
|
|
|
}
|
|
|
|
int find_child(const char *name);
|
|
|
|
int find_child(Fl_Tree_Item *item);
|
|
|
|
int remove_child(Fl_Tree_Item *item);
|
|
|
|
int remove_child(const char *new_label);
|
|
|
|
void clear_children();
|
|
|
|
void swap_children(int ax, int bx);
|
|
|
|
int swap_children(Fl_Tree_Item *a, Fl_Tree_Item *b);
|
2014-01-21 01:23:24 +04:00
|
|
|
const Fl_Tree_Item *find_child_item(const char *name) const;
|
|
|
|
Fl_Tree_Item *find_child_item(const char *name);
|
|
|
|
const Fl_Tree_Item *find_child_item(char **arr) const;
|
|
|
|
Fl_Tree_Item *find_child_item(char **arr);
|
|
|
|
const Fl_Tree_Item *find_item(char **arr) const;
|
|
|
|
Fl_Tree_Item *find_item(char **arr);
|
2009-11-14 18:49:12 +03:00
|
|
|
//////////////////
|
|
|
|
// Adding items
|
|
|
|
//////////////////
|
2014-01-21 01:23:24 +04:00
|
|
|
Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs,
|
|
|
|
const char *new_label,
|
|
|
|
Fl_Tree_Item *newitem);
|
|
|
|
Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs,
|
|
|
|
const char *new_label);
|
|
|
|
Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs,
|
|
|
|
char **arr,
|
|
|
|
Fl_Tree_Item *newitem);
|
|
|
|
Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs,
|
|
|
|
char **arr);
|
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
Fl_Tree_Item *replace(Fl_Tree_Item *new_item);
|
|
|
|
Fl_Tree_Item *replace_child(Fl_Tree_Item *olditem, Fl_Tree_Item *newitem);
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
Fl_Tree_Item *insert(const Fl_Tree_Prefs &prefs, const char *new_label, int pos=0);
|
|
|
|
Fl_Tree_Item *insert_above(const Fl_Tree_Prefs &prefs, const char *new_label);
|
2014-09-04 22:56:52 +04:00
|
|
|
Fl_Tree_Item* deparent(int index);
|
|
|
|
int reparent(Fl_Tree_Item *newchild, int index);
|
|
|
|
int move(int to, int from);
|
|
|
|
int move(Fl_Tree_Item *item, int op=0, int pos=0);
|
|
|
|
int move_above(Fl_Tree_Item *item);
|
|
|
|
int move_below(Fl_Tree_Item *item);
|
|
|
|
int move_into(Fl_Tree_Item *item, int pos=0);
|
2009-11-14 18:49:12 +03:00
|
|
|
int depth() const;
|
|
|
|
Fl_Tree_Item *prev();
|
|
|
|
Fl_Tree_Item *next();
|
2010-08-26 17:32:30 +04:00
|
|
|
Fl_Tree_Item *next_sibling();
|
|
|
|
Fl_Tree_Item *prev_sibling();
|
2012-01-19 16:44:26 +04:00
|
|
|
void update_prev_next(int index);
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
Fl_Tree_Item *next_displayed(Fl_Tree_Prefs &prefs); // deprecated
|
|
|
|
Fl_Tree_Item *prev_displayed(Fl_Tree_Prefs &prefs); // deprecated
|
|
|
|
Fl_Tree_Item *next_visible(Fl_Tree_Prefs &prefs);
|
|
|
|
Fl_Tree_Item *prev_visible(Fl_Tree_Prefs &prefs);
|
2009-11-14 18:49:12 +03:00
|
|
|
|
2010-08-26 17:32:30 +04:00
|
|
|
/// Return the parent for this item. Returns NULL if we are the root.
|
2009-11-14 18:49:12 +03:00
|
|
|
Fl_Tree_Item *parent() {
|
|
|
|
return(_parent);
|
|
|
|
}
|
2010-08-26 17:32:30 +04:00
|
|
|
/// Return the const parent for this item. Returns NULL if we are the root.
|
2009-11-14 18:49:12 +03:00
|
|
|
const Fl_Tree_Item *parent() const {
|
|
|
|
return(_parent);
|
|
|
|
}
|
|
|
|
/// Set the parent for this item.
|
|
|
|
/// Should only be used by Fl_Tree's internals.
|
|
|
|
///
|
|
|
|
void parent(Fl_Tree_Item *val) {
|
|
|
|
_parent = val;
|
|
|
|
}
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
2014-01-21 01:23:24 +04:00
|
|
|
const Fl_Tree_Prefs& prefs() const;
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
/// Return the tree for this item.
|
2016-10-17 15:45:55 +03:00
|
|
|
/// \version 1.3.3 (ABI feature)
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
const Fl_Tree *tree() const {
|
|
|
|
return(_tree);
|
|
|
|
}
|
2016-10-17 15:45:55 +03:00
|
|
|
#endif
|
|
|
|
#if FLTK_ABI_VERSION >= 10304
|
|
|
|
/// Return the tree for this item.
|
|
|
|
/// \version 1.3.4 (ABI feature)
|
|
|
|
Fl_Tree *tree() {
|
|
|
|
return(_tree);
|
|
|
|
}
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
//////////////////
|
|
|
|
// State
|
|
|
|
//////////////////
|
|
|
|
void open();
|
|
|
|
void close();
|
|
|
|
/// See if the item is 'open'.
|
|
|
|
int is_open() const {
|
2012-05-10 01:26:32 +04:00
|
|
|
return(is_flag(OPEN));
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// See if the item is 'closed'.
|
|
|
|
int is_close() const {
|
2012-05-10 01:26:32 +04:00
|
|
|
return(is_flag(OPEN)?0:1);
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Toggle the item's open/closed state.
|
|
|
|
void open_toggle() {
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
is_open()?close():open(); // handles calling recalc_tree()
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Change the item's selection state to the optionally specified 'val'.
|
|
|
|
/// If 'val' is not specified, the item will be selected.
|
|
|
|
///
|
|
|
|
void select(int val=1) {
|
2012-05-10 01:26:32 +04:00
|
|
|
set_flag(SELECTED, val);
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Toggle the item's selection state.
|
|
|
|
void select_toggle() {
|
|
|
|
if ( is_selected() ) {
|
2012-05-10 01:26:32 +04:00
|
|
|
deselect(); // deselect if selected
|
2009-11-14 18:49:12 +03:00
|
|
|
} else {
|
2009-12-08 11:06:44 +03:00
|
|
|
select(); // select if deselected
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
}
|
2012-04-27 06:03:48 +04:00
|
|
|
/// Select item and all its children.
|
2009-12-08 11:39:31 +03:00
|
|
|
/// Returns count of how many items were in the 'deselected' state,
|
|
|
|
/// ie. how many items were "changed".
|
|
|
|
///
|
|
|
|
int select_all() {
|
|
|
|
int count = 0;
|
|
|
|
if ( ! is_selected() ) {
|
|
|
|
select();
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
for ( int t=0; t<children(); t++ ) {
|
|
|
|
count += child(t)->select_all();
|
|
|
|
}
|
|
|
|
return(count);
|
|
|
|
}
|
2009-11-14 18:49:12 +03:00
|
|
|
/// Disable the item's selection state.
|
|
|
|
void deselect() {
|
2012-05-10 01:26:32 +04:00
|
|
|
set_flag(SELECTED, 0);
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
2012-04-27 06:03:48 +04:00
|
|
|
/// Deselect item and all its children.
|
2009-11-14 18:49:12 +03:00
|
|
|
/// Returns count of how many items were in the 'selected' state,
|
|
|
|
/// ie. how many items were "changed".
|
|
|
|
///
|
|
|
|
int deselect_all() {
|
|
|
|
int count = 0;
|
|
|
|
if ( is_selected() ) {
|
2009-12-08 11:06:44 +03:00
|
|
|
deselect();
|
|
|
|
++count;
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
for ( int t=0; t<children(); t++ ) {
|
2009-12-08 11:06:44 +03:00
|
|
|
count += child(t)->deselect_all();
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
/// See if the item is selected.
|
|
|
|
char is_selected() const {
|
2012-05-10 01:26:32 +04:00
|
|
|
return(is_flag(SELECTED));
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
/// Change the item's activation state to the optionally specified 'val'.
|
|
|
|
///
|
|
|
|
/// When deactivated, the item will be 'grayed out'; the callback()
|
2014-01-21 01:23:24 +04:00
|
|
|
/// won't be invoked if the user clicks on the label. If a widget()
|
|
|
|
/// is associated with the item, its activation state will be changed as well.
|
2009-11-14 18:49:12 +03:00
|
|
|
///
|
|
|
|
/// If 'val' is not specified, the item will be activated.
|
|
|
|
///
|
|
|
|
void activate(int val=1) {
|
2012-05-10 01:26:32 +04:00
|
|
|
set_flag(ACTIVE,val);
|
2009-11-14 18:49:12 +03:00
|
|
|
if ( _widget && val != (int)_widget->active() ) {
|
2009-12-08 11:06:44 +03:00
|
|
|
if ( val ) {
|
|
|
|
_widget->activate();
|
|
|
|
} else {
|
|
|
|
_widget->deactivate();
|
|
|
|
}
|
|
|
|
_widget->redraw();
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Deactivate the item; the callback() won't be invoked when clicked.
|
|
|
|
/// Same as activate(0)
|
|
|
|
///
|
|
|
|
void deactivate() {
|
|
|
|
activate(0);
|
|
|
|
}
|
|
|
|
/// See if the item is activated.
|
|
|
|
char is_activated() const {
|
2012-05-10 01:26:32 +04:00
|
|
|
return(is_flag(ACTIVE));
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
2014-01-21 01:23:24 +04:00
|
|
|
/// See if the item is activated. Alias for is_activated().
|
2009-11-14 18:49:12 +03:00
|
|
|
char is_active() const {
|
2012-05-10 01:26:32 +04:00
|
|
|
return(is_activated());
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
2012-05-10 01:26:32 +04:00
|
|
|
/// See if the item is visible. Alias for is_visible().
|
2010-08-26 17:32:30 +04:00
|
|
|
int visible() const {
|
2012-05-10 01:26:32 +04:00
|
|
|
return(is_visible());
|
|
|
|
}
|
|
|
|
/// See if the item is visible.
|
|
|
|
int is_visible() const {
|
|
|
|
return(is_flag(VISIBLE));
|
2010-08-26 17:32:30 +04:00
|
|
|
}
|
|
|
|
int visible_r() const;
|
|
|
|
|
2016-07-21 03:35:06 +03:00
|
|
|
/// Set the item's user icon to an Fl_Image. Use '0' to disable.
|
|
|
|
/// No internal copy is made, caller must manage icon's memory.
|
|
|
|
///
|
|
|
|
/// Note, if you expect your items to be deactivated(),
|
|
|
|
/// use userdeicon(Fl_Image*) to set up a 'grayed out' version of your icon
|
|
|
|
/// to be used for display.
|
|
|
|
///
|
|
|
|
/// \see userdeicon(Fl_Image*)
|
|
|
|
///
|
2009-12-08 11:06:44 +03:00
|
|
|
void usericon(Fl_Image *val) {
|
2009-11-14 18:49:12 +03:00
|
|
|
_usericon = val;
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
recalc_tree(); // may change tree geometry
|
2009-11-14 18:49:12 +03:00
|
|
|
}
|
2012-04-27 06:03:48 +04:00
|
|
|
/// Get the item's user icon as an Fl_Image. Returns '0' if disabled.
|
2009-12-08 11:06:44 +03:00
|
|
|
Fl_Image *usericon() const {
|
2009-11-14 18:49:12 +03:00
|
|
|
return(_usericon);
|
|
|
|
}
|
2016-07-21 03:35:06 +03:00
|
|
|
/// Set the usericon to draw when the item is deactivated. Use '0' to disable.
|
|
|
|
/// No internal copy is made; caller must manage icon's memory.
|
|
|
|
///
|
|
|
|
/// To create a typical 'grayed out' version of your usericon image,
|
|
|
|
/// you can do the following:
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// // Create tree + usericon for items
|
|
|
|
/// Fl_Tree *tree = new Fl_Tree(..);
|
|
|
|
/// Fl_Image *usr_icon = new Fl_Pixmap(..); // your usericon
|
|
|
|
/// Fl_Image *de_icon = usr_icon->copy(); // make a copy, and..
|
|
|
|
/// de_icon->inactive(); // make it 'grayed out'
|
|
|
|
/// ...
|
|
|
|
/// for ( .. ) { // item loop..
|
|
|
|
/// item = tree->add("..."); // create new item
|
|
|
|
/// item->usericon(usr_icon); // assign usericon to items
|
|
|
|
/// item->userdeicon(de_icon); // assign userdeicon to items
|
|
|
|
/// ..
|
|
|
|
/// }
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// In the above example, the app should 'delete' the two icons
|
|
|
|
/// when they're no longer needed (e.g. after the tree is destroyed)
|
|
|
|
///
|
|
|
|
/// \version 1.3.4
|
|
|
|
///
|
2015-04-28 22:39:53 +03:00
|
|
|
#if FLTK_ABI_VERSION >= 10304
|
2016-07-21 03:35:06 +03:00
|
|
|
void userdeicon(Fl_Image* val) {
|
|
|
|
_userdeicon = val;
|
|
|
|
}
|
2015-04-28 22:39:53 +03:00
|
|
|
/// Return the deactivated version of the user icon, if any.
|
|
|
|
/// Returns 0 if none.
|
|
|
|
Fl_Image* userdeicon() const {
|
|
|
|
return _userdeicon;
|
|
|
|
}
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
//////////////////
|
|
|
|
// Events
|
|
|
|
//////////////////
|
2014-01-16 04:58:58 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
const Fl_Tree_Item* find_clicked(const Fl_Tree_Prefs &prefs, int yonly=0) const;
|
|
|
|
Fl_Tree_Item* find_clicked(const Fl_Tree_Prefs &prefs, int yonly=0);
|
|
|
|
#else
|
|
|
|
const Fl_Tree_Item* find_clicked(const Fl_Tree_Prefs &prefs) const;
|
|
|
|
Fl_Tree_Item* find_clicked(const Fl_Tree_Prefs &prefs);
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
int event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const;
|
|
|
|
int event_on_label(const Fl_Tree_Prefs &prefs) const;
|
|
|
|
/// Is this item the root of the tree?
|
|
|
|
int is_root() const {
|
|
|
|
return(_parent==0?1:0);
|
|
|
|
}
|
2012-05-10 01:26:32 +04:00
|
|
|
|
|
|
|
// Protected methods
|
2014-01-21 01:23:24 +04:00
|
|
|
// TODO: move these to top 'protected:' section
|
2012-05-10 01:26:32 +04:00
|
|
|
protected:
|
2012-11-07 00:46:14 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10301
|
2012-05-10 01:26:32 +04:00
|
|
|
/// Set a flag to an on or off value. val is 0 or 1.
|
|
|
|
inline void set_flag(unsigned short flag,int val) {
|
Adds horizontal scrollbar to Fl_Tree as an ABI 1.3.3 feature.
***************************************************************
NOTE: You MUST uncomment the FLTK_ABI_VERSION in Enumerations.H
to use these changes.
***************************************************************
Also: separated tree size calculation from draw() code,
so that one can cause the tree to recalculate immediately
after making modifications to the tree by calling Fl_Tree::calc_tree().
Numerous improvements to docs for the tree as well, enough
to create a rather large diff.
Large internal changes were needed to do this properly.
The following was added to the CHANGES file:
- Fl_Tree: various related changes:
o Added horizontal scrollbar
o Separated draw() and tree size calculation
o Added new public methods:
> resize() -- uses optimized dim calc, avoids tree recalc
> next_item() -- added parameters: direction, visibility
> extend_selection() -- added parameters, improved algorithm
> calc_dimensions() -- calc tix/y/w/h, tox/y/w/h and scrollbars
> calc_tree() -- calc tree_w/tree_h
> recalc_tree() -- schedules calc_tree()
> first_visible_item(), last_visible_item(), next_visible_item()
> first_selected_item(), last_selected_item(), next_selected_item()
o Added protected variables:
> _tix/y/w/h -- tree widget 'inner' dimension
> _tox/y/w/h -- tree widget 'outer' dimension
> _tree_w,_tree_h -- entire tree hierarchy width/height
o Deprecated:
> item_clicked() -- use callback_item() instead
> first_visible() -- use first_visible_item() instead
> last_visible() -- use last_visible_item() instead
- Fl_Tree_Item: various related changes:
o Added Fl_Tree ptr: needed for auto-recalc when item modified directly
o Added new methods tree(), recalc_tree()
o Added new ctor that accepts Fl_Tree*
o draw() parameters changed to include tree size calculations
o Deprecated:
> ctor using Fl_Tree_Prefs parameter (Fl_Tree* version better,
and must be used for 1.3.3 ABI features to work correctly)
> next_displayed() -- use next_visible() instead
> prev_displayed() -- use prev_visible() instead
- test/tree: added tests for newly added features
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10034 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-12-15 22:59:02 +04:00
|
|
|
if ( flag==OPEN || flag==VISIBLE ) {
|
|
|
|
recalc_tree(); // may change tree geometry
|
|
|
|
}
|
2012-05-10 01:26:32 +04:00
|
|
|
if ( val ) _flags |= flag; else _flags &= ~flag;
|
|
|
|
}
|
|
|
|
/// See if flag set. Returns 0 or 1.
|
|
|
|
inline int is_flag(unsigned short val) const {
|
|
|
|
return(_flags & val ? 1 : 0);
|
|
|
|
}
|
|
|
|
#else /*FLTK_ABI_VERSION*/
|
|
|
|
/// Set a flag to an on or off value. val is 0 or 1.
|
|
|
|
void set_flag(unsigned short flag,int val) {
|
|
|
|
switch (flag) {
|
|
|
|
case OPEN: _open = val; break;
|
|
|
|
case VISIBLE: _visible = val; break;
|
|
|
|
case ACTIVE: _active = val; break;
|
|
|
|
case SELECTED: _selected = val; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// See if flag set. Returns 0 or 1.
|
|
|
|
int is_flag(unsigned short flag) const {
|
|
|
|
switch (flag) {
|
|
|
|
case OPEN: return(_open ? 1 : 0);
|
|
|
|
case VISIBLE: return(_visible ? 1 : 0);
|
|
|
|
case ACTIVE: return(_active ? 1 : 0);
|
|
|
|
case SELECTED: return(_selected ? 1 : 0);
|
|
|
|
default: return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /*FLTK_ABI_VERSION*/
|
|
|
|
|
2009-11-14 18:49:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*FL_TREE_ITEM_H*/
|
2009-11-18 15:22:51 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// End of "$Id$".
|
|
|
|
//
|