00001
00002
00003
00004
00005
00006
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
00039 style->draw_rect(0, 0, width, height, GUICOLOR_DARK_OUTLINE);
00040
00041
00042 style->draw_box(1, 1, width - 1 , height - 1, GUICOLOR_DARK_SHADE, GUICOLOR_BRIGHT_SHADE);
00043
00044
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
00051
00052 }