| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "RadioBox.h" |
| 10 |
|
| 11 |
#include "WiPicture.h" |
| 12 |
#include "OptionAgent.h" |
| 13 |
#include "MouseStroke.h" |
| 14 |
|
| 15 |
//----------------------------------------------------------------- |
| 16 |
RadioBox::RadioBox(const std::string ¶m, const std::string &value, |
| 17 |
const Path &picture) |
| 18 |
: WiContainer(new WiPicture(picture), BORDER), m_param(param), m_value(value) |
| 19 |
{ |
| 20 |
} |
| 21 |
//----------------------------------------------------------------- |
| 22 |
/** |
| 23 |
* Draw border for selected button. |
| 24 |
*/ |
| 25 |
void |
| 26 |
RadioBox::drawOn(SDL_Surface *screen) |
| 27 |
{ |
| 28 |
if (OptionAgent::agent()->getParam(m_param) == m_value) { |
| 29 |
SDL_Rect rect; |
| 30 |
rect.x = m_shift.getX(); |
| 31 |
rect.y = m_shift.getY(); |
| 32 |
rect.w = getW(); |
| 33 |
rect.h = getH(); |
| 34 |
|
| 35 |
Uint32 green = SDL_MapRGB(screen->format, 0x00, 0xff, 0x00); |
| 36 |
SDL_FillRect(screen, &rect, green); |
| 37 |
} |
| 38 |
WiContainer::drawOn(screen); |
| 39 |
} |
| 40 |
//----------------------------------------------------------------- |
| 41 |
/** |
| 42 |
* Select button and set param=value. |
| 43 |
*/ |
| 44 |
void |
| 45 |
RadioBox::own_mouseButton(const MouseStroke &stroke) |
| 46 |
{ |
| 47 |
if (stroke.isLeft()) { |
| 48 |
OptionAgent::agent()->setPersistent(m_param, m_value); |
| 49 |
} |
| 50 |
} |
| 51 |
|