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

label.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 <string>
00011 #include <stdlib.h>
00012 #include "../API/GUI/label.h"
00013 #include "../API/GUI/component_options.h"
00014 #include "../API/GUI/stylemanager.h"
00015 #include "label_generic.h"
00016 
00018 // Construction:
00019 
00020 CL_Label::CL_Label(
00021         const CL_ComponentOptions &options,
00022         CL_Component *parent,
00023         CL_StyleManager *style)
00024 :
00025         CL_Component(options, parent, style),
00026         impl(NULL)
00027 {
00028         impl = new CL_Label_Generic(this, options, get_style_manager());
00029         get_style_manager()->connect_styles("label", options, this);
00030 }
00031 
00032 CL_Label::CL_Label(
00033         const CL_Point &pos,
00034         const std::string &text,
00035         CL_Component *parent,
00036         CL_StyleManager *style)
00037 :
00038         CL_Component(
00039                 CL_Label_Generic::create_options(CL_Rect(pos.x, pos.y, 0, 0), text),
00040                 parent,
00041                 style),
00042         impl(NULL)
00043 {
00044         CL_Rect rect(pos.x, pos.y, 0, 0);
00045         CL_ComponentOptions options = CL_Label_Generic::create_options(rect, text);
00046         impl = new CL_Label_Generic(this, options, get_style_manager());
00047         get_style_manager()->connect_styles("label", options, this);
00048 }
00049 
00050 CL_Label::CL_Label(
00051         const CL_Rect &pos,
00052         const std::string &text,
00053         CL_Component *parent,
00054         CL_StyleManager *style)
00055 :
00056         CL_Component(
00057                 CL_Label_Generic::create_options(pos, text),
00058                 parent,
00059                 style),
00060         impl(NULL)
00061 {
00062         CL_ComponentOptions options = CL_Label_Generic::create_options(pos, text);
00063         impl = new CL_Label_Generic(this, options, get_style_manager());
00064         get_style_manager()->connect_styles("label", options, this);
00065 }
00066 
00067 CL_Label::~CL_Label()
00068 {
00069         delete impl;
00070 }
00071 
00073 // Attributes:
00074 
00075 const std::string &CL_Label::get_text() const
00076 {
00077         return impl->text;
00078 }
00079 
00080 int CL_Label::get_alignment() const
00081 {
00082         return impl->alignment;
00083 }
00084 
00086 // Operations:
00087 
00088 void CL_Label::set_text(const std::string &text)
00089 {
00090         impl->text = text;
00091 }
00092 
00093 void CL_Label::set_text(int number)
00094 {
00095         char buf[20];
00096         sprintf(buf, "%d", number);
00097         impl->text = buf;
00098 }
00099 
00100 void CL_Label::set_text(double number)
00101 {
00102         char buf[20];
00103         sprintf(buf, "%f", number);
00104         impl->text = buf;
00105 }
00106 
00107 void CL_Label::clear()
00108 {
00109         impl->text = "";
00110 }
00111 
00112 void CL_Label::set_alignment(int alignment)
00113 {
00114         impl->alignment = alignment;
00115 }
00116 
00118 // Signals:

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