If you have comments or questions concerning this source file, discuss them in the forum.
/*
Copyright (c) 2002 Nicolai Haehnle

See the license.txt for details. If that file was not included in the
source distributions, please email <prefect@rtts.org>
*/
// gui_button.h

#ifndef GUI_BUTTON_H
#define GUI_BUTTON_H

#include "gui_label.h"

/*
A button is a panel that can be clicked on to trigger a signal
*/

class GButton : public GLabel {
public:
    byte    m_disabledcolor[4]; // the color used when oblivious
    byte    m_focuscolor[4];
    byte    m_mouseovercolor[4];
    byte    m_clickedcolor[4];  // used while we're clicked
    int     m_id;

public:
    GButton(GPanel *pParent, int x, int y, int w, int h, const char *szText = 0,
            int iAlign = 0, int id = -1);
    GButton(GPanel *pParent, const char *szPic, int type, u32 colorkey,
            int x, int y, int w, int h, int id = -1);

    LSignal1<int> Clicked;

    inline void SetId(int id) { m_id = id; }

    inline void SetDisabledColor(int r, int g, int b, int a = 255) {
        m_disabledcolor[0] = r;
        m_disabledcolor[1] = g;
        m_disabledcolor[2] = b;
        m_disabledcolor[3] = a;
    }
    inline void SetFocusColor(int r, int g, int b, int a = 255) {
        m_focuscolor[0] = r;
        m_focuscolor[1] = g;
        m_focuscolor[2] = b;
        m_focuscolor[3] = a;
    }
    inline void SetMouseOverColor(int r, int g, int b, int a = 255) {
        m_mouseovercolor[0] = r;
        m_mouseovercolor[1] = g;
        m_mouseovercolor[2] = b;
        m_mouseovercolor[3] = a;
    }
    inline void SetClickedColor(int r, int g, int b, int a = 255) {
        m_clickedcolor[0] = r;
        m_clickedcolor[1] = g;
        m_clickedcolor[2] = b;
        m_clickedcolor[3] = a;
    }

public:
    void Fire();

    virtual void Draw();

    virtual bool Key(int code, char c, bool down);
    virtual bool MouseButton(int btn, int x, int y, bool down);
};

#endif // GUI_BUTTON_H