Root/src/iconbutton.h

1#ifndef ICONBUTTON_H
2#define ICONBUTTON_H
3
4#include "button.h"
5#include "asfont.h"
6
7#include <string>
8
9using std::string;
10
11class GMenu2X;
12class Surface;
13
14class IconButton : public Button {
15protected:
16    GMenu2X *gmenu2x;
17    string icon, label;
18    int labelPosition, labelMargin;
19    ASFont::HAlign labelHAlign;
20    ASFont::VAlign labelVAlign;
21    void recalcSize();
22    SDL_Rect iconRect, labelRect;
23
24    Surface *iconSurface;
25
26    void updateSurfaces();
27
28public:
29    static const int DISP_RIGHT = 0;
30    static const int DISP_LEFT = 1;
31    static const int DISP_TOP = 2;
32    static const int DISP_BOTTOM = 3;
33
34    IconButton(GMenu2X *gmenu2x, const string &icon, const string &label="");
35    virtual ~IconButton() {};
36
37    virtual void paint();
38    virtual bool paintHover();
39
40    virtual void setPosition(int x, int y);
41
42    const string &getLabel();
43    void setLabel(const string &label);
44    void setLabelPosition(int pos, int margin);
45
46    const string &getIcon();
47    void setIcon(const string &icon);
48
49    void setAction(ButtonAction action);
50};
51
52#endif
53

Archive Download this file



interactive