- Added wxWrapSizer (Arne Steinarson)
- Added wxSpinCtrlDouble (John Labenski)
- Added multisample (anti-aliasing) support to wxGLCanvas (Olivier Playez).
+- Initialize wx{Client,Paint,Window}DC with fonts/colours of its window.
- Added wxNativeContainerWindow to allow embedding wx into native windows
- Added custom controls support to wxFileDialog (Diaa Sami and Marcin Wojdyr)
- Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron).
{
public:
wxDCImpl( wxDC *owner );
- ~wxDCImpl();
+ virtual ~wxDCImpl();
wxDC *GetOwner() const { return m_owner; }
// setters and getters
virtual void SetFont(const wxFont& font) = 0;
- virtual const wxFont& GetFont() const { return m_font; }
+ virtual const wxFont& GetFont() const { return m_font; }
virtual void SetPen(const wxPen& pen) = 0;
- virtual const wxPen& GetPen() const { return m_pen; }
+ virtual const wxPen& GetPen() const { return m_pen; }
virtual void SetBrush(const wxBrush& brush) = 0;
- virtual const wxBrush& GetBrush() const { return m_brush; }
+ virtual const wxBrush& GetBrush() const { return m_brush; }
virtual void SetBackground(const wxBrush& brush) = 0;
- virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
+ virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
virtual void SetBackgroundMode(int mode) = 0;
virtual int GetBackgroundMode() const { return m_backgroundMode; }
virtual void SetTextForeground(const wxColour& colour)
{ m_textForegroundColour = colour; }
- virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
+ virtual const wxColour& GetTextForeground() const
+ { return m_textForegroundColour; }
virtual void SetTextBackground(const wxColour& colour)
{ m_textBackgroundColour = colour; }
- virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
+ virtual const wxColour& GetTextBackground() const
+ { return m_textBackgroundColour; }
#if wxUSE_PALETTE
virtual void SetPalette(const wxPalette& palette) = 0;
#endif // wxUSE_PALETTE
+ // inherit the DC attributes (font and colours) from the given window
+ //
+ // this is called automatically when a window, client or paint DC is
+ // created
+ virtual void InheritAttributes(wxWindow *win);
+
+
// logical functions
virtual void SetLogicalFunction(int function) = 0;
A wxDC is a @e "device context" onto which graphics and text can be drawn.
It is intended to represent different output devices and offers a common
abstract API for drawing on any of them.
-
+
wxWidgets offers an alternative drawing API based on the modern drawing
backends GDI+, CoreGraphics and Cairo. See wxGraphicsContext, wxGraphicsRenderer
and related classes. There is also a wxGCDC linking the APIs by offering
wxDC is an abstract base class and cannot be created directly.
Use wxPaintDC, wxClientDC, wxWindowDC, wxScreenDC, wxMemoryDC or
- wxPrinterDC.
+ wxPrinterDC. Notice that device contexts which are associated with windows
+ (i.e. wxClientDC, wxWindowDC and wxPaintDC) use the window font and colours
+ by default (starting with wxWidgets 2.9.0) but the other device context
+ classes use system-default values so you always must set the appropriate
+ fonts and colours before using them.
In addition to the versions of the methods documented below, there
are also versions which accept single wxPoint parameter instead
To draw on the whole window including decorations, construct a wxWindowDC
object (Windows only).
+ A wxPaintDC object is initialized to use the same font and colours as the
+ window it is associated with.
+
@library{wxcore}
@category{dc}
To draw on the whole window including decorations, construct a wxWindowDC
object (Windows only).
+ A wxClientDC object is initialized to use the same font and colours as the
+ window it is associated with.
+
@library{wxcore}
@category{dc}
To draw on the client area of a window from outside an EVT_PAINT() handler,
construct a wxClientDC object.
+ A wxWindowDC object is initialized to use the same font and colours as the
+ window it is associated with.
+
@library{wxcore}
@category{dc}
wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window )
{
- return new wxWindowDCImpl( owner, window );
+ wxDCImpl * const impl = new wxWindowDCImpl( owner, window );
+ impl->InheritAttributes(window);
+ return impl;
}
wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner, wxWindow *window )
{
- return new wxClientDCImpl( owner, window );
+ wxDCImpl * const impl = new wxClientDCImpl( owner, window );
+ impl->InheritAttributes(window);
+ return impl;
}
wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner, wxWindow *window )
{
- return new wxPaintDCImpl( owner, window );
+ wxDCImpl * const impl = new wxPaintDCImpl( owner, window );
+ impl->InheritAttributes(window);
+ return impl;
}
wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner )
m_pen.SetColour(oldPenColour);
}
+void wxDCImpl::InheritAttributes(wxWindow *win)
+{
+ wxCHECK_RET( win, "window can't be NULL" );
+
+ SetFont(win->GetFont());
+ SetTextForeground(win->GetForegroundColour());
+ SetTextBackground(win->GetBackgroundColour());
+ SetBackground(wxBrush(win->GetBackgroundColour()));
+}
+
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
// DrawText() to OPAQUE as required, otherwise always TRANSPARENT,
::SetBkMode(GetHdc(), TRANSPARENT);
- // default bg colour is pne of the window
- SetBackground(wxBrush(m_window->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
-
// since we are a window dc we need to grab the palette from the window
#if wxUSE_PALETTE
InitializePalette();