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 "API/Display/Font/font.h" 00011 #include "API/Core/Resources/resource_manager.h" 00012 #include "label_default.h" 00013 00014 CL_Label_Default::CL_Label_Default( 00015 CL_Label *_label, 00016 const CL_ComponentOptions &options, 00017 CL_StyleManager_Default *style) 00018 : CL_ComponentStyle(_label), label(_label) 00019 { 00020 this->style = style; 00021 00022 resources = style->get_resources(); 00023 font = CL_Font::load("Label/font", resources); 00024 00025 slot_paint = label->sig_paint().connect(CL_CreateSlot(this, &CL_Label_Default::on_paint)); 00026 } 00027 00028 CL_Label_Default::~CL_Label_Default() 00029 { 00030 // resources->get_resource("Label/font")->unload(); 00031 } 00032 00033 void CL_Label_Default::on_paint() 00034 { 00035 int x = 0; 00036 int y = 0; 00037 const char *text = label->get_text().c_str(); 00038 00039 if(label->get_alignment()) 00040 { 00041 x = (label->get_width() - font->get_text_width(text)) / 2; 00042 } 00043 00044 font->print_left(x, y, text); 00045 }
1.2.6 written by Dimitri van Heesch,
© 1997-2001