summaryrefslogtreecommitdiff
path: root/src/Fl_Tree_Item.cxx
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2014-01-16 00:58:58 +0000
committerGreg Ercolano <erco@seriss.com>2014-01-16 00:58:58 +0000
commitb849a1d2d9c5eb76bccebe4f48716db15933e135 (patch)
treed8841161b42c03810b570d197abebbab9c56fa6f /src/Fl_Tree_Item.cxx
parent9c6eb8be290cf9a95f987be96677cdb45be27fd8 (diff)
ABI fixes.
These are problems "ABI Compliance Checker" found with the recent Fl_Tree mods. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10062 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tree_Item.cxx')
-rw-r--r--src/Fl_Tree_Item.cxx76
1 files changed, 55 insertions, 21 deletions
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index cd40bfdd9..ca0fdfcb3 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -494,11 +494,15 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_
}
}
-// Internal
-// 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.
-//
-const Fl_Tree_Item *Fl_Tree_Item::find_clicked_(const Fl_Tree_Prefs &prefs, int yonly) const {
+#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
+/// \param[in] yonly -- 0: check both event's X and Y values.
+/// -- 1: only check event's Y value, don't care about X.
+/// \returns pointer to clicked item, or NULL if none found
+///
+const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int yonly) const {
if ( ! is_visible() ) return(0);
if ( is_root() && !prefs.showroot() ) {
// skip event check if we're root but root not being shown
@@ -518,33 +522,63 @@ const Fl_Tree_Item *Fl_Tree_Item::find_clicked_(const Fl_Tree_Prefs &prefs, int
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, yonly)) != NULL) { // check child and its descendents
- return(item); // found?
- }
+ if ( (item = _children[t]->find_clicked(prefs, yonly)) != NULL) // recurse into child for descendents
+ return(item); // found?
}
}
return(0);
}
/// Find the item that the last event was over.
-/// There is both a const and non-const version of this method.
-///
-/// Returns the item if it is visible, and mouse is over it.
-/// Works even if widget deactivated.
-/// Use event_on_collapse_icon() to determine if collapse button was pressed.
-///
-/// If \a yonly is set, only the mouse Y position is checked.
+/// 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
+/// \param[in] yonly -- 0: check both event's X and Y values.
+/// -- 1: only check event's Y value, don't care about X.
+/// \returns pointer to clicked item, or NULL if none found
+/// \version 1.3.3 ABI
///
-/// \returns const visible item under the event if found, or 0 if none.
+Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int yonly) {
+ // "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, 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, int yonly) const {
- return(find_clicked_(prefs, yonly));
+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);
}
-/// A const version of Fl_Tree_Item::find_clicked()
-Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int yonly) {
- return((Fl_Tree_Item*)find_clicked_(prefs, yonly));
+/// 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
+///
+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;