#include <gdk/gdk.h>
#include <gdk/gdkx.h>
+#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
#include "gdk/gdkprivate.h"
-void gdk_draw_bitmap (GdkDrawable *drawable,
+void gdk_wx_draw_bitmap (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,
gint xsrc,
gint width,
gint height)
{
+#ifdef __WXGTK20__
+ gint src_width, src_height;
+#else
GdkWindowPrivate *drawable_private;
GdkWindowPrivate *src_private;
GdkGCPrivate *gc_private;
+#endif
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
+#ifdef __WXGTK20__
+ if (GDK_WINDOW_DESTROYED(drawable) || GDK_WINDOW_DESTROYED(src))
+ return;
+
+ gdk_drawable_get_size(src, &src_width, &src_height);
+#else
drawable_private = (GdkWindowPrivate*) drawable;
src_private = (GdkWindowPrivate*) src;
if (drawable_private->destroyed || src_private->destroyed)
return;
+ src_width = src_private->width;
+ src_height = src_private->height;
+
gc_private = (GdkGCPrivate*) gc;
+#endif
- if (width == -1) width = src_private->width;
- if (height == -1) height = src_private->height;
+ if (width == -1) width = src_width;
+ if (height == -1) height = src_height;
+#ifdef __WXGTK20__
+ XCopyPlane( GDK_WINDOW_XDISPLAY(drawable),
+ GDK_WINDOW_XID(src),
+ GDK_WINDOW_XID(drawable),
+ GDK_GC_XGC(gc),
+ xsrc, ysrc,
+ width, height,
+ xdest, ydest,
+ 1 );
+#else
XCopyPlane( drawable_private->xdisplay,
src_private->xwindow,
drawable_private->xwindow,
width, height,
xdest, ydest,
1 );
+#endif
}
//-----------------------------------------------------------------------------
wxTEXT_COLOUR,
wxBG_COLOUR,
wxPEN_COLOUR,
- wxBRUSH_COLOUR
+ wxBRUSH_COLOUR,
+ wxTEXT_SCREEN,
+ wxBG_SCREEN,
+ wxPEN_SCREEN,
+ wxBRUSH_SCREEN
};
struct wxGC
m_isMemDC = FALSE;
m_isScreenDC = FALSE;
m_owner = (wxWindow *)NULL;
+#ifdef __WXGTK20__
+ m_context = (PangoContext *)NULL;
+ m_fontdesc = (PangoFontDescription *)NULL;
+#endif
}
wxWindowDC::wxWindowDC( wxWindow *window )
wxASSERT_MSG( widget, wxT("DC needs a widget") );
+#ifdef __WXGTK20__
+ m_context = gtk_widget_get_pango_context( widget );
+ m_fontdesc = widget->style->font_desc;
+#endif
+
GtkPizza *pizza = GTK_PIZZA( widget );
m_window = pizza->bin_window;
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
+ if (m_isScreenDC)
+ {
+ m_penGC = wxGetPoolGC( m_window, wxPEN_SCREEN );
+ m_brushGC = wxGetPoolGC( m_window, wxBRUSH_SCREEN );
+ m_textGC = wxGetPoolGC( m_window, wxTEXT_SCREEN );
+ m_bgGC = wxGetPoolGC( m_window, wxBG_SCREEN );
+ }
+ else
if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
{
m_penGC = wxGetPoolGC( m_window, wxPEN_MONO );
if (m_window)
{
if (m_brush.GetStyle() != wxTRANSPARENT)
- gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
+ {
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_arc( m_window, m_textGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
+ gdk_gc_set_ts_origin( m_textGC, 0, 0 );
+ } else
+ if (m_brush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
+ }
+ }
if (m_pen.GetStyle() != wxTRANSPARENT)
gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
wxCoord end = wxCoord(ea * 64.0);
if (m_brush.GetStyle() != wxTRANSPARENT)
- gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end );
+ {
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, ww, hh, start, end );
+ gdk_gc_set_ts_origin( m_textGC, 0, 0 );
+ } else
+ if (m_brush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end );
+ }
+ }
if (m_pen.GetStyle() != wxTRANSPARENT)
gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, start, end );
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */
if (is_mono)
- gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
+ gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
drawing a mono-bitmap (XBitmap) we use the current text GC */
if (is_mono)
- gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
+ gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
wxCHECK_RET( font, wxT("invalid font") );
+#ifdef __WXGTK20__
+ wxCHECK_RET( m_context, wxT("no Pango context") );
+#endif
+
x = XLOG2DEV(x);
y = YLOG2DEV(y);
+#ifdef __WXGTK20__
+ /* FIXME: the layout engine should probably be abstracted at a higher level in wxDC... */
+ PangoLayout *layout = pango_layout_new(m_context);
+ pango_layout_set_font_description(layout, m_fontdesc);
+ {
+ wxWX2MBbuf data = text.mb_str(wxConvUTF8);
+ pango_layout_set_text(layout, data, strlen(data));
+ }
+ PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
+ PangoRectangle rect;
+ pango_layout_line_get_extents(line, NULL, &rect);
+ wxCoord width = rect.width;
+ wxCoord height = rect.height;
+ gdk_draw_layout( m_window, m_textGC, x, y, layout );
+#else
+ wxCoord width = gdk_string_width( font, text.mbc_str() );
+ wxCoord height = font->ascent + font->descent;
/* CMB 21/5/98: draw text background if mode is wxSOLID */
if (m_backgroundMode == wxSOLID)
{
- wxCoord width = gdk_string_width( font, text.mbc_str() );
- wxCoord height = font->ascent + font->descent;
gdk_gc_set_foreground( m_textGC, m_textBackgroundColour.GetColor() );
gdk_draw_rectangle( m_window, m_textGC, TRUE, x, y, width, height );
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
}
gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text.mbc_str() );
+#endif
/* CMB 17/7/98: simple underline: ignores scaling and underlying
X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS
properties (see wxXt implementation) */
if (m_font.GetUnderlined())
{
- wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord ul_y = y + font->ascent;
if (font->descent > 0) ul_y++;
gdk_draw_line( m_window, m_textGC, x, ul_y, x + width, ul_y);
}
- wxCoord w, h;
- GetTextExtent (text, &w, &h);
- CalcBoundingBox (x + w, y + h);
+#ifdef __WXGTK20__
+ g_object_unref( G_OBJECT( layout ) );
+#endif
+
+ width = wxCoord(width / m_scaleX);
+ height = wxCoord(height / m_scaleY);
+ CalcBoundingBox (x + width, y + height);
CalcBoundingBox (x, y);
}
for ( wxCoord srcY = 0; srcY < h; srcY++ )
{
// transform source coords to dest coords
- double r = sqrt(srcX*srcX + srcY*srcY);
- double angleOrig = atan2(srcY, srcX) - rad;
+ double r = sqrt((double)srcX*srcX + srcY*srcY);
+ double angleOrig = atan2((double)srcY, (double)srcX) - rad;
wxCoord dstX = (wxCoord)(r*cos(angleOrig) + 0.5),
dstY = (wxCoord)(r*sin(angleOrig) + 0.5);
void wxWindowDC::SetFont( const wxFont &font )
{
m_font = font;
+#ifdef __WXGTK20__
+ // fix fontdesc?
+#endif
}
void wxWindowDC::SetPen( const wxPen &pen )