diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-18 01:53:10 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-18 01:53:10 +0000 |
commit | 8fb163024e321e00e55ff324ccdac34b9adfb773 (patch) | |
tree | 5b461cee991aaff633a6ae11f1d16a280952ebbb | |
parent | 73e815469fd2332d424852afe6153243b5d12043 (diff) | |
download | mana-8fb163024e321e00e55ff324ccdac34b9adfb773.tar.gz mana-8fb163024e321e00e55ff324ccdac34b9adfb773.tar.bz2 mana-8fb163024e321e00e55ff324ccdac34b9adfb773.tar.xz mana-8fb163024e321e00e55ff324ccdac34b9adfb773.zip |
Added colon to the fixed font and removed some alfont usage.
-rw-r--r-- | data/graphic/fixedfont.bmp | bin | 17318 -> 17578 bytes | |||
-rw-r--r-- | src/gui/button.cpp | 70 | ||||
-rw-r--r-- | src/gui/button.h | 14 | ||||
-rw-r--r-- | src/gui/checkbox.cpp | 16 | ||||
-rw-r--r-- | src/gui/checkbox.h | 2 | ||||
-rw-r--r-- | src/gui/gui.cpp | 3 | ||||
-rw-r--r-- | src/gui/login.cpp | 4 | ||||
-rw-r--r-- | src/gui/window.cpp | 51 | ||||
-rw-r--r-- | src/gui/window.h | 1 |
9 files changed, 50 insertions, 111 deletions
diff --git a/data/graphic/fixedfont.bmp b/data/graphic/fixedfont.bmp Binary files differindex eddb804e..14d92742 100644 --- a/data/graphic/fixedfont.bmp +++ b/data/graphic/fixedfont.bmp diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 030dd9de..fd82b9b1 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -24,26 +24,17 @@ Button::Button(const std::string& caption): gcn::Button(caption) { - mouseDown = false; - keyDown = false; setBorderSize(0); } void Button::draw(gcn::Graphics* graphics) { - int x, y; int mode; - int offset = 0; - - getAbsolutePosition(x, y); - - //printf("draw - %d,%d\n", x, y); if (false /*disabled*/) { mode = 3; } - else if (hasMouse() && mouseDown || keyDown) { + else if (isPressed()) { mode = 2; - offset = 1; } else if (hasMouse()) { mode = 1; @@ -52,48 +43,37 @@ void Button::draw(gcn::Graphics* graphics) { mode = 0; } + int x, y; + getAbsolutePosition(x, y); + draw_skinned_rect(gui_bitmap, &gui_skin.button.background[mode], x, y, getWidth(), getHeight()); - int rtm = alfont_text_mode(-1); - gui_text(gui_bitmap, getCaption().c_str(), - x + 2 + offset, y + 4 + offset, - gui_skin.button.textcolor[mode], FALSE); - alfont_text_mode(rtm); -} + graphics->setColor(getForegroundColor()); -void Button::lostFocus() { - mouseDown = false; - keyDown = false; -} + int textX; + int textY = getHeight() / 2 - getFont()->getHeight() / 2; -void Button::mousePress(int x, int y, int button) { - if (button == gcn::MouseInput::LEFT && hasMouse()) { - mouseDown = true; + switch (getAlignment()) { + case gcn::Graphics::LEFT: + textX = 4; + break; + case gcn::Graphics::CENTER: + textX = getWidth() / 2; + break; + case gcn::Graphics::RIGHT: + textX = getWidth() - 4; + break; + default: + throw GCN_EXCEPTION("Button::draw. Uknown alignment."); } -} - -void Button::mouseRelease(int x, int y, int button) { - if (button == gcn::MouseInput::LEFT) { - mouseDown = false; - } -} -void Button::keyPress(const gcn::Key& key) { - if (key.getValue() == gcn::Key::ENTER || - key.getValue() == gcn::Key::SPACE) - { - keyDown = true; - } - mouseDown = false; -} + graphics->setFont(getFont()); -void Button::keyRelease(const gcn::Key& key) { - if ((key.getValue() == gcn::Key::ENTER || - key.getValue() == gcn::Key::SPACE) && keyDown) - { - keyDown = false; - generateAction(); + if (isPressed()) { + graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); } + else { + graphics->drawText(getCaption(), textX, textY, getAlignment()); + } } - diff --git a/src/gui/button.h b/src/gui/button.h index d7026951..b7d48929 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -36,20 +36,6 @@ class Button : public gcn::Button { // Inherited from Widget void draw(gcn::Graphics* graphics); - void lostFocus(); - - // Inherited from MouseListener - - void mousePress(int x, int y, int button); - void mouseRelease(int x, int y, int button); - - // Inherited from KeyListener - - void keyPress(const gcn::Key& key); - void keyRelease(const gcn::Key& key); - - private: - bool mouseDown, keyDown; }; #endif diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 9105ae69..d30298ea 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -26,11 +26,9 @@ CheckBox::CheckBox(const std::string& caption, bool marked): { } -void CheckBox::draw(gcn::Graphics* graphics) { +void CheckBox::drawBox(gcn::Graphics* graphics) { BITMAP *box = NULL; int x, y; - int tx, ty; - int col = 0; getAbsolutePosition(x, y); @@ -46,20 +44,8 @@ void CheckBox::draw(gcn::Graphics* graphics) { box = gui_skin.checkbox.normal; } - if (false /*disabled*/) { - col = gui_skin.checkbox.textcolor[1]; - } else { - col = gui_skin.checkbox.textcolor[0]; - } - x += 2; y += 2; - tx = x + box->w + 2; - ty = y - 2; masked_blit(box, gui_bitmap, 0, 0, x, y, box->w, box->h); - - int rtm = alfont_text_mode(-1); - gui_text(gui_bitmap, getCaption().c_str(), tx, ty, col, 0); - alfont_text_mode(rtm); } diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index c4240a40..42e637fb 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -35,7 +35,7 @@ class CheckBox : public gcn::CheckBox { // Inherited from Widget - void draw(gcn::Graphics* graphics); + void drawBox(gcn::Graphics* graphics); }; #endif diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 22391550..424ac393 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -88,7 +88,8 @@ void init_gui(BITMAP *bitmap, const char *skin) { gui->setInput(guiInput); gui->setTop(guiTop); guiFont = new gcn::ImageFont("./data/graphic/fixedfont.bmp", - " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:" + ); gcn::Widget::setGlobalFont(guiFont); diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 2250f59b..32039294 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -81,8 +81,8 @@ void login() { cancelButton = new Button("Cancel"); dialog->setDimension(gcn::Rectangle(300, 250, 200, 80)); - userLabel->setPosition(4, 14); - passLabel->setPosition(4, 34); + userLabel->setPosition(4, 11); + passLabel->setPosition(4, 31); userField->setPosition(60, 10); passField->setPosition(60, 30); userField->setWidth(130); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 507f9ffb..1429ae1c 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -37,12 +37,6 @@ Window::Window(std::string text) : gcn::Widget::setBaseColor(gcn::Color(255, 255, 255)); - /* Crappy window caption - captionLabel = new Label(caption.c_str()); - captionLabel->setPosition(3, 3); - add(captionLabel); - */ - //load dialog title bar image dLeft = load_bitmap("data/Skin/dialogLeft.bmp", NULL); dMid = load_bitmap("data/Skin/dialogMiddle.bmp", NULL); @@ -59,9 +53,7 @@ Window::Window(std::string text) : Window::~Window() { - //delete captionLabel; - - //free dialog bitmaps + // Free dialog bitmaps release_bitmap(dLeft); release_bitmap(dMid); release_bitmap(dRight); @@ -71,13 +63,8 @@ Window::~Window() void Window::draw(gcn::Graphics* graphics) { - int x, y; - getAbsolutePosition(x, y); - - //draw container background - //Container::draw(graphics); - if (mOpaque) - { + // Draw container background when opaque + if (mOpaque) { graphics->setColor(getBaseColor()); graphics->fillRectangle(gcn::Rectangle(0, titlebarHeight, getDimension().width, @@ -85,35 +72,35 @@ void Window::draw(gcn::Graphics* graphics) } - //skinned dialog render + // Skinned dialog render if (typeid(*graphics) == typeid(gcn::AllegroGraphics)) { - //its allegro !! - gcn::AllegroGraphics *gfx = (gcn::AllegroGraphics*)graphics; //woo - BITMAP *screen = gfx->getTarget(); //get screen surface + gcn::AllegroGraphics *gfx = (gcn::AllegroGraphics*)graphics; + BITMAP *screen = gfx->getTarget(); + int x, y; + getAbsolutePosition(x, y); - //left + // Draw title bar masked_blit(dLeft, screen, 0, 0, x, y, 24, 24); - //center for (int i = 1; i <= (getDimension().width - 24) / 24; i++) { blit(dMid, screen, 0, 0, x + i * 24, y, 24, 24); } - //right - masked_blit(dRight, screen, 0, 0, x + getDimension().width - 24, y, 24, 24); - - //draw caption - int rtm = alfont_text_mode(-1); - gui_text(gui_bitmap, caption.c_str(), x + 4, y + 4, gui_skin.button.textcolor[0], FALSE); - alfont_text_mode(rtm); - } else - { - //plain title bar + masked_blit(dRight, screen, 0, 0, + x + getDimension().width - 24, y, + 24, 24); + } + else { + // Plain title bar graphics->setColor(titlebarColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getDimension().width, titlebarHeight)); } + // Draw title + graphics->setFont(getFont()); + graphics->drawText(caption, 4, 4, gcn::Graphics::LEFT); + drawChildren(graphics); } diff --git a/src/gui/window.h b/src/gui/window.h index 492b679e..8b9f983e 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -36,7 +36,6 @@ class Window : public gcn::Container, public gcn::MouseListener private: gcn::Container *chrome; /**< Contained container */ std::string caption; /**< Title bar caption */ - gcn::Label* captionLabel; /**< Title bar caption label */ int z; /**< Z position of the window */ int mousePX; /**< Mouse down location */ int mousePY; /**< Mouse down location */ |