wxPaintDC::wxPaintDC(void)
{
+ m_penGC = NULL;
+ m_brushGC = NULL;
+ m_textGC = NULL;
+ m_bgGC = NULL;
+ m_cmap = NULL;
};
wxPaintDC::wxPaintDC( wxWindow *window )
{
+ m_penGC = NULL;
+ m_brushGC = NULL;
+ m_textGC = NULL;
+ m_bgGC = NULL;
+ m_cmap = NULL;
+
if (!window) return;
GtkWidget *widget = window->m_wxwindow;
if (!widget) return;
return TRUE;
};
-void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(use16) )
+void wxPaintDC::DrawText( const wxString &text, long x, long y, bool
+WXUNUSED(use16) )
{
if (!Ok()) return;
-
+
GdkFont *font = m_font.GetInternalFont( m_scaleY );
+ x = XLOG2DEV(x);
+ y = YLOG2DEV(y);
+
// CMB 21/5/98: draw text background if mode is wxSOLID
if (m_backgroundMode == wxSOLID)
{
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,
- XLOG2DEV(x),
- YLOG2DEV(y) + font->ascent, text );
+ gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text );
+
+ // 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())
+ {
+ long width = gdk_string_width( font, text );
+ long 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);
+ }
};
+
+
bool wxPaintDC::CanGetTextExtent(void) const
{
return TRUE;
};
};
+// CMB 21/7/98: Added SetBackground. Sets background brush
+// for Clear() and bg colour for shapes filled with cross-hatch brush
+void wxPaintDC::SetBackground( const wxBrush &brush )
+{
+ if (!Ok()) return;
+
+ if (m_backgroundBrush == brush) return;
+
+ m_backgroundBrush = brush;
+
+ if (!m_backgroundBrush.Ok()) return;
+
+ m_backgroundBrush.GetColour().CalcPixel( m_cmap );
+ gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() );
+ gdk_gc_set_foreground( m_bgGC, m_backgroundBrush.GetColour().GetColor() );
+
+ GdkFill fillStyle = GDK_SOLID;
+ switch (m_backgroundBrush.GetStyle())
+ {
+ case wxSOLID:
+ case wxTRANSPARENT:
+ break;
+ default:
+ fillStyle = GDK_STIPPLED;
+ };
+
+ gdk_gc_set_fill( m_bgGC, fillStyle );
+
+ if (m_backgroundBrush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() );
+ };
+
+ if (IS_HATCH(m_backgroundBrush.GetStyle()))
+ {
+ int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
+ gdk_gc_set_stipple( m_bgGC, hatches[num] );
+ };
+};
+
void wxPaintDC::SetLogicalFunction( int function )
{
if (m_logicalFunction == function) return;
void wxPaintDC::SetBackgroundMode( int mode )
{
m_backgroundMode = mode;
+
+ // CMB 21/7/98: fill style of cross-hatch brushes is affected by
+ // transparent/solid background mode
+ if (m_brush.GetStyle() != wxSOLID && m_brush.GetStyle() != wxTRANSPARENT)
+ {
+ gdk_gc_set_fill( m_brushGC,
+ (m_backgroundMode == wxTRANSPARENT) ? GDK_STIPPLED : GDK_OPAQUE_STIPPLED);
+ }
};
void wxPaintDC::SetPalette( const wxPalette& WXUNUSED(palette) )
{
m_ok = TRUE;
m_logicalFunction = wxCOPY;
+ if (m_penGC) gdk_gc_unref( m_penGC );
m_penGC = gdk_gc_new( m_window );
+ if (m_brushGC) gdk_gc_unref( m_brushGC );
m_brushGC = gdk_gc_new( m_window );
+ if (m_textGC) gdk_gc_unref( m_textGC );
m_textGC = gdk_gc_new( m_window );
+ if (m_bgGC) gdk_gc_unref( m_bgGC );
m_bgGC = gdk_gc_new( m_window );
SetTextForeground( m_textForegroundColour );
SetTextBackground( m_textBackgroundColour );