texture tests

This commit is contained in:
fluxgen 2004-01-11 20:57:53 +00:00
parent d03b0107e7
commit a819ff8252
4 changed files with 406 additions and 5 deletions

View file

@ -5,8 +5,9 @@ XFLAGS= -I/usr/X11R6/include
XLIBS= -L/usr/X11R6/lib -lX11 -lXft
COMPILEFILE=$(CXX) -c $(CXXFLAGS)
FONT_OBJ = ../FbTk/libFbTk.a
COMPILE = ${CXX} ${CXXFLAGS} ${XLIBS}
all: testStringUtil testFont
all: testFont testTexture
.cc.o:
$(CXX) -c $(CXXFLAGS) $<
@ -15,7 +16,7 @@ glxtest: ../FbTk/App.hh glxtest.cc
${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest
testStringUtil: StringUtiltest.o
$(CXX) $(LIBS) StringUtiltest.o -o testStringUtil
$(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil
testKeys: testKeys.o
$(CXX) $(LIBS) $(XLIBS) testKeys.o -o testKeys
@ -38,6 +39,10 @@ testTransp: transpTest.cc
testScale: scaleTest.cc
${CXX} ${CXXFLAGS} ${XLIBS} scaleTest.cc ../FbTk/libFbTk.a -lXpm -o testScale
testTexture: texturetest.cc
${COMPILE} texturetest.cc ../FbTk/libFbTk.a -lXpm -o testTexture
run: testLayers testResource testKeys testStringUtil testFont
./testLayers
./testKeys

View file

@ -1,5 +1,5 @@
// StringUtiltest.cc
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
// Copyright (c) 2001 - 2004 Henrik Kinnunen (fluxgen@linuxmail.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include "../StringUtil.hh"
#include "StringUtil.hh"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif //_GNU_SOURCE
@ -36,6 +36,7 @@ uds::uds_flags_t uds::flags = uds::leak_check|uds::log_allocs;
#endif
using namespace std;
using namespace FbTk;
void testStringtok() {
vector<string> ls;

260
src/tests/test.theme Normal file
View file

@ -0,0 +1,260 @@
texture0: Flat Solid
texture0.color: blue
texture1: Gradient Vertical
texture1.color: blue
texture1.colorTo: green
texture2: Gradient Horizontal
texture2.color: blue
texture2.colorTo: green
texture3: Gradient Diagonal
texture3.color: blue
texture3.colorTo: green
texture4: Gradient CrossDiagonal
texture4.color: blue
texture4.colorTo: green
texture5: Gradient Rectangle
texture5.color: blue
texture5.colorTo: green
texture6: Gradient Pyramid
texture6.color: blue
texture6.colorTo: green
texture7: Gradient PipeCross
texture7.color: blue
texture7.colorTo: green
texture8: Gradient Elliptic
texture8.color: blue
texture8.colorTo: green
--- new line
texture9: Flat Solid sunken
texture9.color: blue
texture9.colorTo: green
texture10: Gradient Vertical sunken
texture10.color: blue
texture10.colorTo: green
texture11: Gradient Horizontal sunken
texture11.color: blue
texture11.colorTo: green
texture12: Gradient Diagonal sunken
texture12.color: blue
texture12.colorTo: green
texture13: Gradient CrossDiagonal sunken
texture13.color: blue
texture13.colorTo: green
texture14: Gradient Rectangle sunken
texture14.color: blue
texture14.colorTo: green
texture15: Gradient Pyramid sunken
texture15.color: blue
texture15.colorTo: green
texture16: Gradient PipeCross sunken
texture16.color: blue
texture16.colorTo: green
texture17: Gradient Elliptic sunken
texture17.color: blue
texture17.colorTo: green
--- new line
texture18: Flat Solid raised
texture18.color: blue
texture18.colorTo: green
texture19: Gradient Vertical raised
texture19.color: blue
texture19.colorTo: green
texture20: Gradient Horizontal raised
texture20.color: blue
texture20.colorTo: green
texture21: Gradient Diagonal raised
texture21.color: blue
texture21.colorTo: green
texture22: Gradient CrossDiagonal raised
texture22.color: blue
texture22.colorTo: green
texture23: Gradient Rectangle raised
texture23.color: blue
texture23.colorTo: green
texture24: Gradient Pyramid raised
texture24.color: blue
texture24.colorTo: green
texture25: Gradient PipeCross raised
texture25.color: blue
texture25.colorTo: green
texture26: Gradient Elliptic raised
texture26.color: blue
texture26.colorTo: green
--- new line
texture27: Flat Solid invert
texture27.color: blue
texture27.colorTo: green
texture28: Gradient Vertical invert
texture28.color: blue
texture28.colorTo: green
texture29: Gradient Horizontal invert
texture29.color: blue
texture29.colorTo: green
texture30: Gradient Diagonal invert
texture30.color: blue
texture30.colorTo: green
texture31: Gradient CrossDiagonal invert
texture31.color: blue
texture31.colorTo: green
texture32: Gradient Rectangle invert
texture32.color: blue
texture32.colorTo: green
texture33: Gradient Pyramid invert
texture33.color: blue
texture33.colorTo: green
texture34: Gradient PipeCross invert
texture34.color: blue
texture34.colorTo: green
texture35: Gradient Elliptic invert
texture35.color: blue
texture35.colorTo: green
--- new line
texture36: Flat Solid interlaced
texture36.color: blue
texture36.colorTo: green
texture37: Gradient Vertical interlaced
texture37.color: blue
texture37.colorTo: green
texture38: Gradient Horizontal interlaced
texture38.color: blue
texture38.colorTo: green
texture39: Gradient Diagonal interlaced
texture39.color: blue
texture39.colorTo: green
texture40: Gradient CrossDiagonal interlaced
texture40.color: blue
texture40.colorTo: green
texture41: Gradient Rectangle interlaced
texture41.color: blue
texture41.colorTo: green
texture42: Gradient Pyramid interlaced
texture42.color: blue
texture42.colorTo: green
texture43: Gradient PipeCross interlaced
texture43.color: blue
texture43.colorTo: green
texture44: Gradient Elliptic interlaced
texture44.color: blue
texture44.colorTo: green
--- new line
texture45: Flat Solid bevel1
texture45.color: blue
texture45.colorTo: green
texture46: Gradient Vertical bevel1
texture46.color: blue
texture46.colorTo: green
texture47: Gradient Horizontal bevel1
texture47.color: blue
texture47.colorTo: green
texture48: Gradient Diagonal bevel1
texture48.color: blue
texture48.colorTo: green
texture49: Gradient CrossDiagonal bevel1
texture49.color: blue
texture49.colorTo: green
texture50: Gradient Rectangle bevel1
texture50.color: blue
texture50.colorTo: green
texture51: Gradient Pyramid bevel1
texture51.color: blue
texture51.colorTo: green
texture52: Gradient PipeCross bevel1
texture52.color: blue
texture52.colorTo: green
texture53: Gradient Elliptic bevel1
texture53.color: blue
texture53.colorTo: green
--- new line
texture54: Flat Solid bevel2
texture54.color: blue
texture54.colorTo: green
texture55: Gradient Vertical bevel2
texture55.color: blue
texture55.colorTo: green
texture56: Gradient Horizontal bevel2
texture56.color: blue
texture56.colorTo: green
texture57: Gradient Diagonal bevel2
texture57.color: blue
texture57.colorTo: green
texture58: Gradient CrossDiagonal bevel2
texture58.color: blue
texture58.colorTo: green
texture59: Gradient Rectangle bevel2
texture59.color: blue
texture59.colorTo: green
texture60: Gradient Pyramid bevel2
texture60.color: blue
texture60.colorTo: green
texture61: Gradient PipeCross bevel2
texture61.color: blue
texture61.colorTo: green
texture62: Gradient Elliptic bevel2
texture62.color: blue
texture62.colorTo: green

135
src/tests/texturetest.cc Normal file
View file

@ -0,0 +1,135 @@
#include "ImageControl.hh"
#include "Color.hh"
#include "GContext.hh"
#include "FbPixmap.hh"
#include "Texture.hh"
#include "FbWindow.hh"
#include "EventHandler.hh"
#include "EventManager.hh"
#include "Theme.hh"
#include "Font.hh"
#include "App.hh"
#include <memory>
#include <iostream>
#include <string>
using namespace std;
using namespace FbTk;
class TestTheme: public Theme {
public:
TestTheme(int screen):Theme(screen) { }
bool fallback(ThemeItem_base &item) { return false; }
void reconfigTheme() { }
};
class Application: public FbTk::FbWindow, public FbTk::EventHandler {
public:
Application(int box_size, int num):
FbWindow(0, 0, 0, 640, box_size*num/8 - 3*5, ExposureMask | KeyPressMask),
m_box_size(box_size),
m_num(num),
m_font("fixed"),
m_imgctrl(screenNumber(), true, 8,
100, 100),
m_background(*this, 640, 480, depth()),
m_gc(m_background) {
setName("Texture Test");
setBackgroundPixmap(m_background.drawable());
FbTk::EventManager::instance()->add(*this, *this);
renderPixmaps();
show();
}
void keyPressEvent(XKeyEvent &ev) {
App::instance()->end();
}
void exposeEvent(XExposeEvent &ev) {
clear();
}
private:
void renderPixmap(const Texture &text, int x, int y) {
Pixmap pm = m_imgctrl.renderImage(m_box_size, m_box_size,
text);
m_background.copyArea(pm, m_gc.gc(),
0, 0,
x, y,
m_box_size, m_box_size);
m_imgctrl.removeImage(pm);
}
void renderPixmaps() {
m_gc.setForeground(Color("gray", screenNumber()));
m_background.fillRectangle(m_gc.gc(),
0, 0,
width(), height());
// for text color
m_gc.setForeground(Color("black", screenNumber()));
const int step_size = m_box_size + 5;
int next_x = 5;
int next_y = 5;
TestTheme tm(screenNumber());
std::auto_ptr<ThemeItem<Texture> > text;
char value[18];
for (int i=0; i<m_num; ++i) {
sprintf(value, "%d", i);
text.reset(new ThemeItem<Texture>
(tm,
string("texture") + value,
string("Texture") + value));
cerr<<"Theme: "<<text->name()<<endl;
// load new style
ThemeManager::instance().load("test.theme");
renderPixmap(**text.get(), next_x, next_y);
next_x += step_size;
if (next_x + m_box_size > width()) {
m_font.drawText(m_background.drawable(),
screenNumber(),
m_gc.gc(),
value, strlen(value),
next_x, next_y + m_box_size/2);
next_x = 5;
next_y += step_size;
}
}
}
const int m_box_size;
const int m_num;
FbTk::Font m_font;
ImageControl m_imgctrl;
FbPixmap m_background;
FbTk::GContext m_gc;
};
int main(int argc, char **argv) {
int boxsize= 60;
int num = 63;
for (int i=1; i<argc; ++i) {
if (strcmp(argv[i], "-boxsize") == 0 && i + 1 < argc)
boxsize = atoi(argv[++i]);
else if (strcmp(argv[i], "-num") == 0 && i + 1 < argc)
num = atoi(argv[++i]);
}
App realapp;
Application app(boxsize, num);
realapp.eventLoop();
}