wg_label.cpp

00001 // wg_label.cpp
00002 //
00003 // CLabel class implementation
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 

Generated on Wed May 16 23:11:25 2007 for wGui by  doxygen 1.5.1