converted most of X11 DC code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-11-30 15:26:05 +00:00
parent 7a8dce715f
commit 2b77c3fce7
6 changed files with 376 additions and 329 deletions

View File

@@ -22,14 +22,11 @@
// wxDC
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxDC : public wxDCBase
class WXDLLEXPORT wxX11DCImpl : public wxDCImpl
{
public:
wxDC();
virtual ~wxDC() { }
// implement base class pure virtuals
// ----------------------------------
wxX11DCImpl( wxDC *owner );
virtual ~wxX11DCImpl() { }
virtual wxSize GetPPI() const;
@@ -49,7 +46,7 @@ protected:
wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel(y); }
private:
DECLARE_ABSTRACT_CLASS(wxDC)
DECLARE_CLASS(wxX11DCImpl)
};
#endif

View File

@@ -13,6 +13,8 @@
#define _WX_DCCLIENT_H_
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/x11/dc.h"
#include "wx/region.h"
// -----------------------------------------------------------------------------
@@ -21,21 +23,17 @@
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxWindowDC;
class WXDLLIMPEXP_FWD_CORE wxPaintDC;
class WXDLLIMPEXP_FWD_CORE wxClientDC;
//-----------------------------------------------------------------------------
// wxWindowDC
// wxWindowDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowDC : public wxDC
class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxX11DCImpl
{
public:
wxWindowDC() { Init(); }
wxWindowDC( wxWindow *win );
virtual ~wxWindowDC();
wxWindowDCImpl( wxDC *owner );
wxWindowDCImpl( wxDC *owner, wxWindow *win );
virtual ~wxWindowDCImpl();
virtual bool CanDrawBitmap() const { return true; }
virtual bool CanGetTextExtent() const { return true; }
@@ -121,7 +119,7 @@ protected:
void Init();
WXDisplay *m_display;
WXWindow m_window;
WXWindow m_x11window;
WXGC m_penGC;
WXGC m_brushGC;
WXGC m_textGC;
@@ -129,7 +127,6 @@ protected:
WXColormap m_cmap;
bool m_isMemDC;
bool m_isScreenDC;
wxWindow *m_owner;
wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion;
@@ -142,38 +139,38 @@ protected:
void Destroy();
private:
DECLARE_DYNAMIC_CLASS(wxWindowDC)
DECLARE_CLASS(wxWindowDCImpl)
};
//-----------------------------------------------------------------------------
// wxClientDC
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClientDC : public wxWindowDC
class WXDLLIMPEXP_CORE wxClientDCImpl : public wxWindowDCImpl
{
public:
wxClientDC() { }
wxClientDC( wxWindow *win );
wxClientDCImpl( wxDC *owner ) : wxWindowDCImpl( owner ) { }
wxClientDCImpl( wxDC *owner, wxWindow *win );
protected:
virtual void DoGetSize(int *width, int *height) const;
private:
DECLARE_DYNAMIC_CLASS(wxClientDC)
DECLARE_CLASS(wxClientDCImpl)
};
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC
class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl
{
public:
wxPaintDC() { }
wxPaintDC( wxWindow *win );
wxPaintDCImpl( wxDC *owner ) : wxClientDCImpl( owner ) { }
wxPaintDCImpl( wxDC *owner, wxWindow *win );
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
DECLARE_CLASS(wxPaintDCImpl)
};
#endif

View File

@@ -12,16 +12,21 @@
#ifndef _WX_DCMEMORY_H_
#define _WX_DCMEMORY_H_
#include "wx/dcclient.h"
#include "wx/dc.h"
#include "wx/dcmemory.h"
#include "wx/x11/dcclient.h"
class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase
class WXDLLIMPEXP_CORE wxMemoryDCImpl : public wxWindowDCImpl
{
public:
wxMemoryDC() { Init(); }
wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC();
wxMemoryDCImpl( wxDC* owner );
wxMemoryDCImpl( wxDC* owner, wxBitmap& bitmap);
wxMemoryDCImpl( wxDC* owner, wxDC *dc );
virtual ~wxMemoryDCImpl();
virtual const wxBitmap& GetSelectedBitmap() const;
virtual wxBitmap& GetSelectedBitmap();
// implementation
wxBitmap m_selected;
@@ -32,7 +37,8 @@ protected:
private:
void Init();
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
private:
DECLARE_CLASS(wxMemoryDCImpl)
};
#endif

View File

@@ -13,18 +13,20 @@
#include "wx/wxprec.h"
#include "wx/dc.h"
#include "wx/x11/dc.h"
#ifndef WX_PRECOMP
#include "wx/dcmemory.h"
#endif
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxX11DCImpl, wxDCImpl)
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
wxDC::wxDC()
wxX11DCImpl::wxX11DCImpl( wxDC *owner ) :
wxDCImpl( owner )
{
m_ok = false;
@@ -35,7 +37,7 @@ wxDC::wxDC()
m_backgroundMode = wxTRANSPARENT;
}
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
void wxX11DCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
m_clipping = true;
m_clipX1 = x;
@@ -44,10 +46,10 @@ void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord hei
m_clipY2 = y + height;
}
void wxDC::DoGetSizeMM( int* width, int* height ) const
void wxX11DCImpl::DoGetSizeMM( int* width, int* height ) const
{
int w, h;
GetSize( &w, &h );
DoGetSize( &w, &h );
if ( width )
*width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
@@ -56,7 +58,7 @@ void wxDC::DoGetSizeMM( int* width, int* height ) const
}
// Resolution in pixels per logical inch
wxSize wxDC::GetPPI() const
wxSize wxX11DCImpl::GetPPI() const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);

File diff suppressed because it is too large Load Diff

View File

@@ -20,10 +20,30 @@
#endif
#include "wx/x11/private.h"
#include "wx/x11/dcmemory.h"
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxWindowDCImpl)
void wxMemoryDC::Init()
wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner )
: wxWindowDCImpl( owner )
{
Init();
}
wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner, wxBitmap& bitmap )
: wxWindowDCImpl( owner )
{
Init();
DoSelect(bitmap);
}
wxMemoryDCImpl::wxMemoryDCImpl( wxDC* owner, wxDC *WXUNUSED(dc) )
: wxWindowDCImpl( owner )
{
Init();
}
void wxMemoryDCImpl::Init()
{
m_ok = false;
@@ -33,17 +53,11 @@ void wxMemoryDC::Init()
m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
}
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
: wxWindowDC()
{
Init();
}
wxMemoryDC::~wxMemoryDC()
wxMemoryDCImpl::~wxMemoryDCImpl()
{
}
void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
{
Destroy();
@@ -52,11 +66,11 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
{
if (m_selected.GetPixmap())
{
m_window = (WXWindow) m_selected.GetPixmap();
m_x11window = (WXWindow) m_selected.GetPixmap();
}
else
{
m_window = m_selected.GetBitmap();
m_x11window = m_selected.GetBitmap();
}
m_isMemDC = true;
@@ -66,11 +80,11 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
else
{
m_ok = false;
m_window = NULL;
m_x11window = NULL;
}
}
void wxMemoryDC::DoGetSize( int *width, int *height ) const
void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
{
if (m_selected.Ok())
{
@@ -83,3 +97,13 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const
if (height) (*height) = 0;
}
}
const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
{
return m_selected;
}
wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
{
return m_selected;
}