diff options
author | Mateusz Kaduk <mateusz.kaduk@gmail.com> | 2004-12-22 10:46:24 +0000 |
---|---|---|
committer | Mateusz Kaduk <mateusz.kaduk@gmail.com> | 2004-12-22 10:46:24 +0000 |
commit | d4b405c509b6f65df32f13df0d4be9b77e3c8fac (patch) | |
tree | a07af50a6afe5e92af4322c945d8199b55ed2a3c /src/gui/setup.cpp | |
parent | d5c18a1a368766805fba12bebd4ed7bac3a68b70 (diff) | |
download | mana-client-d4b405c509b6f65df32f13df0d4be9b77e3c8fac.tar.gz mana-client-d4b405c509b6f65df32f13df0d4be9b77e3c8fac.tar.bz2 mana-client-d4b405c509b6f65df32f13df0d4be9b77e3c8fac.tar.xz mana-client-d4b405c509b6f65df32f13df0d4be9b77e3c8fac.zip |
Setup has create_setup() method that creates only one instance.
Diffstat (limited to 'src/gui/setup.cpp')
-rw-r--r-- | src/gui/setup.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 8e6e23d6..3c48986a 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -18,9 +18,9 @@ Setup::Setup(gcn::Container *parent) cancelButton = new gcn::Button("Cancel"); /* Set dimension */ - displayLabel->setDimension(gcn::Rectangle(0,0,128, 16)); - applyButton->setDimension(gcn::Rectangle(0,0,128, 16)); - cancelButton->setDimension(gcn::Rectangle(0,0,128, 16)); + displayLabel->setDimension(gcn::Rectangle(0,0,80, 16)); + applyButton->setDimension(gcn::Rectangle(0,0,80, 16)); + cancelButton->setDimension(gcn::Rectangle(0,0,80, 16)); /* Set events */ applyButton->setEventId("apply"); @@ -28,8 +28,8 @@ Setup::Setup(gcn::Container *parent) /* Set position */ displayLabel->setPosition(10,10); - applyButton->setPosition(10,100); - cancelButton->setPosition(100,100); + applyButton->setPosition(10,190); + cancelButton->setPosition(150,190); /* Listen for actions */ applyButton->addActionListener(this); @@ -42,6 +42,9 @@ Setup::Setup(gcn::Container *parent) setSize(240,216); setLocationRelativeTo(getParent()); + + /* Is hidden */ + //setVisible(false); } Setup::~Setup() { @@ -52,22 +55,20 @@ Setup::~Setup() { void Setup::action(const std::string& eventId) { - if(eventId == "apply") { - puts("apply"); + setVisible(false); } else if(eventId == "cancel") { - puts("cancel"); + setVisible(false); } } -void create_setup() { - Setup *setup; - setup = new Setup(guiTop); - - while(!key[KEY_ESC] && !key[KEY_ENTER]) { - gui_update(NULL); - } - - delete setup; +Setup * Setup::ptr = NULL; +Setup * Setup::create_setup() { + if(ptr == NULL) + ptr = new Setup(guiTop); + else + ptr->setVisible(true); + + return ptr; } |