1. wxColourScheme used by Win32 renderer
2. wxScrollBar half implemented (drawing only) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8148 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
#include "wx/dc.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/image.h"
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
|
||||
// ============================================================================
|
||||
@@ -63,38 +65,15 @@ wxControlRenderer::wxControlRenderer(wxControl *control,
|
||||
m_rect.height = size.y;
|
||||
}
|
||||
|
||||
int wxControlRenderer::GetStateFlags() const
|
||||
{
|
||||
int flags = 0;
|
||||
if ( m_ctrl->IsEnabled() )
|
||||
flags |= wxRENDER_ENABLED;
|
||||
|
||||
// the following states are only possible if our application is active - if
|
||||
// it is not, even our default/focused controls shouldn't appear as such
|
||||
if ( wxTheApp->IsActive() )
|
||||
{
|
||||
if ( m_ctrl->IsCurrent() )
|
||||
flags |= wxRENDER_CURRENT;
|
||||
if ( m_ctrl->IsFocused() )
|
||||
flags |= wxRENDER_FOCUSED;
|
||||
if ( m_ctrl->IsPressed() )
|
||||
flags |= wxRENDER_PRESSED;
|
||||
if ( m_ctrl->IsDefault() )
|
||||
flags |= wxRENDER_DEFAULT;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBorder()
|
||||
{
|
||||
int flags = GetStateFlags();
|
||||
int flags = m_ctrl->GetStateFlags();
|
||||
|
||||
// draw outline
|
||||
m_renderer->DrawBorder(m_dc, m_ctrl->GetBorder(),
|
||||
m_rect, flags, &m_rect);
|
||||
|
||||
// fill the inside
|
||||
// fill the inside (TODO: query the theme for bg bitmap)
|
||||
m_renderer->DrawBackground(m_dc,
|
||||
m_ctrl->GetBackgroundColour(), m_rect, flags);
|
||||
}
|
||||
@@ -104,18 +83,10 @@ void wxControlRenderer::DrawLabel()
|
||||
m_dc.SetFont(m_ctrl->GetFont());
|
||||
m_dc.SetTextForeground(m_ctrl->GetForegroundColour());
|
||||
|
||||
// shift the label if a button is pressed
|
||||
wxRect rectLabel = m_rect;
|
||||
if ( GetStateFlags() & wxRENDER_PRESSED )
|
||||
{
|
||||
rectLabel.x++;
|
||||
rectLabel.y++;
|
||||
}
|
||||
|
||||
m_renderer->DrawLabel(m_dc,
|
||||
m_ctrl->GetLabel(),
|
||||
rectLabel,
|
||||
GetStateFlags(),
|
||||
m_rect,
|
||||
m_ctrl->GetStateFlags(),
|
||||
m_ctrl->GetAlignment(),
|
||||
m_ctrl->GetAccelIndex());
|
||||
}
|
||||
@@ -129,17 +100,90 @@ void wxControlRenderer::DrawFrame()
|
||||
m_renderer->DrawFrame(m_dc,
|
||||
m_ctrl->GetLabel(),
|
||||
m_rect,
|
||||
GetStateFlags(),
|
||||
m_ctrl->GetStateFlags(),
|
||||
m_ctrl->GetAlignment(),
|
||||
m_ctrl->GetAccelIndex());
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawButtonBorder()
|
||||
{
|
||||
int flags = GetStateFlags();
|
||||
int flags = m_ctrl->GetStateFlags();
|
||||
|
||||
m_renderer->DrawButtonBorder(m_dc, m_rect, flags, &m_rect);
|
||||
|
||||
m_renderer->DrawBackground(m_dc, m_ctrl->GetBackgroundColour(),
|
||||
m_rect, flags);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBackgroundBitmap()
|
||||
{
|
||||
// get the bitmap and the flags
|
||||
int alignment;
|
||||
wxStretch stretch;
|
||||
wxBitmap bmp = m_ctrl->GetBackgroundBitmap(&alignment, &stretch);
|
||||
if ( !bmp.Ok() )
|
||||
return;
|
||||
|
||||
int width = bmp.GetWidth(),
|
||||
height = bmp.GetHeight();
|
||||
|
||||
wxCoord x = 0,
|
||||
y = 0;
|
||||
if ( stretch & wxTILE )
|
||||
{
|
||||
// tile the bitmap
|
||||
for ( ; x < m_rect.width; x += width )
|
||||
{
|
||||
for ( y = 0; y < m_rect.height; y += height )
|
||||
{
|
||||
m_dc.DrawBitmap(bmp, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( stretch & wxEXPAND )
|
||||
{
|
||||
// stretch bitmap to fill the entire control
|
||||
bmp = wxImage(bmp).Scale(m_rect.width, m_rect.height).ConvertToBitmap();
|
||||
}
|
||||
else // not stretched, not tiled
|
||||
{
|
||||
if ( alignment & wxALIGN_RIGHT )
|
||||
{
|
||||
x = m_rect.GetRight() - width;
|
||||
}
|
||||
else if ( alignment & wxALIGN_CENTRE )
|
||||
{
|
||||
x = (m_rect.GetLeft() + m_rect.GetRight() - width) / 2;
|
||||
}
|
||||
else // alignment & wxALIGN_LEFT
|
||||
{
|
||||
x = m_rect.GetLeft();
|
||||
}
|
||||
|
||||
if ( alignment & wxALIGN_BOTTOM )
|
||||
{
|
||||
y = m_rect.GetBottom() - height;
|
||||
}
|
||||
else if ( alignment & wxALIGN_CENTRE_VERTICAL )
|
||||
{
|
||||
y = (m_rect.GetTop() + m_rect.GetBottom() - height) / 2;
|
||||
}
|
||||
else // alignment & wxALIGN_TOP
|
||||
{
|
||||
y = m_rect.GetTop();
|
||||
}
|
||||
}
|
||||
|
||||
// do draw it
|
||||
m_dc.DrawBitmap(bmp, x, y);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawScrollbar(int thumbStart, int thumbEnd)
|
||||
{
|
||||
m_renderer->DrawScrollbar(m_dc,
|
||||
m_ctrl->GetWindowStyle() & wxVERTICAL
|
||||
? wxVERTICAL
|
||||
: wxHORIZONTAL,
|
||||
thumbStart, thumbEnd, m_rect,
|
||||
m_ctrl->GetStateFlags());
|
||||
}
|
||||
|
Reference in New Issue
Block a user