Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

checkbox_default.cpp

Go to the documentation of this file.
00001 /*
00002         ClanGUI, copyrights by various people. Have a look in the CREDITS file.
00003         
00004         This sourcecode is distributed using the Library GNU Public Licence,
00005         version 2 or (at your option) any later version. Please read LICENSE
00006         for details.
00007 */
00008 
00009 #include "precomp.h"
00010 #include <stdio.h>
00011 #include "API/Display/Display/surface.h"
00012 #include "API/Core/Resources/resource_manager.h"
00013 #include "API/Display/Font/font.h"
00014 #include "checkbox_default.h"
00015 
00016 CL_CheckBox_Default::CL_CheckBox_Default(
00017         CL_CheckBox *_checkbox,
00018         const CL_ComponentOptions &options,
00019         CL_StyleManager_Default *style) : CL_ComponentStyle(_checkbox), checkbox(_checkbox)
00020 {
00021         this->style = style;
00022         resources = style->get_resources();
00023         sur_checked = CL_Surface::load("CheckBox/sur_checked", resources);
00024         sur_unchecked = CL_Surface::load("CheckBox/sur_unchecked", resources);
00025         sur_disabled = CL_Surface::load("CheckBox/sur_disabled", resources);
00026         font = CL_Font::load("CheckBox/font", resources);
00027 
00028         slot_paint = checkbox->sig_paint().connect(CL_CreateSlot(this, &CL_CheckBox_Default::on_paint));
00029 
00030         int width = sur_checked->get_width();
00031         int height = sur_checked->get_height();
00032         if (checkbox->get_text().length() > 0)
00033                 width += 4 + font->get_text_width(checkbox->get_text().c_str());
00034         checkbox->set_width(width);
00035         checkbox->set_height(height);
00036 }
00037 
00038 CL_CheckBox_Default::~CL_CheckBox_Default()
00039 {
00040 /*      delete font;
00041         delete sur_checked;
00042         delete sur_unchecked;
00043         delete sur_disabled;
00044 */
00045 }
00046 
00047 void CL_CheckBox_Default::on_paint()
00048 {
00049         CL_Surface *show_surface = sur_disabled;
00050 
00051         if (checkbox->is_enabled())
00052         {
00053                 if (checkbox->is_checked())
00054                         show_surface = sur_checked;
00055                 else
00056                         show_surface = sur_unchecked;
00057         }
00058 
00059         show_surface->put_screen(0, 0);
00060         if (checkbox->get_text().length() > 0)
00061                 font->print_left(4 + show_surface->get_width(), 0, checkbox->get_text().c_str());
00062 }

Generated at Wed Apr 4 19:53:59 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001