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>
28 #define min(x,y) (x < y ? x : y)
32 #define max(x,y) (x > y ? x : y)
35 #define round(x) (int)(x + 0.5)
41 fl_pile::fl_pile(int X
,int Y
,int W
,int H
,const char *l
)
42 : Fl_Widget (X
, Y
, W
, H
, l
)
49 // I don't know if this is a good solution
50 // lyellow = FL_COLOR_CUBE +
51 // FL_RED_MULTIPLY * 4 +
52 // FL_GREEN_MULTIPLY * 7 +
53 // FL_BLUE_MULTIPLY * 3;
54 lyellow
= fl_color_cube(255 * FL_NUM_RED
/256,
55 255 * FL_NUM_GREEN
/256,
56 200 * FL_NUM_BLUE
/256);
72 ** I don't think I have to handle anything here
74 int fl_pile::handle (int event
)
89 /* set everything to background color */
90 fl_color (Fl_Widget::color());
91 fl_rectf (x()+1, y()+1, w()-2, h()-2);
96 fl_color (lyellow
); // yellow
98 fl_color (FL_BLACK
); // black
100 for (i
= 1; i
<= nrpieces
; i
++)
103 y1
= yoffset
- round (i
* pieceh
* 1.5);
105 fl_rectf (x1
, y1
, piecew
, pieceh
);
109 for (i
= 1; i
<= nrpieces
; i
++)
112 y1
= yoffset
- round (i
* pieceh
* 1.5);
114 fl_rect (x1
, y1
, piecew
, pieceh
);
121 void fl_pile::resize (int x
, int y
, int w
, int h
)
123 Fl_Widget::resize (x
, y
, w
, h
);
138 ** to be used at every resize-event and at class-creation
140 void fl_pile::calcsizes ()
145 width
= round (w() / 1.5);
146 height
= round (h() / 5.5);
147 piecew
= min (width
, height
);
148 pieceh
= (int) (piecew
/ 5.0);
150 xoffset
= round((w() - piecew
) / 2) + x();
157 void fl_pile::setvalue (int val
)
166 void fl_pile::setcolor (char col
)