/////////////////////////////////////////////////////////////////////////////
-// Name: gtk/dcclient.cpp
+// Name: src/gtk/dcclient.cpp
// Purpose:
// Author: Robert Roebling
// RCS-ID: $Id$
#endif
#include "wx/dcclient.h"
-#include "wx/dcmemory.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/log.h"
+ #include "wx/dcmemory.h"
+ #include "wx/math.h" // for floating-point functions
+#endif
+
#include "wx/image.h"
#include "wx/module.h"
-#include "wx/log.h"
#include "wx/fontutil.h"
#include "wx/gtk/win_gtk.h"
-
-#include "wx/math.h" // for floating-point functions
+#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
for (int i = 0; i < wxGCPoolSize; i++)
{
if (wxGCPool[i].m_gc)
- gdk_gc_unref( wxGCPool[i].m_gc );
+ g_object_unref (wxGCPool[i].m_gc);
}
free(wxGCPool);
Destroy();
if (m_layout)
- g_object_unref( G_OBJECT( m_layout ) );
+ g_object_unref (m_layout);
if (m_fontdesc)
pango_font_description_free( m_fontdesc );
}
/* background colour */
m_backgroundBrush = *wxWHITE_BRUSH;
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
- GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
+#ifdef __WXGTK24__
+ const GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
+#else
+ GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
+#endif
/* m_textGC */
m_textForegroundColour.CalcPixel( m_cmap );
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
- bool is_mono = (bitmap.GetBitmap() != NULL);
+ bool is_mono = bitmap.GetDepth() == 1;
// scale/translate size and position
int xx = XLOG2DEV(x);
gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED );
gdk_gc_set_stipple( gc, mask );
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
- gdk_gc_unref( gc );
+ g_object_unref (gc);
}
if (is_mono)
GdkGC *gc = gdk_gc_new( bitmap2 );
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
- gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
+ gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap2, 0, 0, xx, yy, -1, -1 );
- gdk_bitmap_unref( bitmap2 );
- gdk_gc_unref( gc );
+ g_object_unref (bitmap2);
+ g_object_unref (gc);
}
else
{
else
#endif
{
- gdk_draw_pixmap(m_window, m_penGC,
- use_bitmap.GetPixmap(),
- 0, 0, xx, yy, -1, -1);
+ gdk_draw_drawable(m_window, m_penGC,
+ use_bitmap.GetPixmap(),
+ 0, 0, xx, yy, -1, -1);
}
}
}
if (new_mask)
- gdk_bitmap_unref( new_mask );
+ g_object_unref (new_mask);
}
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest,
gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED );
gdk_gc_set_stipple( gc, mask );
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh );
- gdk_gc_unref( gc );
+ g_object_unref (gc);
}
if (is_mono)
GdkGC *gc = gdk_gc_new( bitmap );
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_wx_draw_bitmap( bitmap, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
- gdk_bitmap_unref( bitmap );
- gdk_gc_unref( gc );
+ g_object_unref (bitmap);
+ g_object_unref (gc);
}
else
{
- // was: gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
- gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, cx, cy, cw, ch );
+ // was: gdk_draw_drawable( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
+ gdk_draw_drawable( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, cx, cy, cw, ch );
}
// remove mask again if any
}
if (new_mask)
- gdk_bitmap_unref( new_mask );
+ g_object_unref (new_mask);
}
else // use_bitmap_method
{
wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh );
// draw scaled bitmap
- // was: gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
- gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, cx, cy, -1, -1 );
+ // was: gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
+ gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, cx, cy, -1, -1 );
}
else
{
// copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
- gdk_draw_pixmap( m_window, m_penGC,
- srcDC->GetWindow(),
- xsrc, ysrc, xx, yy,
- width, height );
+ gdk_draw_drawable( m_window, m_penGC,
+ srcDC->GetWindow(),
+ xsrc, ysrc, xx, yy,
+ width, height );
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
}
}
bool underlined = m_font.Ok() && m_font.GetUnderlined();
-#if wxUSE_UNICODE
- const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
-#else
- const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
- if ( !wdata )
+ const wxCharBuffer data = wxGTK_CONV( text );
+ if ( !data )
return;
- const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
-#endif
- size_t datalen = strlen((const char*)data);
- pango_layout_set_text( m_layout, (const char*) data, datalen);
+ const size_t datalen = strlen(data);
+ pango_layout_set_text( m_layout, data, datalen);
if (underlined)
{
void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
{
+ if (!m_window || text.empty())
+ return;
+
+ wxCHECK_RET( Ok(), wxT("invalid window dc") );
+
if ( wxIsNullDouble(angle) )
{
DrawText(text, x, y);
return;
}
- wxCHECK_RET( Ok(), wxT("invalid window dc") );
-
- if (!m_window) return;
-
wxCoord w;
wxCoord h;
*externalLeading = 0;
if (string.empty())
- {
return;
- }
- // Set new font description
- if (theFont)
- pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
+ // ensure that theFont is always non-NULL
+ if ( !theFont || !theFont->Ok() )
+ theFont = wx_const_cast(wxFont *, &m_font);
- // Set layout's text
-#if wxUSE_UNICODE
- const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
- const char *dataUTF8 = (const char *)data;
-#else
- const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string );
- if ( !wdata )
- return;
-
- const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
- const char *dataUTF8 = (const char *)data;
-#endif
+ // and use it if it's valid
+ if ( theFont->Ok() )
+ {
+ pango_layout_set_font_description
+ (
+ m_layout,
+ theFont->GetNativeFontInfo()->description
+ );
+ }
+ // Set layout's text
+ const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, *theFont);
if ( !dataUTF8 )
{
// hardly ideal, but what else can we do if conversion failed?
if (oldContext != m_context)
{
if (m_layout)
- g_object_unref( G_OBJECT( m_layout ) );
+ g_object_unref (m_layout);
m_layout = pango_layout_new( m_context );
}
if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok()))
{
- if (m_brush.GetStipple()->GetPixmap())
+ if (m_brush.GetStipple()->GetDepth() != 1)
{
gdk_gc_set_fill( m_brushGC, GDK_TILED );
gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() );
else
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );
- gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() );
+ gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetPixmap() );
}
}
if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok()))
{
- if (m_backgroundBrush.GetStipple()->GetPixmap())
+ if (m_backgroundBrush.GetStipple()->GetDepth() != 1)
{
gdk_gc_set_fill( m_bgGC, GDK_TILED );
gdk_gc_set_tile( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() );
else
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
- gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetBitmap() );
+ gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() );
}
}