5 #include <l4/scout-gfx/widget>
7 namespace Scout_gfx { namespace Pt {
10 class Horizontal_shadow : public Widget
18 explicit Horizontal_shadow(int height, int intensity)
19 : _intensity(intensity), _h(height)
20 { _size = Area(0, height); }
25 void draw(Canvas *c, Point const &p);
26 Widget *find(Point const &) { return 0; }
28 Area min_size() const { return Area(0, _h); }
29 Area preferred_size() const { return Area(0, _h); }
30 Area max_size() const { return Area(Area::Max_w, _h); }
31 bool empty() const { return false; }
32 Orientations expanding() const { return Horizontal; }
33 Rect geometry() const { return Rect(_pos, _size); }
34 void set_geometry(Rect const &s)
36 Area x = s.area().max(min_size()).max(min_size());
37 _pos = s.p1(); _size = x;
43 /***********************
44 ** Horizontal shadow **
45 ***********************/
47 template <typename PT>
48 void Horizontal_shadow<PT>::draw(Canvas *c, Point const &_p)
50 typedef typename PT::Pixel Pixel;
51 typedef typename PT::Color Color;
53 char *addr = (char *)c->buffer();
58 Rect clip = c->clip();
59 Rect cr = (Rect(_size) + _p) & clip;
64 int curr_a = _intensity;
65 int step = _size.h() ? (curr_a/_size.h()) : 0;
67 int bpl = c->bytes_per_line();
69 addr += bpl * cr.y1() + cr.x1() * sizeof(Pixel);
71 Color shadow_color(0,0,0);
74 for (int j = 0; j < h; j++, addr += bpl)
76 Pixel *d = reinterpret_cast<Pixel*>(addr);
79 for (int i = 0; i < w; i++, d++)
80 *d = PT::mix(*d, shadow_color, curr_a);