2 // "$Id: scroll.cxx 7978 2010-12-08 14:00:35Z AlbrechtS $"
4 // Fl_Scroll test program for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
29 #include <FL/Fl_Double_Window.H>
30 #include <FL/Fl_Scroll.H>
31 #include <FL/Fl_Light_Button.H>
32 #include <FL/Fl_Choice.H>
33 #include <FL/Fl_Box.H>
36 #include <FL/fl_draw.H>
39 class Drawing
: public Fl_Widget
{
42 Drawing(int X
,int Y
,int W
,int H
,const char* L
) : Fl_Widget(X
,Y
,W
,H
,L
) {
49 void Drawing::draw() {
52 fl_translate(x()+w()/2, y()+h()/2);
53 fl_scale(w()/2, h()/2);
55 for (int i
= 0; i
< 20; i
++) {
56 for (int j
= i
+1; j
< 20; j
++) {
58 fl_vertex(cos(M_PI
*i
/10+.1), sin(M_PI
*i
/10+.1));
59 fl_vertex(cos(M_PI
*j
/10+.1), sin(M_PI
*j
/10+.1));
68 void box_cb(Fl_Widget
* o
, void*) {
69 thescroll
->box(((Fl_Button
*)o
)->value() ? FL_DOWN_FRAME
: FL_NO_BOX
);
73 void type_cb(Fl_Widget
*, void* v
) {
74 thescroll
->type((uchar
)((fl_intptr_t
)v
));
78 Fl_Menu_Item choices
[] = {
79 {"0", 0, type_cb
, (void*)0},
80 {"HORIZONTAL", 0, type_cb
, (void*)Fl_Scroll::HORIZONTAL
},
81 {"VERTICAL", 0, type_cb
, (void*)Fl_Scroll::VERTICAL
},
82 {"BOTH", 0, type_cb
, (void*)Fl_Scroll::BOTH
},
83 {"HORIZONTAL_ALWAYS", 0, type_cb
, (void*)Fl_Scroll::HORIZONTAL_ALWAYS
},
84 {"VERTICAL_ALWAYS", 0, type_cb
, (void*)Fl_Scroll::VERTICAL_ALWAYS
},
85 {"BOTH_ALWAYS", 0, type_cb
, (void*)Fl_Scroll::BOTH_ALWAYS
},
89 void align_cb(Fl_Widget
*, void* v
) {
90 thescroll
->scrollbar
.align((uchar
)((fl_intptr_t
)v
));
94 Fl_Menu_Item align_choices
[] = {
95 {"left+top", 0, align_cb
, (void*)(FL_ALIGN_LEFT
+FL_ALIGN_TOP
)},
96 {"left+bottom", 0, align_cb
, (void*)(FL_ALIGN_LEFT
+FL_ALIGN_BOTTOM
)},
97 {"right+top", 0, align_cb
, (void*)(FL_ALIGN_RIGHT
+FL_ALIGN_TOP
)},
98 {"right+bottom", 0, align_cb
, (void*)(FL_ALIGN_RIGHT
+FL_ALIGN_BOTTOM
)},
102 int main(int argc
, char** argv
) {
103 Fl_Window
window(5*75,400);
104 window
.box(FL_NO_BOX
);
105 Fl_Scroll
scroll(0,0,5*75,300);
108 for (int y
=0; y
<16; y
++) for (int x
=0; x
<5; x
++) {
109 char buf
[20]; sprintf(buf
,"%d",n
++);
110 Fl_Button
* b
= new Fl_Button(x
*75,y
*25+(y
>=8?5*75:0),75,25);
113 b
->labelcolor(FL_WHITE
);
115 Drawing
drawing(0,8*25,5*75,5*75,0);
117 window
.resizable(scroll
);
119 Fl_Box
box(0,300,5*75,window
.h()-300); // gray area below the scroll
120 box
.box(FL_FLAT_BOX
);
122 Fl_Light_Button
but1(150, 310, 200, 25, "box");
123 but1
.callback(box_cb
);
125 Fl_Choice
choice(150, 335, 200, 25, "type():");
126 choice
.menu(choices
);
129 Fl_Choice
achoice(150, 360, 200, 25, "scrollbar.align():");
130 achoice
.menu(align_choices
);
135 //scroll.box(FL_DOWN_BOX);
136 //scroll.type(Fl_Scroll::VERTICAL);
138 window
.show(argc
,argv
);
143 // End of "$Id: scroll.cxx 7978 2010-12-08 14:00:35Z AlbrechtS $".