Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

RadioBox.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "RadioBox.h"
00010 
00011 #include "WiPicture.h"
00012 #include "OptionAgent.h"
00013 #include "MouseStroke.h"
00014 
00015 //-----------------------------------------------------------------
00016 RadioBox::RadioBox(const std::string &param, const std::string &value,
00017         const Path &picture)
00018 : WiContainer(new WiPicture(picture), BORDER), m_param(param), m_value(value)
00019 {
00020 }
00021 //-----------------------------------------------------------------
00022 /**
00023  * Draw border for selected button.
00024  */
00025     void
00026 RadioBox::drawOn(SDL_Surface *screen)
00027 {
00028     if (OptionAgent::agent()->getParam(m_param) == m_value) {
00029         SDL_Rect rect;
00030         rect.x = m_shift.getX();
00031         rect.y = m_shift.getY();
00032         rect.w = getW();
00033         rect.h = getH();
00034 
00035         Uint32 green = SDL_MapRGB(screen->format, 0x00, 0xff, 0x00);
00036         SDL_FillRect(screen, &rect, green);
00037     }
00038     WiContainer::drawOn(screen);
00039 }
00040 //-----------------------------------------------------------------
00041 /**
00042  * Select button and set param=value.
00043  */
00044     void
00045 RadioBox::own_mouseButton(const MouseStroke &stroke)
00046 {
00047     if (stroke.isLeft()) {
00048         OptionAgent::agent()->setPersistent(m_param, m_value);
00049     }
00050 }
00051 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2