Root/src/menusettingstringbase.cpp

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#include "menusettingstringbase.h"
21#include "gmenu2x.h"
22
23using std::string;
24
25MenuSettingStringBase::MenuSettingStringBase(
26        GMenu2X *gmenu2x, const string &name,
27        const string &description, string *value)
28    : MenuSetting(gmenu2x, name, description)
29    , originalValue(*value)
30    , _value(value)
31{
32}
33
34MenuSettingStringBase::~MenuSettingStringBase()
35{
36}
37
38void MenuSettingStringBase::draw(int y)
39{
40    MenuSetting::draw(y);
41    gmenu2x->s->write(gmenu2x->font, value(), 155, y,
42            ASFont::HAlignLeft, ASFont::VAlignTop);
43}
44
45void MenuSettingStringBase::manageInput(bevent_t *event)
46{
47    switch (event->button) {
48        case CLEAR:
49            clear();
50            break;
51        case ACCEPT:
52            edit();
53            break;
54        default:
55            break;
56    }
57}
58
59void MenuSettingStringBase::clear()
60{
61    setValue("");
62}
63
64bool MenuSettingStringBase::edited()
65{
66    return originalValue != value();
67}
68

Archive Download this file



interactive