Author: fabien
Date: 2012-04-15 13:11:36 -0700 (Sun, 15 Apr 2012)
New Revision: 9347
Log:
STR 2827 implementation. Implemented Reselect code and related API all within
ABI controlled preprocessor blocks because of new attribute defintion would
break ABI anyway. Because the code is already ABI controlled, I took the
opportunity to keep keep the REASON enum sorted. Added test code in Tree.fl
adequately.
Modified:
branches/branch-1.3/FL/Fl_Tree.H
branches/branch-1.3/ide/Xcode3/FLTK.xcodeproj/project.pbxproj
branches/branch-1.3/src/Fl_Tree.cxx
branches/branch-1.3/test/tree.fl
Modified: branches/branch-1.3/FL/Fl_Tree.H
===================================================================
--- branches/branch-1.3/FL/Fl_Tree.H 2012-04-14 20:37:55 UTC (rev 9346)
+++ branches/branch-1.3/FL/Fl_Tree.H 2012-04-15 20:11:36 UTC (rev 9347)
@@ -186,11 +186,16 @@
FL_TREE_REASON_NONE=0, ///< unknown reason
FL_TREE_REASON_SELECTED, ///< an item was selected
FL_TREE_REASON_DESELECTED, ///< an item was de-selected
+#if FLTK_ABI_VERSION >= 10302
+ FL_TREE_REASON_RESELECTED, ///< an item was re-selected
+#endif
FL_TREE_REASON_OPENED, ///< an item was opened
FL_TREE_REASON_CLOSED ///< an item was closed
};
-
+/// \enum Fl_Tree_Item_Select_Mode
+/// Defines the ways an item can be (re) selected.
+///
class FL_EXPORT Fl_Tree : public Fl_Group {
Fl_Tree_Item *_root; // can be null!
Fl_Tree_Item *_item_focus; // item that has focus box
@@ -202,6 +207,25 @@
#if FLTK_ABI_VERSION >= 10302
// NEW:
Fl_Tree_Item *_lastselect;
+
+ // NEW:
+public:
+ enum Fl_Tree_Item_Reselect_Mode
+ {
+ FL_TREE_SELECTABLE_ONCE=0, /// backward compatible default: an item can
only be selected once
+ FL_TREE_SELECTABLE_ALWAYS, /// needed for new RESELECT feature
+ };
+ //! Returns the current item re/selection mode
+ Fl_Tree_Item_Reselect_Mode item_reselect_mode() const {
+ return _itemReselectMode;
+ }
+
+ //! Sets the item re/selection mode
+ void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode) {
+ _itemReselectMode = mode;
+ }
+private:
+ Fl_Tree_Item_Reselect_Mode _itemReselectMode;
#else
// OLD: static data inside handle() method
#endif
@@ -280,7 +304,6 @@
void set_item_focus(Fl_Tree_Item *item);
int is_selected(Fl_Tree_Item *item) const;
int is_selected(const char *path);
-
/////////////////////////////////
// Item attribute related methods
/////////////////////////////////
Modified: branches/branch-1.3/ide/Xcode3/FLTK.xcodeproj/project.pbxproj
===================================================================
--- branches/branch-1.3/ide/Xcode3/FLTK.xcodeproj/project.pbxproj
2012-04-14 20:37:55 UTC (rev 9346)
+++ branches/branch-1.3/ide/Xcode3/FLTK.xcodeproj/project.pbxproj
2012-04-15 20:11:36 UTC (rev 9347)
@@ -13066,10 +13066,16 @@
ARCHS =
"$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 =
"x86_64 i386 ppc";
GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_SSE41_EXTENSIONS = NO;
+ GCC_ENABLE_SSE42_EXTENSIONS = YES;
+ GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 3;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
+ VALID_ARCHS = "i386 x86_64";
};
name = Release;
};
@@ -14154,14 +14160,15 @@
AC3226B9FE17327A0476ACA0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+ ARCHS = "$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- ONLY_ACTIVE_ARCH = YES;
+ ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 =
"$(NATIVE_ARCH_ACTUAL)";
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
+ VALID_ARCHS = "i386 x86_64";
};
name = Debug;
};
Modified: branches/branch-1.3/src/Fl_Tree.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Tree.cxx 2012-04-14 20:37:55 UTC (rev 9346)
+++ branches/branch-1.3/src/Fl_Tree.cxx 2012-04-15 20:11:36 UTC (rev 9347)
@@ -98,10 +98,11 @@
_callback_item = 0;
_callback_reason = FL_TREE_REASON_NONE;
_scrollbar_size = 0; // 0: uses
Fl::scrollbar_size()
-
+
#if FLTK_ABI_VERSION >= 10302
// NEW
_lastselect = 0;
+ _itemReselectMode = FL_TREE_SELECTABLE_ONCE;
#else
// OLD: data initialized static inside handle()
#endif
@@ -257,7 +258,8 @@
// fprintf(stderr, "ERCODEBUG: Fl_Tree::handle(): Event was %s (%d)\n",
fl_eventnames[e], e); // DEBUGGING
if ( ! _root ) return(ret);
switch ( e ) {
- case FL_PUSH: { // clicked on a tree
item?
+ case FL_PUSH: {
+ // clicked on a tree item?
if (Fl::visible_focus() && handle(FL_FOCUS)) {
Fl::focus(this);
}
@@ -273,6 +275,7 @@
} else if ( o->event_on_label(_prefs) && // label clicked?
(!o->widget() || !Fl::event_inside(o->widget())) &&
// not inside widget
(!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) {
// not on scroller
+
switch ( _prefs.selectmode() ) {
case FL_TREE_SELECT_NONE:
break;
@@ -995,13 +998,25 @@
/// - 0 - item was already selected, no change was made
///
int Fl_Tree::select(Fl_Tree_Item *item, int docallback) {
- if ( ! item->is_selected() ) {
+ int alreadySelected = item->is_selected();
+
+ if ( !alreadySelected
+#if FLTK_ABI_VERSION >= 10302
+ || item_reselect_mode()==FL_TREE_SELECTABLE_ALWAYS
+#endif
+ ) {
item->select();
set_changed();
if ( docallback ) {
- do_callback_for_item(item, FL_TREE_REASON_SELECTED);
+ do_callback_for_item(item,
+#if FLTK_ABI_VERSION >= 10302
+ alreadySelected ? FL_TREE_REASON_RESELECTED
:FL_TREE_REASON_SELECTED);
+#else
+ FL_TREE_REASON_SELECTED);
+#endif
}
- redraw();
+
+ redraw();
return(1);
}
return(0);
@@ -1165,7 +1180,13 @@
int changed = 0;
for ( Fl_Tree_Item *item = first(); item; item = item->next() ) {
if ( item == selitem ) {
- if ( item->is_selected() ) continue; // don't count if already
selected
+ if ( item->is_selected()
+
+#if FLTK_ABI_VERSION >= 10302
+ && item_reselect_mode()!=FL_TREE_SELECTABLE_ALWAYS
+#endif
+
+ ) continue; // don't count if already selected
select(item, docallback);
++changed;
} else {
Modified: branches/branch-1.3/test/tree.fl
===================================================================
--- branches/branch-1.3/test/tree.fl 2012-04-14 20:37:55 UTC (rev 9346)
+++ branches/branch-1.3/test/tree.fl 2012-04-15 20:11:36 UTC (rev 9347)
@@ -45,6 +45,9 @@
case FL_TREE_REASON_DESELECTED: return("deselected");
case FL_TREE_REASON_OPENED: return("opened");
case FL_TREE_REASON_CLOSED: return("closed");
+\#if FLTK_ABI_VERSION >= 10302
+ case FL_TREE_REASON_RESELECTED: return("reselected");
+\#endif
default: return("???");
}} {}
}
@@ -221,7 +224,9 @@
label Tree
user_data 1234
callback {G_cb_counter++; // Increment callback counter whenever tree
callback is invoked
-
+\#if FLTK_ABI_VERSION >= 10302
+ tree->item_reselect_mode(Fl_Tree::FL_TREE_SELECTABLE_ALWAYS);
+\#endif
Fl_Tree_Item *item = tree->callback_item();
if ( item ) {
fprintf(stderr, "TREE CALLBACK: label='%s' userdata=%ld reason=%s\\n",
@@ -231,7 +236,7 @@
} else {
fprintf(stderr, "TREE CALLBACK: reason=%s item=(no item -- probably multiple
items were changed at once)\\n",
reason_as_name(tree->callback_reason()));
-}} open
+}} open selected
tooltip {Test tree} xywh {15 22 280 411} box DOWN_BOX color 55
selection_color 15
class Fl_Tree
} {}
@@ -1165,7 +1170,7 @@
}
item = item->next();
}
-tree->redraw();} selected
+tree->redraw();}
tooltip {Adds 20,000 items to the selected item's parent} xywh {530
398 95 16} labelsize 9
}
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit