made ProvideBackground() const

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-09-21 20:38:05 +00:00
parent a34d639546
commit ad2e39c11d
4 changed files with 36 additions and 35 deletions

View File

@@ -83,7 +83,7 @@ public:
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__
virtual bool IsCanvasWindow() const { return TRUE; } virtual bool IsCanvasWindow() const { return TRUE; }
virtual bool ProvidesBackground() { return TRUE; } virtual bool ProvidesBackground() const { return TRUE; }
#endif #endif
WX_DECLARE_CONTROL_CONTAINER(); WX_DECLARE_CONTROL_CONTAINER();

View File

@@ -143,7 +143,7 @@ public:
virtual int GetMinWidth() const; virtual int GetMinWidth() const;
virtual int GetMinHeight() const; virtual int GetMinHeight() const;
virtual bool ProvidesBackground() { return TRUE; } virtual bool ProvidesBackground() const { return TRUE; }
protected: protected:
// handle titlebar button click event // handle titlebar button click event

View File

@@ -179,7 +179,7 @@ public:
// to be used with function above: transparent windows get // to be used with function above: transparent windows get
// their background from parents that return TRUE here, // their background from parents that return TRUE here,
// so this is mostly for wxPanel, wxTopLevelWindow etc. // so this is mostly for wxPanel, wxTopLevelWindow etc.
virtual bool ProvidesBackground() { return FALSE; } virtual bool ProvidesBackground() const { return FALSE; }
// return TRUE if this control can be highlighted when the mouse is over // return TRUE if this control can be highlighted when the mouse is over
// it (the theme decides itself whether it is really highlighted or not) // it (the theme decides itself whether it is really highlighted or not)

View File

