4 ** all that is necessary for drawing a pile of pieces
7 ** Copyright (C) 1998 Kurt Van den Branden
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
19 ** You should have received a copy of the GNU General Public License
20 ** along with this program; if not, write to the Free Software
21 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <FL/fl_draw.H>
29 #define round(x) (int)(x + 0.5)
35 fl_pile::fl_pile(int X
,int Y
,int W
,int H
,const char *l
)
36 : Fl_Widget (X
, Y
, W
, H
, l
)
43 // I don't know if this is a good solution
44 // lyellow = FL_COLOR_CUBE +
45 // FL_RED_MULTIPLY * 4 +
46 // FL_GREEN_MULTIPLY * 7 +
47 // FL_BLUE_MULTIPLY * 3;
48 lyellow
= fl_color_cube(255 * FL_NUM_RED
/256,
49 255 * FL_NUM_GREEN
/256,
50 200 * FL_NUM_BLUE
/256);
66 ** I don't think I have to handle anything here
68 int fl_pile::handle (int event
)
83 /* set everything to background color */
84 fl_color (Fl_Widget::color());
85 fl_rectf (x()+1, y()+1, w()-2, h()-2);
90 fl_color (lyellow
); // yellow
92 fl_color (FL_BLACK
); // black
94 for (i
= 1; i
<= nrpieces
; i
++)
97 y1
= yoffset
- round (i
* pieceh
* 1.5);
99 fl_rectf (x1
, y1
, piecew
, pieceh
);
103 for (i
= 1; i
<= nrpieces
; i
++)
106 y1
= yoffset
- round (i
* pieceh
* 1.5);
108 fl_rect (x1
, y1
, piecew
, pieceh
);
115 void fl_pile::resize (int x
, int y
, int w
, int h
)
117 Fl_Widget::resize (x
, y
, w
, h
);
132 ** to be used at every resize-event and at class-creation
134 void fl_pile::calcsizes ()
139 width
= round (w() / 1.5);
140 height
= round (h() / 5.5);
141 piecew
= std::min (width
, height
);
142 pieceh
= (int) (piecew
/ 5.0);
144 xoffset
= round((w() - piecew
) / 2) + x();
151 void fl_pile::setvalue (int val
)
160 void fl_pile::setcolor (char col
)