summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-04-13 19:18:56 +0000
committerManolo Gouy <Manolo>2016-04-13 19:18:56 +0000
commit7a580fd4216824a8fe4babf7295188d6112b3ab5 (patch)
treea219cd37daed25b1baa5b5179e26a448d691e51c /src
parent70f7738c920fac5ff84c40a673bb7b87245d4d0c (diff)
Remove FL_ABI_VERSION clauses from the Fl_Tree class source code
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11602 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Tree.cxx318
-rw-r--r--src/Fl_Tree_Item.cxx413
-rw-r--r--src/Fl_Tree_Item_Array.cxx30
-rw-r--r--src/Fl_Tree_Prefs.cxx16
4 files changed, 7 insertions, 770 deletions
diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx
index 575be2b23..285a6d86a 100644
--- a/src/Fl_Tree.cxx
+++ b/src/Fl_Tree.cxx
@@ -77,11 +77,7 @@ static int find_total_children(Fl_Tree_Item *item, int count=0) {
/// Constructor.
Fl_Tree::Fl_Tree(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L) {
-#if FLTK_ABI_VERSION >= 10303
_root = new Fl_Tree_Item(this);
-#else
- _root = new Fl_Tree_Item(_prefs);
-#endif
_root->parent(0); // we are root of tree
_root->label("ROOT");
_item_focus = 0;
@@ -89,12 +85,7 @@ Fl_Tree::Fl_Tree(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L
_callback_reason = FL_TREE_REASON_NONE;
_scrollbar_size = 0; // 0: uses Fl::scrollbar_size()
-#if FLTK_ABI_VERSION >= 10301
- // NEW
_lastselect = 0;
-#else /*FLTK_ABI_VERSION*/
- // OLD: data initialized static inside handle()
-#endif /*FLTK_ABI_VERSION*/
box(FL_DOWN_BOX);
color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR);
@@ -105,7 +96,6 @@ Fl_Tree::Fl_Tree(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L
_vscroll->type(FL_VERTICAL);
_vscroll->step(1);
_vscroll->callback(scroll_cb, (void*)this);
-#if FLTK_ABI_VERSION >= 10303
_hscroll = new Fl_Scrollbar(X,Y+H-scrollsize,W,scrollsize);
_hscroll->hide();
_hscroll->type(FL_HORIZONTAL);
@@ -117,7 +107,6 @@ Fl_Tree::Fl_Tree(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L
_toh = _tih = H - Fl::box_dh(box());
_tree_w = -1;
_tree_h = -1;
-#endif
end();
}
@@ -131,12 +120,10 @@ Fl_Tree::~Fl_Tree() {
///
/// Efficient: does not walk entire tree; starts with \p 'from' and stops
/// at \p 'to' while moving in direction \p 'dir'. Dir must be specified though.
-#if FLTK_ABI_VERSION >= 10303
///
/// If dir cannot be known in advance, such as during SHIFT-click operations,
/// the method extend_selection(Fl_Tree_Item*,Fl_Tree_Item*,int,bool)
/// should be used.
-#endif
///
/// Handles calling redraw() if anything changed.
///
@@ -187,17 +174,9 @@ int Fl_Tree::extend_selection_dir(Fl_Tree_Item *from, Fl_Tree_Item *to,
/// \param[in] visible true=affect only open(), visible items,<br>
/// false=affect open or closed items (default)
/// \returns The number of items whose selection states were changed, if any.
-#if FLTK_ABI_VERSION >= 10303
/// \version 1.3.3 ABI feature
int Fl_Tree::extend_selection(Fl_Tree_Item *from, Fl_Tree_Item *to,
int val, bool visible) {
-#else
-/// \note Made public in 1.3.3 ABI
-// Adding overload if not at least one overload breaks ABI, so avoid
-// by making a private function until ABI can change..
-int Fl_Tree::extend_selection__(Fl_Tree_Item *from, Fl_Tree_Item *to,
- int val, bool visible) {
-#endif
int changed = 0;
if ( from == to ) {
if ( visible && !from->is_visible() ) return(0); // do nothing
@@ -240,20 +219,6 @@ int Fl_Tree::extend_selection__(Fl_Tree_Item *from, Fl_Tree_Item *to,
return(changed);
}
-#if FLTK_ABI_VERSION >= 10303
-// not needed, above overload handles this
-#else
-/// Extend a selection between \p 'from' and \p 'to'.
-/// Extends selection for items and all children, visible ('open') or not.
-/// Walks entire tree from top to bottom looking for \p 'from' and \p 'to'.
-/// \version 1.3.0
-///
-void Fl_Tree::extend_selection(Fl_Tree_Item *from, Fl_Tree_Item *to) {
- const int val = 1; // 0=clr, 1=set, 2=toggle
- const bool visible = false; // true=only 'open' items, false='open' or 'closed'
- extend_selection__(from, to, val, visible); // use private method until we can release it
-}
-#endif
/// Standard FLTK event handler for this widget.
/// \todo add Fl_Widget_Tracker (see Fl_Browser_.cxx::handle())
@@ -263,12 +228,6 @@ int Fl_Tree::handle(int e) {
char is_shift = Fl::event_state() & FL_SHIFT ? 1 : 0;
char is_ctrl = Fl::event_state() & FL_CTRL ? 1 : 0;
char is_command = Fl::event_state() & FL_COMMAND ? 1 : 0; // ctrl on win/lin, 'Command' on mac
-#if FLTK_ABI_VERSION >= 10301
- // NEW: data inside Fl_Tree
-#else /*FLTK_ABI_VERSION*/
- // OLD:
- static Fl_Tree_Item *_lastselect = 0;
-#endif /*FLTK_ABI_VERSION*/
// Developer note: Fl_Browser_::handle() used for reference here..
// #include <FL/names.h> // for event debugging
// fprintf(stderr, "DEBUG: %s (%d)\n", fl_eventnames[e], e);
@@ -425,11 +384,7 @@ int Fl_Tree::handle(int e) {
case FL_PUSH: { // clicked on tree
last_my = Fl::event_y(); // save for dragging direction..
if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
-#if FLTK_ABI_VERSION >= 10303
Fl_Tree_Item *item = _root->find_clicked(_prefs, 0);
-#else
- Fl_Tree_Item *item = _root->find_clicked(_prefs);
-#endif
if ( !item ) { // clicked, but not on an item?
_lastselect = 0;
switch ( _prefs.selectmode() ) {
@@ -463,11 +418,7 @@ int Fl_Tree::handle(int e) {
if ( _lastselect ) {
int val = is_ctrl ? 2 : 1;
bool visible = true;
-#if FLTK_ABI_VERSION >= 10303
extend_selection(_lastselect, item, val, visible);
-#else
- extend_selection__(_lastselect, item, val, visible);
-#endif
} else {
select(item); // add to selection
}
@@ -510,11 +461,7 @@ int Fl_Tree::handle(int e) {
// During drag, only interested in left-mouse operations.
//
if ( Fl::event_button() != FL_LEFT_MOUSE ) break;
-#if FLTK_ABI_VERSION >= 10303
Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
-#else
- Fl_Tree_Item *item = _root->find_clicked(_prefs); // item we're on, vertically
-#endif
if ( !item ) break; // not near item? ignore drag event
ret |= 1; // acknowledge event
if (_prefs.selectmode() != FL_TREE_SELECT_SINGLE_DRAGGABLE)
@@ -549,11 +496,7 @@ int Fl_Tree::handle(int e) {
case FL_RELEASE:
if (_prefs.selectmode() == FL_TREE_SELECT_SINGLE_DRAGGABLE &&
Fl::event_button() == FL_LEFT_MOUSE) {
-#if FLTK_ABI_VERSION >= 10303
Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
-#else
- Fl_Tree_Item *item = _root->find_clicked(_prefs); // item we're on, vertically
-#endif
if (item && _lastselect && item != _lastselect &&
Fl::event_x() >= item->label_x()) {
@@ -604,19 +547,7 @@ int Fl_Tree::handle(int e) {
return(ret);
}
-#if FLTK_ABI_VERSION >= 10303
-// nothing
-#else
-// Redraw timeout callback
-// (Only need this hack for old ABI 10302 and older)
-//
-static void redraw_soon(void *data) {
- ((Fl_Tree*)data)->redraw();
- Fl::remove_timeout(redraw_soon, data);
-}
-#endif
-#if FLTK_ABI_VERSION >= 10303
/// Recalculate widget dimensions and scrollbar visibility,
/// normally managed automatically.
///
@@ -754,18 +685,14 @@ void Fl_Tree::calc_tree() {
// Calc tree dims again; now that tree_w/tree_h are known, scrollbars are calculated.
calc_dimensions();
}
-#endif
void Fl_Tree::resize(int X,int Y,int W, int H) {
fix_scrollbar_order();
Fl_Group::resize(X,Y,W,H);
-#if FLTK_ABI_VERSION >= 10303
calc_dimensions();
-#endif
init_sizes();
}
-#if FLTK_ABI_VERSION >= 10303
/// Standard FLTK draw() method, handles drawing the tree widget.
void Fl_Tree::draw() {
fix_scrollbar_order();
@@ -837,128 +764,6 @@ void Fl_Tree::draw() {
}
}
}
-#else
-/// Standard FLTK draw() method, handles drawing the tree widget.
-void Fl_Tree::draw() {
- int ytoofar = draw_tree();
-
- // See if we're scrolled below bottom of tree
- // This can happen if someone just closed a large item.
- // If so, change scroller as needed.
- //
- if ( _vscroll->visible() && ytoofar > 0 ) {
- int scrollval = _vscroll->value();
- int ch = h() - Fl::box_dh(box());
- int range2 = scrollval - ytoofar;
- int size2 = ch + range2;
- if ( range2 < 0 ) {
- _vscroll->value(0);
- _vscroll->hide();
- } else {
- _vscroll->slider_size(float(ch)/float(size2));
- _vscroll->range(0.0,range2);
- _vscroll->value(range2);
- }
- Fl::add_timeout(.10, redraw_soon, (void*)this); // use timer to trigger redraw; we can't
- }
-
- // Draw dragging line
- if (_prefs.selectmode() == FL_TREE_SELECT_SINGLE_DRAGGABLE &&
- Fl::pushed() == this) {
-
- Fl_Tree_Item *item = _root->find_clicked(_prefs); // item we're on, vertically
- if (item && item != _item_focus) {
- // Are we dropping above or before the target item?
- const int h = Fl::event_y() - item->y();
- const int mid = item->h() / 2;
- const bool before = h < mid;
-
- fl_color(FL_BLACK);
-
- int tgt;
- if (before) {
- tgt = item->y();
- } else {
- tgt = item->y() + item->h();
- }
- fl_line(item->x(), tgt, item->x() + item->w(), tgt);
- }
- }
-}
-
-// This method is undocumented, and has been removed in ABI 1.3.3
-int Fl_Tree::draw_tree() {
- int ret = 0;
- fix_scrollbar_order();
- // Let group draw box+label but *NOT* children.
- // We handle drawing children ourselves by calling each item's draw()
- //
- int cx = x() + Fl::box_dx(box());
- int cy = y() + Fl::box_dy(box());
- int cw = w() - Fl::box_dw(box());
- int ch = h() - Fl::box_dh(box());
- {
- // Handle group's bg
- if ( damage() & ~FL_DAMAGE_CHILD) { // redraw entire widget?
- Fl_Group::draw_box();
- Fl_Group::draw_label();
- }
- if ( ! _root ) return(0);
- // These values are changed during drawing
- // By end, 'Y' will be the lowest point on the tree
- int X = cx + _prefs.marginleft();
- int Y = cy + _prefs.margintop() - (_vscroll->visible() ? _vscroll->value() : 0);
- int W = cw - _prefs.marginleft(); // - _prefs.marginright();
- // Adjust root's X/W if connectors off
- if (_prefs.connectorstyle() == FL_TREE_CONNECTOR_NONE) {
- X -= _prefs.openicon()->w();
- W += _prefs.openicon()->w();
- }
- int Ysave = Y;
- fl_push_clip(cx,cy,cw,ch);
- {
- fl_font(_prefs.labelfont(), _prefs.labelsize());
- _root->draw(X, Y, W, this,
- (Fl::focus()==this)?_item_focus:0, // show focus item ONLY if Fl_Tree has focus
- _prefs);
- }
- fl_pop_clip();
-
- // Show vertical scrollbar?
- {
-#if FLTK_ABI_VERSION >= 10301
- // NEW
- int SY = Y + _prefs.marginbottom();
-#else /*FLTK_ABI_VERSION*/
- // OLD
- int SY = Y;
-#endif /*FLTK_ABI_VERSION*/
- int ydiff = (SY+_prefs.margintop())-Ysave; // ydiff=size of tree
- int ytoofar = (cy+ch) - SY; // ytoofar -- if >0, scrolled beyond bottom
- if ( ytoofar > 0 ) ydiff += ytoofar;
- if ( Ysave<cy || ydiff>ch || int(_vscroll->value())>1 ) {
- _vscroll->visible();
- int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size();
- int sx = x()+w()-Fl::box_dx(box())-scrollsize;
- int sy = y()+Fl::box_dy(box());
- int sw = scrollsize;
- int sh = h()-Fl::box_dh(box());
- _vscroll->show();
- _vscroll->resize(sx,sy,sw,sh);
- _vscroll->slider_size(float(ch)/float(ydiff));
- _vscroll->range(0.0,ydiff-ch);
- ret = ytoofar;
- } else {
- _vscroll->Fl_Slider::value(0);
- _vscroll->hide();
- ret = 0;
- }
- }
- }
- draw_child(*_vscroll); // draw scroll last
- return(ret);
-}
-#endif
/// Print the tree as 'ascii art' to stdout.
/// Used mainly for debugging.
@@ -989,12 +794,10 @@ Fl_Tree_Item* Fl_Tree::root() {
/// If a root item already exists, clear() is first to clear it
/// before replacing it with newitem.
///
-#if FLTK_ABI_VERSION >= 10303
/// Use this to install a custom item (derived from Fl_Tree_Item) as the root
/// of the tree. This allows the derived class to implement custom drawing
/// by overriding Fl_Tree_Item::draw_item_content().
///
-#endif
/// \version 1.3.3
///
void Fl_Tree::root(Fl_Tree_Item *newitem) {
@@ -1023,11 +826,7 @@ void Fl_Tree::root(Fl_Tree_Item *newitem) {
Fl_Tree_Item* Fl_Tree::add(const char *path, Fl_Tree_Item *item) {
// Tree has no root? make one
if ( ! _root ) {
-#if FLTK_ABI_VERSION >= 10303
_root = new Fl_Tree_Item(this);
-#else
- _root = new Fl_Tree_Item(_prefs);
-#endif
_root->parent(0);
_root->label("ROOT");
}
@@ -1038,20 +837,6 @@ Fl_Tree_Item* Fl_Tree::add(const char *path, Fl_Tree_Item *item) {
return(item);
}
-#if FLTK_ABI_VERSION >= 10303
-// do nothing here: add(path,item) where item defaults to 0 takes its place
-#else
-/// Adds a new item given a menu style \p 'path'.
-/// Same as calling add(path, NULL);
-/// \param[in] path The path to the item to be created, e.g. "Flintsone/Fred".
-/// \returns The new item added, or 0 on error.
-/// \see add(const char*,Fl_Tree_Item*)
-/// \version 1.3.0 release
-///
-Fl_Tree_Item* Fl_Tree::add(const char *path) {
- return add(path, 0);
-}
-#endif
/// Add a new child item labeled \p 'name' to the specified \p 'parent_item'.
///
@@ -1234,7 +1019,6 @@ int Fl_Tree::item_pathname(char *pathname, int pathnamelen, const Fl_Tree_Item *
return(0);
}
-#if FLTK_ABI_VERSION >= 10303
/// Find the item that was last clicked on.
/// You should use callback_item() instead, which is fast,
/// and is meant to be used within a callback to determine the item clicked.
@@ -1263,33 +1047,6 @@ Fl_Tree_Item *Fl_Tree::find_clicked(int yonly) {
return(const_cast<Fl_Tree_Item*>(
static_cast<const Fl_Tree&>(*this).find_clicked(yonly)));
}
-#else
-/// Find the item that was last clicked on.
-/// You should use callback_item() instead, which is fast,
-/// and is meant to be used within a callback to determine the item clicked.
-///
-/// This method walks the entire tree looking for the first item that is
-/// under the mouse, i.e. at Fl::event_x() / Fl::event_y().
-///
-/// Use this method /only/ if you've subclassed Fl_Tree, and are receiving
-/// events before Fl_Tree has been able to process and update callback_item().
-///
-/// \returns The item clicked, or NULL if no item was under the current event.
-/// \version 1.3.0
-///
-const Fl_Tree_Item* Fl_Tree::find_clicked() const {
- if ( ! _root ) return(NULL);
- return(_root->find_clicked(_prefs));
-}
-
-/// Non-const version of Fl_Tree::find_clicked() const.
-/// \version 1.3.0
-Fl_Tree_Item *Fl_Tree::find_clicked() {
- // "Effective C++, 3rd Ed", p.23. Sola fide, Amen.
- return(const_cast<Fl_Tree_Item*>(
- static_cast<const Fl_Tree&>(*this).find_clicked()));
-}
-#endif
/// Set the item that was last clicked.
/// Should only be used by subclasses needing to change this value.
@@ -1475,28 +1232,6 @@ Fl_Tree_Item *Fl_Tree::first_selected_item() {
return(next_selected_item(0));
}
-#if FLTK_ABI_VERSION >= 10303
-// nothing
-#else
-/// Returns the next selected item after \p 'item'.
-/// If \p item is 0, search starts at the first item (root).
-///
-/// This is a convenience method; equivalent to next_selected_item(item, FL_Down);
-///
-/// Use this to walk the tree forward (downward) looking for all the selected items, e.g.
-/// \code
-/// for ( Fl_Tree_Item *i = tree->first_selected_item(); i; i = tree->next_selected_item(i) )
-/// printf("Selected item: %s\n", i->label());
-/// \endcode
-///
-/// \param[in] item The item to use to find the next selected item. If NULL, first() is used.
-/// \returns The next selected item, or 0 if there are no more selected items.
-/// \see first_selected_item(), last_selected_item(), next_selected_item()
-///
-Fl_Tree_Item *Fl_Tree::next_selected_item(Fl_Tree_Item *item) {
- return(next_selected_item(item, FL_Down));
-}
-#endif
/// Returns the last selected item in the tree.
///
@@ -1634,7 +1369,6 @@ Fl_Tree_Item *Fl_Tree::next_selected_item(Fl_Tree_Item *item, int dir) {
return(0);
}
-#if FLTK_ABI_VERSION >= 10303 /* reason for this: Fl_Tree_Item_Array::manage_item_destroy() */
/// Returns the currently selected items as an array of \p 'ret_items'.
///
/// Example:
@@ -1661,7 +1395,6 @@ int Fl_Tree::get_selected_items(Fl_Tree_Item_Array &ret_items) {
}
return ret_items.total();
}
-#endif
/// Open the specified \p 'item'.
///
@@ -1898,14 +1631,12 @@ int Fl_Tree::select(Fl_Tree_Item *item, int docallback) {
redraw();
return(1);
}
-#if FLTK_ABI_VERSION >= 10301
// NEW
if ( alreadySelected ) {
if ( (item_reselect_mode() == FL_TREE_SELECTABLE_ALWAYS) && docallback ) {
do_callback_for_item(item, FL_TREE_REASON_RESELECTED);
}
}
-#endif /*FLTK_ABI_VERSION*/
return(0);
}
@@ -2086,7 +1817,6 @@ int Fl_Tree::select_only(Fl_Tree_Item *selitem, int docallback) {
++changed;
}
}
-#if FLTK_ABI_VERSION >= 10301
// Should we 'reselect' item if already selected?
if ( selitem->is_selected() && (item_reselect_mode()==FL_TREE_SELECTABLE_ALWAYS) ) {
// Selection unchanged, so no ++change
@@ -2096,13 +1826,6 @@ int Fl_Tree::select_only(Fl_Tree_Item *selitem, int docallback) {
select(selitem, docallback);
++changed;
}
-#else
- if ( !selitem->is_selected() ) {
- // All items deselected, now select the one we want
- select(selitem, docallback);
- ++changed;
- }
-#endif
return(changed);
}
@@ -2278,7 +2001,6 @@ void Fl_Tree::margintop(int val) {
recalc_tree();
}
-#if FLTK_ABI_VERSION >= 10301
/// Get the amount of white space (in pixels) that should appear
/// below the last visible item when the vertical scroller is scrolled to the bottom.
///
@@ -2294,7 +2016,6 @@ void Fl_Tree::marginbottom(int val) {
redraw();
recalc_tree();
}
-#endif /*FLTK_ABI_VERSION*/
/// Get the amount of white space (in pixels) that should appear
/// between items in the tree.
@@ -2356,7 +2077,6 @@ void Fl_Tree::labelmarginleft(int val) {
recalc_tree();
}
-#if FLTK_ABI_VERSION >= 10301
/// Get the amount of white space (in pixels) that should appear
/// to the left of the child fltk widget (if any).
int Fl_Tree::widgetmarginleft() const {
@@ -2370,7 +2090,6 @@ void Fl_Tree::widgetmarginleft(int val) {
redraw();
recalc_tree();
}
-#endif /*FLTK_ABI_VERSION*/
/// Gets the width of the horizontal connection lines (in pixels)
/// that appear to the left of each tree item's label.
@@ -2538,7 +2257,6 @@ void Fl_Tree::selectmode(Fl_Tree_Select val) {
_prefs.selectmode(val);
}
-#if FLTK_ABI_VERSION >= 10301
/// Returns the current item re/selection mode.
/// \version 1.3.1 ABI feature
///
@@ -2582,7 +2300,6 @@ void Fl_Tree::item_draw_mode(Fl_Tree_Item_Draw_Mode mode) {
void Fl_Tree::item_draw_mode(int mode) {
_prefs.item_draw_mode(Fl_Tree_Item_Draw_Mode(mode));
}
-#endif
/// See if \p 'item' is currently displayed on-screen (visible within the widget).
///
@@ -2654,11 +2371,7 @@ void Fl_Tree::show_item_top(Fl_Tree_Item *item) {
///
void Fl_Tree::show_item_middle(Fl_Tree_Item *item) {
item = item ? item : first();
-#if FLTK_ABI_VERSION >= 10303
if (item) show_item(item, (_tih/2)-(item->h()/2));
-#else
- if (item) show_item(item, (h()/2)-(item->h()/2));
-#endif
}
/// Adjust the vertical scrollbar so that \p 'item' is at the bottom of the display.
@@ -2667,11 +2380,7 @@ void Fl_Tree::show_item_middle(Fl_Tree_Item *item) {
///
void Fl_Tree::show_item_bottom(Fl_Tree_Item *item) {
item = item ? item : first();
-#if FLTK_ABI_VERSION >= 10303
if (item) show_item(item, _tih-item->h());
-#else
- if (item) show_item(item, h()-item->h());
-#endif
}
/// Displays \p 'item', scrolling the tree as necessary.
@@ -2711,11 +2420,7 @@ void Fl_Tree::vposition(int pos) {
/// \note Must be using FLTK ABI 1.3.3 or higher for this to be effective.
///
int Fl_Tree::hposition() const {
-#if FLTK_ABI_VERSION >= 10303
return((int)_hscroll->value());
-#else
- return(0);
-#endif
}
/// Sets the horizontal scroll offset to position \p 'pos'.
@@ -2725,13 +2430,11 @@ int Fl_Tree::hposition() const {
/// \note Must be using FLTK ABI 1.3.3 or higher for this to be effective.
///
void Fl_Tree::hposition(int pos) {
-#if FLTK_ABI_VERSION >= 10303
if (pos < 0) pos = 0;
if (pos > _hscroll->maximum()) pos = (int)_hscroll->maximum();
if (pos == _hscroll->value()) return;
_hscroll->value(pos);
redraw();
-#endif
}
/// See if widget \p 'w' is one of the Fl_Tree widget's scrollbars.
@@ -2748,11 +2451,7 @@ void Fl_Tree::hposition(int pos) {
/// \todo should be const
///
int Fl_Tree::is_scrollbar(Fl_Widget *w) {
-#if FLTK_ABI_VERSION >= 10303
return( (w==_vscroll || w==_hscroll) ? 1 : 0 );
-#else
- return( (w==_vscroll) ? 1 : 0 );
-#endif
}
/// Gets the default size of scrollbars' troughs for this widget
@@ -2793,14 +2492,12 @@ void Fl_Tree::scrollbar_size(int size) {
if ( _vscroll->w() != scrollsize ) {
_vscroll->resize(x()+w()-scrollsize, h(), scrollsize, _vscroll->h());
}
-#if FLTK_ABI_VERSION >= 10303
if ( _hscroll->h() != scrollsize ) {
_hscroll->resize(x(), y()+h()-scrollsize, _hscroll->w(), scrollsize);
}
// Changing scrollbar size affects _tiw/_tih + may affect scrollbar visibility
calc_dimensions();
-#endif
-}
+}
/// See if the vertical scrollbar is currently visible.
/// \returns 1 if scrollbar visible, 0 if not.
@@ -2814,11 +2511,7 @@ int Fl_Tree::is_vscroll_visible() const {
/// \note Must be using FLTK ABI 1.3.3 or higher for this to be effective.
///
int Fl_Tree::is_hscroll_visible() const {
-#if FLTK_ABI_VERSION >= 10303
return(_hscroll->visible() ? 1 : 0);
-#else
- return 0;
-#endif
}
/// Do the callback for the specified \p 'item' using \p 'reason',
@@ -2928,18 +2621,11 @@ void Fl_Tree::fix_scrollbar_order() {
Fl_Widget** a = (Fl_Widget**)array();
if (a[children()-1] != _vscroll) {
int i,j;
-#if FLTK_ABI_VERSION >= 10303
for (i = j = 0; j < children(); j++) {
if (a[j] != _vscroll && a[j] != _hscroll ) a[i++] = a[j];
}
a[i++] = _hscroll;
a[i++] = _vscroll;
-#else
- for (i = j = 0; j < children(); j++) {
- if (a[j] != _vscroll) a[i++] = a[j];
- }
- a[i++] = _vscroll;
-#endif
}
}
@@ -2947,9 +2633,7 @@ void Fl_Tree::fix_scrollbar_order() {
/// \note Must be using FLTK ABI 1.3.3 or higher for this to be effective.
///
void Fl_Tree::recalc_tree() {
-#if FLTK_ABI_VERSION >= 10303
_tree_w = _tree_h = -1;
-#endif
}
//
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index d0536a0fb..3472f8e99 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -36,9 +36,7 @@ static int event_inside(const int xywh[4]) {
/// Constructor.
/// Makes a new instance of Fl_Tree_Item using defaults from \p 'prefs'.
-#if FLTK_ABI_VERSION >= 10303
/// \deprecated in 1.3.3 ABI -- you must use Fl_Tree_Item(Fl_Tree*) for proper horizontal scrollbar behavior.
-#endif
///
Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Prefs &prefs) {
_Init(prefs, 0);
@@ -48,23 +46,14 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Prefs &prefs) {
// Used by constructors
//
void Fl_Tree_Item::_Init(const Fl_Tree_Prefs &prefs, Fl_Tree *tree) {
-#if FLTK_ABI_VERSION >= 10303
_tree = tree;
-#endif
_label = 0;
_labelfont = prefs.labelfont();
_labelsize = prefs.labelsize();
_labelfgcolor = prefs.labelfgcolor();
_labelbgcolor = prefs.labelbgcolor();
_widget = 0;
-#if FLTK_ABI_VERSION >= 10301
_flags = OPEN|VISIBLE|ACTIVE;
-#else /*FLTK_ABI_VERSION*/
- _open = 1;
- _visible = 1;
- _active = 1;
- _selected = 0;
-#endif /*FLTK_ABI_VERSION*/
_xywh[0] = 0;
_xywh[1] = 0;
_xywh[2] = 0;
@@ -78,21 +67,14 @@ void Fl_Tree_Item::_Init(const Fl_Tree_Prefs &prefs, Fl_Tree *tree) {
_label_xywh[2] = 0;
_label_xywh[3] = 0;
_usericon = 0;
-#if FLTK_ABI_VERSION >= 10304
_userdeicon = 0;
-#endif
_userdata = 0;
_parent = 0;
-#if FLTK_ABI_VERSION >= 10303
_children.manage_item_destroy(1); // let array's dtor manage destroying Fl_Tree_Items
-#endif
-#if FLTK_ABI_VERSION >= 10301
_prev_sibling = 0;
_next_sibling = 0;
-#endif /*FLTK_ABI_VERSION*/
}
-#if FLTK_ABI_VERSION >= 10303
/// Constructor.
/// Makes a new instance of Fl_Tree_Item for \p 'tree'.
///
@@ -104,7 +86,6 @@ void Fl_Tree_Item::_Init(const Fl_Tree_Prefs &prefs, Fl_Tree *tree) {
Fl_Tree_Item::Fl_Tree_Item(Fl_Tree *tree) {
_Init(tree->_prefs, tree);
}
-#endif
// DTOR
Fl_Tree_Item::~Fl_Tree_Item() {
@@ -114,36 +95,23 @@ Fl_Tree_Item::~Fl_Tree_Item() {
}
_widget = 0; // Fl_Group will handle destruction
_usericon = 0; // user handled allocation
-#if FLTK_ABI_VERSION >= 10304
if ( _userdeicon ) delete _userdeicon; // delete our copy (if any) for deactivated icon
-#endif
-#if FLTK_ABI_VERSION >= 10303
// focus item? set to null
if ( _tree && this == _tree->_item_focus )
{ _tree->_item_focus = 0; }
-#endif
//_children.clear(); // array's destructor handles itself
}
/// Copy constructor.
Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) {
-#if FLTK_ABI_VERSION >= 10303
_tree = o->_tree;
-#endif
_label = o->label() ? strdup(o->label()) : 0;
_labelfont = o->labelfont();
_labelsize = o->labelsize();
_labelfgcolor = o->labelfgcolor();
_labelbgcolor = o->labelbgcolor();
_widget = o->widget();
-#if FLTK_ABI_VERSION >= 10301
_flags = o->_flags;
-#else /*FLTK_ABI_VERSION*/
- _open = o->_open;
- _visible = o->_visible;
- _active = o->_active;
- _selected = o->_selected;
-#endif /*FLTK_ABI_VERSION*/
_xywh[0] = o->_xywh[0];
_xywh[1] = o->_xywh[1];
_xywh[2] = o->_xywh[2];
@@ -159,10 +127,8 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) {
_usericon = o->usericon();
_userdata = o->user_data();
_parent = o->_parent;
-#if FLTK_ABI_VERSION >= 10301
_prev_sibling = 0; // do not copy ptrs! use update_prev_next()
_next_sibling = 0; // do not copy ptrs! use update_prev_next()
-#endif /*FLTK_ABI_VERSION*/
}
/// Print the tree as 'ascii art' to stdout.
@@ -170,14 +136,9 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) {
///
void Fl_Tree_Item::show_self(const char *indent) const {
const char *thelabel = label() ? label() : "(NULL)";
-#if FLTK_ABI_VERSION >= 10301
printf("%s-%s (%d children, this=%p, parent=%p, prev=%p, next=%p, depth=%d)\n",
indent,thelabel,children(),(void*)this, (void*)_parent,
_prev_sibling, _next_sibling, depth());
-#else /*FLTK_ABI_VERSION*/
- printf("%s-%s (%d children, this=%p, parent=%p depth=%d)\n",
- indent,thelabel,children(),(void*)this, (void*)_parent, depth());
-#endif /*FLTK_ABI_VERSION*/
if ( children() ) {
char *i2 = new char [strlen(indent)+2];
strcpy(i2, indent);
@@ -342,13 +303,8 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs,
Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs,
const char *new_label,
Fl_Tree_Item *item) {
-#if FLTK_ABI_VERSION >= 10303
if ( !item )
{ item = new Fl_Tree_Item(_tree); item->label(new_label); }
-#else
- if ( !item )
- { item = new Fl_Tree_Item(prefs); item->label(new_label); }
-#endif
recalc_tree(); // may change tree geometry
item->_parent = this;
switch ( prefs.sortorder() ) {
@@ -436,11 +392,7 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs,
/// \returns the new item inserted.
///
Fl_Tree_Item *Fl_Tree_Item::insert(const Fl_Tree_Prefs &prefs, const char *new_label, int pos) {
-#if FLTK_ABI_VERSION >= 10303
Fl_Tree_Item *item = new Fl_Tree_Item(_tree);
-#else
- Fl_Tree_Item *item = new Fl_Tree_Item(prefs);
-#endif
item->label(new_label);
item->_parent = this;
_children.insert(pos, item);
@@ -603,7 +555,6 @@ int Fl_Tree_Item::move_into(Fl_Tree_Item *item, int pos) {
return move(item, 2, pos);
}
-#if FLTK_ABI_VERSION >= 10303
/// Return the parent tree's prefs.
/// \returns a reference to the parent tree's Fl_Tree_Prefs
/// \version 1.3.3 ABI feature
@@ -659,7 +610,6 @@ Fl_Tree_Item *Fl_Tree_Item::replace_child(Fl_Tree_Item *olditem,
recalc_tree(); // newitem may have changed tree geometry
return newitem;
}
-#endif
/// Remove \p 'item' from the current item's children.
/// \returns 0 if removed, -1 if item not an immediate child.
@@ -784,7 +734,6 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_
}
}
-#if FLTK_ABI_VERSION >= 10303
/// Find the item that the last event was over.
/// If \p 'yonly' is 1, only check event's y value, don't care about x.
/// \param[in] prefs The parent tree's Fl_Tree_Prefs
@@ -826,39 +775,6 @@ Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int yonly)
return(const_cast<Fl_Tree_Item*>(
static_cast<const Fl_Tree_Item &>(*this).find_clicked(prefs, yonly)));
}
-#else
-/// Find the item that the last event was over.
-/// \param[in] prefs The parent tree's Fl_Tree_Prefs
-/// \returns pointer to clicked item, or NULL if none found
-/// \version 1.3.0
-///
-const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) const {
- if ( ! is_visible() ) return(0);
- if ( is_root() && !prefs.showroot() ) {
- // skip event check if we're root but root not being shown
- } else {
- // See if event is over us
- if ( event_inside(_xywh) ) { // event within this item?
- return(this); // found
- }
- }
- if ( is_open() ) { // open? check children of this item
- for ( int t=0; t<children(); t++ ) {
- const Fl_Tree_Item *item;
- if ( (item = _children[t]->find_clicked(prefs)) != NULL) // recurse into child for descendents
- return(item); // found?
- }
- }
- return(0);
-}
-
-/// Non-const version of Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs&) const.
-Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) {
- // "Effective C++, 3rd Ed", p.23. Sola fide, Amen.
- return(const_cast<Fl_Tree_Item*>(
- static_cast<const Fl_Tree_Item &>(*this).find_clicked(prefs)));
-}
-#endif
static void draw_item_focus(Fl_Boxtype B, Fl_Color fg, Fl_Color bg, int X, int Y, int W, int H) {
if (!Fl::visible_focus()) return;
@@ -874,12 +790,12 @@ static void draw_item_focus(Fl_Boxtype B, Fl_Color fg, Fl_Color bg, int X, int Y
}
fl_color(fl_contrast(fg, bg));
-#if defined(USE_X11) || defined(__APPLE_QUARTZ__) // PORTME: Fl_Graphics_Driver - platform look and feel
+//#if defined(USE_X11) || defined(__APPLE_QUARTZ__)
fl_line_style(FL_DOT);
fl_rect(X + Fl::box_dx(B), Y + Fl::box_dy(B),
W - Fl::box_dw(B) - 1, H - Fl::box_dh(B) - 1);
fl_line_style(FL_SOLID);
-#else
+/*#else
// Some platforms don't implement dotted line style, so draw
// every other pixel around the focus area...
//
@@ -897,7 +813,7 @@ static void draw_item_focus(Fl_Boxtype B, Fl_Color fg, Fl_Color bg, int X, int Y
for (yy = 0; yy < H; yy ++, i ++) if (i & 1) fl_point(X + W, Y + yy);
for (xx = W; xx > 0; xx --, i ++) if (i & 1) fl_point(X + xx, Y + H);
for (yy = H; yy > 0; yy --, i ++) if (i & 1) fl_point(X, Y + yy);
-#endif
+#endif*/
}
/// Return the item's 'visible' height. Takes into account the item's:
@@ -916,13 +832,11 @@ int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const {
fl_font(_labelfont, _labelsize); // fl_descent() needs this :/
H = _labelsize + fl_descent() + 1; // at least one pixel space below descender
}
-#if FLTK_ABI_VERSION >= 10301
- if ( widget() &&
+ if ( widget() &&
(prefs.item_draw_mode() & FL_TREE_ITEM_HEIGHT_FROM_WIDGET) &&
H < widget()->h()) {
H = widget()->h();
}
-#endif /*FLTK_ABI_VERSION*/
if ( has_children() && prefs.openicon() && H<prefs.openicon()->h() )
H = prefs.openicon()->h();
if ( usericon() && H<usericon()->h() )
@@ -930,7 +844,6 @@ int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const {
return(H);
}
-#if FLTK_ABI_VERSION >= 10303
// These methods held for 1.3.3 ABI: all need 'tree()' back-reference.
/// Returns the recommended foreground color used for drawing this item.
@@ -1153,9 +1066,7 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
}
char clipped = ((Y+H) < tree_top) || (Y>tree_bot) ? 1 : 0;
if (!render) clipped = 0; // NOT rendering? Then don't clip, so we calc unclipped items
-#if FLTK_ABI_VERSION >= 10304
char active = (is_active() && tree()->active_r()) ? 1 : 0;
-#endif
char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1;
if ( !clipped ) {
Fl_Color fg = drawfgcolor();
@@ -1184,7 +1095,6 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
// Draw collapse icon
if ( render && has_children() && prefs.showcollapse() ) {
// Draw icon image
-#if FLTK_ABI_VERSION >= 10304
if ( is_open() ) {
if ( active ) prefs.closeicon()->draw(icon_x,icon_y);
else prefs.closedeicon()->draw(icon_x,icon_y);
@@ -1192,16 +1102,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
if ( active ) prefs.openicon()->draw(icon_x,icon_y);
else prefs.opendeicon()->draw(icon_x,icon_y);
}
-#else
- if ( is_open() ) {
- prefs.closeicon()->draw(icon_x,icon_y);
- } else {
- prefs.openicon()->draw(icon_x,icon_y);
- }
-#endif
}
// Draw user icon (if any)
-#if FLTK_ABI_VERSION >= 10304
if ( render && usericon() ) {
// Item has user icon? Use it
int uicon_y = item_y_center - (usericon()->h() >> 1);
@@ -1213,17 +1115,6 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
if ( active ) prefs.usericon()->draw(uicon_x,uicon_y);
else prefs.userdeicon()->draw(uicon_x,uicon_y);
}
-#else
- if ( render && usericon() ) {
- // Item has user icon? Use it
- int uicon_y = item_y_center - (usericon()->h() >> 1);
- usericon()->draw(uicon_x,uicon_y);
- } else if ( render && prefs.usericon() ) {
- // Prefs has user icon? Use it
- int uicon_y = item_y_center - (prefs.usericon()->h() >> 1);
- prefs.usericon()->draw(uicon_x,uicon_y);
- }
-#endif
// Draw item's content
xmax = draw_item_content(render);
} // end non-child damage
@@ -1272,246 +1163,6 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
}
}
-#else
-
-/// Draw this item and its children.
-///
-/// \param[in] X Horizontal position for item being drawn
-/// \param[in,out] Y Vertical position for item being drawn,
-/// returns new position for next item
-/// \param[in] W Recommended width of item
-/// \param[in] tree The parent tree
-/// \param[in] itemfocus The tree's current focus item (if any)
-/// \param[in] prefs The tree's preferences
-/// \param[in] lastchild Is this item the last child in a subtree?
-///
-/// \version 1.3.0 release, removed 1.3.3 ABI
-///
-void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
- Fl_Tree_Item *itemfocus,
- const Fl_Tree_Prefs &prefs, int lastchild) {
- if ( ! is_visible() ) return;
- int tree_top = tree->y();
- int tree_bot = tree_top + tree->h();
- int H = calc_item_height(prefs); // height of item
- int H2 = H + prefs.linespacing(); // height of item with line spacing
-
- // Update the xywh of this item
- _xywh[0] = X;
- _xywh[1] = Y;
- _xywh[2] = W;
- _xywh[3] = H;
-
- // Determine collapse icon's xywh
- // Note: calculate collapse icon's xywh for possible mouse click detection.
- // We don't care about items clipped off the viewport; they won't get mouse events.
- //
- int item_y_center = Y+(H/2);
- _collapse_xywh[2] = prefs.openicon()->w();
- int &icon_w = _collapse_xywh[2];
- _collapse_xywh[0] = X + (icon_w + prefs.connectorwidth())/2 - 3;
- int &icon_x = _collapse_xywh[0];
- _collapse_xywh[1] = item_y_center - (prefs.openicon()->h()/2);
- int &icon_y = _collapse_xywh[1];
- _collapse_xywh[3] = prefs.openicon()->h();
-
- // Horizontal connector values
- // XXX: Must calculate these even if(clipped) because 'draw children' code (below)
- // needs hconn_x_center value. (Otherwise, these calculations could be 'clipped')
- //
- int hconn_x = X+icon_w/2-1;
- int hconn_x2 = hconn_x + prefs.connectorwidth();
- int hconn_x_center = X + icon_w + ((hconn_x2 - (X + icon_w)) / 2);
- int cw1 = icon_w+prefs.connectorwidth()/2, cw2 = prefs.connectorwidth();
- int conn_w = cw1>cw2 ? cw1 : cw2;
-
- // Background position
- int &bg_x = _label_xywh[0] = X+(icon_w/2-1+conn_w);
- int &bg_y = _label_xywh[1] = Y;
- int &bg_w = _label_xywh[2] = W-(icon_w/2-1+conn_w);
- int &bg_h = _label_xywh[3] = H;
-
- // Usericon position
- int uicon_x = bg_x + ( (usericon() || prefs.usericon()) ? prefs.usericonmarginleft() : 0);
- int uicon_w = usericon() ? usericon()->w() : prefs.usericon() ? prefs.usericon()->w() : 0;
-
- // Label position
- int label_x = uicon_x + uicon_w + (_label ? prefs.labelmarginleft() : 0);
-
- // Recalc widget position
- // Do this whether clipped or not, so that when scrolled,
- // the widgets move to appropriate 'offscreen' positions
- // (so that they don't get mouse events, etc)
- //
- if ( widget() ) {
- int wx = label_x;
- int wy = bg_y;
- int ww = widget()->w(); // use widget's width
-#if FLTK_ABI_VERSION >= 10301
- int wh = (prefs.item_draw_mode() & FL_TREE_ITEM_HEIGHT_FROM_WIDGET)
- ? widget()->h() : H;
- if ( _label &&
- (prefs.item_draw_mode() & FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET) ) {
-#else /*FLTK_ABI_VERSION*/
- int wh = H; // lock widget's height to item height
- if ( _label && !widget() ) { // back compat: don't draw label if widget() present
-#endif /*FLTK_ABI_VERSION*/
- fl_font(_labelfont, _labelsize); // fldescent() needs this
- int lw=0, lh=0;
- fl_measure(_label,lw,lh); // get box around text (including white space)
-#if FLTK_ABI_VERSION >= 10301
- // NEW
- wx += (lw + prefs.widgetmarginleft());
-#else /*FLTK_ABI_VERSION*/
- // OLD
- wx += (lw + 3);
-#endif /*FLTK_ABI_VERSION*/
- }
- if ( widget()->x() != wx || widget()->y() != wy ||
- widget()->w() != ww || widget()->h() != wh ) {
- widget()->resize(wx,wy,ww,wh); // we'll handle redraw below
- }
- }
- char clipped = ((Y+H) < tree_top) || (Y>tree_bot) ? 1 : 0;
- char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1;
- char active = (is_active() && tree->active_r()) ? 1 : 0;
- if ( !clipped ) {
- const Fl_Color unspecified = 0xffffffff;
-
- Fl_Color fg = is_selected() ? fl_contrast(_labelfgcolor, tree->selection_color())
- : active ? _labelfgcolor
- : fl_inactive(_labelfgcolor);
- Fl_Color bg = is_selected() ? active ? tree->selection_color()
- : fl_inactive(tree->selection_color())
- : _labelbgcolor == unspecified ? tree->color()
- : _labelbgcolor;
- // See if we should draw this item
- // If this item is root, and showroot() is disabled, don't draw.
- // 'clipped' is an optimization to prevent drawing anything offscreen.
- //
- if ( drawthis ) { // draw this item at all?
- if ( tree->damage() & ~FL_DAMAGE_CHILD ) { // non-child damage?
- // Draw connectors
- if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) {
- // Horiz connector between center of icon and text
- // if this is root, the connector should not dangle in thin air on the left
- if (is_root()) draw_horizontal_connector(hconn_x_center, hconn_x2, item_y_center, prefs);
- else draw_horizontal_connector(hconn_x, hconn_x2, item_y_center, prefs);
- // Small vertical line down to children
- if ( has_children() && is_open() )
- draw_vertical_connector(hconn_x_center, item_y_center, Y+H2, prefs);
- // Connectors for last child
- if ( !is_root() ) {
- if ( lastchild ) draw_vertical_connector(hconn_x, Y, item_y_center, prefs);
- else draw_vertical_connector(hconn_x, Y, Y+H2, prefs);
- }
- }
- // Draw collapse icon
- if ( has_children() && prefs.showcollapse() ) {
- // Draw icon image
-#if FLTK_ABI_VERSION >= 10304
- if ( is_open() ) {
- if ( active ) prefs.closeicon()->draw(icon_x,icon_y);
- else prefs.closedeicon()->draw(icon_x,icon_y);
- } else {
- if ( active ) prefs.openicon()->draw(icon_x,icon_y);
- else prefs.opendeicon()->draw(icon_x,icon_y);
- }
-#else
- if ( is_open() ) {
- prefs.closeicon()->draw(icon_x,icon_y);
- } else {
- prefs.openicon()->draw(icon_x,icon_y);
- }
-#endif
- }
- // Draw background for the item.. only if different from tree's bg color
- if ( bg != tree->color() || is_selected() ) {
- if ( is_selected() ) { // Selected? Use selectbox() style
- fl_draw_box(prefs.selectbox(),bg_x,bg_y,bg_w,bg_h,bg);
- } else { // Not Selected? use plain filled rectangle
- fl_color(bg);
- fl_rectf(bg_x,bg_y,bg_w,bg_h);
- }
- if ( widget() ) widget()->damage(FL_DAMAGE_ALL); // if there's a child widget, we just damaged it
- }
- // Draw user icon (if any)
-#if FLTK_ABI_VERSION >= 10304
- if ( usericon() ) {
- // Item has user icon? Use it
- int uicon_y = item_y_center - (usericon()->h() >> 1);
- if ( active ) usericon()->draw(uicon_x,uicon_y);
- else userdeicon()->draw(uicon_x,uicon_y);
- } else if ( prefs.usericon() ) {
- // Prefs has user icon? Use it
- int uicon_y = item_y_center - (prefs.usericon()->h() >> 1);
- if ( active ) prefs.usericon()->draw(uicon_x,uicon_y);
- else prefs.userdeicon()->draw(uicon_x,uicon_y);
- }
-#else
- if ( usericon() ) {
- // Item has user icon? Use it
- int uicon_y = item_y_center - (usericon()->h() >> 1);
- usericon()->draw(uicon_x,uicon_y);
- } else if ( prefs.usericon() ) {
- // Prefs has user icon? Use it
- int uicon_y = item_y_center - (prefs.usericon()->h() >> 1);
- prefs.usericon()->draw(uicon_x,uicon_y);
- }
-#endif
- // Draw label
-#if FLTK_ABI_VERSION >= 10301
- if ( _label &&
- ( !widget() ||
- (prefs.item_draw_mode() & FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET) ) )
-#else /*FLTK_ABI_VERSION*/
- if ( _label && !widget() ) // back compat: don't draw label if widget() present
-#endif /*FLTK_ABI_VERSION*/
- {
- fl_color(fg);
- fl_font(_labelfont, _labelsize);
- int label_y = Y+(H/2)+(_labelsize/2)-fl_descent()/2;
- fl_draw(_label, label_x, label_y);
- }
- } // end non-child damage
- // Draw child FLTK widget?
- if ( widget() ) {
- ((Fl_Tree*)tree)->draw_child(*widget()); // let group handle drawing child
- if ( widget()->label() )
- ((Fl_Tree*)tree)->draw_outside_label(*widget()); // label too
- }
- // Draw focus box around item's bg last
- if ( this == itemfocus &&
- Fl::visible_focus() &&
- Fl::focus() == tree &&
- prefs.selectmode() != FL_TREE_SELECT_NONE ) {
- draw_item_focus(FL_NO_BOX,fg,bg,bg_x+1,bg_y+1,bg_w-1,bg_h-1);
- }
- } // end drawthis
- } // end clipped
- if ( drawthis ) Y += H2; // adjust Y (even if clipped)
- // Draw child items (if any)
- if ( has_children() && is_open() ) {
- int child_x = drawthis ? (hconn_x_center - (icon_w/2) + 1) // offset children to right,
- : X; // unless didn't drawthis
- int child_w = W - (child_x-X);
- int child_y_start = Y;
- for ( int t=0; t<children(); t++ ) {
- int lastchild = ((t+1)==children()) ? 1 : 0;
- _children[t]->draw(child_x, Y, child_w, tree, itemfocus, prefs, lastchild);
- }
- if ( has_children() && is_open() ) {
- Y += prefs.openchild_marginbottom(); // offset below open child tree
- }
- if ( ! lastchild ) {
- // Special 'clipped' calculation. (intentional variable shadowing)
- int clipped = ((child_y_start < tree_top) && (Y < tree_top)) ||
- ((child_y_start > tree_bot) && (Y > tree_bot));
- if (!clipped) draw_vertical_connector(hconn_x, child_y_start, Y, prefs);
- }
- }
-}
-#endif
/// Was the event on the 'collapse' button of this item?
///
@@ -1603,22 +1254,11 @@ Fl_Tree_Item *Fl_Tree_Item::next() {
if ( c->has_children() ) {
return(c->child(0));
}
-#if FLTK_ABI_VERSION >= 10301
- // NEW
while ( ( p = c->parent() ) != NULL ) { // loop upwards through parents
if ( c->_next_sibling ) // not last child?
return(c->_next_sibling); // return next child
c = p; // child becomes parent to move up generation
} // loop: moves up to next parent
-#else /*FLTK_ABI_VERSION*/
- // OLD
- while ( ( p = c->parent() ) != NULL ) { // loop upwards through parents
- int t = p->find_child(c); // find our position in parent's children[] array
- if ( ++t < p->children() ) // not last child?
- return(p->child(t)); // return next child
- c = p; // child becomes parent to move up generation
- } // loop: moves up to next parent
-#endif /*FLTK_ABI_VERSION*/
return(0); // hit root? done
}
@@ -1631,8 +1271,6 @@ Fl_Tree_Item *Fl_Tree_Item::next() {
/// or 0 if there's no item above this one (hit the root).
///
Fl_Tree_Item *Fl_Tree_Item::prev() {
-#if FLTK_ABI_VERSION >= 10301
- // NEW
if ( !parent() ) return(0); // hit root? done
if ( !_prev_sibling ) { // are we first child?
return(parent()); // return parent
@@ -1660,20 +1298,6 @@ Fl_Tree_Item *Fl_Tree_Item::prev() {
p = p->child(p->children()-1); // descend hierarchy finding deepest 'last child'
}
return(p);
-#else /*FLTK_ABI_VERSION*/
- // OLD
- Fl_Tree_Item *p=parent(); // start with parent
- if ( ! p ) return(0); // hit root? done
- int t = p->find_child(this); // find our position in parent's children[] array
- if ( --t == -1 ) { // are we first child?
- return(p); // return immediate parent
- }
- p = p->child(t); // take parent's previous child
- while ( p->has_children() ) { // has children?
- p = p->child(p->children()-1); // take last child
- }
- return(p);
-#endif /*FLTK_ABI_VERSION*/
}
/// Return this item's next sibling.
@@ -1685,18 +1309,7 @@ Fl_Tree_Item *Fl_Tree_Item::prev() {
/// \returns item's next sibling, or 0 if none.
///
Fl_Tree_Item *Fl_Tree_Item::next_sibling() {
-#if FLTK_ABI_VERSION >= 10301
- // NEW
return(_next_sibling);
-#else /*FLTK_ABI_VERSION*/
- // OLD
- if ( !parent() ) return(0); // No parent (root)? We have no siblings
- int index = parent()->find_child(this); // find our position in parent's child() array
- if ( index == -1 ) return(0); // parent doesn't know us? weird
- if ( (index+1) < parent()->children() ) // is there a next child?
- return(parent()->child(index+1)); // return next child if there's one below us
- return(0); // no siblings below us
-#endif /*FLTK_ABI_VERSION*/
}
/// Return this item's previous sibling.
@@ -1707,17 +1320,7 @@ Fl_Tree_Item *Fl_Tree_Item::next_sibling() {
/// \returns This item's previous sibling, or 0 if none.
///
Fl_Tree_Item *Fl_Tree_Item::prev_sibling() {
-#if FLTK_ABI_VERSION >= 10301
- // NEW
return(_prev_sibling);
-#else /*FLTK_ABI_VERSION*/
- // OLD
- if ( !parent() ) return(0); // No parent (root)? We have no siblings
- int index = parent()->find_child(this); // find next position up in parent's child() array
- if ( index == -1 ) return(0); // parent doesn't know us? weird
- if ( index > 0 ) return(parent()->child(index-1)); // return previous child if there's one above us
- return(0); // no siblings above us
-#endif /*FLTK_ABI_VERSION*/
}
/// Update our _prev_sibling and _next_sibling pointers to point to neighbors
@@ -1727,8 +1330,6 @@ Fl_Tree_Item *Fl_Tree_Item::prev_sibling() {
/// Special case if index=-1: become an orphan; null out all parent/sibling associations.
///
void Fl_Tree_Item::update_prev_next(int index) {
-#if FLTK_ABI_VERSION >= 10301
- // NEW
if ( index == -1 ) { // special case: become an orphan
_parent = 0;
_prev_sibling = 0;
@@ -1747,10 +1348,6 @@ void Fl_Tree_Item::update_prev_next(int index) {
// Adjust neighbors to point to us
if ( item_prev ) item_prev->_next_sibling = this;
if ( item_next ) item_next->_prev_sibling = this;
-#else /*FLTK_ABI_VERSION*/
- // OLD
- // -- does nothing --
-#endif /*FLTK_ABI_VERSION*/
}
/// Return the next open(), visible() item.
@@ -1833,9 +1430,7 @@ int Fl_Tree_Item::visible_r() const {
/// \version 1.3.3 ABI
///
void Fl_Tree_Item::recalc_tree() {
-#if FLTK_ABI_VERSION >= 10303
_tree->recalc_tree();
-#endif
}
//
diff --git a/src/Fl_Tree_Item_Array.cxx b/src/Fl_Tree_Item_Array.cxx
index 7f7476569..1da368c9a 100644
--- a/src/Fl_Tree_Item_Array.cxx
+++ b/src/Fl_Tree_Item_Array.cxx
@@ -36,9 +36,7 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(int new_chunksize) {
_items = 0;
_total = 0;
_size = 0;
-#if FLTK_ABI_VERSION >= 10303
_flags = 0;
-#endif
_chunksize = new_chunksize;
}
@@ -53,11 +51,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
_total = 0;
_size = o->_size;
_chunksize = o->_chunksize;
-#if FLTK_ABI_VERSION >= 10303
_flags = o->_flags;
-#endif
for ( int t=0; t<o->_total; t++ ) {
-#if FLTK_ABI_VERSION >= 10303
if ( _flags & MANAGE_ITEM ) {
_items[t] = new Fl_Tree_Item(o->_items[t]); // make new copy of item
++_total;
@@ -66,11 +61,6 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
_items[t] = o->_items[t]; // copy ptr only
++_total;
}
-#else
- _items[t] = new Fl_Tree_Item(o->_items[t]); // make new copy of item
- ++_total;
- _items[t]->update_prev_next(t); // update uses _total's current value
-#endif
}
}
@@ -82,9 +72,7 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
void Fl_Tree_Item_Array::clear() {
if ( _items ) {
for ( int t=0; t<_total; t++ ) {
-#if FLTK_ABI_VERSION >= 10303
if ( _flags & MANAGE_ITEM )
-#endif
{
delete _items[t];
_items[t] = 0;
@@ -132,9 +120,7 @@ void Fl_Tree_Item_Array::insert(int pos, Fl_Tree_Item *new_item) {
}
_items[pos] = new_item;
_total++;
-#if FLTK_ABI_VERSION >= 10303
if ( _flags & MANAGE_ITEM )
-#endif
{
_items[pos]->update_prev_next(pos); // adjust item's prev/next and its neighbors
}
@@ -157,16 +143,12 @@ void Fl_Tree_Item_Array::add(Fl_Tree_Item *val) {
///
void Fl_Tree_Item_Array::replace(int index, Fl_Tree_Item *newitem) {
if ( _items[index] ) { // delete if non-zero
-#if FLTK_ABI_VERSION >= 10303
if ( _flags & MANAGE_ITEM )
-#endif
// Destroy old item
delete _items[index];
}
_items[index] = newitem; // install new item
-#if FLTK_ABI_VERSION >= 10303
- if ( _flags & MANAGE_ITEM )
-#endif
+ if ( _flags & MANAGE_ITEM )
{
// Restitch into linked list
_items[index]->update_prev_next(index);
@@ -179,9 +161,7 @@ void Fl_Tree_Item_Array::replace(int index, Fl_Tree_Item *newitem) {
///
void Fl_Tree_Item_Array::remove(int index) {
if ( _items[index] ) { // delete if non-zero
-#if FLTK_ABI_VERSION >= 10303
if ( _flags & MANAGE_ITEM )
-#endif
delete _items[index];
}
_items[index] = 0;
@@ -189,9 +169,7 @@ void Fl_Tree_Item_Array::remove(int index) {
for ( int i=index; i<_total; i++ ) { // reshuffle the array
_items[i] = _items[i+1];
}
-#if FLTK_ABI_VERSION >= 10303
- if ( _flags & MANAGE_ITEM )
-#endif
+ if ( _flags & MANAGE_ITEM )
{
if ( index < _total ) { // removed item not last?
_items[index]->update_prev_next(index); // update next item's prev/next and neighbors
@@ -216,22 +194,18 @@ int Fl_Tree_Item_Array::remove(Fl_Tree_Item *item) {
return(-1);
}
-#if FLTK_ABI_VERSION >= 10301
/// Swap the two items at index positions \p ax and \p bx.
void Fl_Tree_Item_Array::swap(int ax, int bx) {
Fl_Tree_Item *asave = _items[ax];
_items[ax] = _items[bx];
_items[bx] = asave;
-#if FLTK_ABI_VERSION >= 10303
if ( _flags & MANAGE_ITEM )
-#endif
{
// Adjust prev/next ptrs
_items[ax]->update_prev_next(ax);
_items[bx]->update_prev_next(bx);
}
}
-#endif /* FLTK_ABI_VERSION */
/// Move item at 'from' to new position 'to' in the array.
/// Due to how the moving an item shuffles the array around,
diff --git a/src/Fl_Tree_Prefs.cxx b/src/Fl_Tree_Prefs.cxx
index 1bc513d0e..1a7fcd591 100644
--- a/src/Fl_Tree_Prefs.cxx
+++ b/src/Fl_Tree_Prefs.cxx
@@ -107,7 +107,6 @@ static Fl_Pixmap L_closepixmap(L_close_xpm);
///
void Fl_Tree_Prefs::openicon(Fl_Image *val) {
_openimage = val ? val : &L_openpixmap;
-#if FLTK_ABI_VERSION >= 10304
// Update deactivated version of icon..
if ( _opendeimage ) delete _opendeimage;
if ( _openimage ) {
@@ -116,7 +115,6 @@ void Fl_Tree_Prefs::openicon(Fl_Image *val) {
} else {
_opendeimage = 0;
}
-#endif
}
/// Sets the icon to be used as the 'close' icon.
@@ -126,7 +124,6 @@ void Fl_Tree_Prefs::openicon(Fl_Image *val) {
///
void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
_closeimage = val ? val : &L_closepixmap;
-#if FLTK_ABI_VERSION >= 10304
// Update deactivated version of icon..
if ( _closedeimage ) delete _closedeimage;
if ( _closeimage ) {
@@ -135,7 +132,6 @@ void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
} else {
_closedeimage = 0;
}
-#endif
}
/// Fl_Tree_Prefs constructor
@@ -144,15 +140,11 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
_labelsize = FL_NORMAL_SIZE;
_marginleft = 6;
_margintop = 3;
-#if FLTK_ABI_VERSION >= 10301
_marginbottom = 20;
-#endif /*FLTK_ABI_VERSION*/
_openchild_marginbottom = 0;
_usericonmarginleft = 3;
_labelmarginleft = 3;
-#if FLTK_ABI_VERSION >= 10301
_widgetmarginleft = 3;
-#endif /*FLTK_ABI_VERSION*/
_linespacing = 0;
_labelfgcolor = FL_BLACK;
_labelbgcolor = 0xffffffff; // we use this as 'transparent'
@@ -165,27 +157,21 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
_openimage = &L_openpixmap;
_closeimage = &L_closepixmap;
_userimage = 0;
-#if FLTK_ABI_VERSION >= 10304
_opendeimage = _openimage->copy();
_opendeimage->inactive();
_closedeimage = _closeimage->copy();
_closedeimage->inactive();
_userdeimage = 0;
-#endif
_showcollapse = 1;
_showroot = 1;
_connectorwidth = 17;
_sortorder = FL_TREE_SORT_NONE;
_selectbox = FL_FLAT_BOX;
_selectmode = FL_TREE_SELECT_SINGLE;
-#if FLTK_ABI_VERSION >= 10301
_itemreselectmode = FL_TREE_SELECTABLE_ONCE;
_itemdrawmode = FL_TREE_ITEM_DRAW_DEFAULT;
-#endif
-#if FLTK_ABI_VERSION >= 10303
_itemdrawcallback = 0;
_itemdrawuserdata = 0;
-#endif
// Let fltk's current 'scheme' affect defaults
if (Fl::is_scheme("gtk+")) {
_selectbox = _FL_GTK_THIN_UP_BOX;
@@ -194,14 +180,12 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
}
}
-#if FLTK_ABI_VERSION >= 10304
/// Fl_Tree_Prefs destructor
Fl_Tree_Prefs::~Fl_Tree_Prefs() {
if ( _opendeimage ) delete _opendeimage;
if ( _closedeimage ) delete _closedeimage;
if ( _userdeimage ) delete _userdeimage;
}
-#endif
//
// End of "$Id$".