mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-10 21:55:11 +01:00
More gui work.
This commit is contained in:
parent
c483dc63bb
commit
59365e831f
@ -5,160 +5,181 @@
|
|||||||
|
|
||||||
namespace widgets
|
namespace widgets
|
||||||
{
|
{
|
||||||
gcn::ImageFont* font;
|
gcn::ImageFont* font;
|
||||||
gcn::Container* top;
|
gcn::ImageFont* title_font;
|
||||||
gcn::Button* button;
|
gcn::Container* top;
|
||||||
gcn::TextField* textField;
|
gcn::Button* button;
|
||||||
gcn::TextBox* textBox;
|
gcn::TextField* textField;
|
||||||
gcn::ScrollArea* textBoxScrollArea;
|
gcn::TextBox* textBox;
|
||||||
gcn::ListBox* listBox;
|
gcn::ScrollArea* textBoxScrollArea;
|
||||||
gcn::DropDown* dropDown;
|
gcn::ListBox* listBox;
|
||||||
gcn::CheckBox* checkBox1;
|
gcn::DropDown* dropDown;
|
||||||
gcn::CheckBox* checkBox2;
|
gcn::CheckBox* checkBox1;
|
||||||
gcn::Window *window;
|
gcn::CheckBox* checkBox2;
|
||||||
gcn::Image *darkbitsImage;
|
gcn::Window *window;
|
||||||
gcn::Icon* darkbitsIcon;
|
gcn::Image *darkbitsImage;
|
||||||
gcn::TabbedArea* tabbedArea;
|
gcn::Icon* darkbitsIcon;
|
||||||
gcn::Button* tabOneButton;
|
gcn::TabbedArea* tabbedArea;
|
||||||
gcn::CheckBox* tabTwoCheckBox;
|
gcn::Button* tabOneButton;
|
||||||
|
gcn::CheckBox* tabTwoCheckBox;
|
||||||
|
|
||||||
|
|
||||||
class BackgroundContainer : public gcn::Container, gcn::Icon
|
class BackgroundContainer : public gcn::Container
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BackgroundContainer(const char *fn) : gcn::Icon(fn), gcn::Container()
|
BackgroundContainer(gcn::ImageFont *fnt, const char *bg, const char *title) : gcn::Container()
|
||||||
{
|
{
|
||||||
}
|
this->bg = new gcn::Icon(bg);
|
||||||
|
this->fnt = fnt;
|
||||||
|
// We set the dimension of the top container to match the screen.
|
||||||
|
this->setDimension(gcn::Rectangle(0, 0, 640, 480));
|
||||||
|
this->title = new gcn::Label(title);
|
||||||
|
this->title->setFont(fnt);
|
||||||
|
this->add(this->title);
|
||||||
|
this->title->adjustSize();
|
||||||
|
this->title->setPosition(140, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void draw(gcn::Graphics *graphics)
|
void draw(gcn::Graphics *graphics)
|
||||||
{
|
{
|
||||||
graphics->drawImage(mImage, 0, 0);
|
this->bg->draw(graphics);
|
||||||
this->drawChildren(graphics);
|
this->drawChildren(graphics);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
/*
|
|
||||||
* List boxes and drop downs need an instance of a list model
|
|
||||||
* in order to display a list.
|
|
||||||
*/
|
|
||||||
class DemoListModel : public gcn::ListModel
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int getNumberOfElements()
|
|
||||||
{
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getElementAt(int i)
|
private:
|
||||||
{
|
gcn::Icon *bg;
|
||||||
switch(i)
|
gcn::Font *fnt;
|
||||||
{
|
gcn::Label *title;
|
||||||
case 0:
|
};
|
||||||
return std::string("zero");
|
|
||||||
case 1:
|
|
||||||
return std::string("one");
|
|
||||||
case 2:
|
|
||||||
return std::string("two");
|
|
||||||
case 3:
|
|
||||||
return std::string("three");
|
|
||||||
case 4:
|
|
||||||
return std::string("four");
|
|
||||||
default: // Just to keep warnings away
|
|
||||||
return std::string("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DemoListModel demoListModel;
|
/*
|
||||||
|
* List boxes and drop downs need an instance of a list model
|
||||||
|
* in order to display a list.
|
||||||
|
*/
|
||||||
|
class DemoListModel : public gcn::ListModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int getNumberOfElements()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
std::string getElementAt(int i)
|
||||||
* Initialises the widgets example by populating the global Gui
|
{
|
||||||
* object.
|
switch(i)
|
||||||
*/
|
{
|
||||||
void init()
|
case 0:
|
||||||
{
|
return std::string("zero");
|
||||||
// We first create a container to be used as the top widget.
|
case 1:
|
||||||
// The top widget in Guichan can be any kind of widget, but
|
return std::string("one");
|
||||||
// in order to make the Gui contain more than one widget we
|
case 2:
|
||||||
// make the top widget a container.
|
return std::string("two");
|
||||||
top = new BackgroundContainer("data/menu_background.png");
|
case 3:
|
||||||
// We set the dimension of the top container to match the screen.
|
return std::string("three");
|
||||||
top->setDimension(gcn::Rectangle(0, 0, 640, 480));
|
case 4:
|
||||||
// Finally we pass the top widget to the Gui object.
|
return std::string("four");
|
||||||
globals::gui->setTop(top);
|
case 5:
|
||||||
|
return std::string("four");
|
||||||
|
case 6:
|
||||||
|
return std::string("four");
|
||||||
|
case 7:
|
||||||
|
return std::string("four");
|
||||||
|
default: // Just to keep warnings away
|
||||||
|
return std::string("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Now we load the font used in this example.
|
DemoListModel demoListModel;
|
||||||
font = new gcn::ImageFont("data/fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
|
||||||
// Widgets may have a global font so we don't need to pass the
|
|
||||||
// font object to every created widget. The global font is static.
|
|
||||||
gcn::Widget::setGlobalFont(font);
|
|
||||||
|
|
||||||
// Now we create the widgets
|
/**
|
||||||
button = new gcn::Button("Button");
|
* Initialises the widgets example by populating the global Gui
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
// Now we load the font used in this example.
|
||||||
|
font = new gcn::ImageFont("data/fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
||||||
|
// Widgets may have a global font so we don't need to pass the
|
||||||
|
// font object to every created widget. The global font is static.
|
||||||
|
gcn::Widget::setGlobalFont(font);
|
||||||
|
|
||||||
textField = new gcn::TextField("Text field");
|
title_font = new gcn::ImageFont("data/techyfontbig.png", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
||||||
|
// We first create a container to be used as the top widget.
|
||||||
|
// The top widget in Guichan can be any kind of widget, but
|
||||||
|
// in order to make the Gui contain more than one widget we
|
||||||
|
// make the top widget a container.
|
||||||
|
top = new BackgroundContainer(title_font, "data/menu_background.png", "Main menu");
|
||||||
|
// Finally we pass the top widget to the Gui object.
|
||||||
|
globals::gui->setTop(top);
|
||||||
|
|
||||||
textBox = new gcn::TextBox("Multiline\nText box");
|
// Now we create the widgets
|
||||||
textBoxScrollArea = new gcn::ScrollArea(textBox);
|
button = new gcn::Button("Button");
|
||||||
textBoxScrollArea->setWidth(200);
|
|
||||||
textBoxScrollArea->setHeight(100);
|
|
||||||
textBoxScrollArea->setFrameSize(1);
|
|
||||||
|
|
||||||
listBox = new gcn::ListBox(&demoListModel);
|
textField = new gcn::TextField("Text field");
|
||||||
listBox->setFrameSize(1);
|
|
||||||
dropDown = new gcn::DropDown(&demoListModel);
|
|
||||||
|
|
||||||
checkBox1 = new gcn::CheckBox("Checkbox 1");
|
|
||||||
checkBox2 = new gcn::CheckBox("Checkbox 2");
|
|
||||||
|
|
||||||
window = new gcn::Window("I am a window Drag me");
|
textBox = new gcn::TextBox("Multiline\nText box");
|
||||||
window->setBaseColor(gcn::Color(255, 150, 200, 190));
|
textBoxScrollArea = new gcn::ScrollArea(textBox);
|
||||||
|
textBoxScrollArea->setWidth(200);
|
||||||
|
textBoxScrollArea->setHeight(100);
|
||||||
|
textBoxScrollArea->setFrameSize(1);
|
||||||
|
|
||||||
darkbitsImage = gcn::Image::load("data/darkbitslogo_by_haiko.bmp");
|
listBox = new gcn::ListBox(&demoListModel);
|
||||||
darkbitsIcon = new gcn::Icon(darkbitsImage);
|
listBox->setFrameSize(1);
|
||||||
window->add(darkbitsIcon);
|
dropDown = new gcn::DropDown(&demoListModel);
|
||||||
window->resizeToContent();
|
|
||||||
|
|
||||||
tabbedArea = new gcn::TabbedArea();
|
checkBox1 = new gcn::CheckBox("Checkbox 1");
|
||||||
tabbedArea->setSize(200, 100);
|
checkBox2 = new gcn::CheckBox("Checkbox 2");
|
||||||
tabOneButton = new gcn::Button("A button in tab 1");
|
|
||||||
tabbedArea->addTab("Tab 1", tabOneButton);
|
|
||||||
tabTwoCheckBox = new gcn::CheckBox("A check box in tab 2");
|
|
||||||
tabbedArea->addTab("Tab 2", tabTwoCheckBox);
|
|
||||||
|
|
||||||
// Now it's time to add the widgets to the top container
|
window = new gcn::Window("I am a window Drag me");
|
||||||
// so they will be conected to the GUI.
|
window->setBaseColor(gcn::Color(255, 150, 200, 190));
|
||||||
|
|
||||||
top->add(button, 200, 10);
|
darkbitsImage = gcn::Image::load("data/darkbitslogo_by_haiko.bmp");
|
||||||
top->add(textField, 250, 10);
|
darkbitsIcon = new gcn::Icon(darkbitsImage);
|
||||||
top->add(textBoxScrollArea, 200, 50);
|
window->add(darkbitsIcon);
|
||||||
top->add(listBox, 200, 200);
|
window->resizeToContent();
|
||||||
top->add(dropDown, 500, 10);
|
|
||||||
top->add(checkBox1, 500, 130);
|
tabbedArea = new gcn::TabbedArea();
|
||||||
top->add(checkBox2, 500, 150);
|
tabbedArea->setSize(200, 100);
|
||||||
top->add(window, 50, 350);
|
tabOneButton = new gcn::Button("A button in tab 1");
|
||||||
top->add(tabbedArea, 400, 350);
|
tabbedArea->addTab("Tab 1", tabOneButton);
|
||||||
}
|
tabTwoCheckBox = new gcn::CheckBox("A check box in tab 2");
|
||||||
|
tabbedArea->addTab("Tab 2", tabTwoCheckBox);
|
||||||
/**
|
|
||||||
* Halts the widgets example.
|
// Now it's time to add the widgets to the top container
|
||||||
*/
|
// so they will be conected to the GUI.
|
||||||
void halt()
|
top->add(button, 200, 80);
|
||||||
{
|
top->add(textField, 250, 80);
|
||||||
delete font;
|
top->add(textBoxScrollArea, 200, 50);
|
||||||
delete top;
|
top->add(listBox, 200, 200);
|
||||||
delete button;
|
top->add(dropDown, 500, 80);
|
||||||
delete textField;
|
top->add(checkBox1, 500, 130);
|
||||||
delete textBox;
|
top->add(checkBox2, 500, 150);
|
||||||
delete textBoxScrollArea;
|
top->add(window, 50, 350);
|
||||||
delete listBox;
|
top->add(tabbedArea, 400, 350);
|
||||||
delete dropDown;
|
}
|
||||||
delete checkBox1;
|
|
||||||
delete checkBox2;
|
/**
|
||||||
delete window;
|
* Halts the widgets example.
|
||||||
delete darkbitsIcon;
|
*/
|
||||||
delete darkbitsImage;
|
void halt()
|
||||||
delete tabbedArea;
|
{
|
||||||
delete tabOneButton;
|
delete font;
|
||||||
delete tabTwoCheckBox;
|
delete title_font;
|
||||||
}
|
delete top;
|
||||||
|
delete button;
|
||||||
|
delete textField;
|
||||||
|
delete textBox;
|
||||||
|
delete textBoxScrollArea;
|
||||||
|
delete listBox;
|
||||||
|
delete dropDown;
|
||||||
|
delete checkBox1;
|
||||||
|
delete checkBox2;
|
||||||
|
delete window;
|
||||||
|
delete darkbitsIcon;
|
||||||
|
delete darkbitsImage;
|
||||||
|
delete tabbedArea;
|
||||||
|
delete tabOneButton;
|
||||||
|
delete tabTwoCheckBox;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 13 KiB |
BIN
data/techyfontbig.png
Normal file
BIN
data/techyfontbig.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Loading…
Reference in New Issue
Block a user