File: ratio.cpp

package info (click to toggle)
fox1.6 1.6.57-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 17,592 kB
  • sloc: cpp: 148,083; sh: 4,294; ansic: 2,345; makefile: 1,422; perl: 119
file content (48 lines) | stat: -rw-r--r-- 1,851 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "fx.h"


/*
  Example proportional layout using FXSpring widgets
*/
int main(int argc,char **argv){

  // Create application object
  FXApp application("Ratio","FoxTest");

  // Initialize and open display
  application.init(argc,argv);

  // Create main window
  FXMainWindow *main=new FXMainWindow(&application,"Ratio",NULL,NULL,DECOR_ALL,0,0,400,200,8,8,8,8,6,6);
  
  // Add quit button and connect it to application
  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);
  
  // Label above it
  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);

  // Layout manager to place the springs  
  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);

  // First spring is set to behave normally in Y direction,
  // but to have a ratio 1 for the X direction
  FXSpring *spring1=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,1,0, 0,0,0,0, 0,0,0,0);
  FXLabel *label1=new FXLabel(spring1,"1",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
  label1->setBackColor(FXRGB(255,0,0));

  // Second spring has ratio 2 in the X direction
  FXSpring *spring2=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,2,0, 0,0,0,0, 0,0,0,0);
  FXLabel *label2=new FXLabel(spring2,"2",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
  label2->setBackColor(FXRGB(0,255,0));

  // Second spring has ratio 3 in the X direction
  FXSpring *spring3=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,3,0, 0,0,0,0, 0,0,0,0);
  FXLabel *label3=new FXLabel(spring3,"3",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
  label3->setBackColor(FXRGB(0,0,255));

  application.create();

  main->show(PLACEMENT_SCREEN);

  return application.run();
  }