Rune - Further Object abstraction work
[rune.git] / classes / gfx / fill.d
1 # GFX/FILL.D
2 #
3 # (c)Copyright 2020-2021, Matthew Dillon, All Rights Reserved.
4 #    See the COPYRIGHT file at the base of the Rune distribution.
5
6 public method
7 void
8 Frame.fillRect(int sx, int sy, int w, int h)
9 {
10     this->xFillRect(this->xid, this->pen->gcid,
11                    this->wpos.x + sx, this->wpos.y + sy,
12                    w, h);
13     this->last_draw.x = sx + w;
14     this->last_draw.y = sy + h;
15 }
16
17 public method
18 void
19 Frame.fillText(int x, int y, int w, string_p buf, int len)
20 {
21     int tw;
22     int th;
23
24     this->xDrawImageString(this->xid, this->pen->gcid,
25                            this->wpos.x + x, this->wpos.y + y,
26                            buf, len);
27     tw = this->xTextWidth(this->pen->fontid, buf, len);
28     if (w <= tw) {
29         w = tw;
30     } else {
31         th = this->pen->textHeight();
32
33         # XXX th + decent, not th + 2
34         # XXX fill color
35         #
36         this->xFillRect(this->xid, this->pen->gcid,
37                         this->wpos.x + x + tw, this->wpos.y + y - th + 2,
38                         w - tw, th);
39     }
40
41     # XXX height does not match th, center button?
42     #
43     this->last_draw.x = x + w;
44     this->last_draw.y = y;
45 }
46
47 # Clear area to background and generate exposures
48 #
49 public method
50 void
51 Frame.clearArea(int sx, int sy, int w, int h)
52 {
53     this->xClearArea(this->xid, this->wpos.x + sx, this->wpos.y + sy, w, h);
54 }