summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-01-11 20:57:53 (GMT)
committerfluxgen <fluxgen>2004-01-11 20:57:53 (GMT)
commita819ff8252cc65c7e49d41b67c9bb1c1a40f0fb2 (patch)
tree22bd24d218a83281c7d10e9c7e03be759959d81c
parentd03b0107e7cb1d58acd28f2b3df8b393199d84bd (diff)
downloadfluxbox_lack-a819ff8252cc65c7e49d41b67c9bb1c1a40f0fb2.zip
fluxbox_lack-a819ff8252cc65c7e49d41b67c9bb1c1a40f0fb2.tar.bz2
texture tests
-rw-r--r--src/tests/Makefile9
-rw-r--r--src/tests/StringUtiltest.cc7
-rw-r--r--src/tests/test.theme260
-rw-r--r--src/tests/texturetest.cc135
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
5XLIBS= -L/usr/X11R6/lib -lX11 -lXft 5XLIBS= -L/usr/X11R6/lib -lX11 -lXft
6COMPILEFILE=$(CXX) -c $(CXXFLAGS) 6COMPILEFILE=$(CXX) -c $(CXXFLAGS)
7FONT_OBJ = ../FbTk/libFbTk.a 7FONT_OBJ = ../FbTk/libFbTk.a
8COMPILE = ${CXX} ${CXXFLAGS} ${XLIBS}
8 9
9all: testStringUtil testFont 10all: 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
17testStringUtil: StringUtiltest.o 18testStringUtil: StringUtiltest.o
18 $(CXX) $(LIBS) StringUtiltest.o -o testStringUtil 19 $(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil
19 20
20testKeys: testKeys.o 21testKeys: 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
38testScale: scaleTest.cc 39testScale: 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
42testTexture: texturetest.cc
43 ${COMPILE} texturetest.cc ../FbTk/libFbTk.a -lXpm -o testTexture
44
45
41run: testLayers testResource testKeys testStringUtil testFont 46run: 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
38using namespace std; 38using namespace std;
39using namespace FbTk;
39 40
40void testStringtok() { 41void 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 @@
1texture0: Flat Solid
2texture0.color: blue
3
4texture1: Gradient Vertical
5texture1.color: blue
6texture1.colorTo: green
7
8texture2: Gradient Horizontal
9texture2.color: blue
10texture2.colorTo: green
11
12texture3: Gradient Diagonal
13texture3.color: blue
14texture3.colorTo: green
15
16texture4: Gradient CrossDiagonal
17texture4.color: blue
18texture4.colorTo: green
19
20texture5: Gradient Rectangle
21texture5.color: blue
22texture5.colorTo: green
23
24texture6: Gradient Pyramid
25texture6.color: blue
26texture6.colorTo: green
27
28texture7: Gradient PipeCross
29texture7.color: blue
30texture7.colorTo: green
31
32texture8: Gradient Elliptic
33texture8.color: blue
34texture8.colorTo: green
35
36--- new line
37
38texture9: Flat Solid sunken
39texture9.color: blue
40texture9.colorTo: green
41
42texture10: Gradient Vertical sunken
43texture10.color: blue
44texture10.colorTo: green
45
46texture11: Gradient Horizontal sunken
47texture11.color: blue
48texture11.colorTo: green
49
50texture12: Gradient Diagonal sunken
51texture12.color: blue
52texture12.colorTo: green
53
54texture13: Gradient CrossDiagonal sunken
55texture13.color: blue
56texture13.colorTo: green
57
58texture14: Gradient Rectangle sunken
59texture14.color: blue
60texture14.colorTo: green
61
62texture15: Gradient Pyramid sunken
63texture15.color: blue
64texture15.colorTo: green
65
66texture16: Gradient PipeCross sunken
67texture16.color: blue
68texture16.colorTo: green
69
70texture17: Gradient Elliptic sunken
71texture17.color: blue
72texture17.colorTo: green
73
74--- new line
75texture18: Flat Solid raised
76texture18.color: blue
77texture18.colorTo: green
78
79texture19: Gradient Vertical raised
80texture19.color: blue
81texture19.colorTo: green
82
83texture20: Gradient Horizontal raised
84texture20.color: blue
85texture20.colorTo: green
86
87texture21: Gradient Diagonal raised
88texture21.color: blue
89texture21.colorTo: green
90
91texture22: Gradient CrossDiagonal raised
92texture22.color: blue
93texture22.colorTo: green
94
95texture23: Gradient Rectangle raised
96texture23.color: blue
97texture23.colorTo: green
98
99texture24: Gradient Pyramid raised
100texture24.color: blue
101texture24.colorTo: green
102
103texture25: Gradient PipeCross raised
104texture25.color: blue
105texture25.colorTo: green
106
107texture26: Gradient Elliptic raised
108texture26.color: blue
109texture26.colorTo: green
110
111--- new line
112
113texture27: Flat Solid invert
114texture27.color: blue
115texture27.colorTo: green
116
117texture28: Gradient Vertical invert
118texture28.color: blue
119texture28.colorTo: green
120
121texture29: Gradient Horizontal invert
122texture29.color: blue
123texture29.colorTo: green
124
125texture30: Gradient Diagonal invert
126texture30.color: blue
127texture30.colorTo: green
128
129texture31: Gradient CrossDiagonal invert
130texture31.color: blue
131texture31.colorTo: green
132
133texture32: Gradient Rectangle invert
134texture32.color: blue
135texture32.colorTo: green
136
137texture33: Gradient Pyramid invert
138texture33.color: blue
139texture33.colorTo: green
140
141texture34: Gradient PipeCross invert
142texture34.color: blue
143texture34.colorTo: green
144
145texture35: Gradient Elliptic invert
146texture35.color: blue
147texture35.colorTo: green
148
149--- new line
150texture36: Flat Solid interlaced
151texture36.color: blue
152texture36.colorTo: green
153
154texture37: Gradient Vertical interlaced
155texture37.color: blue
156texture37.colorTo: green
157
158texture38: Gradient Horizontal interlaced
159texture38.color: blue
160texture38.colorTo: green
161
162texture39: Gradient Diagonal interlaced
163texture39.color: blue
164texture39.colorTo: green
165
166texture40: Gradient CrossDiagonal interlaced
167texture40.color: blue
168texture40.colorTo: green
169
170texture41: Gradient Rectangle interlaced
171texture41.color: blue
172texture41.colorTo: green
173
174texture42: Gradient Pyramid interlaced
175texture42.color: blue
176texture42.colorTo: green
177
178texture43: Gradient PipeCross interlaced
179texture43.color: blue
180texture43.colorTo: green
181
182texture44: Gradient Elliptic interlaced
183texture44.color: blue
184texture44.colorTo: green
185
186
187--- new line
188texture45: Flat Solid bevel1
189texture45.color: blue
190texture45.colorTo: green
191
192texture46: Gradient Vertical bevel1
193texture46.color: blue
194texture46.colorTo: green
195
196texture47: Gradient Horizontal bevel1
197texture47.color: blue
198texture47.colorTo: green
199
200texture48: Gradient Diagonal bevel1
201texture48.color: blue
202texture48.colorTo: green
203
204texture49: Gradient CrossDiagonal bevel1
205texture49.color: blue
206texture49.colorTo: green
207
208texture50: Gradient Rectangle bevel1
209texture50.color: blue
210texture50.colorTo: green
211
212texture51: Gradient Pyramid bevel1
213texture51.color: blue
214texture51.colorTo: green
215
216texture52: Gradient PipeCross bevel1
217texture52.color: blue
218texture52.colorTo: green
219
220texture53: Gradient Elliptic bevel1
221texture53.color: blue
222texture53.colorTo: green
223
224
225--- new line
226texture54: Flat Solid bevel2
227texture54.color: blue
228texture54.colorTo: green
229
230texture55: Gradient Vertical bevel2
231texture55.color: blue
232texture55.colorTo: green
233
234texture56: Gradient Horizontal bevel2
235texture56.color: blue
236texture56.colorTo: green
237
238texture57: Gradient Diagonal bevel2
239texture57.color: blue
240texture57.colorTo: green
241
242texture58: Gradient CrossDiagonal bevel2
243texture58.color: blue
244texture58.colorTo: green
245
246texture59: Gradient Rectangle bevel2
247texture59.color: blue
248texture59.colorTo: green
249
250texture60: Gradient Pyramid bevel2
251texture60.color: blue
252texture60.colorTo: green
253
254texture61: Gradient PipeCross bevel2
255texture61.color: blue
256texture61.colorTo: green
257
258texture62: Gradient Elliptic bevel2
259texture62.color: blue
260texture62.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
17using namespace std;
18using namespace FbTk;
19
20class TestTheme: public Theme {
21public:
22 TestTheme(int screen):Theme(screen) { }
23 bool fallback(ThemeItem_base &item) { return false; }
24 void reconfigTheme() { }
25};
26
27class Application: public FbTk::FbWindow, public FbTk::EventHandler {
28public:
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
54private:
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
121int 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}