diff options
Diffstat (limited to 'src/ArrowButton.cc')
-rw-r--r-- | src/ArrowButton.cc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/ArrowButton.cc b/src/ArrowButton.cc new file mode 100644 index 0000000..bc44393 --- /dev/null +++ b/src/ArrowButton.cc | |||
@@ -0,0 +1,93 @@ | |||
1 | // ArrowButton.cc for Fluxbox Window Manager | ||
2 | // Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | // $Id: ArrowButton.cc,v 1.2 2003/04/27 01:54:18 fluxgen Exp $ | ||
23 | |||
24 | #include "ArrowButton.hh" | ||
25 | |||
26 | ArrowButton::ArrowButton(ArrowButton::Type arrow_type, | ||
27 | FbTk::FbWindow &parent, | ||
28 | int x, int y, | ||
29 | unsigned int width, unsigned int height): | ||
30 | FbTk::Button(parent, x, y, width, height), | ||
31 | m_arrow_type(arrow_type) { | ||
32 | } | ||
33 | |||
34 | ArrowButton::ArrowButton(ArrowButton::Type arrow_type, | ||
35 | int screen_num, | ||
36 | int x, int y, | ||
37 | unsigned int width, unsigned int height): | ||
38 | FbTk::Button(screen_num, x, y, width, height), | ||
39 | m_arrow_type(arrow_type) { | ||
40 | |||
41 | } | ||
42 | |||
43 | void ArrowButton::clear() { | ||
44 | FbTk::Button::clear(); | ||
45 | drawArrow(); | ||
46 | } | ||
47 | |||
48 | void ArrowButton::exposeEvent(XExposeEvent &event) { | ||
49 | FbTk::Button::exposeEvent(event); | ||
50 | drawArrow(); | ||
51 | } | ||
52 | |||
53 | void ArrowButton::buttonPressEvent(XButtonEvent &event) { | ||
54 | FbTk::Button::buttonPressEvent(event); | ||
55 | drawArrow(); | ||
56 | } | ||
57 | |||
58 | void ArrowButton::buttonReleaseEvent(XButtonEvent &event) { | ||
59 | FbTk::Button::buttonReleaseEvent(event); | ||
60 | drawArrow(); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | redraws the arrow button | ||
65 | */ | ||
66 | void ArrowButton::drawArrow() { | ||
67 | XPoint pts[3]; | ||
68 | unsigned int w = width() / 2; | ||
69 | unsigned int h = height() / 2; | ||
70 | switch (m_arrow_type) { | ||
71 | case LEFT: | ||
72 | pts[0].x = w - 2; pts[0].y = h; | ||
73 | pts[1].x = 4; pts[1].y = 2; | ||
74 | pts[2].x = 0; pts[2].y = -4; | ||
75 | break; | ||
76 | case RIGHT: | ||
77 | pts[0].x = w - 2; pts[0].y = h - 2; | ||
78 | pts[1].x = 4; pts[1].y = 2; | ||
79 | pts[2].x = -4; pts[2].y = 2; | ||
80 | break; | ||
81 | case UP: // TODO | ||
82 | break; | ||
83 | case DOWN: // TODO | ||
84 | break; | ||
85 | } | ||
86 | |||
87 | if (gc() != 0) { | ||
88 | window().fillPolygon(gc(), | ||
89 | pts, 3, | ||
90 | Convex, CoordModePrevious); | ||
91 | } | ||
92 | } | ||
93 | |||