1. wxStaticText, wxStaticBox, wxButton drawing implemented
2. "pseudo dynamic" wxTheme creation 3. hack to solve GetBestSize() problem 4. more methods in wxDC:: GetMultiLineTextExtent(), DrawLabel() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
126
src/univ/button.cpp
Normal file
126
src/univ/button.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: univ/button.cpp
|
||||
// Purpose: wxButton
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 14.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "univbutton.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATTEXT
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/validate.h"
|
||||
#endif
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxButton::Init()
|
||||
{
|
||||
m_isPressed =
|
||||
m_isDefault = FALSE;
|
||||
}
|
||||
|
||||
bool wxButton::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString &label,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString &name)
|
||||
{
|
||||
// center label by default
|
||||
if ( !(style & wxALIGN_MASK) )
|
||||
{
|
||||
style |= wxALIGN_CENTRE | wxALIGN_CENTRE_VERTICAL;
|
||||
}
|
||||
|
||||
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||
return FALSE;
|
||||
|
||||
SetLabel(label);
|
||||
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeBest = DoGetBestSize();
|
||||
SetSize(size.x == -1 ? sizeBest.x : size.x,
|
||||
size.y == -1 ? sizeBest.y : size.y);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxButton::~wxButton()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// size management
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxSize wxButton::DoGetBestSize() const
|
||||
{
|
||||
wxClientDC dc(wxConstCast(this, wxButton));
|
||||
wxCoord width, height;
|
||||
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
|
||||
|
||||
wxSize sz(width, height);
|
||||
wxTheme::Get()->GetRenderer()->AdjustSize(&sz, this);
|
||||
return sz;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxButton::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
renderer->DrawButtonBorder();
|
||||
renderer->DrawLabel();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxButton::SetDefault()
|
||||
{
|
||||
m_isDefault = TRUE;
|
||||
}
|
||||
|
||||
#endif // wxUSE_STATTEXT
|
||||
|
Reference in New Issue
Block a user