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

progressbar_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 "progressbar_default.h"
00011 #include "button_default.h"
00012 #include "API/Display/Display/surface.h"
00013 #include "API/Core/Resources/resource_manager.h"
00014 
00015 CL_ProgressBar_Default::CL_ProgressBar_Default(
00016         CL_ProgressBar *_progressbar,
00017         const CL_ComponentOptions &options,
00018         CL_StyleManager_Default *style)
00019 :
00020         CL_ComponentStyle(_progressbar),
00021         progressbar(_progressbar)
00022 {
00023         this->style = style;
00024 
00025         slot_paint = progressbar->sig_paint().connect(CL_CreateSlot(this, &CL_ProgressBar_Default::on_paint));
00026 }
00027 
00028 CL_ProgressBar_Default::~CL_ProgressBar_Default()
00029 {
00030 }
00031 
00032 void CL_ProgressBar_Default::on_paint()
00033 {
00034         int width = progressbar->get_width();
00035         int height = progressbar->get_height();
00036         float percent = progressbar->get_percentage();
00037 
00038         // Outline
00039         style->draw_rect(0, 0, width, height, GUICOLOR_DARK_OUTLINE);
00040 
00041         // Shade box
00042         style->draw_box(1, 1, width - 1 , height - 1, GUICOLOR_DARK_SHADE, GUICOLOR_BRIGHT_SHADE);
00043 
00044         // Fill
00045         int length = (width - 4) * percent;
00046 
00047         style->fill_rect(2, 2, 2 + length, height - 2, GUICOLOR_PROGRESSBAR_FILLED);
00048         style->fill_rect(2 + length, 2, width - 2, height - 2, GUICOLOR_PROGRESSBAR);
00049 
00050         // TODO: Write percentage in text
00051 //      font->print_left(...);
00052 }

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