diff options
author | fluxgen <fluxgen> | 2002-12-13 20:21:12 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-12-13 20:21:12 (GMT) |
commit | 3d8a063bd02a6c42414e202cce81be27415d1abb (patch) | |
tree | 30fe8d0ef4b996dbe0b92854d3a68a090cf39964 | |
parent | 6f01383c89b47edbd635c16dfebca3b9af27eb9a (diff) | |
download | fluxbox_pavel-3d8a063bd02a6c42414e202cce81be27415d1abb.zip fluxbox_pavel-3d8a063bd02a6c42414e202cce81be27415d1abb.tar.bz2 |
arrowbutton
-rw-r--r-- | src/ArrowButton.cc | 95 | ||||
-rw-r--r-- | src/ArrowButton.hh | 49 |
2 files changed, 144 insertions, 0 deletions
diff --git a/src/ArrowButton.cc b/src/ArrowButton.cc new file mode 100644 index 0000000..dfcc05d --- /dev/null +++ b/src/ArrowButton.cc | |||
@@ -0,0 +1,95 @@ | |||
1 | // ArrowButton.cc for Fluxbox Window Manager | ||
2 | // Copyright (c) 2002 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.1 2002/12/13 20:21:09 fluxgen Exp $ | ||
23 | |||
24 | #include "ArrowButton.hh" | ||
25 | |||
26 | #include "App.hh" | ||
27 | |||
28 | ArrowButton::ArrowButton(ArrowButton::Type arrow_type, | ||
29 | FbTk::FbWindow &parent, | ||
30 | int x, int y, | ||
31 | unsigned int width, unsigned int height): | ||
32 | FbTk::Button(parent, x, y, width, height), | ||
33 | m_arrow_type(arrow_type) { | ||
34 | } | ||
35 | |||
36 | ArrowButton::ArrowButton(ArrowButton::Type arrow_type, | ||
37 | int screen_num, | ||
38 | int x, int y, | ||
39 | unsigned int width, unsigned int height): | ||
40 | FbTk::Button(screen_num, x, y, width, height), | ||
41 | m_arrow_type(arrow_type) { | ||
42 | |||
43 | } | ||
44 | |||
45 | void ArrowButton::clear() { | ||
46 | FbTk::Button::clear(); | ||
47 | drawArrow(); | ||
48 | } | ||
49 | |||
50 | void ArrowButton::exposeEvent(XExposeEvent &event) { | ||
51 | FbTk::Button::exposeEvent(event); | ||
52 | drawArrow(); | ||
53 | } | ||
54 | |||
55 | void ArrowButton::buttonPressEvent(XButtonEvent &event) { | ||
56 | FbTk::Button::buttonPressEvent(event); | ||
57 | drawArrow(); | ||
58 | } | ||
59 | |||
60 | void ArrowButton::buttonReleaseEvent(XButtonEvent &event) { | ||
61 | FbTk::Button::buttonReleaseEvent(event); | ||
62 | drawArrow(); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | redraws the arrow button | ||
67 | */ | ||
68 | void ArrowButton::drawArrow() { | ||
69 | XPoint pts[3]; | ||
70 | unsigned int w = width() / 2; | ||
71 | unsigned int h = height() / 2; | ||
72 | switch (m_arrow_type) { | ||
73 | case LEFT: | ||
74 | pts[0].x = w - 2; pts[0].y = h; | ||
75 | pts[1].x = 4; pts[1].y = 2; | ||
76 | pts[2].x = 0; pts[2].y = -4; | ||
77 | break; | ||
78 | case RIGHT: | ||
79 | pts[0].x = w - 2; pts[0].y = h - 2; | ||
80 | pts[1].x = 4; pts[1].y = 2; | ||
81 | pts[2].x = -4; pts[2].y = 2; | ||
82 | break; | ||
83 | case UP: // TODO | ||
84 | break; | ||
85 | case DOWN: // TODO | ||
86 | break; | ||
87 | } | ||
88 | |||
89 | if (gc() != 0) { | ||
90 | Display *disp = FbTk::App::instance()->display(); | ||
91 | XFillPolygon(disp, window().window(), gc(), | ||
92 | pts, 3, Convex, CoordModePrevious); | ||
93 | } | ||
94 | } | ||
95 | |||
diff --git a/src/ArrowButton.hh b/src/ArrowButton.hh new file mode 100644 index 0000000..13ac102 --- /dev/null +++ b/src/ArrowButton.hh | |||
@@ -0,0 +1,49 @@ | |||
1 | // ArrowButton.hh for Fluxbox Window Manager | ||
2 | // Copyright (c) 2002 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.hh,v 1.1 2002/12/13 20:21:12 fluxgen Exp $ | ||
23 | |||
24 | #ifndef ARROWBUTTON_HH | ||
25 | #define ARROWBUTTON_HH | ||
26 | |||
27 | #include "Button.hh" | ||
28 | /// Displays a arrow on a button | ||
29 | class ArrowButton: public FbTk::Button { | ||
30 | public: | ||
31 | enum Type { LEFT, RIGHT, UP, DOWN}; | ||
32 | |||
33 | ArrowButton(Type arrow_type, FbTk::FbWindow &parent, | ||
34 | int x, int y, | ||
35 | unsigned int width, unsigned int height); | ||
36 | ArrowButton(Type arrow_type, int screen_num, | ||
37 | int x, int y, | ||
38 | unsigned int width, unsigned int height); | ||
39 | void clear(); | ||
40 | void buttonReleaseEvent(XButtonEvent &event); | ||
41 | void buttonPressEvent(XButtonEvent &event); | ||
42 | void exposeEvent(XExposeEvent &event); | ||
43 | |||
44 | private: | ||
45 | void drawArrow(); | ||
46 | Type m_arrow_type; | ||
47 | }; | ||
48 | |||
49 | #endif // ARROWBUTTON_HH | ||