Root/src/link.h

Source at commit 00d3c3b57008bddf8770c51271db9d766acaf854 created 7 years 5 months ago.
By Maarten ter Huurne, Gave Layer class a protected constructor
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 <SDL.h>
25
26#include <functional>
27#include <string>
28
29class GMenu2X;
30class OffscreenSurface;
31
32
33/**
34Base class that represents a link on screen.
35
36    @author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
37*/
38class Link {
39public:
40    typedef std::function<void(void)> Action;
41
42    Link(GMenu2X& gmenu2x, Action action);
43    virtual ~Link() {};
44
45    virtual void paint();
46    void paintHover();
47
48    virtual void loadIcon();
49
50    void setSize(int w, int h);
51    void setPosition(int x, int y);
52
53    const std::string &getTitle();
54    void setTitle(const std::string &title);
55    const std::string &getDescription();
56    void setDescription(const std::string &description);
57    const std::string &getLaunchMsg();
58    const std::string &getIcon();
59    void setIcon(const std::string &icon);
60    const std::string &getIconPath();
61
62    void run();
63
64protected:
65    GMenu2X& gmenu2x;
66    bool edited;
67    std::string title, description, launchMsg, icon, iconPath;
68
69    OffscreenSurface *iconSurface;
70
71    virtual const std::string &searchIcon();
72    void setIconPath(const std::string &icon);
73    void updateSurfaces();
74
75private:
76    void recalcCoordinates();
77
78    Action action;
79
80    SDL_Rect rect;
81    uint iconX, padding;
82    int lastTick;
83};
84
85#endif
86

Archive Download this file



interactive