Root/src/link.h

1/***************************************************************************
2 * Copyright (C) 2006 by Massimiliano Torromeo *
3 * massimiliano.torromeo@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#ifndef LINK_H
22#define LINK_H
23
24#include "delegate.h"
25
26#include <SDL.h>
27#include <string>
28
29class GMenu2X;
30class Surface;
31class Touchscreen;
32
33
34/**
35Base class that represents a link on screen.
36
37    @author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
38*/
39class Link {
40public:
41    Link(GMenu2X *gmenu2x, function_t action);
42    virtual ~Link() {};
43
44    bool isPressed();
45    bool handleTS();
46
47    virtual void paint();
48    void paintHover();
49
50    virtual void loadIcon();
51
52    void setSize(int w, int h);
53    void setPosition(int x, int y);
54
55    const std::string &getTitle();
56    void setTitle(const std::string &title);
57    const std::string &getDescription();
58    void setDescription(const std::string &description);
59    const std::string &getIcon();
60    void setIcon(const std::string &icon);
61    const std::string &getIconPath();
62
63    void run();
64
65protected:
66    GMenu2X *gmenu2x;
67    bool edited;
68    std::string title, description, icon, iconPath;
69
70    Surface *iconSurface;
71    Surface *icon_hover;
72
73    virtual const std::string &searchIcon();
74    void setIconPath(const std::string &icon);
75    void updateSurfaces();
76
77private:
78    void recalcCoordinates();
79
80    Touchscreen &ts;
81    function_t action;
82
83    SDL_Rect rect;
84    uint iconX, padding;
85    int lastTick;
86};
87
88#endif
89

Archive Download this file



interactive