00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "wgui_include_config.h"
00026 #include "wg_label.h"
00027
00028
00029 namespace wGui
00030 {
00031
00032 CLabel::CLabel(const CRect& WindowRect, CWindow* pParent, std::wstring sText, CRGBColor& FontColor, CFontEngine* pFontEngine) :
00033 CWindow(WindowRect, pParent),
00034 m_FontColor(FontColor)
00035 {
00036 m_sWindowText = sText;
00037 if (pFontEngine)
00038 {
00039 m_pFontEngine = pFontEngine;
00040 }
00041 else
00042 {
00043 m_pFontEngine = CApplication::Instance()->GetDefaultFontEngine();
00044 }
00045 std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(
00046 m_pFontEngine, sText, CRenderedString::VALIGN_BOTTOM, CRenderedString::HALIGN_LEFT));
00047 m_pRenderedString = pRenderedString;
00048 m_BackgroundColor = CApplication::Instance()->GetDefaultBackgroundColor();
00049 Draw();
00050 }
00051
00052
00053 void CLabel::Draw(void) const
00054 {
00055 CWindow::Draw();
00056
00057 if (m_pSDLSurface && m_pRenderedString.get())
00058 {
00059 m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), m_WindowRect.SizeRect().BottomLeft(), m_FontColor);
00060 }
00061 }
00062
00063
00064 void CLabel::SetWindowText(const std::wstring& sWindowText)
00065 {
00066 std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(
00067 m_pFontEngine, sWindowText, CRenderedString::VALIGN_BOTTOM, CRenderedString::HALIGN_LEFT));
00068 m_pRenderedString = pRenderedString;
00069 CWindow::SetWindowText(sWindowText);
00070 }
00071
00072 }
00073
00074
00075