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

scrollbar_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 "scrollbar_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_ScrollBar_Default::CL_ScrollBar_Default(
00016         CL_ScrollBar *_scrollbar,
00017         const CL_ComponentOptions &options,
00018         CL_StyleManager_Default *style)
00019 :
00020         CL_ComponentStyle(_scrollbar),
00021         scrollbar(_scrollbar)
00022 {
00023         this->style = style;
00024         resources = style->get_resources();
00025 
00026         CL_Rect rect_decrease;
00027         CL_Rect rect_increase;
00028         CL_Rect rect_scroll = scrollbar->get_position();
00029 
00030         CL_Component *client_area = scrollbar->get_client_area();
00031 
00032         if (scrollbar->is_vertical())
00033         {
00034                 int button_size = scrollbar->get_width();
00035                 rect_decrease = CL_Rect(0, 0, button_size, button_size);
00036                 rect_increase = CL_Rect(0, scrollbar->get_height() - button_size, button_size, scrollbar->get_height());
00037         }
00038         else
00039         {
00040                 int button_size = scrollbar->get_height();
00041                 rect_decrease = CL_Rect(0, 0, button_size, button_size);
00042                 rect_increase = CL_Rect(scrollbar->get_width() - button_size, 0, scrollbar->get_width(), button_size);
00043         }
00044 
00045         button_increase = new CL_Button(rect_increase, "", scrollbar, style);
00046         button_decrease = new CL_Button(rect_decrease, "", scrollbar, style);
00047 
00048         slot_paint = client_area->sig_paint().connect(CL_CreateSlot(this, &CL_ScrollBar_Default::on_paint));
00049         slot_increase = button_increase->sig_clicked().connect(CL_CreateSlot(this, &CL_ScrollBar_Default::on_increase));
00050         slot_decrease = button_decrease->sig_clicked().connect(CL_CreateSlot(this, &CL_ScrollBar_Default::on_decrease));
00051 }
00052 
00053 CL_ScrollBar_Default::~CL_ScrollBar_Default()
00054 {
00055 }
00056 
00057 void CL_ScrollBar_Default::on_increase()
00058 {
00059         scrollbar->increase();
00060 }
00061 
00062 void CL_ScrollBar_Default::on_decrease()
00063 {
00064         scrollbar->decrease();
00065 }
00066 
00067 void CL_ScrollBar_Default::on_paint()
00068 {
00069         int width = scrollbar->get_client_area()->get_width();
00070         int height = scrollbar->get_client_area()->get_height();
00071 
00072         CL_Rect rect = scrollbar->get_slider_rect();
00073 
00074         // Background
00075         // TODO: Split this into two parts (at the sides of the slider)
00076         style->fill_rect(
00077                 0, 0,
00078                 width, height,
00079                 GUICOLOR_SCROLLBAR);
00080 
00081         // Slider
00082         style->fill_rect(
00083                 rect.x1 + 2,
00084                 rect.y1 + 2,
00085                 rect.x2 - 2,
00086                 rect.y2 - 2,
00087                 GUICOLOR_WHITE);
00088 
00089         style->draw_rect(
00090                 rect.x1 + 1,
00091                 rect.y1 + 1,
00092                 rect.x2 - 1,
00093                 rect.y2 - 1, 
00094                 GUICOLOR_DARK_OUTLINE);
00095 }

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