#ifdeffed new paint clipping :-(

Moved replacement code to printing preview canvas where
    its effect was particularly useful.
  Completed GC pooling.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6240 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2000-02-23 17:47:43 +00:00
parent c52a6847be
commit 809934d22a
8 changed files with 200 additions and 153 deletions

View File

@ -195,6 +195,11 @@ void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
wxPaintDC dc(this);
PrepareDC( dc );
#ifdef __WXGTK__
if (!GetUpdateRegion().IsEmpty())
dc.SetClippingRegion( GetUpdateRegion() );
#endif
if (m_printPreview)
{
m_printPreview->PaintPage(this, dc);

View File

@ -187,7 +187,7 @@ public:
~wxListHeaderWindow();
wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = 0, const wxString &name = "columntitles" );
long style = 0, const wxString &name = "wxlistctrlcolumntitles" );
void DoDrawRect( wxDC *dc, int x, int y, int w, int h );
void OnPaint( wxPaintEvent &event );
void DrawCurrent();
@ -233,7 +233,7 @@ public:
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
int style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = "wxListTextCtrlText" );
const wxString &name = "listctrltextctrl" );
void OnChar( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
@ -281,7 +281,7 @@ public:
wxListMainWindow();
wxListMainWindow( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = 0, const wxString &name = "listctrl" );
long style = 0, const wxString &name = "listctrlmainwindow" );
~wxListMainWindow();
void RefreshLine( wxListLineData *line );
void OnPaint( wxPaintEvent &event );

View File

@ -23,6 +23,12 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// local defines
//-----------------------------------------------------------------------------
#define USE_PAINT_REGION 0
//-----------------------------------------------------------------------------
// local data
//-----------------------------------------------------------------------------
@ -250,6 +256,86 @@ wxWindowDC::~wxWindowDC()
Destroy();
}
void wxWindowDC::SetUpDC()
{
m_ok = TRUE;
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
{
m_penGC = wxGetPoolGC( m_window, wxPEN_MONO );
m_brushGC = wxGetPoolGC( m_window, wxBRUSH_MONO );
m_textGC = wxGetPoolGC( m_window, wxTEXT_MONO );
m_bgGC = wxGetPoolGC( m_window, wxBG_MONO );
}
else
{
m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR );
m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR );
m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR );
m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR );
}
/* background colour */
m_backgroundBrush = *wxWHITE_BRUSH;
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
/* m_textGC */
m_textForegroundColour.CalcPixel( m_cmap );
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
m_textBackgroundColour.CalcPixel( m_cmap );
gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
gdk_gc_set_fill( m_textGC, GDK_SOLID );
/* m_penGC */
m_pen.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() );
gdk_gc_set_background( m_penGC, bg_col );
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* m_brushGC */
m_brush.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() );
gdk_gc_set_background( m_brushGC, bg_col );
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
/* m_bgGC */
gdk_gc_set_background( m_bgGC, bg_col );
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
/* ROPs */
gdk_gc_set_function( m_textGC, GDK_COPY );
gdk_gc_set_function( m_brushGC, GDK_COPY );
gdk_gc_set_function( m_penGC, GDK_COPY );
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL );
if (!hatch_bitmap)
{
hatch_bitmap = hatches;
hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height );
hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height );
hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height );
hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height );
hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height );
hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height );
}
}
void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxColour &WXUNUSED(col), int WXUNUSED(style) )
{
@ -1539,8 +1625,10 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo
m_currentClippingRegion.Clear();
m_currentClippingRegion.Union( rect );
#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsEmpty())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() );
@ -1567,8 +1655,10 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion &region )
m_currentClippingRegion.Clear();
m_currentClippingRegion.Union( region );
#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsEmpty())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() );
@ -1605,77 +1695,6 @@ void wxWindowDC::DestroyClippingRegion()
}
}
void wxWindowDC::SetUpDC()
{
m_ok = TRUE;
if (!m_penGC)
{
m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR );
m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR );
m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR );
m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR );
}
/* background colour */
m_backgroundBrush = *wxWHITE_BRUSH;
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
/* m_textGC */
m_textForegroundColour.CalcPixel( m_cmap );
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
m_textBackgroundColour.CalcPixel( m_cmap );
gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
gdk_gc_set_fill( m_textGC, GDK_SOLID );
/* m_penGC */
m_pen.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() );
gdk_gc_set_background( m_penGC, bg_col );
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* m_brushGC */
m_brush.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() );
gdk_gc_set_background( m_brushGC, bg_col );
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
/* m_bgGC */
gdk_gc_set_background( m_bgGC, bg_col );
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
/* ROPs */
gdk_gc_set_function( m_textGC, GDK_COPY );
gdk_gc_set_function( m_brushGC, GDK_COPY );
gdk_gc_set_function( m_penGC, GDK_COPY );
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL );
if (!hatch_bitmap)
{
hatch_bitmap = hatches;
hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height );
hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height );
hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height );
hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height );
hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height );
hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height );
}
}
void wxWindowDC::Destroy()
{
if (m_penGC) wxFreePoolGC( m_penGC );
@ -1905,6 +1924,7 @@ wxPaintDC::wxPaintDC()
wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
#if USE_PAINT_REGION
if (!win->GetUpdateRegion().IsEmpty())
{
m_paintClippingRegion = win->GetUpdateRegion();
@ -1915,6 +1935,7 @@ wxPaintDC::wxPaintDC( wxWindow *win )
gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
}
#endif
}
//-----------------------------------------------------------------------------