@@ -109,7 +109,7 @@ void wxWindow::Init()
m_isCurrent = FALSE; m_isCurrent = FALSE;
m_renderer = wxTheme::Get()->GetRenderer(); m_renderer = wxTheme::Get()->GetRenderer();
m_oldSize.x = -1; m_oldSize.x = -1;
m_oldSize.y = -1; m_oldSize.y = -1;
} }
@@ -240,7 +240,7 @@ void wxWindow::OnErase(wxEraseEvent& event)
return; return;
} }
DoDrawBackground(*event.GetDC()); DoDrawBackground(*event.GetDC());
// if we have both scrollbars, we also have a square in the corner between // if we have both scrollbars, we also have a square in the corner between
@@ -267,41 +267,42 @@ void wxWindow::OnErase(wxEraseEvent& event)
bool wxWindow::DoDrawBackground(wxDC& dc) bool wxWindow::DoDrawBackground(wxDC& dc)
{ {
wxRect rect; wxRect rect;
wxSize size = GetSize(); // Why not GetClientSize() ? wxSize size = GetSize(); // Why not GetClientSize() ?
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
rect.width = size.x; rect.width = size.x;
rect.height = size.y; rect.height = size.y;
if (HasTransparentBackground() && GetParent() && GetParent()->ProvidesBackground()) wxWindow * const parent = GetParent();
if ( HasTransparentBackground() && parent && parent->ProvidesBackground() )
{ {
wxASSERT( !IsTopLevel() ); wxASSERT( !IsTopLevel() );
wxPoint pos = GetPosition(); wxPoint pos = GetPosition();
AdjustForParentClientOrigin( pos.x, pos.y, 0 ); AdjustForParentClientOrigin( pos.x, pos.y, 0 );
// Adjust DC logical origin // Adjust DC logical origin
wxCoord x,y; wxCoord x,y;
dc.GetLogicalOrigin( &x, &y ); dc.GetLogicalOrigin( &x, &y );
x += pos.x; x += pos.x;
y += pos.y; y += pos.y;
dc.SetLogicalOrigin( x, y ); dc.SetLogicalOrigin( x, y );
// Adjust draw rect // Adjust draw rect
rect.x = pos.x; rect.x = pos.x;
rect.y = pos.y; rect.y = pos.y;
// Let parent draw the background // Let parent draw the background
GetParent()->EraseBackground( dc, rect ); parent->EraseBackground( dc, rect );
} }
else else
{ {
// Draw background ouselves // Draw background ouselves
EraseBackground( dc, rect ); EraseBackground( dc, rect );
} }
return TRUE; return TRUE;
} }
@@ -315,10 +316,10 @@ void wxWindow::EraseBackground(wxDC& dc, const wxRect& rect)
wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch); wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch); wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
} }
else else
{ {
// Just fill it with bg colour if no bitmap // Just fill it with bg colour if no bitmap
m_renderer->DrawBackground(dc, wxTHEME_BG_COLOUR(this), m_renderer->DrawBackground(dc, wxTHEME_BG_COLOUR(this),
rect, GetStateFlags()); rect, GetStateFlags());
} }
@@ -478,28 +479,28 @@ int wxWindow::GetStateFlags() const
void wxWindow::OnSize(wxSizeEvent& event) void wxWindow::OnSize(wxSizeEvent& event)
{ {
event.Skip(); event.Skip();
if ( m_scrollbarVert || m_scrollbarHorz ) if ( m_scrollbarVert || m_scrollbarHorz )
{ {
PositionScrollbars(); PositionScrollbars();
} }
#if 0 // ndef __WXMSW__ #if 0 // ndef __WXMSW__
// Refresh the area (strip) previously occupied by the border // Refresh the area (strip) previously occupied by the border
if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) && IsShown()) if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) && IsShown())
{ {
// This code assumes that wxSizeEvent.GetSize() returns // This code assumes that wxSizeEvent.GetSize() returns
// the area of the entire window, not just the client // the area of the entire window, not just the client
// area. // area.
wxSize newSize = event.GetSize(); wxSize newSize = event.GetSize();
if (m_oldSize.x == -1 && m_oldSize.y == -1) if (m_oldSize.x == -1 && m_oldSize.y == -1)
{ {
m_oldSize = newSize; m_oldSize = newSize;
return; return;
} }
if (HasFlag( wxSIMPLE_BORDER )) if (HasFlag( wxSIMPLE_BORDER ))
{ {
if (newSize.y > m_oldSize.y) if (newSize.y > m_oldSize.y)
@@ -520,7 +521,7 @@ void wxWindow::OnSize(wxSizeEvent& event)
rect.width = newSize.x; rect.width = newSize.x;
wxWindowNative::Refresh( TRUE, &rect ); wxWindowNative::Refresh( TRUE, &rect );
} }
if (newSize.x > m_oldSize.x) if (newSize.x > m_oldSize.x)
{ {
wxRect rect; wxRect rect;
@@ -561,7 +562,7 @@ void wxWindow::OnSize(wxSizeEvent& event)
rect.width = newSize.x; rect.width = newSize.x;
wxWindowNative::Refresh( TRUE, &rect ); wxWindowNative::Refresh( TRUE, &rect );
} }
if (newSize.x > m_oldSize.x) if (newSize.x > m_oldSize.x)
{ {
wxRect rect; wxRect rect;
@@ -581,7 +582,7 @@ void wxWindow::OnSize(wxSizeEvent& event)
wxWindowNative::Refresh( TRUE, &rect ); wxWindowNative::Refresh( TRUE, &rect );
} }
} }
m_oldSize = newSize; m_oldSize = newSize;
} }
#endif #endif
@@ -915,7 +916,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
wxWindowNative::ScrollWindow(dx, dy, rect); wxWindowNative::ScrollWindow(dx, dy, rect);
#else #else // !wxX11
// before scrolling it, ensure that we don't have any unpainted areas // before scrolling it, ensure that we don't have any unpainted areas
Update(); Update();
@@ -933,11 +934,11 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
r = ScrollNoRefresh(0, dy, rect); r = ScrollNoRefresh(0, dy, rect);
Refresh(TRUE /* erase bkgnd */, &r); Refresh(TRUE /* erase bkgnd */, &r);
} }
// scroll children accordingly: // scroll children accordingly:
wxPoint offset(dx, dy); wxPoint offset(dx, dy);
for (wxWindowList::Node *node = GetChildren().GetFirst(); for (wxWindowList::Node *node = GetChildren().GetFirst();
node; node = node->GetNext()) node; node = node->GetNext())
{ {
wxWindow *child = node->GetData(); wxWindow *child = node->GetData();
@@ -945,13 +946,13 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
continue; continue;
// VS: Scrolling children has non-trivial semantics. If rect=NULL then // VS: Scrolling children has non-trivial semantics. If rect=NULL then
// it is easy: we scroll all children. Otherwise it gets // it is easy: we scroll all children. Otherwise it gets
// complicated: // complicated:
// 1. if scrolling in one direction only, scroll only // 1. if scrolling in one direction only, scroll only
// those children that intersect shaft defined by the rectangle // those children that intersect shaft defined by the rectangle
// and scrolling direction // and scrolling direction
// 2. if scrolling in both axes, scroll all children // 2. if scrolling in both axes, scroll all children
if ( rect && (dx * dy == 0 /* moving in only one of x, y axis */) ) if ( rect && (dx * dy == 0 /* moving in only one of x, y axis */) )
{ {
wxRect childRect = child->GetRect(); wxRect childRect = child->GetRect();
@@ -970,8 +971,8 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
{ {
child->Move(child->GetPosition() + offset); child->Move(child->GetPosition() + offset);
} }
} }
#endif #endif // wxX11/!wxX11
} }
wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal) wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal)