DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2792
Version: 1.3-feature


This patch changes how the selection of an item in a browser_ widget is
selected if there is no selection on a hold (or checkbox) type browser. 
Basically up selects bottom, down selects first, previously down would
select second item, first never selected.  The local variable name was
changed to make more since (so it shows more changes that actually
occurred).  Basically now browser_ of that type can send an item_next or
item_prev request with a null value so all derived classes need to be able
to handle a null.


Link: http://www.fltk.org/str.php?L2792
Version: 1.3-feature
Index: fluid/Fl_Type.cxx
===================================================================
--- fluid/Fl_Type.cxx   (revision 9205)
+++ fluid/Fl_Type.cxx   (working copy)
@@ -222,9 +222,9 @@
 
 void *Widget_Browser::item_first() const {return Fl_Type::first;}
 
-void *Widget_Browser::item_next(void *l) const {return ((Fl_Type*)l)->next;}
+void *Widget_Browser::item_next(void *l) const {return l ? ((Fl_Type*)l)->next 
: item_first();}
 
-void *Widget_Browser::item_prev(void *l) const {return ((Fl_Type*)l)->prev;}
+void *Widget_Browser::item_prev(void *l) const {return l ? ((Fl_Type*)l)->prev 
: item_last();}
 
 int Widget_Browser::item_selected(void *l) const {return 
((Fl_Type*)l)->new_selected;}
 
Index: src/Fl_Browser.cxx
===================================================================
--- src/Fl_Browser.cxx  (revision 9205)
+++ src/Fl_Browser.cxx  (working copy)
@@ -76,7 +76,7 @@
   \returns The next item after \p item, or NULL if there are none after this 
one.
   \see item_first(), item_last(), item_next(), item_prev()
 */
-void* Fl_Browser::item_next(void* item) const {return ((FL_BLINE*)item)->next;}
+void* Fl_Browser::item_next(void* item) const {return  item ? 
((FL_BLINE*)item)->next : item_first();}
 
 /**
   Returns the previous item before \p item.
@@ -84,7 +84,7 @@
   \returns The previous item before \p item, or NULL if there none before this 
one.
   \see item_first(), item_last(), item_next(), item_prev()
 */
-void* Fl_Browser::item_prev(void* item) const {return ((FL_BLINE*)item)->prev;}
+void* Fl_Browser::item_prev(void* item) const {return item ? 
((FL_BLINE*)item)->prev : item_last();}
 
 /**
   Returns the very last item in the list.
Index: src/Fl_Browser_.cxx
===================================================================
--- src/Fl_Browser_.cxx (revision 9205)
+++ src/Fl_Browser_.cxx (working copy)
@@ -705,19 +705,19 @@
   // must do shortcuts first or the scrollbar will get them...
   if (event == FL_ENTER || event == FL_LEAVE) return 1;
   if (event == FL_KEYBOARD && type() >= FL_HOLD_BROWSER) {
-    void* l1 = selection_;
-    void* l = l1; if (!l) l = top_; if (!l) l = item_first();
+    void* ls = selection_;
+    void* l = ls; if (!l) l = top_; if (!l) l = item_first();
     if (l) {
       if (type()==FL_HOLD_BROWSER) {
         switch (Fl::event_key()) {
         case FL_Down:
-          while ((l = item_next(l)))
-            if (item_height(l)>0) {select_only(l, when()); break;}
+          while ((ls = item_next(ls)))
+            if (item_height(ls)>0) {select_only(ls, when()); break;}
             return 1;
         case FL_Up:
-          while ((l = item_prev(l))) {
-           if (item_height(l)>0) {
-             select_only(l, when());
+          while ((ls = item_prev(ls))) {
+            if (item_height(ls)>0) {
+              select_only(ls, when());
              break; // no need to test wp (return 1)
            }
          }
@@ -741,7 +741,7 @@
         case FL_Down:
           while ((l = item_next(l))) {
             if (Fl::event_state(FL_SHIFT|FL_CTRL))
-              select(l, l1 ? item_selected(l1) : 1, when());
+              select(l, ls ? item_selected(ls) : 1, when());
            if (wp.deleted()) return 1;
             if (item_height(l)>0) goto J1;
           }
@@ -749,7 +749,7 @@
         case FL_Up:
           while ((l = item_prev(l))) {
             if (Fl::event_state(FL_SHIFT|FL_CTRL))
-              select(l, l1 ? item_selected(l1) : 1, when());
+              select(l, ls ? item_selected(ls) : 1, when());
            if (wp.deleted()) return 1;
             if (item_height(l)>0) goto J1;
           }
Index: src/Fl_Check_Browser.cxx
===================================================================
--- src/Fl_Check_Browser.cxx    (revision 9205)
+++ src/Fl_Check_Browser.cxx    (working copy)
@@ -90,11 +90,11 @@
 }
 
 void *Fl_Check_Browser::item_next(void *l) const {
-       return ((cb_item *)l)->next;
+  return l ? ((cb_item *)l)->next : item_first();
 }
 
 void *Fl_Check_Browser::item_prev(void *l) const {
-       return ((cb_item *)l)->prev;
+  return l ? ((cb_item *)l)->prev : item_last();
 }
 
 int Fl_Check_Browser::item_height(void *) const {
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to