SetBackgroundStyle(wxBG_STYLE_CUSTOM) can now be used to optimize
background erase on wxGTK (no-op on other platforms) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28954 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -80,6 +80,8 @@ public:
|
|||||||
virtual bool SetCursor( const wxCursor &cursor );
|
virtual bool SetCursor( const wxCursor &cursor );
|
||||||
virtual bool SetFont( const wxFont &font );
|
virtual bool SetFont( const wxFont &font );
|
||||||
|
|
||||||
|
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
|
||||||
|
|
||||||
virtual int GetCharHeight() const;
|
virtual int GetCharHeight() const;
|
||||||
virtual int GetCharWidth() const;
|
virtual int GetCharWidth() const;
|
||||||
virtual void GetTextExtent(const wxString& string,
|
virtual void GetTextExtent(const wxString& string,
|
||||||
@@ -238,6 +240,8 @@ public:
|
|||||||
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
|
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
|
||||||
// chain needs update
|
// chain needs update
|
||||||
#endif
|
#endif
|
||||||
|
bool m_needsStyleChange:1; // May not be able to change
|
||||||
|
// background style until OnIdle
|
||||||
|
|
||||||
// C++ has no virtual methods in the constrcutor of any class but we need
|
// C++ has no virtual methods in the constrcutor of any class but we need
|
||||||
// different methods of inserting a child window into a wxFrame,
|
// different methods of inserting a child window into a wxFrame,
|
||||||
|
@@ -80,6 +80,8 @@ public:
|
|||||||
virtual bool SetCursor( const wxCursor &cursor );
|
virtual bool SetCursor( const wxCursor &cursor );
|
||||||
virtual bool SetFont( const wxFont &font );
|
virtual bool SetFont( const wxFont &font );
|
||||||
|
|
||||||
|
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
|
||||||
|
|
||||||
virtual int GetCharHeight() const;
|
virtual int GetCharHeight() const;
|
||||||
virtual int GetCharWidth() const;
|
virtual int GetCharWidth() const;
|
||||||
virtual void GetTextExtent(const wxString& string,
|
virtual void GetTextExtent(const wxString& string,
|
||||||
@@ -238,6 +240,8 @@ public:
|
|||||||
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
|
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
|
||||||
// chain needs update
|
// chain needs update
|
||||||
#endif
|
#endif
|
||||||
|
bool m_needsStyleChange:1; // May not be able to change
|
||||||
|
// background style until OnIdle
|
||||||
|
|
||||||
// C++ has no virtual methods in the constrcutor of any class but we need
|
// C++ has no virtual methods in the constrcutor of any class but we need
|
||||||
// different methods of inserting a child window into a wxFrame,
|
// different methods of inserting a child window into a wxFrame,
|
||||||
|
@@ -632,7 +632,7 @@ static void gtk_window_draw_callback( GtkWidget *widget,
|
|||||||
#ifndef __WXUNIVERSAL__
|
#ifndef __WXUNIVERSAL__
|
||||||
GtkPizza *pizza = GTK_PIZZA (widget);
|
GtkPizza *pizza = GTK_PIZZA (widget);
|
||||||
|
|
||||||
if (win->GetThemeEnabled())
|
if (win->GetThemeEnabled() && win->GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
wxWindow *parent = win->GetParent();
|
wxWindow *parent = win->GetParent();
|
||||||
while (parent && !parent->IsTopLevel())
|
while (parent && !parent->IsTopLevel())
|
||||||
@@ -2646,6 +2646,8 @@ void wxWindowGTK::Init()
|
|||||||
|
|
||||||
m_clipPaintRegion = FALSE;
|
m_clipPaintRegion = FALSE;
|
||||||
|
|
||||||
|
m_needsStyleChange = false;
|
||||||
|
|
||||||
m_cursor = *wxSTANDARD_CURSOR;
|
m_cursor = *wxSTANDARD_CURSOR;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
@@ -3119,6 +3121,13 @@ void wxWindowGTK::OnInternalIdle()
|
|||||||
if ( m_dirtyTabOrder )
|
if ( m_dirtyTabOrder )
|
||||||
RealizeTabOrder();
|
RealizeTabOrder();
|
||||||
#endif
|
#endif
|
||||||
|
// Update style if the window was not yet realized
|
||||||
|
// and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called
|
||||||
|
if (m_needsStyleChange)
|
||||||
|
{
|
||||||
|
SetBackgroundStyle(GetBackgroundStyle());
|
||||||
|
m_needsStyleChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Update invalidated regions.
|
// Update invalidated regions.
|
||||||
GtkUpdate();
|
GtkUpdate();
|
||||||
@@ -3601,7 +3610,6 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
void wxWindowGTK::SetFocus()
|
void wxWindowGTK::SetFocus()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
||||||
|
|
||||||
if ( m_hasFocus )
|
if ( m_hasFocus )
|
||||||
{
|
{
|
||||||
// don't do anything if we already have focus
|
// don't do anything if we already have focus
|
||||||
@@ -3935,7 +3943,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
// widget to draw on
|
// widget to draw on
|
||||||
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
||||||
|
|
||||||
if (GetThemeEnabled())
|
if (GetThemeEnabled() && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
// find ancestor from which to steal background
|
// find ancestor from which to steal background
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
@@ -3989,7 +3997,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
wxEraseEvent erase_event( GetId(), &dc );
|
wxEraseEvent erase_event( GetId(), &dc );
|
||||||
erase_event.SetEventObject( this );
|
erase_event.SetEventObject( this );
|
||||||
|
|
||||||
if (!GetEventHandler()->ProcessEvent(erase_event))
|
if (!GetEventHandler()->ProcessEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
if (!g_eraseGC)
|
if (!g_eraseGC)
|
||||||
{
|
{
|
||||||
@@ -4114,8 +4122,9 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply style change (forceStyle=true so that new style is applied
|
// apply style change (forceStyle=true so that new style is applied
|
||||||
// even if the bg colour changed from valid to wxNullColour):
|
// even if the bg colour changed from valid to wxNullColour)
|
||||||
ApplyWidgetStyle(true);
|
if (GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
|
ApplyWidgetStyle(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4242,6 +4251,43 @@ void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
|
|||||||
gtk_widget_modify_style(m_widget, style);
|
gtk_widget_modify_style(m_widget, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
|
||||||
|
{
|
||||||
|
wxWindowBase::SetBackgroundStyle(style);
|
||||||
|
|
||||||
|
if (style == wxBG_STYLE_CUSTOM)
|
||||||
|
{
|
||||||
|
GdkWindow *window = (GdkWindow*) NULL;
|
||||||
|
if (m_wxwindow)
|
||||||
|
window = GTK_PIZZA(m_wxwindow)->bin_window;
|
||||||
|
else
|
||||||
|
window = GetConnectWidget()->window;
|
||||||
|
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
// Make sure GDK/X11 doesn't refresh the window
|
||||||
|
// automatically.
|
||||||
|
gdk_window_set_back_pixmap( window, None, False );
|
||||||
|
#ifdef __X__
|
||||||
|
Display* display = GDK_WINDOW_DISPLAY(window);
|
||||||
|
XFlush(display);
|
||||||
|
#endif
|
||||||
|
m_needsStyleChange = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// Do in OnIdle, because the window is not yet available
|
||||||
|
m_needsStyleChange = true;
|
||||||
|
|
||||||
|
// Don't apply widget style, or we get a grey background
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// apply style change (forceStyle=true so that new style is applied
|
||||||
|
// even if the bg colour changed from valid to wxNullColour):
|
||||||
|
ApplyWidgetStyle(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Pop-up menu stuff
|
// Pop-up menu stuff
|
||||||
|
@@ -632,7 +632,7 @@ static void gtk_window_draw_callback( GtkWidget *widget,
|
|||||||
#ifndef __WXUNIVERSAL__
|
#ifndef __WXUNIVERSAL__
|
||||||
GtkPizza *pizza = GTK_PIZZA (widget);
|
GtkPizza *pizza = GTK_PIZZA (widget);
|
||||||
|
|
||||||
if (win->GetThemeEnabled())
|
if (win->GetThemeEnabled() && win->GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
wxWindow *parent = win->GetParent();
|
wxWindow *parent = win->GetParent();
|
||||||
while (parent && !parent->IsTopLevel())
|
while (parent && !parent->IsTopLevel())
|
||||||
@@ -2646,6 +2646,8 @@ void wxWindowGTK::Init()
|
|||||||
|
|
||||||
m_clipPaintRegion = FALSE;
|
m_clipPaintRegion = FALSE;
|
||||||
|
|
||||||
|
m_needsStyleChange = false;
|
||||||
|
|
||||||
m_cursor = *wxSTANDARD_CURSOR;
|
m_cursor = *wxSTANDARD_CURSOR;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
@@ -3119,6 +3121,13 @@ void wxWindowGTK::OnInternalIdle()
|
|||||||
if ( m_dirtyTabOrder )
|
if ( m_dirtyTabOrder )
|
||||||
RealizeTabOrder();
|
RealizeTabOrder();
|
||||||
#endif
|
#endif
|
||||||
|
// Update style if the window was not yet realized
|
||||||
|
// and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called
|
||||||
|
if (m_needsStyleChange)
|
||||||
|
{
|
||||||
|
SetBackgroundStyle(GetBackgroundStyle());
|
||||||
|
m_needsStyleChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Update invalidated regions.
|
// Update invalidated regions.
|
||||||
GtkUpdate();
|
GtkUpdate();
|
||||||
@@ -3601,7 +3610,6 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
void wxWindowGTK::SetFocus()
|
void wxWindowGTK::SetFocus()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
||||||
|
|
||||||
if ( m_hasFocus )
|
if ( m_hasFocus )
|
||||||
{
|
{
|
||||||
// don't do anything if we already have focus
|
// don't do anything if we already have focus
|
||||||
@@ -3935,7 +3943,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
// widget to draw on
|
// widget to draw on
|
||||||
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
||||||
|
|
||||||
if (GetThemeEnabled())
|
if (GetThemeEnabled() && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
// find ancestor from which to steal background
|
// find ancestor from which to steal background
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
@@ -3989,7 +3997,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
wxEraseEvent erase_event( GetId(), &dc );
|
wxEraseEvent erase_event( GetId(), &dc );
|
||||||
erase_event.SetEventObject( this );
|
erase_event.SetEventObject( this );
|
||||||
|
|
||||||
if (!GetEventHandler()->ProcessEvent(erase_event))
|
if (!GetEventHandler()->ProcessEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
if (!g_eraseGC)
|
if (!g_eraseGC)
|
||||||
{
|
{
|
||||||
@@ -4114,8 +4122,9 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply style change (forceStyle=true so that new style is applied
|
// apply style change (forceStyle=true so that new style is applied
|
||||||
// even if the bg colour changed from valid to wxNullColour):
|
// even if the bg colour changed from valid to wxNullColour)
|
||||||
ApplyWidgetStyle(true);
|
if (GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
|
||||||
|
ApplyWidgetStyle(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4242,6 +4251,43 @@ void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
|
|||||||
gtk_widget_modify_style(m_widget, style);
|
gtk_widget_modify_style(m_widget, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
|
||||||
|
{
|
||||||
|
wxWindowBase::SetBackgroundStyle(style);
|
||||||
|
|
||||||
|
if (style == wxBG_STYLE_CUSTOM)
|
||||||
|
{
|
||||||
|
GdkWindow *window = (GdkWindow*) NULL;
|
||||||
|
if (m_wxwindow)
|
||||||
|
window = GTK_PIZZA(m_wxwindow)->bin_window;
|
||||||
|
else
|
||||||
|
window = GetConnectWidget()->window;
|
||||||
|
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
// Make sure GDK/X11 doesn't refresh the window
|
||||||
|
// automatically.
|
||||||
|
gdk_window_set_back_pixmap( window, None, False );
|
||||||
|
#ifdef __X__
|
||||||
|
Display* display = GDK_WINDOW_DISPLAY(window);
|
||||||
|
XFlush(display);
|
||||||
|
#endif
|
||||||
|
m_needsStyleChange = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// Do in OnIdle, because the window is not yet available
|
||||||
|
m_needsStyleChange = true;
|
||||||
|
|
||||||
|
// Don't apply widget style, or we get a grey background
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// apply style change (forceStyle=true so that new style is applied
|
||||||
|
// even if the bg colour changed from valid to wxNullColour):
|
||||||
|
ApplyWidgetStyle(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Pop-up menu stuff
|
// Pop-up menu stuff
|
||||||
|
Reference in New Issue
Block a user