I'm afraid my english is bad so you might not understand therefore i set up a little testcase.
Code: Select all
#include <cstdlib>
#include <irrlicht.h>
using namespace std;
using namespace irr;
using namespace gui;
using namespace scene;
using namespace video;
gui::IGUITabControl* tc = NULL;//pointer to our tab control
//quick event receiver class
class MyEventReceiver : public IEventReceiver
{
virtual bool OnEvent(const SEvent& event)
{
if(event.EventType == EET_GUI_EVENT)
{
if(event.GUIEvent.EventType == EGET_CHECKBOX_CHANGED)
tc->getTab(0)->setDrawBackground(((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked());
else if(event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
tc->setTabVerticalAlignment(((gui::IGUIButton*)event.GUIEvent.Caller)->isPressed()?EGUIA_LOWERRIGHT:EGUIA_UPPERLEFT);
else
return false;
return true;
}
return false;
}
} ;
/*
*
*/
int main(int argc, char** argv)
{
MyEventReceiver receiver;
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<u32> (800, 600), 32, false, false, false, &receiver);
if (!device)
return EXIT_FAILURE;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
//set the tab control and add a tab to it
tc = guienv->addTabControl(core::rect<s32>(30,10,230,190),NULL,true,true);
tc->addTab(L"Test Tab")->setBackgroundColor(video::SColor(0xA0FF00FF));
//add checkbox that toggles the background drawing of the tab
guienv->addCheckBox(false,core::rect<s32>(240,140,380,160),NULL, -1, L"Toggle Tab Draw Background");
//add button that will call setTabVerticalAlignment() and align the tab to bottom
guienv->addButton(core::rect<s32>(240,170,380,190),NULL,-1,L"setTabVerticalAlignment()")->setIsPushButton(true);
while (device->run())
{
driver->beginScene(true, true, video::SColor(0xFFA0A0A0));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
return EXIT_SUCCESS;
}