View File

@ -56,9 +56,9 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
m_window = m_selected.GetBitmap();
}
SetUpDC();
m_isMemDC = TRUE;
SetUpDC();
}
else
{

View File

@ -613,7 +613,7 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
DEBUG_MAIN_THREAD
/*
if (win->GetName() == wxT("columntitles"))
if (win->GetName() == wxT("grid window"))
{
wxPrintf( wxT("OnExpose from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@ -664,7 +664,7 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
return;
/*
if (win->GetName() == wxT("columntitles"))
if (win->GetName() == wxT("grid window"))
{
wxPrintf( wxT("OnDraw from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())

View File

@ -23,6 +23,12 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// local defines
//-----------------------------------------------------------------------------
#define USE_PAINT_REGION 0
//-----------------------------------------------------------------------------
// local data
//-----------------------------------------------------------------------------
@ -250,6 +256,86 @@ wxWindowDC::~wxWindowDC()
Destroy();
}
void wxWindowDC::SetUpDC()
{
m_ok = TRUE;
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
{
m_penGC = wxGetPoolGC( m_window, wxPEN_MONO );
m_brushGC = wxGetPoolGC( m_window, wxBRUSH_MONO );
m_textGC = wxGetPoolGC( m_window, wxTEXT_MONO );
m_bgGC = wxGetPoolGC( m_window, wxBG_MONO );
}
else
{
m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR );
m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR );
m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR );
m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR );
}
/* background colour */
m_backgroundBrush = *wxWHITE_BRUSH;
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
/* m_textGC */
m_textForegroundColour.CalcPixel( m_cmap );
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
m_textBackgroundColour.CalcPixel( m_cmap );
gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
gdk_gc_set_fill( m_textGC, GDK_SOLID );
/* m_penGC */
m_pen.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() );
gdk_gc_set_background( m_penGC, bg_col );
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* m_brushGC */
m_brush.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() );
gdk_gc_set_background( m_brushGC, bg_col );
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
/* m_bgGC */
gdk_gc_set_background( m_bgGC, bg_col );
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
/* ROPs */
gdk_gc_set_function( m_textGC, GDK_COPY );
gdk_gc_set_function( m_brushGC, GDK_COPY );
gdk_gc_set_function( m_penGC, GDK_COPY );
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL );
if (!hatch_bitmap)
{
hatch_bitmap = hatches;
hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height );
hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height );
hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height );
hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height );
hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height );
hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height );
}
}
void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxColour &WXUNUSED(col), int WXUNUSED(style) )
{
@ -1539,8 +1625,10 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo
m_currentClippingRegion.Clear();
m_currentClippingRegion.Union( rect );
#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsEmpty())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() );
@ -1567,8 +1655,10 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion &region )
m_currentClippingRegion.Clear();
m_currentClippingRegion.Union( region );
#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsEmpty())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() );
@ -1605,77 +1695,6 @@ void wxWindowDC::DestroyClippingRegion()
}
}
void wxWindowDC::SetUpDC()
{
m_ok = TRUE;
if (!m_penGC)
{
m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR );
m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR );
m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR );
m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR );
}
/* background colour */
m_backgroundBrush = *wxWHITE_BRUSH;
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
/* m_textGC */
m_textForegroundColour.CalcPixel( m_cmap );
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
m_textBackgroundColour.CalcPixel( m_cmap );
gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
gdk_gc_set_fill( m_textGC, GDK_SOLID );
/* m_penGC */
m_pen.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() );
gdk_gc_set_background( m_penGC, bg_col );
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* m_brushGC */
m_brush.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() );
gdk_gc_set_background( m_brushGC, bg_col );
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
/* m_bgGC */
gdk_gc_set_background( m_bgGC, bg_col );
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
/* ROPs */
gdk_gc_set_function( m_textGC, GDK_COPY );
gdk_gc_set_function( m_brushGC, GDK_COPY );
gdk_gc_set_function( m_penGC, GDK_COPY );
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL );
if (!hatch_bitmap)
{
hatch_bitmap = hatches;
hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height );
hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height );
hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height );
hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height );
hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height );
hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height );
}
}
void wxWindowDC::Destroy()
{
if (m_penGC) wxFreePoolGC( m_penGC );
@ -1905,6 +1924,7 @@ wxPaintDC::wxPaintDC()
wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
#if USE_PAINT_REGION
if (!win->GetUpdateRegion().IsEmpty())
{
m_paintClippingRegion = win->GetUpdateRegion();
@ -1915,6 +1935,7 @@ wxPaintDC::wxPaintDC( wxWindow *win )
gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
}
#endif
}
//-----------------------------------------------------------------------------

View File

@ -56,9 +56,9 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
m_window = m_selected.GetBitmap();
}
SetUpDC();
m_isMemDC = TRUE;
SetUpDC();
}
else
{

View File

@ -613,7 +613,7 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
DEBUG_MAIN_THREAD
/*
if (win->GetName() == wxT("columntitles"))
if (win->GetName() == wxT("grid window"))
{
wxPrintf( wxT("OnExpose from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@ -664,7 +664,7 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
return;
/*
if (win->GetName() == wxT("columntitles"))
if (win->GetName() == wxT("grid window"))
{
wxPrintf( wxT("OnDraw from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())