git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43982 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
103 lines
2.9 KiB
C++
103 lines
2.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: src/univ/stattext.cpp
|
|
// Purpose: wxStaticText
|
|
// Author: Vadim Zeitlin
|
|
// Modified by:
|
|
// Created: 14.08.00
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ============================================================================
|
|
// declarations
|
|
// ============================================================================
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// headers
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#if wxUSE_STATTEXT
|
|
|
|
#include "wx/stattext.h"
|
|
|
|
#ifndef WX_PRECOMP
|
|
#include "wx/dcclient.h"
|
|
#include "wx/validate.h"
|
|
#endif
|
|
|
|
#include "wx/univ/renderer.h"
|
|
#include "wx/univ/theme.h"
|
|
|
|
// ============================================================================
|
|
// implementation
|
|
// ============================================================================
|
|
|
|
IMPLEMENT_ABSTRACT_CLASS(wxStaticText, wxControl)
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// creation
|
|
// ----------------------------------------------------------------------------
|
|
|
|
bool wxStaticText::Create(wxWindow *parent,
|
|
wxWindowID id,
|
|
const wxString &label,
|
|
const wxPoint &pos,
|
|
const wxSize &size,
|
|
long style,
|
|
const wxString &name)
|
|
{
|
|
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
|
return false;
|
|
|
|
SetLabel(label);
|
|
SetInitialSize(size);
|
|
|
|
return true;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// size management
|
|
// ----------------------------------------------------------------------------
|
|
|
|
void wxStaticText::SetLabel(const wxString& label)
|
|
{
|
|
wxControl::SetLabel(label);
|
|
}
|
|
|
|
wxSize wxStaticText::DoGetBestClientSize() const
|
|
{
|
|
wxStaticText *self = wxConstCast(this, wxStaticText);
|
|
wxClientDC dc(self);
|
|
dc.SetFont(GetFont());
|
|
wxCoord width, height;
|
|
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
|
|
|
|
return wxSize(width, height);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// drawing
|
|
// ----------------------------------------------------------------------------
|
|
|
|
void wxStaticText::DoDraw(wxControlRenderer *renderer)
|
|
{
|
|
if ( UseBgCol() )
|
|
{
|
|
wxDC& dc = renderer->GetDC();
|
|
dc.SetBrush(GetBackgroundColour());
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
dc.DrawRectangle(renderer->GetRect());
|
|
}
|
|
|
|
renderer->DrawLabel();
|
|
}
|
|
|
|
#endif // wxUSE_STATTEXT
|