diff options
author | fluxgen <fluxgen> | 2004-01-11 20:57:53 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-01-11 20:57:53 (GMT) |
commit | a819ff8252cc65c7e49d41b67c9bb1c1a40f0fb2 (patch) | |
tree | 22bd24d218a83281c7d10e9c7e03be759959d81c | |
parent | d03b0107e7cb1d58acd28f2b3df8b393199d84bd (diff) | |
download | fluxbox_paul-a819ff8252cc65c7e49d41b67c9bb1c1a40f0fb2.zip fluxbox_paul-a819ff8252cc65c7e49d41b67c9bb1c1a40f0fb2.tar.bz2 |
texture tests
-rw-r--r-- | src/tests/Makefile | 9 | ||||
-rw-r--r-- | src/tests/StringUtiltest.cc | 7 | ||||
-rw-r--r-- | src/tests/test.theme | 260 | ||||
-rw-r--r-- | src/tests/texturetest.cc | 135 |
4 files changed, 406 insertions, 5 deletions
diff --git a/src/tests/Makefile b/src/tests/Makefile index 3b4b7e7..3c6c634 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile | |||
@@ -5,8 +5,9 @@ XFLAGS= -I/usr/X11R6/include | |||
5 | XLIBS= -L/usr/X11R6/lib -lX11 -lXft | 5 | XLIBS= -L/usr/X11R6/lib -lX11 -lXft |
6 | COMPILEFILE=$(CXX) -c $(CXXFLAGS) | 6 | COMPILEFILE=$(CXX) -c $(CXXFLAGS) |
7 | FONT_OBJ = ../FbTk/libFbTk.a | 7 | FONT_OBJ = ../FbTk/libFbTk.a |
8 | COMPILE = ${CXX} ${CXXFLAGS} ${XLIBS} | ||
8 | 9 | ||
9 | all: testStringUtil testFont | 10 | all: testFont testTexture |
10 | 11 | ||
11 | .cc.o: | 12 | .cc.o: |
12 | $(CXX) -c $(CXXFLAGS) $< | 13 | $(CXX) -c $(CXXFLAGS) $< |
@@ -15,7 +16,7 @@ glxtest: ../FbTk/App.hh glxtest.cc | |||
15 | ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest | 16 | ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest |
16 | 17 | ||
17 | testStringUtil: StringUtiltest.o | 18 | testStringUtil: StringUtiltest.o |
18 | $(CXX) $(LIBS) StringUtiltest.o -o testStringUtil | 19 | $(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil |
19 | 20 | ||
20 | testKeys: testKeys.o | 21 | testKeys: testKeys.o |
21 | $(CXX) $(LIBS) $(XLIBS) testKeys.o -o testKeys | 22 | $(CXX) $(LIBS) $(XLIBS) testKeys.o -o testKeys |
@@ -38,6 +39,10 @@ testTransp: transpTest.cc | |||
38 | testScale: scaleTest.cc | 39 | testScale: scaleTest.cc |
39 | ${CXX} ${CXXFLAGS} ${XLIBS} scaleTest.cc ../FbTk/libFbTk.a -lXpm -o testScale | 40 | ${CXX} ${CXXFLAGS} ${XLIBS} scaleTest.cc ../FbTk/libFbTk.a -lXpm -o testScale |
40 | 41 | ||
42 | testTexture: texturetest.cc | ||
43 | ${COMPILE} texturetest.cc ../FbTk/libFbTk.a -lXpm -o testTexture | ||
44 | |||
45 | |||
41 | run: testLayers testResource testKeys testStringUtil testFont | 46 | run: testLayers testResource testKeys testStringUtil testFont |
42 | ./testLayers | 47 | ./testLayers |
43 | ./testKeys | 48 | ./testKeys |
diff --git a/src/tests/StringUtiltest.cc b/src/tests/StringUtiltest.cc index 8d8f206..7c2e2d8 100644 --- a/src/tests/StringUtiltest.cc +++ b/src/tests/StringUtiltest.cc | |||
@@ -1,5 +1,5 @@ | |||
1 | // StringUtiltest.cc | 1 | // StringUtiltest.cc |
2 | // Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) | 2 | // Copyright (c) 2001 - 2004 Henrik Kinnunen (fluxgen@linuxmail.org) |
3 | // | 3 | // |
4 | // Permission is hereby granted, free of charge, to any person obtaining a | 4 | // Permission is hereby granted, free of charge, to any person obtaining a |
5 | // copy of this software and associated documentation files (the "Software"), | 5 | // copy of this software and associated documentation files (the "Software"), |
@@ -13,13 +13,13 @@ | |||
13 | // | 13 | // |
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 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, | 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 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 | 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 | 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 | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | #include "../StringUtil.hh" | 22 | #include "StringUtil.hh" |
23 | #ifndef _GNU_SOURCE | 23 | #ifndef _GNU_SOURCE |
24 | #define _GNU_SOURCE | 24 | #define _GNU_SOURCE |
25 | #endif //_GNU_SOURCE | 25 | #endif //_GNU_SOURCE |
@@ -36,6 +36,7 @@ uds::uds_flags_t uds::flags = uds::leak_check|uds::log_allocs; | |||
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | using namespace std; | 38 | using namespace std; |
39 | using namespace FbTk; | ||
39 | 40 | ||
40 | void testStringtok() { | 41 | void testStringtok() { |
41 | vector<string> ls; | 42 | vector<string> ls; |
diff --git a/src/tests/test.theme b/src/tests/test.theme new file mode 100644 index 0000000..e73e818 --- /dev/null +++ b/src/tests/test.theme | |||
@@ -0,0 +1,260 @@ | |||
1 | texture0: Flat Solid | ||
2 | texture0.color: blue | ||
3 | |||
4 | texture1: Gradient Vertical | ||
5 | texture1.color: blue | ||
6 | texture1.colorTo: green | ||
7 | |||
8 | texture2: Gradient Horizontal | ||
9 | texture2.color: blue | ||
10 | texture2.colorTo: green | ||
11 | |||
12 | texture3: Gradient Diagonal | ||
13 | texture3.color: blue | ||
14 | texture3.colorTo: green | ||
15 | |||
16 | texture4: Gradient CrossDiagonal | ||
17 | texture4.color: blue | ||
18 | texture4.colorTo: green | ||
19 | |||
20 | texture5: Gradient Rectangle | ||
21 | texture5.color: blue | ||
22 | texture5.colorTo: green | ||
23 | |||
24 | texture6: Gradient Pyramid | ||
25 | texture6.color: blue | ||
26 | texture6.colorTo: green | ||
27 | |||
28 | texture7: Gradient PipeCross | ||
29 | texture7.color: blue | ||
30 | texture7.colorTo: green | ||
31 | |||
32 | texture8: Gradient Elliptic | ||
33 | texture8.color: blue | ||
34 | texture8.colorTo: green | ||
35 | |||
36 | --- new line | ||
37 | |||
38 | texture9: Flat Solid sunken | ||
39 | texture9.color: blue | ||
40 | texture9.colorTo: green | ||
41 | |||
42 | texture10: Gradient Vertical sunken | ||
43 | texture10.color: blue | ||
44 | texture10.colorTo: green | ||
45 | |||
46 | texture11: Gradient Horizontal sunken | ||
47 | texture11.color: blue | ||
48 | texture11.colorTo: green | ||
49 | |||
50 | texture12: Gradient Diagonal sunken | ||
51 | texture12.color: blue | ||
52 | texture12.colorTo: green | ||
53 | |||
54 | texture13: Gradient CrossDiagonal sunken | ||
55 | texture13.color: blue | ||
56 | texture13.colorTo: green | ||
57 | |||
58 | texture14: Gradient Rectangle sunken | ||
59 | texture14.color: blue | ||
60 | texture14.colorTo: green | ||
61 | |||
62 | texture15: Gradient Pyramid sunken | ||
63 | texture15.color: blue | ||
64 | texture15.colorTo: green | ||
65 | |||
66 | texture16: Gradient PipeCross sunken | ||
67 | texture16.color: blue | ||
68 | texture16.colorTo: green | ||
69 | |||
70 | texture17: Gradient Elliptic sunken | ||
71 | texture17.color: blue | ||
72 | texture17.colorTo: green | ||
73 | |||
74 | --- new line | ||
75 | texture18: Flat Solid raised | ||
76 | texture18.color: blue | ||
77 | texture18.colorTo: green | ||
78 | |||
79 | texture19: Gradient Vertical raised | ||
80 | texture19.color: blue | ||
81 | texture19.colorTo: green | ||
82 | |||
83 | texture20: Gradient Horizontal raised | ||
84 | texture20.color: blue | ||
85 | texture20.colorTo: green | ||
86 | |||
87 | texture21: Gradient Diagonal raised | ||
88 | texture21.color: blue | ||
89 | texture21.colorTo: green | ||
90 | |||
91 | texture22: Gradient CrossDiagonal raised | ||
92 | texture22.color: blue | ||
93 | texture22.colorTo: green | ||
94 | |||
95 | texture23: Gradient Rectangle raised | ||
96 | texture23.color: blue | ||
97 | texture23.colorTo: green | ||
98 | |||
99 | texture24: Gradient Pyramid raised | ||
100 | texture24.color: blue | ||
101 | texture24.colorTo: green | ||
102 | |||
103 | texture25: Gradient PipeCross raised | ||
104 | texture25.color: blue | ||
105 | texture25.colorTo: green | ||
106 | |||
107 | texture26: Gradient Elliptic raised | ||
108 | texture26.color: blue | ||
109 | texture26.colorTo: green | ||
110 | |||
111 | --- new line | ||
112 | |||
113 | texture27: Flat Solid invert | ||
114 | texture27.color: blue | ||
115 | texture27.colorTo: green | ||
116 | |||
117 | texture28: Gradient Vertical invert | ||
118 | texture28.color: blue | ||
119 | texture28.colorTo: green | ||
120 | |||
121 | texture29: Gradient Horizontal invert | ||
122 | texture29.color: blue | ||
123 | texture29.colorTo: green | ||
124 | |||
125 | texture30: Gradient Diagonal invert | ||
126 | texture30.color: blue | ||
127 | texture30.colorTo: green | ||
128 | |||
129 | texture31: Gradient CrossDiagonal invert | ||
130 | texture31.color: blue | ||
131 | texture31.colorTo: green | ||
132 | |||
133 | texture32: Gradient Rectangle invert | ||
134 | texture32.color: blue | ||
135 | texture32.colorTo: green | ||
136 | |||
137 | texture33: Gradient Pyramid invert | ||
138 | texture33.color: blue | ||
139 | texture33.colorTo: green | ||
140 | |||
141 | texture34: Gradient PipeCross invert | ||
142 | texture34.color: blue | ||
143 | texture34.colorTo: green | ||
144 | |||
145 | texture35: Gradient Elliptic invert | ||
146 | texture35.color: blue | ||
147 | texture35.colorTo: green | ||
148 | |||
149 | --- new line | ||
150 | texture36: Flat Solid interlaced | ||
151 | texture36.color: blue | ||
152 | texture36.colorTo: green | ||
153 | |||
154 | texture37: Gradient Vertical interlaced | ||
155 | texture37.color: blue | ||
156 | texture37.colorTo: green | ||
157 | |||
158 | texture38: Gradient Horizontal interlaced | ||
159 | texture38.color: blue | ||
160 | texture38.colorTo: green | ||
161 | |||
162 | texture39: Gradient Diagonal interlaced | ||
163 | texture39.color: blue | ||
164 | texture39.colorTo: green | ||
165 | |||
166 | texture40: Gradient CrossDiagonal interlaced | ||
167 | texture40.color: blue | ||
168 | texture40.colorTo: green | ||
169 | |||
170 | texture41: Gradient Rectangle interlaced | ||
171 | texture41.color: blue | ||
172 | texture41.colorTo: green | ||
173 | |||
174 | texture42: Gradient Pyramid interlaced | ||
175 | texture42.color: blue | ||
176 | texture42.colorTo: green | ||
177 | |||
178 | texture43: Gradient PipeCross interlaced | ||
179 | texture43.color: blue | ||
180 | texture43.colorTo: green | ||
181 | |||
182 | texture44: Gradient Elliptic interlaced | ||
183 | texture44.color: blue | ||
184 | texture44.colorTo: green | ||
185 | |||
186 | |||
187 | --- new line | ||
188 | texture45: Flat Solid bevel1 | ||
189 | texture45.color: blue | ||
190 | texture45.colorTo: green | ||
191 | |||
192 | texture46: Gradient Vertical bevel1 | ||
193 | texture46.color: blue | ||
194 | texture46.colorTo: green | ||
195 | |||
196 | texture47: Gradient Horizontal bevel1 | ||
197 | texture47.color: blue | ||
198 | texture47.colorTo: green | ||
199 | |||
200 | texture48: Gradient Diagonal bevel1 | ||
201 | texture48.color: blue | ||
202 | texture48.colorTo: green | ||
203 | |||
204 | texture49: Gradient CrossDiagonal bevel1 | ||
205 | texture49.color: blue | ||
206 | texture49.colorTo: green | ||
207 | |||
208 | texture50: Gradient Rectangle bevel1 | ||
209 | texture50.color: blue | ||
210 | texture50.colorTo: green | ||
211 | |||
212 | texture51: Gradient Pyramid bevel1 | ||
213 | texture51.color: blue | ||
214 | texture51.colorTo: green | ||
215 | |||
216 | texture52: Gradient PipeCross bevel1 | ||
217 | texture52.color: blue | ||
218 | texture52.colorTo: green | ||
219 | |||
220 | texture53: Gradient Elliptic bevel1 | ||
221 | texture53.color: blue | ||
222 | texture53.colorTo: green | ||
223 | |||
224 | |||
225 | --- new line | ||
226 | texture54: Flat Solid bevel2 | ||
227 | texture54.color: blue | ||
228 | texture54.colorTo: green | ||
229 | |||
230 | texture55: Gradient Vertical bevel2 | ||
231 | texture55.color: blue | ||
232 | texture55.colorTo: green | ||
233 | |||
234 | texture56: Gradient Horizontal bevel2 | ||
235 | texture56.color: blue | ||
236 | texture56.colorTo: green | ||
237 | |||
238 | texture57: Gradient Diagonal bevel2 | ||
239 | texture57.color: blue | ||
240 | texture57.colorTo: green | ||
241 | |||
242 | texture58: Gradient CrossDiagonal bevel2 | ||
243 | texture58.color: blue | ||
244 | texture58.colorTo: green | ||
245 | |||
246 | texture59: Gradient Rectangle bevel2 | ||
247 | texture59.color: blue | ||
248 | texture59.colorTo: green | ||
249 | |||
250 | texture60: Gradient Pyramid bevel2 | ||
251 | texture60.color: blue | ||
252 | texture60.colorTo: green | ||
253 | |||
254 | texture61: Gradient PipeCross bevel2 | ||
255 | texture61.color: blue | ||
256 | texture61.colorTo: green | ||
257 | |||
258 | texture62: Gradient Elliptic bevel2 | ||
259 | texture62.color: blue | ||
260 | texture62.colorTo: green | ||
diff --git a/src/tests/texturetest.cc b/src/tests/texturetest.cc new file mode 100644 index 0000000..0ba6741 --- /dev/null +++ b/src/tests/texturetest.cc | |||
@@ -0,0 +1,135 @@ | |||
1 | #include "ImageControl.hh" | ||
2 | #include "Color.hh" | ||
3 | #include "GContext.hh" | ||
4 | #include "FbPixmap.hh" | ||
5 | #include "Texture.hh" | ||
6 | #include "FbWindow.hh" | ||
7 | #include "EventHandler.hh" | ||
8 | #include "EventManager.hh" | ||
9 | #include "Theme.hh" | ||
10 | #include "Font.hh" | ||
11 | #include "App.hh" | ||
12 | |||
13 | #include <memory> | ||
14 | #include <iostream> | ||
15 | #include <string> | ||
16 | |||
17 | using namespace std; | ||
18 | using namespace FbTk; | ||
19 | |||
20 | class TestTheme: public Theme { | ||
21 | public: | ||
22 | TestTheme(int screen):Theme(screen) { } | ||
23 | bool fallback(ThemeItem_base &item) { return false; } | ||
24 | void reconfigTheme() { } | ||
25 | }; | ||
26 | |||
27 | class Application: public FbTk::FbWindow, public FbTk::EventHandler { | ||
28 | public: | ||
29 | Application(int box_size, int num): | ||
30 | FbWindow(0, 0, 0, 640, box_size*num/8 - 3*5, ExposureMask | KeyPressMask), | ||
31 | m_box_size(box_size), | ||
32 | m_num(num), | ||
33 | m_font("fixed"), | ||
34 | m_imgctrl(screenNumber(), true, 8, | ||
35 | 100, 100), | ||
36 | m_background(*this, 640, 480, depth()), | ||
37 | m_gc(m_background) { | ||
38 | setName("Texture Test"); | ||
39 | setBackgroundPixmap(m_background.drawable()); | ||
40 | |||
41 | FbTk::EventManager::instance()->add(*this, *this); | ||
42 | |||
43 | renderPixmaps(); | ||
44 | |||
45 | show(); | ||
46 | } | ||
47 | void keyPressEvent(XKeyEvent &ev) { | ||
48 | App::instance()->end(); | ||
49 | } | ||
50 | void exposeEvent(XExposeEvent &ev) { | ||
51 | clear(); | ||
52 | } | ||
53 | |||
54 | private: | ||
55 | |||
56 | void renderPixmap(const Texture &text, int x, int y) { | ||
57 | Pixmap pm = m_imgctrl.renderImage(m_box_size, m_box_size, | ||
58 | text); | ||
59 | |||
60 | m_background.copyArea(pm, m_gc.gc(), | ||
61 | 0, 0, | ||
62 | x, y, | ||
63 | m_box_size, m_box_size); | ||
64 | m_imgctrl.removeImage(pm); | ||
65 | } | ||
66 | |||
67 | void renderPixmaps() { | ||
68 | |||
69 | m_gc.setForeground(Color("gray", screenNumber())); | ||
70 | |||
71 | m_background.fillRectangle(m_gc.gc(), | ||
72 | 0, 0, | ||
73 | width(), height()); | ||
74 | // for text color | ||
75 | m_gc.setForeground(Color("black", screenNumber())); | ||
76 | |||
77 | const int step_size = m_box_size + 5; | ||
78 | int next_x = 5; | ||
79 | int next_y = 5; | ||
80 | |||
81 | TestTheme tm(screenNumber()); | ||
82 | std::auto_ptr<ThemeItem<Texture> > text; | ||
83 | char value[18]; | ||
84 | for (int i=0; i<m_num; ++i) { | ||
85 | sprintf(value, "%d", i); | ||
86 | text.reset(new ThemeItem<Texture> | ||
87 | (tm, | ||
88 | string("texture") + value, | ||
89 | string("Texture") + value)); | ||
90 | cerr<<"Theme: "<<text->name()<<endl; | ||
91 | // load new style | ||
92 | ThemeManager::instance().load("test.theme"); | ||
93 | |||
94 | renderPixmap(**text.get(), next_x, next_y); | ||
95 | |||
96 | next_x += step_size; | ||
97 | if (next_x + m_box_size > width()) { | ||
98 | m_font.drawText(m_background.drawable(), | ||
99 | screenNumber(), | ||
100 | m_gc.gc(), | ||
101 | value, strlen(value), | ||
102 | next_x, next_y + m_box_size/2); | ||
103 | next_x = 5; | ||
104 | next_y += step_size; | ||
105 | } | ||
106 | |||
107 | } | ||
108 | |||
109 | |||
110 | } | ||
111 | |||
112 | |||
113 | const int m_box_size; | ||
114 | const int m_num; | ||
115 | FbTk::Font m_font; | ||
116 | ImageControl m_imgctrl; | ||
117 | FbPixmap m_background; | ||
118 | FbTk::GContext m_gc; | ||
119 | }; | ||
120 | |||
121 | int main(int argc, char **argv) { | ||
122 | int boxsize= 60; | ||
123 | int num = 63; | ||
124 | for (int i=1; i<argc; ++i) { | ||
125 | if (strcmp(argv[i], "-boxsize") == 0 && i + 1 < argc) | ||
126 | boxsize = atoi(argv[++i]); | ||
127 | else if (strcmp(argv[i], "-num") == 0 && i + 1 < argc) | ||
128 | num = atoi(argv[++i]); | ||
129 | } | ||
130 | App realapp; | ||
131 | Application app(boxsize, num); | ||
132 | |||
133 | realapp.eventLoop(); | ||
134 | |||
135 | } | ||