X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e1208c3103734c8581c9854c344b97323e381897..37d403aa1cf182cfc01e2ce1753c2dda39ba82ea:/src/gtk1/dcclient.cpp diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 465a33f868..9ffa33f3ba 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -11,6 +11,10 @@ #pragma implementation "dcclient.h" #endif +#ifdef __VMS +#define XCopyPlane XCOPYPLANE +#endif + #include "wx/dcclient.h" #include "wx/dcmemory.h" #include "wx/image.h" @@ -22,6 +26,7 @@ #include #include +#include #include //----------------------------------------------------------------------------- @@ -42,6 +47,10 @@ #include "cross.xbm" #define num_hatches 6 +#define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH) +#define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH) + + static GdkPixmap *hatches[num_hatches]; static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL; @@ -68,7 +77,7 @@ static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } #include "gdk/gdkprivate.h" -void gdk_draw_bitmap (GdkDrawable *drawable, +void gdk_wx_draw_bitmap (GdkDrawable *drawable, GdkGC *gc, GdkDrawable *src, gint xsrc, @@ -78,24 +87,47 @@ void gdk_draw_bitmap (GdkDrawable *drawable, gint width, gint height) { + gint src_width, src_height; +#ifndef __WXGTK20__ 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, @@ -104,6 +136,7 @@ void gdk_draw_bitmap (GdkDrawable *drawable, width, height, xdest, ydest, 1 ); +#endif } //----------------------------------------------------------------------------- @@ -122,7 +155,11 @@ enum wxPoolGCType wxTEXT_COLOUR, wxBG_COLOUR, wxPEN_COLOUR, - wxBRUSH_COLOUR + wxBRUSH_COLOUR, + wxTEXT_SCREEN, + wxBG_SCREEN, + wxPEN_SCREEN, + wxBRUSH_SCREEN }; struct wxGC @@ -165,9 +202,9 @@ static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type ) return wxGCPool[i].m_gc; } } - + wxFAIL_MSG( wxT("No GC available") ); - + return (GdkGC*) NULL; } @@ -181,7 +218,7 @@ static void wxFreePoolGC( GdkGC *gc ) return; } } - + wxFAIL_MSG( wxT("Wrong GC") ); } @@ -201,6 +238,10 @@ wxWindowDC::wxWindowDC() 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 ) @@ -230,6 +271,11 @@ 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; @@ -264,9 +310,17 @@ wxWindowDC::~wxWindowDC() void wxWindowDC::SetUpDC() { m_ok = TRUE; - + 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 ); @@ -300,29 +354,27 @@ void wxWindowDC::SetUpDC() 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 ); @@ -438,7 +490,40 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, 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 (IS_15_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + 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 + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + 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 + 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 ); @@ -467,7 +552,40 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord 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 (IS_15_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_gc_set_ts_origin( m_brushGC, 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 ); @@ -532,16 +650,28 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor { if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), + gdk_gc_set_ts_origin( m_textGC, + m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else + if (IS_15_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else if (m_brush.GetStyle() == wxSTIPPLE) { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), + gdk_gc_set_ts_origin( m_brushGC, + m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); @@ -552,8 +682,6 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor } } - // To do: Fillstyle - if (m_pen.GetStyle() != wxTRANSPARENT) { for (i = 0 ; i < n ; i++) @@ -592,16 +720,28 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h { if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), + gdk_gc_set_ts_origin( m_textGC, + m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } - else if (m_brush.GetStyle() == wxSTIPPLE) + } else + if (IS_15_PIX_HATCH(m_brush.GetStyle())) { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); + gdk_gc_set_ts_origin( m_brushGC, 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_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); @@ -666,20 +806,71 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx if (m_brush.GetStyle() != wxTRANSPARENT) { - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + 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_rectangle( m_window, m_textGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_gc_set_ts_origin( m_textGC, 0, 0 ); + } else + if (IS_15_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_gc_set_ts_origin( m_brushGC, 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_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } + else + { + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + } } if (m_pen.GetStyle() != wxTRANSPARENT) { - gdk_draw_line( m_window, m_penGC, xx+rr, yy, xx+ww-rr, yy ); - gdk_draw_line( m_window, m_penGC, xx+rr, yy+hh, xx+ww-rr, yy+hh ); - gdk_draw_line( m_window, m_penGC, xx, yy+rr, xx, yy+hh-rr ); - gdk_draw_line( m_window, m_penGC, xx+ww, yy+rr, xx+ww, yy+hh-rr ); + gdk_draw_line( m_window, m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); + gdk_draw_line( m_window, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); + gdk_draw_line( m_window, m_penGC, xx, yy+rr+1, xx, yy+hh-rr ); + gdk_draw_line( m_window, m_penGC, xx+ww, yy+rr+1, xx+ww, yy+hh-rr ); gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, dd, dd, 90*64, 90*64 ); gdk_draw_arc( m_window, m_penGC, FALSE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); gdk_draw_arc( m_window, m_penGC, FALSE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); @@ -708,7 +899,40 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei if (m_window) { if (m_brush.GetStyle() != wxTRANSPARENT) - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + { + 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, 0, 360*64 ); + gdk_gc_set_ts_origin( m_textGC, 0, 0 ); + } else + if (IS_15_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_gc_set_ts_origin( m_brushGC, 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, 0, 360*64 ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } + else + { + gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + } + } if (m_pen.GetStyle() != wxTRANSPARENT) gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); @@ -757,7 +981,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, if (tmp.IsEmpty()) return; } - + /* scale bitmap if required */ wxBitmap use_bitmap; if ((w != ww) || (h != hh)) @@ -798,17 +1022,9 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, 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_set_clip_mask( m_brushGC, NULL ); - gdk_gc_set_clip_mask( m_textGC, NULL ); - SetBrush( *wxRED_BRUSH ); - DrawRectangle( 70, 0, 70, 1000 ); - gdk_draw_bitmap( m_window, m_textGC, new_mask, 0, 0, 100, 5, ww, hh ); - gdk_draw_bitmap( m_window, m_textGC, mask, 0, 0, 80, 5, ww, hh ); -*/ gdk_gc_unref( gc ); } - + if (is_mono) { if (new_mask) @@ -832,7 +1048,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, /* 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 ); @@ -939,7 +1155,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he int old_logical_func = m_logicalFunction; SetLogicalFunction( logical_func ); - + if (use_bitmap_method) { /* scale/translate bitmap size */ @@ -993,7 +1209,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh ); gdk_gc_unref( gc ); } - + if (is_mono) { if (new_mask) @@ -1016,9 +1232,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he /* 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(), 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 ); @@ -1059,28 +1275,22 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he for a different implementation of the same problem. */ wxBitmap bitmap( width, height ); - - if (srcDC->m_isScreenDC) - gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); + /* copy including child window contents */ + gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); gdk_window_copy_area( bitmap.GetPixmap(), m_penGC, 0, 0, srcDC->GetWindow(), xsrc, ysrc, width, height ); + gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); - if (srcDC->m_isScreenDC) - gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); - /* scale image */ - wxImage image( bitmap ); image = image.Scale( ww, hh ); /* convert to bitmap */ - bitmap = image.ConvertToBitmap(); /* draw scaled bitmap */ - gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); } @@ -1088,15 +1298,12 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he { /* No scaling and not a memory dc with a mask either */ - if (srcDC->m_isScreenDC) - gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); - + /* copy including child window contents */ + gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); gdk_window_copy_area( m_window, m_penGC, xx, yy, srcDC->GetWindow(), xsrc, ysrc, width, height ); - - if (srcDC->m_isScreenDC) - gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); } } @@ -1114,34 +1321,57 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) 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); } @@ -1213,8 +1443,8 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord 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); @@ -1322,6 +1552,9 @@ void wxWindowDC::Clear() void wxWindowDC::SetFont( const wxFont &font ) { m_font = font; +#ifdef __WXGTK20__ + // fix fontdesc? +#endif } void wxWindowDC::SetPen( const wxPen &pen ) @@ -1352,15 +1585,15 @@ void wxWindowDC::SetPen( const wxPen &pen ) width = (int)w; } - static const char dotted[] = {1, 1}; - static const char short_dashed[] = {2, 2}; - static const char wxCoord_dashed[] = {2, 4}; - static const char dotted_dashed[] = {3, 3, 1, 3}; + static const wxGTKDash dotted[] = {1, 1}; + static const wxGTKDash short_dashed[] = {2, 2}; + static const wxGTKDash wxCoord_dashed[] = {2, 4}; + static const wxGTKDash dotted_dashed[] = {3, 3, 1, 3}; // We express dash pattern in pen width unit, so we are // independent of zoom factor and so on... int req_nb_dash; - const char *req_dash; + const wxGTKDash *req_dash; GdkLineStyle lineStyle = GDK_LINE_SOLID; switch (m_pen.GetStyle()) @@ -1369,7 +1602,7 @@ void wxWindowDC::SetPen( const wxPen &pen ) { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = m_pen.GetDashCount(); - req_dash = m_pen.GetDash(); + req_dash = (wxGTKDash*)m_pen.GetDash(); break; } case wxDOT: @@ -1409,16 +1642,16 @@ void wxWindowDC::SetPen( const wxPen &pen ) default: { lineStyle = GDK_LINE_SOLID; - req_dash = (wxDash*)NULL; + req_dash = (wxGTKDash*)NULL; req_nb_dash = 0; break; } } -#if (GTK_MINOR_VERSION > 0) +#if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1) if (req_dash && req_nb_dash) { - char *real_req_dash = new char[req_nb_dash]; + wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash]; if (real_req_dash) { for (int i = 0; i < req_nb_dash; i++) @@ -1429,7 +1662,7 @@ void wxWindowDC::SetPen( const wxPen &pen ) else { // No Memory. We use non-scaled dash pattern... - gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash ); + gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash ); } } #endif @@ -1669,8 +1902,6 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo { wxCHECK_RET( Ok(), wxT("invalid window dc") ); - wxDC::DoSetClippingRegion( x, y, width, height ); - if (!m_window) return; wxRect rect; @@ -1678,17 +1909,21 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo rect.y = YLOG2DEV(y); rect.width = XLOG2DEVREL(width); rect.height = YLOG2DEVREL(height); - + if (!m_currentClippingRegion.IsNull()) m_currentClippingRegion.Intersect( rect ); else m_currentClippingRegion.Union( rect ); - -#if USE_PAINT_REGION + +#if USE_PAINT_REGION if (!m_paintClippingRegion.IsNull()) m_currentClippingRegion.Intersect( m_paintClippingRegion ); #endif + wxCoord xx, yy, ww, hh; + m_currentClippingRegion.GetBox( xx, yy, ww, hh ); + wxDC::DoSetClippingRegion( xx, yy, ww, hh ); + gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() ); gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); @@ -1705,23 +1940,22 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) return; } - wxCoord x,y,w,h; - region.GetBox( x, y, w, h ); - - wxDC::DoSetClippingRegion( x, y, w, h ); - if (!m_window) return; - + if (!m_currentClippingRegion.IsNull()) m_currentClippingRegion.Intersect( region ); else m_currentClippingRegion.Union( region ); - -#if USE_PAINT_REGION + +#if USE_PAINT_REGION if (!m_paintClippingRegion.IsNull()) m_currentClippingRegion.Intersect( m_paintClippingRegion ); #endif + wxCoord xx, yy, ww, hh; + m_currentClippingRegion.GetBox( xx, yy, ww, hh ); + wxDC::DoSetClippingRegion( xx, yy, ww, hh ); + gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() ); gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); @@ -1735,8 +1969,8 @@ void wxWindowDC::DestroyClippingRegion() wxDC::DestroyClippingRegion(); m_currentClippingRegion.Clear(); - -#if USE_PAINT_REGION + +#if USE_PAINT_REGION if (!m_paintClippingRegion.IsEmpty()) m_currentClippingRegion.Union( m_paintClippingRegion ); #endif @@ -1988,14 +2222,21 @@ wxPaintDC::wxPaintDC() wxPaintDC::wxPaintDC( wxWindow *win ) : wxWindowDC( win ) { -#if USE_PAINT_REGION - m_paintClippingRegion = win->GetUpdateRegion(); - m_currentClippingRegion.Union( m_paintClippingRegion ); +#if USE_PAINT_REGION + if (!win->m_clipPaintRegion) + return; - gdk_gc_set_clip_region( m_penGC, m_paintClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_brushGC, m_paintClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() ); + m_paintClippingRegion = win->GetUpdateRegion(); + GdkRegion *region = m_paintClippingRegion.GetRegion(); + if ( region ) + { + m_currentClippingRegion.Union( m_paintClippingRegion ); + + gdk_gc_set_clip_region( m_penGC, region ); + gdk_gc_set_clip_region( m_brushGC, region ); + gdk_gc_set_clip_region( m_textGC, region ); + gdk_gc_set_clip_region( m_bgGC, region ); + } #endif }