SHARE
TWEET

Untitled

a guest Sep 13th, 2017 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <FL/Fl.H>
  2. #include <FL/Fl_Window.H>
  3. #include <FL/Fl_Scroll.H>
  4. #include <FL/Fl_Box.H>
  5. #define BW 200 //box width
  6. #define BH 50 //box height
  7. #define SEP 10 //separator
  8.  
  9. int main(){
  10.   Fl_Window win(500, 300);
  11.   Fl_Scroll *scr=new Fl_Scroll(10,10,win.w()-20,win.h()-20);
  12.   scr->color(FL_GREEN);
  13.   int col=scr->w()/BW;
  14.   int c=0,line=SEP;
  15.   for(int i=1;i<=20;i++){
  16.      Fl_Box *b = new Fl_Box(scr->x()+SEP+(c*(BW+SEP)),scr->y()+line,BW,BH);
  17.      b->box(FL_FLAT_BOX);
  18.      b->color(FL_RED);
  19.      c += 1;
  20.      if(c == col){
  21.         c = 0;
  22.         line += (BH + SEP);
  23.      }
  24.   }
  25.   new Fl_Box(SEP,scr->y()+line-SEP,SEP,SEP);
  26.   win.show();
  27.   return Fl::run();
  28. }
RAW Paste Data
Top