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
@ -6,6 +6,7 @@
|
||||
namespace widgets
|
||||
{
|
||||
gcn::ImageFont* font;
|
||||
gcn::ImageFont* title_font;
|
||||
gcn::Container* top;
|
||||
gcn::Button* button;
|
||||
gcn::TextField* textField;
|
||||
@ -23,19 +24,34 @@ namespace widgets
|
||||
gcn::CheckBox* tabTwoCheckBox;
|
||||
|
||||
|
||||
class BackgroundContainer : public gcn::Container, gcn::Icon
|
||||
class BackgroundContainer : public gcn::Container
|
||||
{
|
||||
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)
|
||||
{
|
||||
graphics->drawImage(mImage, 0, 0);
|
||||
this->bg->draw(graphics);
|
||||
this->drawChildren(graphics);
|
||||
}
|
||||
|
||||
private:
|
||||
gcn::Icon *bg;
|
||||
gcn::Font *fnt;
|
||||
gcn::Label *title;
|
||||
};
|
||||
|
||||
/*
|
||||
* List boxes and drop downs need an instance of a list model
|
||||
* in order to display a list.
|
||||
@ -62,6 +78,12 @@ namespace widgets
|
||||
return std::string("three");
|
||||
case 4:
|
||||
return std::string("four");
|
||||
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("");
|
||||
}
|
||||
@ -76,22 +98,21 @@ namespace widgets
|
||||
*/
|
||||
void init()
|
||||
{
|
||||
// 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("data/menu_background.png");
|
||||
// We set the dimension of the top container to match the screen.
|
||||
top->setDimension(gcn::Rectangle(0, 0, 640, 480));
|
||||
// Finally we pass the top widget to the Gui object.
|
||||
globals::gui->setTop(top);
|
||||
|
||||
// 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);
|
||||
|
||||
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);
|
||||
|
||||
// Now we create the widgets
|
||||
button = new gcn::Button("Button");
|
||||
|
||||
@ -127,12 +148,11 @@ namespace widgets
|
||||
|
||||
// Now it's time to add the widgets to the top container
|
||||
// so they will be conected to the GUI.
|
||||
|
||||
top->add(button, 200, 10);
|
||||
top->add(textField, 250, 10);
|
||||
top->add(button, 200, 80);
|
||||
top->add(textField, 250, 80);
|
||||
top->add(textBoxScrollArea, 200, 50);
|
||||
top->add(listBox, 200, 200);
|
||||
top->add(dropDown, 500, 10);
|
||||
top->add(dropDown, 500, 80);
|
||||
top->add(checkBox1, 500, 130);
|
||||
top->add(checkBox2, 500, 150);
|
||||
top->add(window, 50, 350);
|
||||
@ -145,6 +165,7 @@ namespace widgets
|
||||
void halt()
|
||||
{
|
||||
delete font;
|
||||
delete title_font;
|
||||
delete top;
|
||||
delete button;
|
||||
delete textField;
|
||||
|
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