[master] 0e4137f - Fix Fl_Check_Browser.{H|cxx} indentation (#121) (#132)

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 0e4137f - Fix Fl_Check_Browser.{H|cxx} indentation (#121) (#132) "Albrecht Schlosser" 11:17 Sep 06 top right image
 
commit 0e4137f66b81e5a6e2ef91ac5a3533513ef2b47c
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Sun Sep 6 20:02:02 2020 +0200
Commit:     GitHub <noreply@github.com>
CommitDate: Sun Sep 6 20:02:02 2020 +0200

    Fix Fl_Check_Browser.{H|cxx} indentation (#121) (#132)
    
    * Fix Fl_Check_Browser.{H|cxx} indentation (#121)
    
    ... and some more whitespace errors as proposed by Greg
    ... in issue #121: Fl_Check_Browser--whitespace-patch.txt
    
    Fixes #121
    
    * Fix copyright years

 FL/Fl_Check_Browser.H    |  40 +++---
 src/Fl_Check_Browser.cxx | 340 +++++++++++++++++++++++------------------------
 2 files changed, 187 insertions(+), 193 deletions(-)

diff --git FL/Fl_Check_Browser.H FL/Fl_Check_Browser.H
index 1031a64..da2cd57 100644
--- FL/Fl_Check_Browser.H
+++ FL/Fl_Check_Browser.H
@@ -1,7 +1,7 @@
 //
 // Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
 //
 // 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
@@ -39,30 +39,29 @@ protected:
   void item_draw(void *, int, int, int, int) const;
   void item_select(void *, int);
   int item_selected(void *) const;
-  const char *item_text(void *item) const /* override */;
+  const char *item_text(void *item) const; // override
 
 public:
-  void *item_at(int index) const /* override */;
-  void item_swap(int ia, int ib) /* override */;
-  void item_swap(void *a, void *b) /* override */;
+  void *item_at(int index) const;   // override
+  void item_swap(int ia, int ib);   // override
+  void item_swap(void *a, void *b); // override
 
   /* private data */
 
-  public: // IRIX 5.3 C++ compiler doesn't support private structures...
+public: // IRIX 5.3 C++ compiler doesn't support private structures...
 
 #ifndef FL_DOXYGEN
   /** For internal use only. */
   struct cb_item {
-          cb_item *next;        /**< For internal use only. */
-          cb_item *prev;        /**< For internal use only. */
-          char checked;         /**< For internal use only. */
-          char selected;        /**< For internal use only. */
-          char *text;           /**< For internal use only. */
+    cb_item *next;        /**< For internal use only. */
+    cb_item *prev;        /**< For internal use only. */
+    char checked;         /**< For internal use only. */
+    char selected;        /**< For internal use only. */
+    char *text;           /**< For internal use only. */
   };
 #endif // !FL_DOXYGEN
 
-  private:
-
+private:
   cb_item *first;
   cb_item *last;
   cb_item *cache;
@@ -72,10 +71,9 @@ public:
   cb_item *find_item(int) const;
   int lineno(cb_item *) const;
 
-  public:
-
+public:
   Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
-   /** The destructor deletes all list items and destroys the browser. */
+  /** The destructor deletes all list items and destroys the browser. */
   ~Fl_Check_Browser() { clear(); }
   int add(char *s);               // add an (unchecked) item
   int add(char *s, int b);        // add an item and set checked
@@ -83,7 +81,7 @@ public:
   int remove(int item);           // delete an item. Returns nitems()
 
   // inline const char * methods to avoid breaking binary compatibility...
-   /** See int Fl_Check_Browser::add(char *s) */
+  /** See int Fl_Check_Browser::add(char *s) */
   int add(const char *s) { return add((char *)s); }
   /** See int Fl_Check_Browser::add(char *s) */
   int add(const char *s, int b) { return add((char *)s, b); }
@@ -94,21 +92,19 @@ public:
     this.
   */
   int nitems() const { return nitems_; }
-  /**    Returns how many items are currently checked.  */
+  /** Returns how many items are currently checked. */
   int nchecked() const { return nchecked_; }
   int checked(int item) const;
   void checked(int item, int b);
-  /**    Equivalent to Fl_Check_Browser::checked(item, 1).  */
+  /** Equivalent to Fl_Check_Browser::checked(item, 1). */
   void set_checked(int item) { checked(item, 1); }
   void check_all();
   void check_none();
   int value() const;              // currently selected item
   char *text(int item) const;     // returns pointer to internal buffer
 
-  protected:
-
+protected:
   int handle(int);
 };
 
 #endif // Fl_Check_Browser_H
-
diff --git src/Fl_Check_Browser.cxx src/Fl_Check_Browser.cxx
index 6f286e4..3b32731 100644
--- src/Fl_Check_Browser.cxx
+++ src/Fl_Check_Browser.cxx
@@ -1,7 +1,7 @@
 //
 // Fl_Check_Browser implementation for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
 //
 // 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
@@ -25,79 +25,78 @@
 either forwards or backwards. */
 
 Fl_Check_Browser::cb_item *Fl_Check_Browser::find_item(int n) const {
-        int i = n;
-        cb_item *p = first;
-
-        if (n <= 0 || n > nitems_ || p == 0) {
-                return 0;
-        }
-
-        if (n == cached_item) {
-                p = cache;
-                n = 1;
-        } else if (n == cached_item + 1) {
-                p = cache->next;
-                n = 1;
-        } else if (n == cached_item - 1) {
-                p = cache->prev;
-                n = 1;
-        }
-
-        while (--n) {
-                p = p->next;
-        }
-
-        /* Cast to not const and cache it. */
-
-        ((Fl_Check_Browser *)this)->cache = p;
-        ((Fl_Check_Browser *)this)->cached_item = i;
-
-        return p;
+  int i = n;
+  cb_item *p = first;
+
+  if (n <= 0 || n > nitems_ || p == 0) {
+    return 0;
+  }
+
+  if (n == cached_item) {
+    p = cache;
+    n = 1;
+  } else if (n == cached_item + 1) {
+    p = cache->next;
+    n = 1;
+  } else if (n == cached_item - 1) {
+    p = cache->prev;
+    n = 1;
+  }
+
+  while (--n) {
+    p = p->next;
+  }
+
+  /* Cast to not const and cache it. */
+  ((Fl_Check_Browser *)this)->cache = p;
+  ((Fl_Check_Browser *)this)->cached_item = i;
+
+  return p;
 }
 
 int Fl_Check_Browser::lineno(cb_item *p0) const {
-        cb_item *p = first;
-
-        if (p == 0) {
-                return 0;
-        }
-
-        int i = 1;
-        while (p) {
-                if (p == p0) {
-                        return i;
-                }
-                i++;
-                p = p->next;
-        }
-
-        return 0;
+  cb_item *p = first;
+
+  if (p == 0) {
+    return 0;
+  }
+
+  int i = 1;
+  while (p) {
+    if (p == p0) {
+      return i;
+    }
+    i++;
+    p = p->next;
+  }
+
+  return 0;
 }
 
+/** The constructor makes an empty browser. */
 Fl_Check_Browser::Fl_Check_Browser(int X, int Y, int W, int H, const char *l)
-/**  The constructor makes an empty browser.*/
-: Fl_Browser_(X, Y, W, H, l) {
-        type(FL_SELECT_BROWSER);
-        when(FL_WHEN_NEVER);
-        first = last = 0;
-        nitems_ = nchecked_ = 0;
-        cached_item = -1;
+  : Fl_Browser_(X, Y, W, H, l) {
+  type(FL_SELECT_BROWSER);
+  when(FL_WHEN_NEVER);
+  first = last = 0;
+  nitems_ = nchecked_ = 0;
+  cached_item = -1;
 }
 
 void *Fl_Check_Browser::item_first() const {
-        return first;
+  return first;
 }
 
 void *Fl_Check_Browser::item_next(void *l) const {
-        return ((cb_item *)l)->next;
+  return ((cb_item *)l)->next;
 }
 
 void *Fl_Check_Browser::item_prev(void *l) const {
-        return ((cb_item *)l)->prev;
+  return ((cb_item *)l)->prev;
 }
 
 int Fl_Check_Browser::item_height(void *) const {
-        return textsize() + 2;
+  return textsize() + 2;
 }
 
 const char *Fl_Check_Browser::item_text(void *item) const {
@@ -173,64 +172,64 @@ void Fl_Check_Browser::item_swap(void *a, void *b) {
 #define CHECK_SIZE (textsize()-2)
 
 int Fl_Check_Browser::item_width(void *v) const {
-        fl_font(textfont(), textsize());
-        return int(fl_width(((cb_item *)v)->text)) + CHECK_SIZE + 8;
+  fl_font(textfont(), textsize());
+  return int(fl_width(((cb_item *)v)->text)) + CHECK_SIZE + 8;
 }
 
 void Fl_Check_Browser::item_draw(void *v, int X, int Y, int, int) const {
-        cb_item *i = (cb_item *)v;
-        char *s = i->text;
-        int tsize = textsize();
-        Fl_Color col = active_r() ? textcolor() : fl_inactive(textcolor());
-        int cy = Y + (tsize + 1 - CHECK_SIZE) / 2;
-        X += 2;
-
-        fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
-        fl_loop(X, cy, X, cy + CHECK_SIZE,
-                X + CHECK_SIZE, cy + CHECK_SIZE, X + CHECK_SIZE, cy);
-        if (i->checked) {
-          int tx = X + 3;
-          int tw = CHECK_SIZE - 4;
-          int d1 = tw/3;
-          int d2 = tw-d1;
-          int ty = cy + (CHECK_SIZE+d2)/2-d1-2;
-          for (int n = 0; n < 3; n++, ty++) {
-            fl_line(tx, ty, tx+d1, ty+d1);
-            fl_line(tx+d1, ty+d1, tx+tw-1, ty+d1-d2+1);
-          }
-        }
-        fl_font(textfont(), tsize);
-        if (i->selected) {
-                col = fl_contrast(col, selection_color());
-        }
-        fl_color(col);
-        fl_draw(s, X + CHECK_SIZE + 8, Y + tsize - 1);
+  cb_item *i = (cb_item *)v;
+  char *s = i->text;
+  int tsize = textsize();
+  Fl_Color col = active_r() ? textcolor() : fl_inactive(textcolor());
+  int cy = Y + (tsize + 1 - CHECK_SIZE) / 2;
+  X += 2;
+
+  fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
+  fl_loop(X, cy, X, cy + CHECK_SIZE,
+          X + CHECK_SIZE, cy + CHECK_SIZE, X + CHECK_SIZE, cy);
+  if (i->checked) {
+    int tx = X + 3;
+    int tw = CHECK_SIZE - 4;
+    int d1 = tw / 3;
+    int d2 = tw - d1;
+    int ty = cy + (CHECK_SIZE + d2) / 2 - d1 - 2;
+    for (int n = 0; n < 3; n++, ty++) {
+      fl_line(tx, ty, tx + d1, ty + d1);
+      fl_line(tx + d1, ty + d1, tx + tw - 1, ty + d1 - d2 + 1);
+    }
+  }
+  fl_font(textfont(), tsize);
+  if (i->selected) {
+    col = fl_contrast(col, selection_color());
+  }
+  fl_color(col);
+  fl_draw(s, X + CHECK_SIZE + 8, Y + tsize - 1);
 }
 
 void Fl_Check_Browser::item_select(void *v, int state) {
-        cb_item *i = (cb_item *)v;
-
-        if (state) {
-                if (i->checked) {
-                        i->checked = 0;
-                        nchecked_--;
-                } else {
-                        i->checked = 1;
-                        nchecked_++;
-                }
-        }
+  cb_item *i = (cb_item *)v;
+
+  if (state) {
+    if (i->checked) {
+      i->checked = 0;
+      nchecked_--;
+    } else {
+      i->checked = 1;
+      nchecked_++;
+    }
+  }
 }
 
 int Fl_Check_Browser::item_selected(void *v) const {
-        cb_item *i = (cb_item *)v;
-        return i->selected;
+  cb_item *i = (cb_item *)v;
+  return i->selected;
 }
 /**
  Add a new unchecked line to the end of the browser.
  \see add(char *s, int b)
 */
 int Fl_Check_Browser::add(char *s) {
-        return (add(s, 0));
+  return (add(s, 0));
 }
 
 /**
@@ -239,27 +238,27 @@ int Fl_Check_Browser::add(char *s) {
  a blank line.  It can set the item checked if \p b is not 0.
  */
 int Fl_Check_Browser::add(char *s, int b) {
-        cb_item *p = (cb_item *)malloc(sizeof(cb_item));
-        p->next = 0;
-        p->prev = 0;
-        p->checked = b;
-        p->selected = 0;
-    p->text = fl_strdup(s?s:"");
-
-        if (b) {
-                nchecked_++;
-        }
-
-        if (last == 0) {
-                first = last = p;
-        } else {
-                last->next = p;
-                p->prev = last;
-                last = p;
-        }
-        nitems_++;
-
-        return (nitems_);
+  cb_item *p = (cb_item *)malloc(sizeof(cb_item));
+  p->next = 0;
+  p->prev = 0;
+  p->checked = b;
+  p->selected = 0;
+  p->text = fl_strdup(s ? s : "");
+
+  if (b) {
+    nchecked_++;
+  }
+
+  if (last == 0) {
+    first = last = p;
+  } else {
+    last->next = p;
+    p->prev = last;
+    last = p;
+  }
+  nitems_++;
+
+  return (nitems_);
 }
 
 /**
@@ -270,12 +269,12 @@ int Fl_Check_Browser::remove(int item) {
   cb_item *p = find_item(item);
 
   // line at item exists
-  if(p) {
+  if (p) {
     // tell the Browser_ what we will do
     deleting(p);
 
     // fix checked count
-    if(p->checked)
+    if (p->checked)
       --nchecked_;
 
     // remove the node
@@ -300,90 +299,89 @@ int Fl_Check_Browser::remove(int item) {
 
 /**  Remove every item from the browser.*/
 void Fl_Check_Browser::clear() {
-        cb_item *p = first;
-        cb_item *next;
-
-        if (p == 0) {
-                return;
-        }
-
-        new_list();
-        do {
-                next = p->next;
-                free(p->text);
-                free(p);
-                p = next;
-        } while (p);
-
-        first = last = 0;
-        nitems_ = nchecked_ = 0;
-        cached_item = -1;
+  cb_item *p = first;
+  cb_item *next;
+
+  if (!p) return;
+
+  new_list();
+  do {
+    next = p->next;
+    free(p->text);
+    free(p);
+    p = next;
+  } while (p);
+
+  first = last = 0;
+  nitems_ = nchecked_ = 0;
+  cached_item = -1;
 }
 
 /** Gets the current status of item item. */
 int Fl_Check_Browser::checked(int i) const {
-        cb_item *p = find_item(i);
+  cb_item *p = find_item(i);
 
-        if (p) return p->checked;
-        return 0;
+  if (p) return p->checked;
+  return 0;
 }
 
 /** Sets the check status of item item to b. */
 void Fl_Check_Browser::checked(int i, int b) {
-        cb_item *p = find_item(i);
-
-        if (p && (p->checked ^ b)) {
-                p->checked = b;
-                if (b) {
-                        nchecked_++;
-                } else {
-                        nchecked_--;
-                }
-                redraw();
-        }
+  cb_item *p = find_item(i);
+
+  if (p && (p->checked ^ b)) {
+    p->checked = b;
+    if (b) {
+      nchecked_++;
+    } else {
+      nchecked_--;
+    }
+    redraw();
+  }
 }
 
 /**  Returns the index of the currently selected item.*/
 int Fl_Check_Browser::value() const {
-        return lineno((cb_item *)selection());
+  return lineno((cb_item *)selection());
 }
 
 /**  Return a pointer to an internal buffer holding item item's text.*/
 char *Fl_Check_Browser::text(int i) const {
-        cb_item *p = find_item(i);
+  cb_item *p = find_item(i);
 
-        if (p) return p->text;
-        return 0;
+  if (p) return p->text;
+  return 0;
 }
 
 /**  Sets all the items checked.*/
 void Fl_Check_Browser::check_all() {
-        cb_item *p;
+  cb_item *p;
 
-        nchecked_ = nitems_;
-        for (p = first; p; p = p->next) {
-                p->checked = 1;
-        }
-        redraw();
+  nchecked_ = nitems_;
+  for (p = first; p; p = p->next) {
+    p->checked = 1;
+  }
+  redraw();
 }
 
 /**  Sets all the items unchecked.*/
 void Fl_Check_Browser::check_none() {
-        cb_item *p;
+  cb_item *p;
 
-        nchecked_ = 0;
-        for (p = first; p; p = p->next) {
-                p->checked = 0;
-        }
-        redraw();
+  nchecked_ = 0;
+  for (p = first; p; p = p->next) {
+    p->checked = 0;
+  }
+  redraw();
 }
 
 int Fl_Check_Browser::handle(int event) {
   if (event == FL_PUSH) {
     int X, Y, W, H;
     bbox(X, Y, W, H);
-    if (Fl::event_inside(X, Y, W, H))
+    if (Fl::event_inside(X, Y, W, H)) {
       deselect();
+    }
   }
   return Fl_Browser_::handle(event);
 }
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2020 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.