diff options
Diffstat (limited to 'src/ArrowButton.cc')
-rw-r--r-- | src/ArrowButton.cc | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/ArrowButton.cc b/src/ArrowButton.cc new file mode 100644 index 0000000..18dc6c6 --- /dev/null +++ b/src/ArrowButton.cc | |||
@@ -0,0 +1,110 @@ | |||
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.5 2003/10/13 23:51:04 fluxgen Exp $ | ||
23 | |||
24 | #include "ArrowButton.hh" | ||
25 | |||
26 | ArrowButton::ArrowButton(ArrowButton::Type arrow_type, | ||
27 | const 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 | m_mouse_handler(0) { | ||
33 | |||
34 | setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | | ||
35 | EnterWindowMask | LeaveWindowMask); | ||
36 | } | ||
37 | |||
38 | ArrowButton::ArrowButton(ArrowButton::Type arrow_type, | ||
39 | int screen_num, | ||
40 | int x, int y, | ||
41 | unsigned int width, unsigned int height): | ||
42 | FbTk::Button(screen_num, x, y, width, height), | ||
43 | m_arrow_type(arrow_type), | ||
44 | m_mouse_handler(0) { | ||
45 | |||
46 | setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | | ||
47 | EnterWindowMask | LeaveWindowMask); | ||
48 | } | ||
49 | |||
50 | void ArrowButton::clear() { | ||
51 | FbTk::Button::clear(); | ||
52 | drawArrow(); | ||
53 | } | ||
54 | |||
55 | void ArrowButton::exposeEvent(XExposeEvent &event) { | ||
56 | FbTk::Button::exposeEvent(event); | ||
57 | drawArrow(); | ||
58 | } | ||
59 | |||
60 | void ArrowButton::buttonPressEvent(XButtonEvent &event) { | ||
61 | FbTk::Button::buttonPressEvent(event); | ||
62 | drawArrow(); | ||
63 | } | ||
64 | |||
65 | void ArrowButton::buttonReleaseEvent(XButtonEvent &event) { | ||
66 | FbTk::Button::buttonReleaseEvent(event); | ||
67 | drawArrow(); | ||
68 | } | ||
69 | |||
70 | void ArrowButton::enterNotifyEvent(XCrossingEvent &ce) { | ||
71 | if (m_mouse_handler) | ||
72 | m_mouse_handler->enterNotifyEvent(ce); | ||
73 | } | ||
74 | |||
75 | void ArrowButton::leaveNotifyEvent(XCrossingEvent &ce) { | ||
76 | if (m_mouse_handler) | ||
77 | m_mouse_handler->leaveNotifyEvent(ce); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | redraws the arrow button | ||
82 | */ | ||
83 | void ArrowButton::drawArrow() { | ||
84 | XPoint pts[3]; | ||
85 | unsigned int w = width() / 2; | ||
86 | unsigned int h = height() / 2; | ||
87 | switch (m_arrow_type) { | ||
88 | case LEFT: | ||
89 | pts[0].x = w - 2; pts[0].y = h; | ||
90 | pts[1].x = 4; pts[1].y = 2; | ||
91 | pts[2].x = 0; pts[2].y = -4; | ||
92 | break; | ||
93 | case RIGHT: | ||
94 | pts[0].x = w - 2; pts[0].y = h - 2; | ||
95 | pts[1].x = 4; pts[1].y = 2; | ||
96 | pts[2].x = -4; pts[2].y = 2; | ||
97 | break; | ||
98 | case UP: // TODO | ||
99 | break; | ||
100 | case DOWN: // TODO | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | if (gc() != 0) { | ||
105 | fillPolygon(gc(), | ||
106 | pts, 3, | ||
107 | Convex, CoordModePrevious); | ||
108 | } | ||
109 | } | ||
110 | |||