DC reorganization
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#define _WX_MSW_DC_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/dc.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// macros
|
||||
@@ -42,11 +43,11 @@ public:
|
||||
|
||||
// this is an ABC: use one of the derived classes to create a DC associated
|
||||
// with a window, screen, printer and so on
|
||||
class WXDLLEXPORT wxDC : public wxDCBase
|
||||
class WXDLLEXPORT wxMSWDCImpl: public wxDCImpl
|
||||
{
|
||||
public:
|
||||
wxDC(WXHDC hDC) { Init(); m_hDC = hDC; }
|
||||
virtual ~wxDC();
|
||||
wxMSWDCImpl(wxDC *owner, WXHDC hDC);
|
||||
virtual ~wxMSWDCImpl();
|
||||
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
@@ -94,10 +95,9 @@ public:
|
||||
virtual void SetRop(WXHDC cdc);
|
||||
virtual void SelectOldObjects(WXHDC dc);
|
||||
|
||||
wxWindow *GetWindow() const { return m_canvas; }
|
||||
void SetWindow(wxWindow *win)
|
||||
{
|
||||
m_canvas = win;
|
||||
m_window = win;
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
// if we have palettes use the correct one for this window
|
||||
@@ -145,7 +145,6 @@ public:
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
m_canvas = NULL;
|
||||
m_bOwnsDC = false;
|
||||
m_hDC = NULL;
|
||||
|
||||
@@ -161,7 +160,7 @@ protected:
|
||||
|
||||
// create an uninitialized DC: this should be only used by the derived
|
||||
// classes
|
||||
wxDC() { Init(); }
|
||||
wxMSWDCImpl( wxDC *owner ) : wxDCImpl( owner ) { Init(); }
|
||||
|
||||
void RealizeScaleAndOrigin();
|
||||
|
||||
@@ -302,12 +301,12 @@ protected:
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
#if wxUSE_DC_CACHEING
|
||||
static wxList sm_bitmapCache;
|
||||
static wxList sm_dcCache;
|
||||
static wxObjectList sm_bitmapCache;
|
||||
static wxObjectList sm_dcCache;
|
||||
#endif
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxDC)
|
||||
DECLARE_NO_COPY_CLASS(wxDC)
|
||||
DECLARE_CLASS(wxMSWDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxMSWDCImpl)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -315,18 +314,18 @@ protected:
|
||||
// only/mainly)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDCTemp : public wxDC
|
||||
class WXDLLEXPORT wxDCTempImpl: public wxMSWDCImpl
|
||||
{
|
||||
public:
|
||||
// construct a temporary DC with the specified HDC and size (it should be
|
||||
// specified whenever we know it for this HDC)
|
||||
wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize)
|
||||
: wxDC(hdc),
|
||||
wxDCTempImpl(wxDC *owner, WXHDC hdc, const wxSize& size )
|
||||
: wxMSWDCImpl( owner, hdc ),
|
||||
m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~wxDCTemp()
|
||||
virtual ~wxDCTempImpl()
|
||||
{
|
||||
// prevent base class dtor from freeing it
|
||||
SetHDC((WXHDC)NULL);
|
||||
@@ -349,8 +348,20 @@ private:
|
||||
// find it ourselves
|
||||
const wxSize m_size;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDCTemp)
|
||||
DECLARE_NO_COPY_CLASS(wxDCTempImpl)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxDCTemp: public wxDC
|
||||
{
|
||||
public:
|
||||
wxDCTemp( WXHDC hdc, const wxSize& size = wxDefaultSize )
|
||||
{
|
||||
m_pimpl = new wxDCTempImpl( this, hdc, size );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _WX_MSW_DC_H_
|
||||
|
||||
|
@@ -17,6 +17,8 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/msw/dc.h"
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/dynarray.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -32,14 +34,14 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxPaintDCInfo, wxArrayDCInfo);
|
||||
// DC classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxWindowDC : public wxDC
|
||||
class WXDLLEXPORT wxWindowDCImpl : public wxMSWDCImpl
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
wxWindowDC();
|
||||
wxWindowDCImpl( wxDC *owner );
|
||||
|
||||
// Create a DC corresponding to the whole window
|
||||
wxWindowDC(wxWindow *win);
|
||||
wxWindowDCImpl( wxDC *owner, wxWindow *win );
|
||||
|
||||
protected:
|
||||
// initialize the newly created DC
|
||||
@@ -49,19 +51,20 @@ protected:
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWindowDC)
|
||||
DECLARE_CLASS(wxWindowDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxWindowDCImpl)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxClientDC : public wxWindowDC
|
||||
class WXDLLEXPORT wxClientDCImpl : public wxWindowDCImpl
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
wxClientDC();
|
||||
wxClientDCImpl( wxDC *owner );
|
||||
|
||||
// Create a DC corresponding to the client area of the window
|
||||
wxClientDC(wxWindow *win);
|
||||
wxClientDCImpl( wxDC *owner, wxWindow *win );
|
||||
|
||||
virtual ~wxClientDC();
|
||||
virtual ~wxClientDCImpl();
|
||||
|
||||
protected:
|
||||
void InitDC();
|
||||
@@ -70,18 +73,19 @@ protected:
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxClientDC)
|
||||
DECLARE_CLASS(wxClientDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxClientDCImpl)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxPaintDC : public wxClientDC
|
||||
class WXDLLEXPORT wxPaintDCImpl : public wxClientDCImpl
|
||||
{
|
||||
public:
|
||||
wxPaintDC();
|
||||
wxPaintDCImpl( wxDC *owner );
|
||||
|
||||
// Create a DC corresponding for painting the window in OnPaint()
|
||||
wxPaintDC(wxWindow *win);
|
||||
wxPaintDCImpl( wxDC *owner, wxWindow *win );
|
||||
|
||||
virtual ~wxPaintDC();
|
||||
virtual ~wxPaintDCImpl();
|
||||
|
||||
// find the entry for this DC in the cache (keyed by the window)
|
||||
static WXHDC FindDCInCache(wxWindow* win);
|
||||
@@ -93,7 +97,8 @@ protected:
|
||||
wxPaintDCInfo *FindInCache(size_t *index = NULL) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPaintDC)
|
||||
DECLARE_CLASS(wxPaintDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxPaintDCImpl)
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -106,10 +111,8 @@ class WXDLLEXPORT wxPaintDCEx : public wxPaintDC
|
||||
{
|
||||
public:
|
||||
wxPaintDCEx(wxWindow *canvas, WXHDC dc);
|
||||
virtual ~wxPaintDCEx();
|
||||
|
||||
private:
|
||||
int saveState;
|
||||
|
||||
DECLARE_CLASS(wxPaintDCEx)
|
||||
DECLARE_NO_COPY_CLASS(wxPaintDCEx)
|
||||
};
|
||||
|
@@ -12,14 +12,15 @@
|
||||
#ifndef _WX_DCMEMORY_H_
|
||||
#define _WX_DCMEMORY_H_
|
||||
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/msw/dc.h"
|
||||
|
||||
class WXDLLEXPORT wxMemoryDC : public wxDC, public wxMemoryDCBase
|
||||
class WXDLLEXPORT wxMemoryDCImpl: public wxMSWDCImpl
|
||||
{
|
||||
public:
|
||||
wxMemoryDC() { CreateCompatible(NULL); Init(); }
|
||||
wxMemoryDC(wxBitmap& bitmap) { CreateCompatible(NULL); Init(); SelectObject(bitmap); }
|
||||
wxMemoryDC(wxDC *dc); // Create compatible DC
|
||||
wxMemoryDCImpl( wxMemoryDC *owner );
|
||||
wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap );
|
||||
wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC
|
||||
|
||||
|
||||
protected:
|
||||
@@ -38,7 +39,8 @@ protected:
|
||||
void Init();
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMemoryDC)
|
||||
DECLARE_CLASS(wxMemoryDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxMemoryDCImpl)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -14,19 +14,20 @@
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/dcprint.h"
|
||||
#include "wx/cmndata.h"
|
||||
#include "wx/msw/dc.h"
|
||||
|
||||
class WXDLLEXPORT wxPrinterDC : public wxDC
|
||||
// ------------------------------------------------------------------------
|
||||
// wxPrinterDCImpl
|
||||
//
|
||||
|
||||
class WXDLLEXPORT wxPrinterDCImpl : public wxMSWDCImpl
|
||||
{
|
||||
public:
|
||||
// Create a printer DC (obsolete function: use wxPrintData version now)
|
||||
wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = true, int orientation = wxPORTRAIT);
|
||||
|
||||
// Create from print data
|
||||
wxPrinterDC(const wxPrintData& data);
|
||||
|
||||
wxPrinterDC(WXHDC theDC);
|
||||
wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data );
|
||||
wxPrinterDCImpl( wxPrinterDC *owner, WXHDC theDC );
|
||||
|
||||
// override some base class virtuals
|
||||
virtual bool StartDoc(const wxString& message);
|
||||
@@ -34,7 +35,7 @@ public:
|
||||
virtual void StartPage();
|
||||
virtual void EndPage();
|
||||
|
||||
wxRect GetPaperRect();
|
||||
virtual wxRect GetPaperRect();
|
||||
|
||||
protected:
|
||||
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
|
||||
@@ -55,15 +56,26 @@ protected:
|
||||
wxPrintData m_printData;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPrinterDC)
|
||||
DECLARE_CLASS(wxPrinterDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxPrinterDCImpl)
|
||||
};
|
||||
|
||||
// Gets an HDC for the default printer configuration
|
||||
// WXHDC WXDLLEXPORT wxGetPrinterDC(int orientation);
|
||||
|
||||
// Gets an HDC for the specified printer configuration
|
||||
WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& data);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// wxPrinterDCromHDC
|
||||
//
|
||||
|
||||
class WXDLLEXPORT wxPrinterDCFromHDC: public wxPrinterDC
|
||||
{
|
||||
public:
|
||||
wxPrinterDCFromHDC( WXHDC theDC )
|
||||
{
|
||||
m_pimpl = new wxPrinterDCImpl( this, theDC );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // wxUSE_PRINTING_ARCHITECTURE
|
||||
|
||||
#endif // _WX_MSW_DCPRINT_H_
|
||||
|
@@ -12,19 +12,14 @@
|
||||
#ifndef _WX_MSW_DCSCREEN_H_
|
||||
#define _WX_MSW_DCSCREEN_H_
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/msw/dc.h"
|
||||
|
||||
class WXDLLEXPORT wxScreenDC : public wxDC
|
||||
class WXDLLEXPORT wxScreenDCImpl : public wxMSWDCImpl
|
||||
{
|
||||
public:
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC();
|
||||
|
||||
// Compatibility with X's requirements for drawing on top of all windows:
|
||||
// they don't do anything under MSW
|
||||
static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return true; }
|
||||
static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return true; }
|
||||
static bool EndDrawingOnTop() { return true; }
|
||||
wxScreenDCImpl( wxScreenDC *owner );
|
||||
|
||||
protected:
|
||||
virtual void DoGetSize(int *w, int *h) const
|
||||
@@ -33,7 +28,8 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxScreenDC)
|
||||
DECLARE_CLASS(wxScreenDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxScreenDCImpl)
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_DCSCREEN_H_
|
||||
|
@@ -82,19 +82,6 @@ public:
|
||||
int width = 0, int height = 0,
|
||||
const wxString& description = wxEmptyString);
|
||||
|
||||
virtual ~wxEnhMetaFileDC();
|
||||
|
||||
// obtain a pointer to the new metafile (caller should delete it)
|
||||
wxEnhMetaFile *Close();
|
||||
|
||||
protected:
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
|
||||
private:
|
||||
// size passed to ctor and returned by DoGetSize()
|
||||
int m_width,
|
||||
m_height;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC)
|
||||
};
|
||||
|
||||
|
@@ -72,20 +72,13 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMetafile)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxMetafileDC: public wxDC
|
||||
class WXDLLEXPORT wxMetafileDCImpl: public wxMSWDCImpl
|
||||
{
|
||||
public:
|
||||
// Don't supply origin and extent
|
||||
// Supply them to wxMakeMetaFilePlaceable instead.
|
||||
wxMetafileDC(const wxString& file = wxEmptyString);
|
||||
|
||||
// Supply origin and extent (recommended).
|
||||
// Then don't need to supply them to wxMakeMetaFilePlaceable.
|
||||
wxMetafileDCImpl(const wxString& file = wxEmptyString);
|
||||
wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
|
||||
virtual ~wxMetafileDCImpl();
|
||||
|
||||
virtual ~wxMetafileDC();
|
||||
|
||||
// Should be called at end of drawing
|
||||
virtual wxMetafile *Close();
|
||||
virtual void SetMapMode(int mode);
|
||||
virtual void DoGetTextExtent(const wxString& string,
|
||||
@@ -107,9 +100,37 @@ protected:
|
||||
wxMetafile* m_metaFile;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMetafileDC)
|
||||
DECLARE_CLASS(wxMetafileDCImpl)
|
||||
DECLARE_NO_COPY_CLASS(wxMetafileDCImpl)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxMetafileDC: public wxDC
|
||||
{
|
||||
public:
|
||||
// Don't supply origin and extent
|
||||
// Supply them to wxMakeMetaFilePlaceable instead.
|
||||
wxMetafileDC(const wxString& file);
|
||||
{ m_pimpl = new wxMetafileDCImpl( this, file ); }
|
||||
|
||||
// Supply origin and extent (recommended).
|
||||
// Then don't need to supply them to wxMakeMetaFilePlaceable.
|
||||
wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
|
||||
{ m_pimpl = new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ); }
|
||||
|
||||
wxMetafile *GetMetafile() const
|
||||
{ return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
|
||||
|
||||
wxMetafile *Close()
|
||||
{ return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxMetafileDC)
|
||||
DECLARE_NO_COPY_CLASS(wxMetafileDC)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Pass filename of existing non-placeable metafile, and bounding box.
|
||||
* Adds a placeable metafile header, sets the mapping mode to anisotropic,
|
||||
|
@@ -213,6 +213,11 @@ struct WinStruct : public T
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
#include "wx/msw/dc.h"
|
||||
#include "wx/msw/dcclient.h"
|
||||
#include "wx/msw/dcmemory.h"
|
||||
|
||||
|
||||
// make conversion from wxColour and COLORREF a bit less painful
|
||||
inline COLORREF wxColourToRGB(const wxColour& c)
|
||||
{
|
||||
|
Reference in New Issue
Block a user