GUI: Made PicButtonWidget derivative of ButtonWidget

This commit is contained in:
Eugene Sandulenko 2011-10-24 18:34:51 +01:00
parent 25766500c0
commit b0fe2bbaf9
2 changed files with 5 additions and 21 deletions

View File

@ -305,16 +305,16 @@ void ButtonWidget::setLabel(const Common::String &label) {
#pragma mark -
PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey)
: Widget(boss, x, y, w, h, tooltip), CommandSender(boss),
_cmd(cmd), _hotkey(hotkey), _gfx(), _alpha(256), _transparency(false) {
: ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey),
_gfx(), _alpha(256), _transparency(false) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
}
PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey)
: Widget(boss, name, tooltip), CommandSender(boss),
_cmd(cmd), _gfx(), _alpha(256), _transparency(false) {
: ButtonWidget(boss, name, "", tooltip, cmd, hotkey),
_alpha(256), _transparency(false) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
}
@ -323,11 +323,6 @@ PicButtonWidget::~PicButtonWidget() {
_gfx.free();
}
void PicButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
sendCommand(_cmd, 0);
}
void PicButtonWidget::setGfx(const Graphics::Surface *gfx) {
_gfx.free();

View File

@ -197,28 +197,17 @@ protected:
};
/* PicButtonWidget */
class PicButtonWidget : public Widget, public CommandSender {
friend class Dialog; // Needed for the hotkey handling
protected:
uint32 _cmd;
uint8 _hotkey;
class PicButtonWidget : public ButtonWidget {
public:
PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0, uint8 hotkey = 0);
PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip = 0, uint32 cmd = 0, uint8 hotkey = 0);
~PicButtonWidget();
void setCmd(uint32 cmd) { _cmd = cmd; }
uint32 getCmd() const { return _cmd; }
void setGfx(const Graphics::Surface *gfx);
void useAlpha(int alpha) { _alpha = alpha; }
void useThemeTransparency(bool enable) { _transparency = enable; }
void handleMouseUp(int x, int y, int button, int clickCount);
void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); }
void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); }
protected:
void drawWidget();