Adds Fl_Browser::middleline(int) and Fl_Browser::bottomline(int).

git-svn-id: file:///fltk/svn/fltk/trunk@257 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Carl E. Thompson 1999-01-30 00:39:28 +00:00
parent 03ad382705
commit 620d03ee7d
2 changed files with 23 additions and 7 deletions

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Browser.H,v 1.6 1999/01/07 19:16:51 mike Exp $" // "$Id: Fl_Browser.H,v 1.7 1999/01/30 00:39:26 carl Exp $"
// //
// Browser header file for the Fast Light Tool Kit (FLTK). // Browser header file for the Fast Light Tool Kit (FLTK).
// //
@ -72,8 +72,13 @@ public:
void clear(); void clear();
int size() const {return lines;} int size() const {return lines;}
int topline() const ; int topline() const ;
void topline(int); enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
void lineposition(int, Fl_Line_Position);
void topline(int l) { lineposition(l, TOP); }
void bottomline(int l) { lineposition(l, BOTTOM); }
void middleline(int l) { lineposition(l, MIDDLE); }
int select(int, int=1); int select(int, int=1);
int selected(int) const ; int selected(int) const ;
@ -108,5 +113,5 @@ public:
#endif #endif
// //
// End of "$Id: Fl_Browser.H,v 1.6 1999/01/07 19:16:51 mike Exp $". // End of "$Id: Fl_Browser.H,v 1.7 1999/01/30 00:39:26 carl Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Browser.cxx,v 1.6 1999/01/07 19:17:16 mike Exp $" // "$Id: Fl_Browser.cxx,v 1.7 1999/01/30 00:39:28 carl Exp $"
// //
// Browser widget for the Fast Light Tool Kit (FLTK). // Browser widget for the Fast Light Tool Kit (FLTK).
// //
@ -356,14 +356,25 @@ Fl_Browser::Fl_Browser(int x, int y, int w, int h, const char*l)
first = last = cache = 0; first = last = cache = 0;
} }
void Fl_Browser::topline(int line) { void Fl_Browser::lineposition(int line, Fl_Line_Position pos) {
if (line<1) line = 1; if (line<1) line = 1;
if (line>lines) line = lines; if (line>lines) line = lines;
int p = 0; int p = 0;
for (FL_BLINE* l=first; l&& line>1; l = l->next) { for (FL_BLINE* l=first; l&& line>1; l = l->next) {
line--; p += item_height(l); line--; p += item_height(l);
} }
position(p);
int final = p, X, Y, W, H;
bbox(X, Y, W, H);
switch(pos) {
case TOP: break;
case BOTTOM: final -= H; break;
case MIDDLE: final -= H/2; break;
}
if (final > (full_height() - H)) final = full_height() -H;
position(final);
} }
int Fl_Browser::topline() const { int Fl_Browser::topline() const {
@ -440,5 +451,5 @@ int Fl_Browser::value() const {
} }
// //
// End of "$Id: Fl_Browser.cxx,v 1.6 1999/01/07 19:17:16 mike Exp $". // End of "$Id: Fl_Browser.cxx,v 1.7 1999/01/30 00:39:28 carl Exp $".
// //