g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
#ifdef __WXGTK20__
gint src_width, src_height;
gdk_drawable_get_size(src, &src_width, &src_height);
#ifdef __WXGTK20__
gint src_width, src_height;
gdk_drawable_get_size(src, &src_width, &src_height);
GdkWindowPrivate *drawable_private;
GdkWindowPrivate *src_private;
GdkGCPrivate *gc_private;
GdkWindowPrivate *drawable_private;
GdkWindowPrivate *src_private;
GdkGCPrivate *gc_private;
drawable_private = (GdkWindowPrivate*) drawable;
src_private = (GdkWindowPrivate*) src;
if (drawable_private->destroyed || src_private->destroyed)
drawable_private = (GdkWindowPrivate*) drawable;
src_private = (GdkWindowPrivate*) src;
if (drawable_private->destroyed || src_private->destroyed)
XCopyPlane( drawable_private->xdisplay,
src_private->xwindow,
drawable_private->xwindow,
XCopyPlane( drawable_private->xdisplay,
src_private->xwindow,
drawable_private->xwindow,
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
// This really could wait until the first call to
// wxGetPoolGC, but we will make the first allocation
// now when other initialization is being performed.
// This really could wait until the first call to
// wxGetPoolGC, but we will make the first allocation
// now when other initialization is being performed.
wxGCPool[i].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_type = type;
wxGCPool[i].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_type = type;
wxGCPool = pptr;
memset(&wxGCPool[wxGCPoolSize], 0,
GC_POOL_ALLOC_SIZE*sizeof(wxGC));
wxGCPool = pptr;
memset(&wxGCPool[wxGCPoolSize], 0,
GC_POOL_ALLOC_SIZE*sizeof(wxGC));
wxGCPool[wxGCPoolSize].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[wxGCPoolSize].m_gc, FALSE );
wxGCPool[wxGCPoolSize].m_type = type;
wxGCPool[wxGCPoolSize].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[wxGCPoolSize].m_gc, FALSE );
wxGCPool[wxGCPoolSize].m_type = type;
-extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y,
wxImage image = bitmap.ConvertToImage();
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
wxImage image = bitmap.ConvertToImage();
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
}
*/
gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n );
}
*/
gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n );
void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{
// VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{
// VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
- DoDrawBitmap( (const wxBitmap&)icon, x, y, (bool)TRUE );
+ DoDrawBitmap( (const wxBitmap&)icon, x, y, true );
wxBitmap use_bitmap = bitmap;
if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh );
wxBitmap use_bitmap = bitmap;
if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh );
#if !GTK_CHECK_VERSION(2,2,0)
// NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code.
// Pixbufs-based bitmaps with alpha channel don't have a mask, so we
#if !GTK_CHECK_VERSION(2,2,0)
// NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code.
// Pixbufs-based bitmaps with alpha channel don't have a mask, so we
// apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
// apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
gdk_gc_unref( gc );
}
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
gdk_gc_unref( gc );
}
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap, 0, 0, xx, yy, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap, 0, 0, xx, yy, -1, -1 );
}
else if (is_mono)
{
// we HAVE TO use the direct way for memory dcs
// that are bitmaps because XCopyArea doesn't cope
// with different bit depths
}
else if (is_mono)
{
// we HAVE TO use the direct way for memory dcs
// that are bitmaps because XCopyArea doesn't cope
// with different bit depths
// in the memory dc is copied in which case XCopyArea
// wouldn't be able able to boost performace by reducing
// the area to be scaled
// in the memory dc is copied in which case XCopyArea
// wouldn't be able able to boost performace by reducing
// the area to be scaled
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (tmp.IsEmpty())
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (tmp.IsEmpty())
// interpret userscale of src too
double xsc,ysc;
memDC->GetUserScale(&xsc,&ysc);
// interpret userscale of src too
double xsc,ysc;
memDC->GetUserScale(&xsc,&ysc);
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
tmp.GetBox(cx,cy,cw,ch);
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
tmp.GetBox(cx,cy,cw,ch);
// Scale and clipped bitmap
use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh);
}
// Scale and clipped bitmap
use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh);
}
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh );
// draw scaled bitmap
wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh );
// draw scaled bitmap
// copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
// copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
#endif
size_t datalen = strlen((const char*)data);
pango_layout_set_text( m_layout, (const char*) data, datalen);
#endif
size_t datalen = strlen((const char*)data);
pango_layout_set_text( m_layout, (const char*) data, datalen);
{
// If there is a user or actually any scale applied to
// the device context, scale the font.
{
// If there is a user or actually any scale applied to
// the device context, scale the font.
// scale font description
gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize;
size = size * m_scaleY;
pango_font_description_set_size( m_fontdesc, (gint)size );
// scale font description
gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize;
size = size * m_scaleY;
pango_font_description_set_size( m_fontdesc, (gint)size );
// actually apply scaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
// actually apply scaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
pango_layout_get_pixel_size( m_layout, &w, &h );
if ( m_backgroundMode == wxSOLID )
{
pango_layout_get_pixel_size( m_layout, &w, &h );
if ( m_backgroundMode == wxSOLID )
{
gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
}
gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
}
// Draw layout.
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
// Draw layout.
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
// actually apply unscaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
}
// actually apply unscaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
}
// undo underline attributes setting:
pango_layout_set_attributes(m_layout, NULL);
}
// undo underline attributes setting:
pango_layout_set_attributes(m_layout, NULL);
}
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
#ifdef __WXGTK20__
// implement later without GdkFont for GTK 2.0
GetTextExtent(text, &w, &h, NULL,NULL, &m_font);
#ifdef __WXGTK20__
// implement later without GdkFont for GTK 2.0
GetTextExtent(text, &w, &h, NULL,NULL, &m_font);
// calc max and min
wxCoord maxX = (wxCoord)(dmax(x2, dmax(x3, x4)) + 0.5),
maxY = (wxCoord)(dmax(y2, dmax(y3, y4)) + 0.5),
// calc max and min
wxCoord maxX = (wxCoord)(dmax(x2, dmax(x3, x4)) + 0.5),
maxY = (wxCoord)(dmax(y2, dmax(y3, y4)) + 0.5),
m_textForegroundColour.Green(),
m_textForegroundColour.Blue() );
image = image.Rotate( rad, wxPoint(0,0) );
m_textForegroundColour.Green(),
m_textForegroundColour.Blue() );
image = image.Rotate( rad, wxPoint(0,0) );
int xoffset = 0;
if ((i_angle >= 90.0) && (i_angle < 270.0))
xoffset = image.GetWidth();
int yoffset = 0;
if ((i_angle >= 0.0) && (i_angle < 180.0))
yoffset = image.GetHeight();
int xoffset = 0;
if ((i_angle >= 90.0) && (i_angle < 270.0))
xoffset = image.GetWidth();
int yoffset = 0;
if ((i_angle >= 0.0) && (i_angle < 180.0))
yoffset = image.GetHeight();
if ((i_angle >= 0) && (i_angle < 90))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 90) && (i_angle < 180))
if ((i_angle >= 0) && (i_angle < 90))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 90) && (i_angle < 180))
if ((i_angle >= 180) && (i_angle < 270))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 270) && (i_angle < 360))
xoffset -= (int)( sin(rad)*h );
if ((i_angle >= 180) && (i_angle < 270))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 270) && (i_angle < 360))
xoffset -= (int)( sin(rad)*h );
src = image;
DoDrawBitmap( src, i_x, i_y, true );
src = image;
DoDrawBitmap( src, i_x, i_y, true );
#ifdef __WXGTK20__
// Set new font description
if (theFont)
pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
#ifdef __WXGTK20__
// Set new font description
if (theFont)
pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
int baseline = pango_layout_iter_get_baseline(iter);
pango_layout_iter_free(iter);
*descent = h - PANGO_PIXELS(baseline);
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
int baseline = pango_layout_iter_get_baseline(iter);
pango_layout_iter_free(iter);
*descent = h - PANGO_PIXELS(baseline);
// Reset old font description
if (theFont)
pango_layout_set_font_description( m_layout, m_fontdesc );
// Reset old font description
if (theFont)
pango_layout_set_font_description( m_layout, m_fontdesc );
// We might want to use the X11 context for faster
// rendering on screen
if (m_font.GetNoAntiAliasing())
m_context = m_owner->GtkGetPangoX11Context();
else
m_context = m_owner->GtkGetPangoDefaultContext();
// We might want to use the X11 context for faster
// rendering on screen
if (m_font.GetNoAntiAliasing())
m_context = m_owner->GtkGetPangoX11Context();
else
m_context = m_owner->GtkGetPangoDefaultContext();
// If we switch back/forth between different contexts
// we also have to create a new layout. I think so,
// If we switch back/forth between different contexts
// we also have to create a new layout. I think so,
gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
}
}
gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
}
}
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );
int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH;
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );
int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH;
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
case wxOR_REVERSE: mode = GDK_OR_REVERSE; break;
case wxAND_REVERSE: mode = GDK_AND_REVERSE; break;
case wxCLEAR: mode = GDK_CLEAR; break;
case wxOR_REVERSE: mode = GDK_OR_REVERSE; break;
case wxAND_REVERSE: mode = GDK_AND_REVERSE; break;
case wxCLEAR: mode = GDK_CLEAR; break;
wxSize sz = win->GetSize();
m_paintClippingRegion = win->GetUpdateRegion();
wxLimitRegionToSize(m_paintClippingRegion, sz);
wxSize sz = win->GetSize();
m_paintClippingRegion = win->GetUpdateRegion();
wxLimitRegionToSize(m_paintClippingRegion, sz);