1 #include "fx.h"
2
3
4 /*
5 Example proportional layout using FXSpring widgets
6 */
main(int argc,char ** argv)7 int main(int argc,char **argv){
8
9 // Create application object
10 FXApp application("Ratio","FoxTest");
11
12 // Initialize and open display
13 application.init(argc,argv);
14
15 // Create main window
16 FXMainWindow *main=new FXMainWindow(&application,"Ratio",NULL,NULL,DECOR_ALL,0,0,400,200,8,8,8,8,6,6);
17
18 // Add quit button and connect it to application
19 new FXButton(main,"&Quit",NULL,&application,FXApp::ID_QUIT,FRAME_RAISED|FRAME_THICK|LAYOUT_SIDE_BOTTOM|LAYOUT_CENTER_X,0,0,0,0,20,20,2,2);
20
21 // Label above it
22 new FXLabel(main,"FXSpring can be used to keep widgets at fixed size ratios.\n\nResize the window to see how it behaves!",NULL,LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
23
24 // Layout manager to place the springs
25 FXHorizontalFrame *horz=new FXHorizontalFrame(main,FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0, 0,0);
26
27 // First spring is set to behave normally in Y direction,
28 // but to have a ratio 1 for the X direction
29 FXSpring *spring1=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,1,0, 0,0,0,0, 0,0,0,0);
30 FXLabel *label1=new FXLabel(spring1,"1",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
31 label1->setBackColor(FXRGB(255,0,0));
32
33 // Second spring has ratio 2 in the X direction
34 FXSpring *spring2=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,2,0, 0,0,0,0, 0,0,0,0);
35 FXLabel *label2=new FXLabel(spring2,"2",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
36 label2->setBackColor(FXRGB(0,255,0));
37
38 // Second spring has ratio 3 in the X direction
39 FXSpring *spring3=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,3,0, 0,0,0,0, 0,0,0,0);
40 FXLabel *label3=new FXLabel(spring3,"3",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
41 label3->setBackColor(FXRGB(0,0,255));
42
43 application.create();
44
45 main->show(PLACEMENT_SCREEN);
46
47 return application.run();
48 }
49