zengine-gewi/test/gewiTest00.cpp

120 lines
3.4 KiB
C++
Raw Normal View History

2003-05-19 22:58:01 +00:00
/*******************************************************************************
This file is Part of the Gewi GUI Library for ZEngine.
Gewi and ZEngine Copyright (C) 2002, 2003 James Turk
Licensed under a BSD-style license. (see licensing.txt)
The maintainer of this library is James Turk (james@conceptofzero.net)
this library is found at the home of ZEngine http://zengine.sourceforge.net
*******************************************************************************/
#include "ZEngine.h"
2003-06-07 05:50:09 +00:00
#include "Gewi.h"
2003-05-19 22:58:01 +00:00
using namespace ZE;
2003-05-21 02:47:56 +00:00
using namespace Gewi;
2003-05-19 22:58:01 +00:00
void Init()
{
ZEngine *ze = ZEngine::GetInstance();
ZConfigFile cfg("gewiTest.zcf");
int w,h,bpp;
bool fs;
string title;
w = cfg.GetInt("screen","width",800);
h = cfg.GetInt("screen","height",600);
bpp = cfg.GetInt("screen","bpp",32);
fs = cfg.GetBool("screen","fullscreen",false);
title = cfg.GetString("screen","title","Gewi Test");
ze->SetupDisplay(w,h,bpp,fs);
ze->CreateDisplay(title);
}
void Test1()
{
ZEngine *ze = ZEngine::GetInstance();
2003-05-21 02:47:56 +00:00
GewiEngine *gewi = GewiEngine::GetInstance();
2003-06-07 05:50:09 +00:00
2003-06-09 03:29:22 +00:00
ZImage bg,temp[8];
2003-06-07 05:50:09 +00:00
ZFont font;
ResourceID id[8],fontID;
GWindow window;
2003-06-09 03:29:22 +00:00
GTextButton txtButton;
2003-06-07 05:50:09 +00:00
GTextField txtField,txtField2(&window);
GButton button(&window);
GHorizSlider hSlider;
GVertSlider vSlider;
GButton hoverButton(&window);
GStaticText label;
bg.Open("data/rainbow.bmp");
bg.Resize(ze->Width(),ze->Height());
temp[0].Open("data/b1.bmp");
temp[1].Open("data/b2.bmp");
temp[2].Open("data/skin1.bmp");
temp[3].Open("data/text.bmp");
temp[4].Open("data/bg3.bmp");
temp[5].Open("data/slider.bmp");
temp[6].Open("data/bg4.bmp");
temp[7].Open("data/slider2.bmp");
2003-06-09 03:29:22 +00:00
font.Open("data/axaxax.ttf",20);
2003-06-07 05:50:09 +00:00
for(int i=0; i < 8; ++i)
{
temp[i].SetColorKey(255,0,255);
id[i] = gewi->AddResource(&temp[i]);
}
fontID = gewi->AddResource(&font);
window.Create(300,300,300,300,id[2]);
button.Create(50,30,10,10,id[0],id[1]);
txtField.Create(100,100,500,50,fontID,id[3],20,20);
txtField2.Create(50,200,200,50,fontID,id[3],20,20);
txtButton.Create(400,200,300,50,id[0],id[1],fontID,"restore window");
hSlider.Create(100,500,200,50,id[4],id[5],0,3,1);
vSlider.Create(700,200,50,200,id[6],id[7],0,200,5);
hoverButton.Create(70,40,100,100,id[0],id[1],GBT_HOVER);
label.Create(100,100,100,100,fontID,"static",GJ_CENTER,GewiEngine::InvalidID);
2003-05-19 22:58:01 +00:00
do
{
ze->CheckEvents();
if(ze->IsActive())
{
2003-06-09 03:29:22 +00:00
if(ze->KeyIsPressed(SDLK_ESCAPE) || hoverButton.IsPressed())
2003-05-19 22:58:01 +00:00
ze->RequestQuit();
2003-06-09 03:29:22 +00:00
if( (button.IsPressed() && window.Visible()) || (txtButton.IsPressed() && !window.Visible()) )
2003-05-19 22:58:01 +00:00
{
2003-06-07 05:50:09 +00:00
window.ToggleVisible();
txtButton.SetState(false);
button.SetState(false);
2003-05-19 22:58:01 +00:00
}
2003-06-09 03:29:22 +00:00
temp[2].SetAlpha(63+hSlider.GetPos()*64);
2003-05-19 22:58:01 +00:00
2003-06-09 03:29:22 +00:00
bg.Draw(0,0);
gewi->Display();
2003-05-19 22:58:01 +00:00
ze->Update();
}
} while(!ze->QuitRequested());
}
2003-06-09 03:29:22 +00:00
2003-05-19 22:58:01 +00:00
int main(int argc, char *argv[])
{
2003-06-09 03:29:22 +00:00
ZEngine *ze = ZEngine::GetInstance();
2003-05-19 22:58:01 +00:00
Init();
Test1();
2003-06-09 03:29:22 +00:00
2003-06-07 05:50:09 +00:00
GewiEngine::ReleaseInstance();
2003-05-19 22:58:01 +00:00
ZEngine::ReleaseInstance();
2003-06-09 03:29:22 +00:00
2003-05-19 22:58:01 +00:00
return 0;
}