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_application.h"
00027 #include "wg_groupbox.h"
00028
00029
00030 namespace wGui
00031 {
00032
00033 CGroupBox::CGroupBox(const CRect& WindowRect, CWindow* pParent, std::wstring sText, CRGBColor& FontColor, CFontEngine* pFontEngine) :
00034 CWindow(WindowRect, pParent),
00035 m_FontColor(FontColor)
00036 {
00037 m_sWindowText = sText;
00038 if (pFontEngine)
00039 {
00040 m_pFontEngine = pFontEngine;
00041 }
00042 else
00043 {
00044 m_pFontEngine = CApplication::Instance()->GetDefaultFontEngine();
00045 }
00046 m_ClientRect.Grow(-2);
00047 m_ClientRect.SetTop(15);
00048 std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(
00049 m_pFontEngine, sText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
00050 m_pRenderedString = pRenderedString;
00051 m_BackgroundColor = CApplication::Instance()->GetDefaultBackgroundColor();
00052 Draw();
00053 }
00054
00055
00056 CGroupBox::~CGroupBox(void)
00057 {
00058
00059 }
00060
00061
00062 void CGroupBox::Draw(void) const
00063 {
00064 CWindow::Draw();
00065
00066 if (m_pSDLSurface)
00067 {
00068 CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
00069 Painter.DrawRect(CRect(0, 5, m_WindowRect.Width() - 1, m_WindowRect.Height() - 5),
00070 false, DEFAULT_LINE_COLOR);
00071 CPoint Dims, Offset;
00072 m_pRenderedString->GetMetrics(&Dims, &Offset, 0);
00073 Painter.DrawRect(CRect(CPoint(6, 0), CPoint(14, 0) + Dims),
00074 true, m_BackgroundColor, m_BackgroundColor);
00075
00076 if (m_pRenderedString.get())
00077 {
00078 m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), CPoint(10, 0), m_FontColor);
00079 }
00080 }
00081 }
00082
00083
00084 void CGroupBox::SetWindowText(const std::wstring& sWindowText)
00085 {
00086 std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(
00087 m_pFontEngine, sWindowText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
00088 m_pRenderedString = pRenderedString;
00089 CWindow::SetWindowText(sWindowText);
00090 }
00091
00092
00093 void CGroupBox::SetWindowRect(const CRect& WindowRect)
00094 {
00095 CWindow::SetWindowRect(WindowRect);
00096 m_ClientRect = m_WindowRect.SizeRect();
00097 m_ClientRect.Grow(-2);
00098 m_ClientRect.SetTop(15);
00099 }
00100
00101 }
00102
00103
00104
00105