diff options
author | fluxgen <fluxgen> | 2004-03-01 10:49:43 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-03-01 10:49:43 (GMT) |
commit | 604c2b9363e0d259d45b09e33e49e92e05aaad5a (patch) | |
tree | 77c2c696f5cb476dccdd429120c1199a9e5d23b9 /src/tests | |
parent | 292f25f2fefea3f5fac8d73a362694cedf2d2b2a (diff) | |
download | fluxbox-604c2b9363e0d259d45b09e33e49e92e05aaad5a.zip fluxbox-604c2b9363e0d259d45b09e33e49e92e05aaad5a.tar.bz2 |
template
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/template.cc | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/tests/template.cc b/src/tests/template.cc new file mode 100644 index 0000000..3eab430 --- /dev/null +++ b/src/tests/template.cc | |||
@@ -0,0 +1,103 @@ | |||
1 | // template.cc for fbtk test suite | ||
2 | // Copyright (c) 2004 Henrik Kinnunen (fluxgen<at>fluxbox dot org) | ||
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: template.cc,v 1.1 2004/03/01 10:49:43 fluxgen Exp $ | ||
23 | |||
24 | /* | ||
25 | * Use this file as a template for new test applications | ||
26 | * | ||
27 | */ | ||
28 | #include "App.hh" | ||
29 | #include "FbWindow.hh" | ||
30 | #include "Font.hh" | ||
31 | #include "EventHandler.hh" | ||
32 | #include "EventManager.hh" | ||
33 | #include "GContext.hh" | ||
34 | #include "Color.hh" | ||
35 | |||
36 | #include <X11/Xutil.h> | ||
37 | #include <X11/keysym.h> | ||
38 | |||
39 | #include <string> | ||
40 | #include <iostream> | ||
41 | using namespace std; | ||
42 | |||
43 | class App:public FbTk::App, public FbTk::EventHandler { | ||
44 | public: | ||
45 | App(const char *displayname): | ||
46 | FbTk::App(displayname), | ||
47 | m_win(DefaultScreen(display()), | ||
48 | 0, 0, 640, 480, KeyPressMask | ExposureMask | | ||
49 | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask) { | ||
50 | |||
51 | m_win.show(); | ||
52 | m_win.setBackgroundColor(FbTk::Color("white", m_win.screenNumber())); | ||
53 | FbTk::EventManager::instance()->add(*this, m_win); | ||
54 | } | ||
55 | |||
56 | ~App() { | ||
57 | } | ||
58 | |||
59 | void keyPressEvent(XKeyEvent &ke) { | ||
60 | cerr<<"KeyPress"<<endl; | ||
61 | KeySym ks; | ||
62 | char keychar[1]; | ||
63 | XLookupString(&ke, keychar, 1, &ks, 0); | ||
64 | if (ks == XK_Escape) | ||
65 | end(); | ||
66 | } | ||
67 | void buttonPressEvent(XButtonEvent &be) { | ||
68 | cerr<<"ButtonPress"<<endl; | ||
69 | } | ||
70 | void buttonReleaseEvent(XButtonEvent &be) { | ||
71 | cerr<<"ButtonRelease"<<endl; | ||
72 | } | ||
73 | void motionNotifyEvent(XMotionEvent &event) { | ||
74 | cerr<<"MotionNotify"<<endl; | ||
75 | } | ||
76 | void exposeEvent(XExposeEvent &event) { | ||
77 | cerr<<"ExposeEvent"<<endl; | ||
78 | redraw(); | ||
79 | } | ||
80 | |||
81 | void redraw() { | ||
82 | |||
83 | } | ||
84 | |||
85 | |||
86 | private: | ||
87 | FbTk::FbWindow m_win; | ||
88 | |||
89 | }; | ||
90 | |||
91 | int main(int argc, char **argv) { | ||
92 | string displayname(""); | ||
93 | for (int a=1; a<argc; ++a) { | ||
94 | if (strcmp("-display", argv[a]) == 0 && a + 1 < argc) { | ||
95 | displayname = argv[++a]; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | App app(displayname.c_str()); | ||
100 | |||
101 | app.eventLoop(); | ||
102 | |||
103 | } | ||