[8498] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL |
---|
| 17 | |
---|
[8688] | 18 | #include "glgui_imagebutton.h" |
---|
[8498] | 19 | |
---|
| 20 | #include "debug.h" |
---|
| 21 | |
---|
[8503] | 22 | namespace OrxGui |
---|
[8498] | 23 | { |
---|
| 24 | |
---|
[8689] | 25 | GLGuiImageButton::GLGuiImageButton(const std::string& label, unsigned int levelID, const std::string& imageName, GLGuiImage* image) |
---|
[8698] | 26 | : GLGuiPushButton(label) |
---|
[8689] | 27 | { |
---|
| 28 | this->imageName = imageName; |
---|
| 29 | this->levelID = levelID; |
---|
| 30 | this->image = image; |
---|
[8698] | 31 | |
---|
| 32 | image->loadImageFromFile(imageName); |
---|
[8689] | 33 | } |
---|
[8498] | 34 | |
---|
[8689] | 35 | GLGuiImageButton::~GLGuiImageButton() |
---|
| 36 | {} |
---|
| 37 | |
---|
| 38 | void GLGuiImageButton::releasing(const Vector2D& pos, bool focused) |
---|
| 39 | { |
---|
[8740] | 40 | GLGuiPushButton::releasing(pos, focused); |
---|
[8698] | 41 | if (focused) |
---|
| 42 | this->emit(startLevel(this->levelID)); |
---|
[8689] | 43 | } |
---|
| 44 | |
---|
| 45 | void GLGuiImageButton::receivedFocus() |
---|
[8691] | 46 | { |
---|
[8698] | 47 | printf("%s:: %s\n", this->label().c_str(), this->imageName.c_str()); |
---|
| 48 | |
---|
[8691] | 49 | this->image->loadImageFromFile(this->imageName); |
---|
| 50 | } |
---|
[8689] | 51 | void GLGuiImageButton::removedFocus() |
---|
[8698] | 52 | {} |
---|
[8689] | 53 | |
---|
| 54 | |
---|
[8694] | 55 | void GLGuiImageButton::showing() |
---|
| 56 | { |
---|
[8698] | 57 | GLGuiPushButton::showing(); |
---|
[8740] | 58 | |
---|
| 59 | //this->image->show(); |
---|
[8694] | 60 | } |
---|
[8689] | 61 | |
---|
[8694] | 62 | void GLGuiImageButton::hiding() |
---|
| 63 | { |
---|
[8698] | 64 | GLGuiPushButton::hiding(); |
---|
| 65 | |
---|
[8740] | 66 | //this->image->hide(); |
---|
[8694] | 67 | } |
---|
[8689] | 68 | |
---|
[8740] | 69 | bool GLGuiImageButton::processEvent(const Event& event) |
---|
| 70 | { |
---|
| 71 | if (event.type == SDLK_SPACE) |
---|
| 72 | { |
---|
| 73 | if (event.bPressed) |
---|
| 74 | // emit(pushed()); |
---|
| 75 | ; |
---|
| 76 | else |
---|
| 77 | { |
---|
| 78 | // emit(released()); |
---|
| 79 | emit(startLevel(this->levelID)); |
---|
| 80 | } |
---|
| 81 | return true; |
---|
| 82 | } |
---|
| 83 | return false; |
---|
| 84 | } |
---|
[8694] | 85 | |
---|
[8740] | 86 | |
---|
| 87 | |
---|
[8498] | 88 | } |
---|