// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "dcclient.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/gtk/win_gtk.h"
-#include <math.h> // for floating-point functions
+#include "wx/math.h" // for floating-point functions
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
gint width,
gint height)
{
- g_return_if_fail (drawable != NULL);
- g_return_if_fail (src != NULL);
- g_return_if_fail (gc != NULL);
+ wxCHECK_RET( drawable, _T("NULL drawable in gdk_wx_draw_bitmap") );
+ wxCHECK_RET( src, _T("NULL src in gdk_wx_draw_bitmap") );
+ wxCHECK_RET( gc, _T("NULL gc in gdk_wx_draw_bitmap") );
#ifdef __WXGTK20__
gint src_width, src_height;
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
-#define GC_POOL_SIZE 200
-
enum wxPoolGCType
{
wxGC_ERROR = 0,
radius1 = 0.0;
radius2 = 360.0;
}
- else
- if (radius == 0.0)
+ else if ( wxIsNullDouble(radius) )
{
- radius1 = radius2 = 0.0;
+ radius1 =
+ radius2 = 0.0;
}
else
{
if (is_mono)
{
#ifdef __WXGTK20__
- GdkPixmap *bitmap = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, -1 );
- GdkGC *gc = gdk_gc_new( bitmap );
+ GdkPixmap *bitmap2 = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, -1 );
+ 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( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
+ gdk_wx_draw_bitmap( bitmap2, 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, bitmap2, 0, 0, xx, yy, -1, -1 );
- gdk_bitmap_unref( bitmap );
+ gdk_bitmap_unref( bitmap2 );
gdk_gc_unref( gc );
#else
gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
else
{
#if GTK_CHECK_VERSION(2,2,0)
- if (use_bitmap.HasPixbuf())
+ if (!gtk_check_version(2,2,0) && use_bitmap.HasPixbuf())
{
gdk_draw_pixbuf(m_window, m_penGC,
use_bitmap.GetPixbuf(),
bool use_bitmap_method = false;
bool is_mono = false;
- // TODO: use the mask origin when drawing transparently
if (xsrcMask == -1 && ysrcMask == -1)
{
xsrcMask = xsrc;
GdkGC *gc = gdk_gc_new( new_mask );
col.pixel = 0;
gdk_gc_set_foreground( gc, &col );
+ gdk_gc_set_ts_origin( gc, -xsrcMask, -ysrcMask);
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh );
col.pixel = 0;
gdk_gc_set_background( gc, &col );
if (is_mono)
{
if (new_mask)
+ {
gdk_gc_set_clip_mask( m_textGC, new_mask );
+ gdk_gc_set_clip_origin( m_textGC, cx, cy );
+ }
else
+ {
gdk_gc_set_clip_mask( m_textGC, mask );
- // was: gdk_gc_set_clip_origin( m_textGC, xx, yy );
- gdk_gc_set_clip_origin( m_textGC, cx, cy );
+ gdk_gc_set_clip_origin( m_textGC, cx-xsrcMask, cy-ysrcMask );
+ }
}
else
{
if (new_mask)
+ {
gdk_gc_set_clip_mask( m_penGC, new_mask );
+ gdk_gc_set_clip_origin( m_penGC, cx, cy );
+ }
else
+ {
gdk_gc_set_clip_mask( m_penGC, mask );
- // was: gdk_gc_set_clip_origin( m_penGC, xx, yy );
- gdk_gc_set_clip_origin( m_penGC, cx, cy );
+ gdk_gc_set_clip_origin( m_penGC, cx-xsrcMask, cy-ysrcMask );
+ }
}
}
void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
{
- if (angle == 0.0)
+ if ( wxIsNullDouble(angle) )
{
DrawText(text, x, y);
return;
int i_angle = (int) angle;
i_angle = i_angle % 360;
+ if (i_angle < 0)
+ i_angle += 360;
int xoffset = 0;
if ((i_angle >= 90.0) && (i_angle < 270.0))
xoffset = image.GetWidth();
#else
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string );
if ( !wdata )
- {
- if (width) (*width) = 0;
- if (height) (*height) = 0;
return;
- }
+
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
const char *dataUTF8 = (const char *)data;
#endif
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
- int w,h;
- pango_layout_get_pixel_size( m_layout, &w, &h );
-
- if (width)
- *width = (wxCoord) w;
- if (height)
- *height = (wxCoord) h;
if (descent)
{
+ int h;
+ pango_layout_get_pixel_size( m_layout, width, &h );
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);
+
+ if (height)
+ *height = (wxCoord) h;
+ }
+ else
+ {
+ pango_layout_get_pixel_size( m_layout, width, height );
}
// Reset old font description
{
#ifdef __WXGTK20__
pango_layout_set_text( m_layout, "H", 1 );
- int w,h;
- pango_layout_get_pixel_size( m_layout, &w, &h );
+ int w;
+ pango_layout_get_pixel_size( m_layout, &w, NULL );
return w;
#else
GdkFont *font = m_font.GetInternalFont( m_scaleY );
{
#ifdef __WXGTK20__
pango_layout_set_text( m_layout, "H", 1 );
- int w,h;
- pango_layout_get_pixel_size( m_layout, &w, &h );
+ int h;
+ pango_layout_get_pixel_size( m_layout, NULL, &h );
return h;
#else
GdkFont *font = m_font.GetInternalFont( m_scaleY );
PangoContext *oldContext = m_context;
// We might want to use the X11 context for faster
- // rendering on screen
+ // rendering on screen.
+ // MR: Lets not want to do this, as this introduces libpangox dependancy.
+#if 0
if (m_font.GetNoAntiAliasing())
m_context = m_owner->GtkGetPangoX11Context();
else
- m_context = m_owner->GtkGetPangoDefaultContext();
+#endif
+ 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 (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1)
if (req_dash && req_nb_dash)
{
wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash];
gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
}
}
-#endif // GTK+ > 1.0
GdkCapStyle capStyle = GDK_CAP_ROUND;
switch (m_pen.GetCap())
{
case wxXOR: mode = GDK_XOR; break;
case wxINVERT: mode = GDK_INVERT; break;
-#if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1)
case wxOR_REVERSE: mode = GDK_OR_REVERSE; break;
case wxAND_REVERSE: mode = GDK_AND_REVERSE; break;
case wxCLEAR: mode = GDK_CLEAR; break;
// unsupported by GTK
case wxNOR: mode = GDK_COPY; break;
-#endif // GTK+ > 1.0
default:
wxFAIL_MSG( wxT("unsupported logical function") );
mode = GDK_COPY;
void wxWindowDC::ComputeScaleAndOrigin()
{
- /* CMB: copy scale to see if it changes */
- double origScaleX = m_scaleX;
- double origScaleY = m_scaleY;
+ const wxRealPoint origScale(m_scaleX, m_scaleY);
wxDC::ComputeScaleAndOrigin();
- /* CMB: if scale has changed call SetPen to recalulate the line width */
- if ((m_scaleX != origScaleX || m_scaleY != origScaleY) &&
- (m_pen.Ok()))
+ // if scale has changed call SetPen to recalulate the line width
+ if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() )
{
- /* this is a bit artificial, but we need to force wxDC to think
- the pen has changed */
- wxPen pen = m_pen;
- m_pen = wxNullPen;
- SetPen( pen );
- }
+ // this is a bit artificial, but we need to force wxDC to think the pen
+ // has changed
+ wxPen pen = m_pen;
+ m_pen = wxNullPen;
+ SetPen( pen );
+ }
}
// Resolution in pixels per logical inch
int wxWindowDC::GetDepth() const
{
+#ifdef __WXGTK20__
+ return gdk_drawable_get_depth(m_window);
+#else
wxFAIL_MSG(wxT("not implemented"));
return -1;
+#endif
}