Slightly better GC pooling,

Implemented automatic updateregion clipping as MSW does.
  Made drawing sample a bit saner.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6183 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2000-02-21 18:01:02 +00:00
parent 1618dca721
commit 0e09f76e6d
9 changed files with 319 additions and 276 deletions

View File

@ -20,7 +20,6 @@
extern "C" {
#endif /* __cplusplus */
#define GTK_PIZZA(obj) GTK_CHECK_CAST (obj, gtk_pizza_get_type (), GtkPizza)
#define GTK_PIZZA_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_pizza_get_type (), GtkPizzaClass)
#define GTK_IS_PIZZA(obj) GTK_CHECK_TYPE (obj, gtk_pizza_get_type ())
@ -28,10 +27,10 @@ extern "C" {
/* Shadow types */
typedef enum
{
GTK_MYSHADOW_NONE,
GTK_MYSHADOW_THIN,
GTK_MYSHADOW_IN,
GTK_MYSHADOW_OUT
GTK_MYSHADOW_NONE,
GTK_MYSHADOW_THIN,
GTK_MYSHADOW_IN,
GTK_MYSHADOW_OUT
} GtkMyShadowType;
typedef struct _GtkPizza GtkPizza;
@ -39,24 +38,25 @@ typedef struct _GtkPizzaClass GtkPizzaClass;
struct _GtkPizza
{
GtkContainer container;
GList *children;
GtkMyShadowType shadow_type;
GtkContainer container;
GList *children;
GtkMyShadowType shadow_type;
guint width;
guint height;
guint width;
guint height;
guint xoffset;
guint yoffset;
guint xoffset;
guint yoffset;
GdkWindow *bin_window;
GdkWindow *bin_window;
GdkVisibilityState visibility;
gulong configure_serial;
gint scroll_x;
gint scroll_y;
GdkVisibilityState visibility;
gulong configure_serial;
gint scroll_x;
gint scroll_y;
gboolean clear_on_draw;
gboolean clear_on_draw;
gboolean use_filter;
};
struct _GtkPizzaClass
@ -71,39 +71,42 @@ struct _GtkPizzaClass
guint gtk_pizza_get_type (void);
GtkWidget* gtk_pizza_new (void);
void gtk_pizza_set_shadow_type (GtkPizza *pizza,
GtkMyShadowType type);
void gtk_pizza_set_shadow_type (GtkPizza *pizza,
GtkMyShadowType type);
void gtk_pizza_set_clear (GtkPizza *pizza,
gboolean clear);
void gtk_pizza_set_clear (GtkPizza *pizza,
gboolean clear);
void gtk_pizza_scroll (GtkPizza *pizza,
gint dx,
gint dy);
void gtk_pizza_set_filter (GtkPizza *pizza,
gboolean use);
void gtk_pizza_put (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void gtk_pizza_scroll (GtkPizza *pizza,
gint dx,
gint dy);
void gtk_pizza_put (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void gtk_pizza_move (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y );
void gtk_pizza_move (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y );
void gtk_pizza_resize (GtkPizza *pizza,
GtkWidget *widget,
gint width,
gint height );
void gtk_pizza_resize (GtkPizza *pizza,
GtkWidget *widget,
gint width,
gint height );
void gtk_pizza_set_size (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void gtk_pizza_set_size (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -20,7 +20,6 @@
extern "C" {
#endif /* __cplusplus */
#define GTK_PIZZA(obj) GTK_CHECK_CAST (obj, gtk_pizza_get_type (), GtkPizza)
#define GTK_PIZZA_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_pizza_get_type (), GtkPizzaClass)
#define GTK_IS_PIZZA(obj) GTK_CHECK_TYPE (obj, gtk_pizza_get_type ())
@ -28,10 +27,10 @@ extern "C" {
/* Shadow types */
typedef enum
{
GTK_MYSHADOW_NONE,
GTK_MYSHADOW_THIN,
GTK_MYSHADOW_IN,
GTK_MYSHADOW_OUT
GTK_MYSHADOW_NONE,
GTK_MYSHADOW_THIN,
GTK_MYSHADOW_IN,
GTK_MYSHADOW_OUT
} GtkMyShadowType;
typedef struct _GtkPizza GtkPizza;
@ -39,24 +38,25 @@ typedef struct _GtkPizzaClass GtkPizzaClass;
struct _GtkPizza
{
GtkContainer container;
GList *children;
GtkMyShadowType shadow_type;
GtkContainer container;
GList *children;
GtkMyShadowType shadow_type;
guint width;
guint height;
guint width;
guint height;
guint xoffset;
guint yoffset;
guint xoffset;
guint yoffset;
GdkWindow *bin_window;
GdkWindow *bin_window;
GdkVisibilityState visibility;
gulong configure_serial;
gint scroll_x;
gint scroll_y;
GdkVisibilityState visibility;
gulong configure_serial;
gint scroll_x;
gint scroll_y;
gboolean clear_on_draw;
gboolean clear_on_draw;
gboolean use_filter;
};
struct _GtkPizzaClass
@ -71,39 +71,42 @@ struct _GtkPizzaClass
guint gtk_pizza_get_type (void);
GtkWidget* gtk_pizza_new (void);
void gtk_pizza_set_shadow_type (GtkPizza *pizza,
GtkMyShadowType type);
void gtk_pizza_set_shadow_type (GtkPizza *pizza,
GtkMyShadowType type);
void gtk_pizza_set_clear (GtkPizza *pizza,
gboolean clear);
void gtk_pizza_set_clear (GtkPizza *pizza,
gboolean clear);
void gtk_pizza_scroll (GtkPizza *pizza,
gint dx,
gint dy);
void gtk_pizza_set_filter (GtkPizza *pizza,
gboolean use);
void gtk_pizza_put (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void gtk_pizza_scroll (GtkPizza *pizza,
gint dx,
gint dy);
void gtk_pizza_put (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void gtk_pizza_move (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y );
void gtk_pizza_move (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y );
void gtk_pizza_resize (GtkPizza *pizza,
GtkWidget *widget,
gint width,
gint height );
void gtk_pizza_resize (GtkPizza *pizza,
GtkWidget *widget,
gint width,
gint height );
void gtk_pizza_set_size (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
void gtk_pizza_set_size (GtkPizza *pizza,
GtkWidget *widget,
gint x,
gint y,
gint width,
gint height);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -154,6 +154,8 @@ private:
MyFrame *m_owner;
ScreenToShow m_show;
wxBitmap m_smile_bmp;
wxIcon m_std_icon;
DECLARE_EVENT_TABLE()
};
@ -310,10 +312,14 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_MOTION (MyCanvas::OnMouseMove)
END_EVENT_TABLE()
#include "../image/smile.xpm"
MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent )
{
m_owner = parent;
m_show = Show_Default;
m_smile_bmp = wxBitmap(smile_xpm);
m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
}
//draw a polygon and an overlapping rectangle
@ -578,29 +584,26 @@ void MyCanvas::DrawDefault(wxDC& dc)
dc.DrawCheckMark(25, 80, 30, 30);
dc.DrawCheckMark(60, 80, 60, 60);
// this is the test for "blitting bitmap into DC damages selected brush"
// bug
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
wxCoord rectSize = icon.GetWidth() + 10;
// this is the test for "blitting bitmap into DC damages selected brush" bug
wxIcon m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
wxCoord rectSize = m_std_icon.GetWidth() + 10;
wxCoord x = 100;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush( *wxGREEN_BRUSH );
dc.DrawRectangle(x, 10, rectSize, rectSize);
dc.DrawBitmap(icon, x + 5, 15, TRUE);
dc.DrawBitmap(m_std_icon, x + 5, 15, TRUE);
x += rectSize + 10;
dc.DrawRectangle(x, 10, rectSize, rectSize);
dc.DrawIcon(wxTheApp->GetStdIcon(wxICON_INFORMATION), x + 5, 15);
dc.DrawIcon(m_std_icon, x + 5, 15);
x += rectSize + 10;
dc.DrawRectangle(x, 10, rectSize, rectSize);
// test for "transparent" bitmap drawing (it intersects with the last
// rectangle above)
//dc.SetBrush( *wxTRANSPARENT_BRUSH );
#include "../image/smile.xpm"
wxBitmap bmp(smile_xpm);
if (bmp.Ok())
dc.DrawBitmap(bmp, x + rectSize - 20, rectSize - 10, TRUE);
if (m_smile_bmp.Ok())
dc.DrawBitmap(m_smile_bmp, x + rectSize - 20, rectSize - 10, TRUE);
dc.SetBrush( *wxBLACK_BRUSH );
dc.DrawRectangle( 0, 160, 1000, 300 );

View File

@ -100,11 +100,24 @@ void gdk_draw_bitmap (GdkDrawable *drawable,
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
enum wxPoolGCType
{
wxGC_ERROR = 0,
wxTEXT_MONO,
wxBG_MONO,
wxPEN_MONO,
wxBRUSH_MONO,
wxTEXT_COLOUR,
wxBG_COLOUR,
wxPEN_COLOUR,
wxBRUSH_COLOUR
};
struct wxGC
{
GdkGC *m_gc;
bool m_mono;
bool m_used;
GdkGC *m_gc;
wxPoolGCType m_type;
bool m_used;
};
static wxGC wxGCPool[200];
@ -123,7 +136,7 @@ static void wxCleanUpGCPool()
}
}
static GdkGC* wxGetPoolGC( GdkWindow *window, bool mono=FALSE )
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
for (int i = 0; i < 200; i++)
{
@ -131,10 +144,10 @@ static GdkGC* wxGetPoolGC( GdkWindow *window, bool mono=FALSE )
{
wxGCPool[i].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_mono = mono;
wxGCPool[i].m_type = type;
wxGCPool[i].m_used = FALSE;
}
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_mono == mono))
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_type == type))
{
wxGCPool[i].m_used = TRUE;
return wxGCPool[i].m_gc;
@ -1587,10 +1600,10 @@ void wxWindowDC::SetUpDC()
if (!m_penGC)
{
m_penGC = wxGetPoolGC( m_window );
m_brushGC = wxGetPoolGC( m_window );
m_textGC = wxGetPoolGC( m_window );
m_bgGC = wxGetPoolGC( m_window );
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 */
@ -1606,14 +1619,12 @@ void wxWindowDC::SetUpDC()
gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
gdk_gc_set_fill( m_textGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_textGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* 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_fill( m_penGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
@ -1623,7 +1634,6 @@ void wxWindowDC::SetUpDC()
gdk_gc_set_background( m_brushGC, bg_col );
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_brushGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* m_bgGC */
@ -1631,13 +1641,11 @@ void wxWindowDC::SetUpDC()
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_bgGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* 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 );
gdk_gc_set_function( m_bgGC, GDK_COPY );
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
@ -1886,7 +1894,6 @@ wxPaintDC::wxPaintDC()
wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
/*
if (!win->GetUpdateRegion().IsEmpty())
{
m_paintClippingRegion = win->GetUpdateRegion();
@ -1897,7 +1904,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
}
*/
}
//-----------------------------------------------------------------------------

View File

@ -193,6 +193,7 @@ gtk_pizza_init (GtkPizza *pizza)
pizza->visibility = GDK_VISIBILITY_PARTIAL;
pizza->clear_on_draw = TRUE;
pizza->use_filter = FALSE;
}
GtkWidget*
@ -215,7 +216,7 @@ gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
void
gtk_pizza_set_shadow_type (GtkPizza *pizza,
GtkMyShadowType type)
GtkMyShadowType type)
{
g_return_if_fail (pizza != NULL);
g_return_if_fail (GTK_IS_PIZZA (pizza));
@ -234,7 +235,7 @@ gtk_pizza_set_shadow_type (GtkPizza *pizza,
void
gtk_pizza_set_clear (GtkPizza *pizza,
gboolean clear)
gboolean clear)
{
g_return_if_fail (pizza != NULL);
g_return_if_fail (GTK_IS_PIZZA (pizza));
@ -242,6 +243,16 @@ gtk_pizza_set_clear (GtkPizza *pizza,
pizza->clear_on_draw = clear;
}
void
gtk_pizza_set_filter (GtkPizza *pizza,
gboolean use)
{
g_return_if_fail (pizza != NULL);
g_return_if_fail (GTK_IS_PIZZA (pizza));
pizza->use_filter = use;
}
void
gtk_pizza_put (GtkPizza *pizza,
GtkWidget *widget,
@ -274,11 +285,14 @@ gtk_pizza_put (GtkPizza *pizza,
if (!IS_ONSCREEN (x, y))
GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);
/*
if (GTK_WIDGET_REALIZED (pizza))
gtk_widget_realize (widget);
*/
gtk_widget_set_usize (widget, width, height);
/*
if (GTK_WIDGET_VISIBLE (pizza) && GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_MAPPED (pizza))
@ -286,6 +300,7 @@ gtk_pizza_put (GtkPizza *pizza,
gtk_widget_queue_resize (widget);
}
*/
}
void
@ -683,14 +698,6 @@ gtk_pizza_expose (GtkWidget *widget,
pizza = GTK_PIZZA (widget);
/*
if (event->window == widget->window)
{
gtk_pizza_draw_border( pizza );
return FALSE;
}
*/
if (event->window != pizza->bin_window)
return FALSE;
@ -881,26 +888,28 @@ gtk_pizza_adjust_allocations (GtkPizza *pizza,
gint dx,
gint dy)
{
GList *tmp_list;
GtkPizzaAdjData data;
GList *tmp_list;
GtkPizzaAdjData data;
data.dx = dx;
data.dy = dy;
data.dx = dx;
data.dy = dy;
tmp_list = pizza->children;
while (tmp_list)
tmp_list = pizza->children;
while (tmp_list)
{
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
child->widget->allocation.x += dx;
child->widget->allocation.y += dy;
child->widget->allocation.x += dx;
child->widget->allocation.y += dy;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_IS_CONTAINER (child->widget))
gtk_container_forall (GTK_CONTAINER (child->widget),
gtk_pizza_adjust_allocations_recurse,
&data);
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_IS_CONTAINER (child->widget))
{
gtk_container_forall (GTK_CONTAINER (child->widget),
gtk_pizza_adjust_allocations_recurse,
&data);
}
}
}
@ -912,23 +921,23 @@ static void
gtk_pizza_expose_area (GtkPizza *pizza,
gint x, gint y, gint width, gint height)
{
if (pizza->visibility == GDK_VISIBILITY_UNOBSCURED)
if (pizza->visibility == GDK_VISIBILITY_UNOBSCURED)
{
GdkEventExpose event;
GdkEventExpose event;
event.type = GDK_EXPOSE;
event.send_event = TRUE;
event.window = pizza->bin_window;
event.count = 0;
event.type = GDK_EXPOSE;
event.send_event = TRUE;
event.window = pizza->bin_window;
event.count = 0;
event.area.x = x;
event.area.y = y;
event.area.width = width;
event.area.height = height;
event.area.x = x;
event.area.y = y;
event.area.width = width;
event.area.height = height;
gdk_window_ref (event.window);
gtk_widget_event (GTK_WIDGET (pizza), (GdkEvent *)&event);
gdk_window_unref (event.window);
gdk_window_ref (event.window);
gtk_widget_event (GTK_WIDGET (pizza), (GdkEvent *)&event);
gdk_window_unref (event.window);
}
}
@ -1143,12 +1152,13 @@ gtk_pizza_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent;
GtkPizza *pizza;
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
XEvent *xevent;
GtkPizza *pizza;
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
switch (xevent->type)
{
case Expose:
@ -1176,7 +1186,7 @@ gtk_pizza_filter (GdkXEvent *gdk_xevent,
break;
}
return GDK_FILTER_CONTINUE;
return GDK_FILTER_CONTINUE;
}
/* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
@ -1188,34 +1198,33 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent;
GtkPizza *pizza;
XEvent *xevent;
GtkPizza *pizza;
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
if (xevent->type == VisibilityNotify)
if (xevent->type == VisibilityNotify)
{
switch (xevent->xvisibility.state)
switch (xevent->xvisibility.state)
{
case VisibilityFullyObscured:
pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
break;
case VisibilityFullyObscured:
pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
break;
case VisibilityPartiallyObscured:
pizza->visibility = GDK_VISIBILITY_PARTIAL;
break;
case VisibilityPartiallyObscured:
pizza->visibility = GDK_VISIBILITY_PARTIAL;
break;
case VisibilityUnobscured:
pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
break;
case VisibilityUnobscured:
pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
break;
}
return GDK_FILTER_REMOVE;
return GDK_FILTER_REMOVE;
}
return GDK_FILTER_CONTINUE;
return GDK_FILTER_CONTINUE;
}

View File

@ -612,10 +612,6 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
{
DEBUG_MAIN_THREAD
if (!win->m_hasVMT)
return;
/*
if (win->GetName() == wxT("columntitles"))
{
wxPrintf( wxT("OnExpose from ") );
@ -626,7 +622,6 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
(int)gdk_event->area.width,
(int)gdk_event->area.height );
}
*/
win->GetUpdateRegion().Union( gdk_event->area.x,
gdk_event->area.y,
@ -637,6 +632,9 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
if (gdk_event->count > 0)
return;
if (!win->m_hasVMT)
return;
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
@ -659,9 +657,11 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
if (g_isIdle)
wxapp_install_idle_handler();
if ((rect->x == 0) && (rect->y == 0) && (rect->width <= 1) && (rect->height <= 1))
return;
/*
if ((win->GetName() == wxT("columntitles")) && (rect->x == 2))
if (win->GetName() == wxT("columntitles"))
{
wxPrintf( wxT("OnDraw from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@ -671,11 +671,13 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
(int)rect->width,
(int)rect->height );
}
*/
win->GetUpdateRegion().Union( rect->x, rect->y,
rect->width, rect->height );
if (!win->m_hasVMT)
return;
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);

View File

@ -100,11 +100,24 @@ void gdk_draw_bitmap (GdkDrawable *drawable,
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
enum wxPoolGCType
{
wxGC_ERROR = 0,
wxTEXT_MONO,
wxBG_MONO,
wxPEN_MONO,
wxBRUSH_MONO,
wxTEXT_COLOUR,
wxBG_COLOUR,
wxPEN_COLOUR,
wxBRUSH_COLOUR
};
struct wxGC
{
GdkGC *m_gc;
bool m_mono;
bool m_used;
GdkGC *m_gc;
wxPoolGCType m_type;
bool m_used;
};
static wxGC wxGCPool[200];
@ -123,7 +136,7 @@ static void wxCleanUpGCPool()
}
}
static GdkGC* wxGetPoolGC( GdkWindow *window, bool mono=FALSE )
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
for (int i = 0; i < 200; i++)
{
@ -131,10 +144,10 @@ static GdkGC* wxGetPoolGC( GdkWindow *window, bool mono=FALSE )
{
wxGCPool[i].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_mono = mono;
wxGCPool[i].m_type = type;
wxGCPool[i].m_used = FALSE;
}
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_mono == mono))
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_type == type))
{
wxGCPool[i].m_used = TRUE;
return wxGCPool[i].m_gc;
@ -1587,10 +1600,10 @@ void wxWindowDC::SetUpDC()
if (!m_penGC)
{
m_penGC = wxGetPoolGC( m_window );
m_brushGC = wxGetPoolGC( m_window );
m_textGC = wxGetPoolGC( m_window );
m_bgGC = wxGetPoolGC( m_window );
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 */
@ -1606,14 +1619,12 @@ void wxWindowDC::SetUpDC()
gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
gdk_gc_set_fill( m_textGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_textGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* 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_fill( m_penGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
@ -1623,7 +1634,6 @@ void wxWindowDC::SetUpDC()
gdk_gc_set_background( m_brushGC, bg_col );
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_brushGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* m_bgGC */
@ -1631,13 +1641,11 @@ void wxWindowDC::SetUpDC()
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
gdk_gc_set_line_attributes( m_bgGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
/* 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 );
gdk_gc_set_function( m_bgGC, GDK_COPY );
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
@ -1886,7 +1894,6 @@ wxPaintDC::wxPaintDC()
wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
/*
if (!win->GetUpdateRegion().IsEmpty())
{
m_paintClippingRegion = win->GetUpdateRegion();
@ -1897,7 +1904,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
}
*/
}
//-----------------------------------------------------------------------------

View File

@ -193,6 +193,7 @@ gtk_pizza_init (GtkPizza *pizza)
pizza->visibility = GDK_VISIBILITY_PARTIAL;
pizza->clear_on_draw = TRUE;
pizza->use_filter = FALSE;
}
GtkWidget*
@ -215,7 +216,7 @@ gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
void
gtk_pizza_set_shadow_type (GtkPizza *pizza,
GtkMyShadowType type)
GtkMyShadowType type)
{
g_return_if_fail (pizza != NULL);
g_return_if_fail (GTK_IS_PIZZA (pizza));
@ -234,7 +235,7 @@ gtk_pizza_set_shadow_type (GtkPizza *pizza,
void
gtk_pizza_set_clear (GtkPizza *pizza,
gboolean clear)
gboolean clear)
{
g_return_if_fail (pizza != NULL);
g_return_if_fail (GTK_IS_PIZZA (pizza));
@ -242,6 +243,16 @@ gtk_pizza_set_clear (GtkPizza *pizza,
pizza->clear_on_draw = clear;
}
void
gtk_pizza_set_filter (GtkPizza *pizza,
gboolean use)
{
g_return_if_fail (pizza != NULL);
g_return_if_fail (GTK_IS_PIZZA (pizza));
pizza->use_filter = use;
}
void
gtk_pizza_put (GtkPizza *pizza,
GtkWidget *widget,
@ -274,11 +285,14 @@ gtk_pizza_put (GtkPizza *pizza,
if (!IS_ONSCREEN (x, y))
GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);
/*
if (GTK_WIDGET_REALIZED (pizza))
gtk_widget_realize (widget);
*/
gtk_widget_set_usize (widget, width, height);
/*
if (GTK_WIDGET_VISIBLE (pizza) && GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_MAPPED (pizza))
@ -286,6 +300,7 @@ gtk_pizza_put (GtkPizza *pizza,
gtk_widget_queue_resize (widget);
}
*/
}
void
@ -683,14 +698,6 @@ gtk_pizza_expose (GtkWidget *widget,
pizza = GTK_PIZZA (widget);
/*
if (event->window == widget->window)
{
gtk_pizza_draw_border( pizza );
return FALSE;
}
*/
if (event->window != pizza->bin_window)
return FALSE;
@ -881,26 +888,28 @@ gtk_pizza_adjust_allocations (GtkPizza *pizza,
gint dx,
gint dy)
{
GList *tmp_list;
GtkPizzaAdjData data;
GList *tmp_list;
GtkPizzaAdjData data;
data.dx = dx;
data.dy = dy;
data.dx = dx;
data.dy = dy;
tmp_list = pizza->children;
while (tmp_list)
tmp_list = pizza->children;
while (tmp_list)
{
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
child->widget->allocation.x += dx;
child->widget->allocation.y += dy;
child->widget->allocation.x += dx;
child->widget->allocation.y += dy;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_IS_CONTAINER (child->widget))
gtk_container_forall (GTK_CONTAINER (child->widget),
gtk_pizza_adjust_allocations_recurse,
&data);
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_IS_CONTAINER (child->widget))
{
gtk_container_forall (GTK_CONTAINER (child->widget),
gtk_pizza_adjust_allocations_recurse,
&data);
}
}
}
@ -912,23 +921,23 @@ static void
gtk_pizza_expose_area (GtkPizza *pizza,
gint x, gint y, gint width, gint height)
{
if (pizza->visibility == GDK_VISIBILITY_UNOBSCURED)
if (pizza->visibility == GDK_VISIBILITY_UNOBSCURED)
{
GdkEventExpose event;
GdkEventExpose event;
event.type = GDK_EXPOSE;
event.send_event = TRUE;
event.window = pizza->bin_window;
event.count = 0;
event.type = GDK_EXPOSE;
event.send_event = TRUE;
event.window = pizza->bin_window;
event.count = 0;
event.area.x = x;
event.area.y = y;
event.area.width = width;
event.area.height = height;
event.area.x = x;
event.area.y = y;
event.area.width = width;
event.area.height = height;
gdk_window_ref (event.window);
gtk_widget_event (GTK_WIDGET (pizza), (GdkEvent *)&event);
gdk_window_unref (event.window);
gdk_window_ref (event.window);
gtk_widget_event (GTK_WIDGET (pizza), (GdkEvent *)&event);
gdk_window_unref (event.window);
}
}
@ -1143,12 +1152,13 @@ gtk_pizza_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent;
GtkPizza *pizza;
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
XEvent *xevent;
GtkPizza *pizza;
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
switch (xevent->type)
{
case Expose:
@ -1176,7 +1186,7 @@ gtk_pizza_filter (GdkXEvent *gdk_xevent,
break;
}
return GDK_FILTER_CONTINUE;
return GDK_FILTER_CONTINUE;
}
/* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
@ -1188,34 +1198,33 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent;
GtkPizza *pizza;
XEvent *xevent;
GtkPizza *pizza;
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
xevent = (XEvent *)gdk_xevent;
pizza = GTK_PIZZA (data);
if (xevent->type == VisibilityNotify)
if (xevent->type == VisibilityNotify)
{
switch (xevent->xvisibility.state)
switch (xevent->xvisibility.state)
{
case VisibilityFullyObscured:
pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
break;
case VisibilityFullyObscured:
pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
break;
case VisibilityPartiallyObscured:
pizza->visibility = GDK_VISIBILITY_PARTIAL;
break;
case VisibilityPartiallyObscured:
pizza->visibility = GDK_VISIBILITY_PARTIAL;
break;
case VisibilityUnobscured:
pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
break;
case VisibilityUnobscured:
pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
break;
}
return GDK_FILTER_REMOVE;
return GDK_FILTER_REMOVE;
}
return GDK_FILTER_CONTINUE;
return GDK_FILTER_CONTINUE;
}

View File

@ -612,10 +612,6 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
{
DEBUG_MAIN_THREAD
if (!win->m_hasVMT)
return;
/*
if (win->GetName() == wxT("columntitles"))
{
wxPrintf( wxT("OnExpose from ") );
@ -626,7 +622,6 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
(int)gdk_event->area.width,
(int)gdk_event->area.height );
}
*/
win->GetUpdateRegion().Union( gdk_event->area.x,
gdk_event->area.y,
@ -637,6 +632,9 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
if (gdk_event->count > 0)
return;
if (!win->m_hasVMT)
return;
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
@ -659,9 +657,11 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
if (g_isIdle)
wxapp_install_idle_handler();
if ((rect->x == 0) && (rect->y == 0) && (rect->width <= 1) && (rect->height <= 1))
return;
/*
if ((win->GetName() == wxT("columntitles")) && (rect->x == 2))
if (win->GetName() == wxT("columntitles"))
{
wxPrintf( wxT("OnDraw from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@ -671,11 +671,13 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
(int)rect->width,
(int)rect->height );
}
*/
win->GetUpdateRegion().Union( rect->x, rect->y,
rect->width, rect->height );
if (!win->m_hasVMT)
return;
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);