summaryrefslogtreecommitdiff
path: root/src/Fl_Browser.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-01 18:03:10 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-06 20:28:20 +0200
commitf09e17c3c564e8310125a10c03397cbf473ff643 (patch)
tree8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /src/Fl_Browser.cxx
parentb0e0c355edaa2e23148cb0260ada907aec930f05 (diff)
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files - update .fl files and generated files accordingly - replace 'http://www.fltk.org' URL's with 'https://...' - replace bug report URL 'str.php' with 'bugs.php' - remove trailing whitespace - fix other whitespace errors flagged by Git - add and/or fix missing or wrong standard headers - convert tabs to spaces in all source files The only relevant code changes are in the fluid/ folder where some .fl files and other source files were used to generate the '$Id' headers and footers.
Diffstat (limited to 'src/Fl_Browser.cxx')
-rw-r--r--src/Fl_Browser.cxx199
1 files changed, 96 insertions, 103 deletions
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx
index 72aa8de37..4534729bc 100644
--- a/src/Fl_Browser.cxx
+++ b/src/Fl_Browser.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Browser widget for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2017 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
@@ -45,14 +43,14 @@
// Changes to FL_BLINE *must* be reflected in Fl_File_Chooser.cxx as well.
// This hack in Fl_File_Chooser should be solved.
//
-struct FL_BLINE { // data is in a linked list of these
+struct FL_BLINE { // data is in a linked list of these
FL_BLINE* prev;
FL_BLINE* next;
void* data;
Fl_Image* icon;
- short length; // sizeof(txt)-1, may be longer than string
- char flags; // selected, displayed
- char txt[1]; // start of allocated array
+ short length; // sizeof(txt)-1, may be longer than string
+ char flags; // selected, displayed
+ char txt[1]; // start of allocated array
};
/**
@@ -124,7 +122,7 @@ void Fl_Browser::item_select(void *item, int val) {
\param[in] item The item whose label text is returned.
\returns The item's text string. (Can be NULL)
*/
-const char *Fl_Browser::item_text(void *item) const {
+const char *Fl_Browser::item_text(void *item) const {
return ((FL_BLINE*)item)->txt;
}
@@ -284,7 +282,7 @@ void Fl_Browser::insert(int line, FL_BLINE* item) {
\param[in] d Optional pointer to user data to be associated with the new line.
*/
void Fl_Browser::insert(int line, const char* newtext, void* d) {
- if (!newtext) newtext = ""; // STR #3269
+ if (!newtext) newtext = ""; // STR #3269
int l = (int) strlen(newtext);
FL_BLINE* t = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
t->length = (short)l;
@@ -320,7 +318,7 @@ void Fl_Browser::move(int to, int from) {
void Fl_Browser::text(int line, const char* newtext) {
if (line < 1 || line > lines) return;
FL_BLINE* t = find_line(line);
- if (!newtext) newtext = ""; // STR #3269
+ if (!newtext) newtext = ""; // STR #3269
int l = (int) strlen(newtext);
if (l > t->length) {
FL_BLINE* n = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
@@ -378,36 +376,36 @@ int Fl_Browser::item_height(void *item) const {
Fl_Font font = textfont(); // default font
int tsize = textsize(); // default size
if ( format_char() ) { // can be NULL
- while (*str==format_char() && *str++ && *str!=format_char()) {
- switch (*str++) {
- case 'l': case 'L': tsize = 24; break;
- case 'm': case 'M': tsize = 18; break;
- case 's': tsize = 11; break;
- case 'b': font = (Fl_Font)(font|FL_BOLD); break;
- case 'i': font = (Fl_Font)(font|FL_ITALIC); break;
- case 'f': case 't': font = FL_COURIER; break;
- case 'B':
- case 'C': while (isdigit(*str & 255)) str++; break; // skip a color number
- case 'F': font = (Fl_Font)strtol(str,&str,10); break;
- case 'S': tsize = strtol(str,&str,10); break;
- case '.': goto END_FORMAT;
- }
- }
+ while (*str==format_char() && *str++ && *str!=format_char()) {
+ switch (*str++) {
+ case 'l': case 'L': tsize = 24; break;
+ case 'm': case 'M': tsize = 18; break;
+ case 's': tsize = 11; break;
+ case 'b': font = (Fl_Font)(font|FL_BOLD); break;
+ case 'i': font = (Fl_Font)(font|FL_ITALIC); break;
+ case 'f': case 't': font = FL_COURIER; break;
+ case 'B':
+ case 'C': while (isdigit(*str & 255)) str++; break; // skip a color number
+ case 'F': font = (Fl_Font)strtol(str,&str,10); break;
+ case 'S': tsize = strtol(str,&str,10); break;
+ case '.': goto END_FORMAT;
+ }
+ }
}
END_FORMAT:
char* ptr = str;
if (ptr && *i++) str = strchr(str, column_char());
else str = NULL;
if((!str && *ptr) || (str && ptr < str)) {
- fl_font(font, tsize); int hh = fl_height();
- if (hh > hmax) hmax = hh;
+ fl_font(font, tsize); int hh = fl_height();
+ if (hh > hmax) hmax = hh;
}
if (!str || !*str) break;
}
}
if (l->icon && (l->icon->h()+2)>hmax) {
- hmax = l->icon->h() + 2; // leave 2px above/below
+ hmax = l->icon->h() + 2; // leave 2px above/below
}
return hmax; // previous version returned hmax+2!
}
@@ -439,7 +437,7 @@ int Fl_Browser::item_width(void *item) const {
Fl_Font font = textfont();
int done = 0;
- if ( format_char() ) { // can be NULL
+ if ( format_char() ) { // can be NULL
while (*str == format_char_ && str[1] && str[1] != format_char_) {
str ++;
switch (*str++) {
@@ -454,8 +452,8 @@ int Fl_Browser::item_width(void *item) const {
case 'F': font = (Fl_Font)strtol(str, &str, 10); break;
case 'S': tsize = strtol(str, &str, 10); break;
case '.':
- done = 1;
- break;
+ done = 1;
+ break;
}
if (done)
@@ -506,9 +504,9 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
char* str = l->txt;
const int* i = column_widths();
- bool firstLoop = true; // for icon
- while (W > 6) { // do each tab-separated field
- int w1 = W; // width for this field
+ bool firstLoop = true; // for icon
+ while (W > 6) { // do each tab-separated field
+ int w1 = W; // width for this field
char* e = 0; // pointer to end of field or null if none
if (*i) { // find end of field and temporarily replace with 0
e = strchr(str, column_char());
@@ -518,9 +516,9 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
if (firstLoop) {
firstLoop = false;
if (l->icon) {
- l->icon->draw(X+2,Y+1); // leave 2px left, 1px above
- int iconw = l->icon->w()+2;
- X += iconw; W -= iconw; w1 -= iconw;
+ l->icon->draw(X+2,Y+1); // leave 2px left, 1px above
+ int iconw = l->icon->w()+2;
+ X += iconw; W -= iconw; w1 -= iconw;
}
}
int tsize = textsize();
@@ -531,49 +529,49 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
//#if defined(__GNUC__)
//#warning FIXME This maybe needs to be more UTF8 aware now...?
//#endif /*__GNUC__*/
- if ( format_char() ) { // can be NULL
+ if ( format_char() ) { // can be NULL
while (*str == format_char() && *++str && *str != format_char()) {
- switch (*str++) {
- case 'l': case 'L': tsize = 24; break;
- case 'm': case 'M': tsize = 18; break;
- case 's': tsize = 11; break;
- case 'b': font = (Fl_Font)(font|FL_BOLD); break;
- case 'i': font = (Fl_Font)(font|FL_ITALIC); break;
- case 'f': case 't': font = FL_COURIER; break;
- case 'c': talign = FL_ALIGN_CENTER; break;
- case 'r': talign = FL_ALIGN_RIGHT; break;
- case 'B':
- if (!(l->flags & SELECTED)) {
- fl_color((Fl_Color)strtoul(str, &str, 10));
- fl_rectf(X, Y, w1, H);
- } else while (isdigit(*str & 255)) str++; // skip digits
- break;
- case 'C':
- lcol = (Fl_Color)strtoul(str, &str, 10);
- break;
- case 'F':
- font = (Fl_Font)strtol(str, &str, 10);
- break;
- case 'N':
- lcol = FL_INACTIVE_COLOR;
- break;
- case 'S':
- tsize = strtol(str, &str, 10);
- break;
- case '-':
- fl_color(FL_DARK3);
- fl_line(X+3, Y+H/2, X+w1-3, Y+H/2);
- fl_color(FL_LIGHT3);
- fl_line(X+3, Y+H/2+1, X+w1-3, Y+H/2+1);
- break;
- case 'u':
- case '_':
- fl_color(lcol);
- fl_line(X+3, Y+H-1, X+w1-3, Y+H-1);
- break;
- case '.':
- goto BREAK;
- }
+ switch (*str++) {
+ case 'l': case 'L': tsize = 24; break;
+ case 'm': case 'M': tsize = 18; break;
+ case 's': tsize = 11; break;
+ case 'b': font = (Fl_Font)(font|FL_BOLD); break;
+ case 'i': font = (Fl_Font)(font|FL_ITALIC); break;
+ case 'f': case 't': font = FL_COURIER; break;
+ case 'c': talign = FL_ALIGN_CENTER; break;
+ case 'r': talign = FL_ALIGN_RIGHT; break;
+ case 'B':
+ if (!(l->flags & SELECTED)) {
+ fl_color((Fl_Color)strtoul(str, &str, 10));
+ fl_rectf(X, Y, w1, H);
+ } else while (isdigit(*str & 255)) str++; // skip digits
+ break;
+ case 'C':
+ lcol = (Fl_Color)strtoul(str, &str, 10);
+ break;
+ case 'F':
+ font = (Fl_Font)strtol(str, &str, 10);
+ break;
+ case 'N':
+ lcol = FL_INACTIVE_COLOR;
+ break;
+ case 'S':
+ tsize = strtol(str, &str, 10);
+ break;
+ case '-':
+ fl_color(FL_DARK3);
+ fl_line(X+3, Y+H/2, X+w1-3, Y+H/2);
+ fl_color(FL_LIGHT3);
+ fl_line(X+3, Y+H/2+1, X+w1-3, Y+H/2+1);
+ break;
+ case 'u':
+ case '_':
+ fl_color(lcol);
+ fl_line(X+3, Y+H-1, X+w1-3, Y+H-1);
+ break;
+ case '.':
+ goto BREAK;
+ }
}
}
BREAK:
@@ -634,7 +632,7 @@ void Fl_Browser::lineposition(int line, Fl_Line_Position pos) {
case BOTTOM: final -= H; break;
case MIDDLE: final -= H/2; break;
}
-
+
if (final > (full_height() - H)) final = full_height() -H;
position(final);
}
@@ -839,21 +837,21 @@ void Fl_Browser::swap(FL_BLINE *a, FL_BLINE *b) {
FL_BLINE *anext = a->next;
FL_BLINE *bprev = b->prev;
FL_BLINE *bnext = b->next;
- if ( b->prev == a ) { // A ADJACENT TO B
+ if ( b->prev == a ) { // A ADJACENT TO B
if ( aprev ) aprev->next = b; else first = b;
b->next = a;
a->next = bnext;
b->prev = aprev;
a->prev = b;
if ( bnext ) bnext->prev = a; else last = a;
- } else if ( a->prev == b ) { // B ADJACENT TO A
+ } else if ( a->prev == b ) { // B ADJACENT TO A
if ( bprev ) bprev->next = a; else first = a;
a->next = b;
b->next = anext;
a->prev = bprev;
b->prev = a;
if ( anext ) anext->prev = b; else last = b;
- } else { // A AND B NOT ADJACENT
+ } else { // A AND B NOT ADJACENT
// handle prev's
b->prev = aprev;
if ( anext ) anext->prev = b; else last = b;
@@ -897,22 +895,22 @@ void Fl_Browser::icon(int line, Fl_Image* icon) {
FL_BLINE* bl = find_line(line);
- int old_h = bl->icon ? bl->icon->h()+2 : 0; // init with *old* icon height
- bl->icon = 0; // remove icon, if any
- int th = item_height(bl); // height of text only
- int new_h = icon ? icon->h()+2 : 0; // init with *new* icon height
+ int old_h = bl->icon ? bl->icon->h()+2 : 0; // init with *old* icon height
+ bl->icon = 0; // remove icon, if any
+ int th = item_height(bl); // height of text only
+ int new_h = icon ? icon->h()+2 : 0; // init with *new* icon height
if (th > old_h) old_h = th;
if (th > new_h) new_h = th;
int dh = new_h - old_h;
- full_height_ += dh; // do this *always*
+ full_height_ += dh; // do this *always*
- bl->icon = icon; // set new icon
+ bl->icon = icon; // set new icon
if (dh>0) {
- redraw(); // icon larger than item? must redraw widget
+ redraw(); // icon larger than item? must redraw widget
} else {
- redraw_line(bl); // icon same or smaller? can redraw just this line
+ redraw_line(bl); // icon same or smaller? can redraw just this line
}
- replacing(bl,bl); // recalc Fl_Browser_::max_width et al
+ replacing(bl,bl); // recalc Fl_Browser_::max_width et al
}
/**
@@ -931,32 +929,27 @@ Fl_Image* Fl_Browser::icon(int line) const {
It's ok to remove an icon if none has been defined.
\param[in] line The line whose icon is to be removed.
*/
-void Fl_Browser::remove_icon(int line) {
+void Fl_Browser::remove_icon(int line) {
icon(line,0);
}
Fl_Hold_Browser::Fl_Hold_Browser(int X,int Y,int W,int H,const char *L)
-: Fl_Browser(X,Y,W,H,L)
+: Fl_Browser(X,Y,W,H,L)
{
type(FL_HOLD_BROWSER);
}
Fl_Multi_Browser::Fl_Multi_Browser(int X,int Y,int W,int H,const char *L)
-: Fl_Browser(X,Y,W,H,L)
+: Fl_Browser(X,Y,W,H,L)
{
type(FL_MULTI_BROWSER);
}
Fl_Select_Browser::Fl_Select_Browser(int X,int Y,int W,int H,const char *L)
-: Fl_Browser(X,Y,W,H,L)
+: Fl_Browser(X,Y,W,H,L)
{
type(FL_SELECT_BROWSER);
}
-
-
-//
-// End of "$Id$".
-//