fixed wxDFB compilation after wxDC-related changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50695 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-12-14 22:41:07 +00:00
parent 34075dba7c
commit 4a624f6ed3
12 changed files with 247 additions and 203 deletions

View File

@ -185,6 +185,18 @@ public:
// query dimension, colour deps, resolution
virtual void DoGetSize(int *width, int *height) const = 0;
void GetSize(int *width, int *height) const
{
return DoGetSize(width, height);
}
wxSize GetSize() const
{
int w, h;
DoGetSize(&w, &h);
return wxSize(w, h);
}
virtual void DoGetSizeMM(int* width, int* height) const = 0;
virtual int GetDepth() const = 0;
@ -570,13 +582,8 @@ public:
void GetSize(int *width, int *height) const
{ m_pimpl->DoGetSize(width, height); }
wxSize GetSize() const
{
int w, h;
m_pimpl->DoGetSize(&w, &h);
return wxSize(w, h);
}
{ return m_pimpl->GetSize(); }
void GetSizeMM(int* width, int* height) const
{ m_pimpl->DoGetSizeMM(width, height); }

View File

@ -13,23 +13,28 @@
#include "wx/defs.h"
#include "wx/region.h"
#include "wx/dc.h"
#include "wx/dfb/dfbptr.h"
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
//-----------------------------------------------------------------------------
// wxDC
// wxDFBDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDC : public wxDCBase
class WXDLLIMPEXP_CORE wxDFBDCImpl : public wxDCImpl
{
public:
wxDC();
// ctors
wxDFBDCImpl(wxDC *owner) : wxDCImpl(owner) { m_surface = NULL; }
wxDFBDCImpl(wxDC *owner, const wxIDirectFBSurfacePtr& surface)
: wxDCImpl(owner)
{
DFBInit(surface);
}
// Ctor.
wxDC(const wxIDirectFBSurfacePtr& surface);
bool IsOk() const { return m_surface != NULL; }
public:
// implement base class pure virtuals
// ----------------------------------
@ -80,7 +85,7 @@ protected:
wxCoord XLOG2DEVREL(wxCoord x) const { return LogicalToDeviceXRel(x); }
wxCoord YLOG2DEV(wxCoord y) const { return LogicalToDeviceY(y); }
wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel(y); }
// initializes the DC from a surface, must be called if default ctor
// was used
void DFBInit(const wxIDirectFBSurfacePtr& surface);
@ -158,7 +163,7 @@ protected:
friend class WXDLLIMPEXP_FWD_CORE wxOverlayImpl; // for Init
DECLARE_DYNAMIC_CLASS(wxDC)
DECLARE_ABSTRACT_CLASS(wxDFBDCImpl)
};
#endif // _WX_DFB_DC_H_

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dcclient.h
// Purpose: wxWindowDC, wxClientDC and wxPaintDC
// Purpose: wxWindowDCImpl, wxClientDCImpl and wxPaintDCImpl
// Author: Vaclav Slavik
// Created: 2006-08-10
// RCS-ID: $Id$
@ -11,20 +11,20 @@
#ifndef _WX_DFB_DCCLIENT_H_
#define _WX_DFB_DCCLIENT_H_
#include "wx/dc.h"
#include "wx/dfb/dc.h"
class WXDLLIMPEXP_FWD_CORE wxWindow;
//-----------------------------------------------------------------------------
// wxWindowDC
// wxWindowDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowDC : public wxDC
class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxDFBDCImpl
{
public:
wxWindowDC() : m_shouldFlip(false) {}
wxWindowDC(wxWindow *win);
virtual ~wxWindowDC();
wxWindowDCImpl(wxDC *owner) : wxDFBDCImpl(owner), m_shouldFlip(false) { }
wxWindowDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxWindowDCImpl();
virtual wxWindow *GetWindow() const { return m_win; }
@ -41,37 +41,37 @@ private:
friend class wxOverlayImpl; // for m_shouldFlip;
DECLARE_DYNAMIC_CLASS(wxWindowDC)
DECLARE_NO_COPY_CLASS(wxWindowDC)
DECLARE_DYNAMIC_CLASS(wxWindowDCImpl)
DECLARE_NO_COPY_CLASS(wxWindowDCImpl)
};
//-----------------------------------------------------------------------------
// wxClientDC
// wxClientDCImpl
//-----------------------------------------------------------------------------
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);
DECLARE_DYNAMIC_CLASS(wxClientDC)
DECLARE_NO_COPY_CLASS(wxClientDC)
DECLARE_DYNAMIC_CLASS(wxClientDCImpl)
DECLARE_NO_COPY_CLASS(wxClientDCImpl)
};
//-----------------------------------------------------------------------------
// wxPaintDC
// wxPaintDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC
class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl
{
public:
wxPaintDC() {}
wxPaintDC(wxWindow *win) : wxClientDC(win) {}
wxPaintDCImpl(wxDC *owner) : wxClientDCImpl(owner) { }
wxPaintDCImpl(wxDC *owner, wxWindow *win) : wxClientDCImpl(owner, win) { }
DECLARE_DYNAMIC_CLASS(wxPaintDC)
DECLARE_NO_COPY_CLASS(wxPaintDC)
DECLARE_DYNAMIC_CLASS(wxPaintDCImpl)
DECLARE_NO_COPY_CLASS(wxPaintDCImpl)
};
#endif // _WX_DFB_DCCLIENT_H_

View File

@ -11,21 +11,30 @@
#ifndef _WX_DFB_DCMEMORY_H_
#define _WX_DFB_DCMEMORY_H_
#include "wx/dc.h"
#include "wx/dfb/dc.h"
#include "wx/bitmap.h"
class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC, public wxMemoryDCBase
class WXDLLIMPEXP_CORE wxMemoryDCImpl : public wxDFBDCImpl
{
public:
wxMemoryDC() { Init(); }
wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC(wxDC *dc); // create compatible DC
wxMemoryDCImpl(wxMemoryDC *owner)
: wxDFBDCImpl(owner)
{
Init();
}
// implementation from now on:
wxMemoryDCImpl(wxMemoryDC *owner, wxBitmap& bitmap)
: wxDFBDCImpl(owner)
{
Init();
DoSelect(bitmap);
}
wxBitmap GetSelectedObject() const { return m_bmp; }
wxMemoryDCImpl(wxMemoryDC *owner, wxDC *dc); // create compatible DC
protected:
// override wxMemoryDC-specific base class virtual methods
virtual const wxBitmap& GetSelectedBitmap() const { return m_bmp; }
virtual wxBitmap& GetSelectedBitmap() { return m_bmp; }
virtual void DoSelect(const wxBitmap& bitmap);
private:
@ -33,7 +42,7 @@ private:
wxBitmap m_bmp;
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
DECLARE_DYNAMIC_CLASS(wxMemoryDCImpl)
};
#endif // _WX_DFB_DCMEMORY_H_

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dcscreen.h
// Purpose: wxScreenDC declaration
// Purpose: wxScreenDCImpl declaration
// Author: Vaclav Slavik
// Created: 2006-08-10
// RCS-ID: $Id$
@ -11,21 +11,14 @@
#ifndef _WX_DFB_DCSCREEN_H_
#define _WX_DFB_DCSCREEN_H_
#include "wx/dc.h"
#include "wx/dfb/dc.h"
class WXDLLIMPEXP_CORE wxScreenDC: public wxDC
class WXDLLIMPEXP_CORE wxScreenDCImpl : public wxDFBDCImpl
{
public:
wxScreenDC();
wxScreenDCImpl(wxScreenDC *owner);
static bool StartDrawingOnTop(wxWindow *WXUNUSED(window))
{ return true; }
static bool StartDrawingOnTop(wxRect *WXUNUSED(rect) = NULL)
{ return true; }
static bool EndDrawingOnTop()
{ return true; }
DECLARE_DYNAMIC_CLASS(wxScreenDC)
DECLARE_DYNAMIC_CLASS(wxScreenDCImpl)
};
#endif // _WX_DFB_DCSCREEN_H_

View File

@ -191,7 +191,7 @@ private:
friend class wxNonOwnedWindow; // for HandleXXXEvent
friend class wxOverlayImpl; // for Add/RemoveOverlay
friend class wxWindowDC; // for PaintOverlays
friend class wxWindowDCImpl; // for PaintOverlays
DECLARE_DYNAMIC_CLASS(wxWindowDFB)
DECLARE_NO_COPY_CLASS(wxWindowDFB)

View File

@ -66,6 +66,12 @@
#include "wx/x11/dcscreen.h"
#endif
#ifdef __WXDFB__
#include "wx/dfb/dcclient.h"
#include "wx/dfb/dcmemory.h"
#include "wx/dfb/dcscreen.h"
#endif
//----------------------------------------------------------------------------
// wxDCFactory
//----------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/dfb/dc.cpp
// Purpose: wxDC class
// Purpose: wxDFBDCImpl class
// Author: Vaclav Slavik
// Created: 2006-08-07
// RCS-ID: $Id$
@ -24,11 +24,11 @@
#endif
#ifndef WX_PRECOMP
#include "wx/dc.h"
#include "wx/dcmemory.h"
#include "wx/log.h"
#endif
#include "wx/dfb/dc.h"
#include "wx/dfb/private.h"
// these values are used to initialize newly created DC
@ -41,29 +41,17 @@
// ===========================================================================
//-----------------------------------------------------------------------------
// wxDC
// wxDFBDCImpl
//-----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
IMPLEMENT_ABSTRACT_CLASS(wxDFBDCImpl, wxDCImpl)
// Default constructor
wxDC::wxDC()
void wxDFBDCImpl::DFBInit(const wxIDirectFBSurfacePtr& surface)
{
m_ok = false;
}
wxDC::wxDC(const wxIDirectFBSurfacePtr& surface)
{
DFBInit(surface);
}
void wxDC::DFBInit(const wxIDirectFBSurfacePtr& surface)
{
m_ok = (surface != NULL);
wxCHECK_RET( surface != NULL, "invalid surface" );
m_surface = surface;
wxCHECK_RET( surface != NULL, "invalid surface" );
m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
(double)wxGetDisplaySizeMM().GetWidth();
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
@ -79,9 +67,9 @@ void wxDC::DFBInit(const wxIDirectFBSurfacePtr& surface)
// clipping
// ---------------------------------------------------------------------------
void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
void wxDFBDCImpl::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxSize size(GetSize());
@ -107,15 +95,15 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
m_clipping = true;
}
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
void wxDFBDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
{
// NB: this can be done because wxDFB only supports rectangular regions
SetClippingRegion(region.AsRect());
GetOwner()->SetClippingRegion(region.AsRect());
}
void wxDC::DestroyClippingRegion()
void wxDFBDCImpl::DestroyClippingRegion()
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
m_surface->SetClip(NULL);
@ -126,7 +114,7 @@ void wxDC::DestroyClippingRegion()
// query capabilities
// ---------------------------------------------------------------------------
int wxDC::GetDepth() const
int wxDFBDCImpl::GetDepth() const
{
return m_surface->GetDepth();
}
@ -135,9 +123,9 @@ int wxDC::GetDepth() const
// drawing
// ---------------------------------------------------------------------------
void wxDC::Clear()
void wxDFBDCImpl::Clear()
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
if ( m_backgroundBrush.GetStyle() == wxTRANSPARENT )
return;
@ -153,30 +141,37 @@ void wxDC::Clear()
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
bool wxDFBDCImpl::DoFloodFill(wxCoord x, wxCoord y,
const wxColour& col, int style)
{
return wxDoFloodFill(this, x, y, col, style);
return wxDoFloodFill(GetOwner(), x, y, col, style);
}
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
bool wxDFBDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
{
wxCHECK_MSG( col, false, "NULL colour parameter in wxDC::GetPixel");
wxCHECK_MSG( col, false, "NULL colour parameter in wxDFBDCImpl::GetPixel");
wxFAIL_MSG( "GetPixel not implemented" );
wxUnusedVar(x);
wxUnusedVar(y);
return false;
}
void wxDC::DoCrossHair(wxCoord x, wxCoord y)
void wxDFBDCImpl::DoCrossHair(wxCoord x, wxCoord y)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "CrossHair not implemented" );
wxUnusedVar(x);
wxUnusedVar(y);
}
void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
void wxDFBDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
if ( m_pen.GetStyle() == wxTRANSPARENT )
return;
@ -214,18 +209,18 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
// and ending at (x2, y2)
void wxDC::DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc)
void wxDFBDCImpl::DoDrawArc(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1),
wxCoord WXUNUSED(x2), wxCoord WXUNUSED(y2),
wxCoord WXUNUSED(xc), wxCoord WXUNUSED(yc))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "DrawArc not implemented" );
}
void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
void wxDFBDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
// NB: DirectFB API doesn't provide a function for drawing points, so
// implement it as 1px long line. This is inefficient, but then, so is
@ -235,24 +230,27 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
// FIXME_DFB: implement special cases for common formats (RGB24,RGBA/RGB32)
}
void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int WXUNUSED(fillStyle))
void wxDFBDCImpl::DoDrawPolygon(int WXUNUSED(n), wxPoint WXUNUSED(points)[],
wxCoord WXUNUSED(xoffset), wxCoord WXUNUSED(yoffset),
int WXUNUSED(fillStyle))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "DrawPolygon not implemented" );
}
void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
void wxDFBDCImpl::DoDrawLines(int WXUNUSED(n), wxPoint WXUNUSED(points)[],
wxCoord WXUNUSED(xoffset), wxCoord WXUNUSED(yoffset))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
// TODO: impl. using DirectDB's DrawLines
wxFAIL_MSG( "DrawLines not implemented" );
}
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxCoord xx = XLOG2DEV(x);
wxCoord yy = YLOG2DEV(y);
@ -290,30 +288,42 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
CalcBoundingBox(x + width, y + height);
}
void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
void wxDFBDCImpl::DoDrawRoundedRectangle(wxCoord WXUNUSED(x),
wxCoord WXUNUSED(y),
wxCoord WXUNUSED(width),
wxCoord WXUNUSED(height),
double WXUNUSED(radius))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "DrawRoundedRectangle not implemented" );
}
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxDFBDCImpl::DoDrawEllipse(wxCoord WXUNUSED(x),
wxCoord WXUNUSED(y),
wxCoord WXUNUSED(width),
wxCoord WXUNUSED(height))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "DrawElipse not implemented" );
}
void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
void wxDFBDCImpl::DoDrawEllipticArc(wxCoord WXUNUSED(x),
wxCoord WXUNUSED(y),
wxCoord WXUNUSED(w),
wxCoord WXUNUSED(h),
double WXUNUSED(sa),
double WXUNUSED(ea))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "DrawElipticArc not implemented" );
}
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
void wxDFBDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxCoord xx = XLOG2DEV(x);
wxCoord yy = YLOG2DEV(y);
@ -321,7 +331,7 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
// update the bounding box
wxCoord w, h;
CalcBoundingBox(x, y);
GetTextExtent(text, &w, &h);
DoGetTextExtent(text, &w, &h);
CalcBoundingBox(x + w, y + h);
// if background mode is solid, DrawText must paint text's background:
@ -345,11 +355,11 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
SelectColour(m_pen.GetColour());
}
void wxDC::DoDrawRotatedText(const wxString& text,
wxCoord x, wxCoord y,
double angle)
void wxDFBDCImpl::DoDrawRotatedText(const wxString& WXUNUSED(text),
wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
double WXUNUSED(angle))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "DrawRotatedText not implemented" );
}
@ -358,36 +368,36 @@ void wxDC::DoDrawRotatedText(const wxString& text,
// set GDI objects
// ---------------------------------------------------------------------------
void wxDC::SetPen(const wxPen& pen)
void wxDFBDCImpl::SetPen(const wxPen& pen)
{
m_pen = pen.Ok() ? pen : DEFAULT_PEN;
SelectColour(m_pen.GetColour());
}
void wxDC::SetBrush(const wxBrush& brush)
void wxDFBDCImpl::SetBrush(const wxBrush& brush)
{
m_brush = brush.Ok() ? brush : DEFAULT_BRUSH;
}
void wxDC::SelectColour(const wxColour& clr)
void wxDFBDCImpl::SelectColour(const wxColour& clr)
{
m_surface->SetColor(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha());
#warning "use SetColorIndex?"
}
#if wxUSE_PALETTE
void wxDC::SetPalette(const wxPalette& WXUNUSED(palette))
void wxDFBDCImpl::SetPalette(const wxPalette& WXUNUSED(palette))
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFAIL_MSG( "SetPalette not implemented" );
}
#endif // wxUSE_PALETTE
void wxDC::SetFont(const wxFont& font)
void wxDFBDCImpl::SetFont(const wxFont& font)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxFont f(font.Ok() ? font : DEFAULT_FONT);
@ -402,29 +412,29 @@ void wxDC::SetFont(const wxFont& font)
}
}
wxIDirectFBFontPtr wxDC::GetCurrentFont() const
wxIDirectFBFontPtr wxDFBDCImpl::GetCurrentFont() const
{
bool aa = (GetDepth() > 8);
return m_font.GetDirectFBFont(aa);
}
void wxDC::SetBackground(const wxBrush& brush)
void wxDFBDCImpl::SetBackground(const wxBrush& brush)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
if (!brush.Ok()) return;
m_backgroundBrush = brush;
}
void wxDC::SetBackgroundMode(int mode)
void wxDFBDCImpl::SetBackgroundMode(int mode)
{
m_backgroundMode = mode;
}
void wxDC::SetLogicalFunction(int function)
void wxDFBDCImpl::SetLogicalFunction(int function)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
// NB: we could also support XOR, but for blitting only (via DSBLIT_XOR);
// and possibly others via SetSrc/DstBlendFunction()
@ -434,21 +444,21 @@ void wxDC::SetLogicalFunction(int function)
m_logicalFunction = function;
}
bool wxDC::StartDoc(const wxString& WXUNUSED(message))
bool wxDFBDCImpl::StartDoc(const wxString& WXUNUSED(message))
{
// We might be previewing, so return true to let it continue.
return true;
}
void wxDC::EndDoc()
void wxDFBDCImpl::EndDoc()
{
}
void wxDC::StartPage()
void wxDFBDCImpl::StartPage()
{
}
void wxDC::EndPage()
void wxDFBDCImpl::EndPage()
{
}
@ -456,9 +466,9 @@ void wxDC::EndPage()
// text metrics
// ---------------------------------------------------------------------------
wxCoord wxDC::GetCharHeight() const
wxCoord wxDFBDCImpl::GetCharHeight() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
wxCHECK_MSG( IsOk(), -1, wxT("invalid dc") );
wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") );
int h = -1;
@ -466,9 +476,9 @@ wxCoord wxDC::GetCharHeight() const
return YDEV2LOGREL(h);
}
wxCoord wxDC::GetCharWidth() const
wxCoord wxDFBDCImpl::GetCharWidth() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
wxCHECK_MSG( IsOk(), -1, wxT("invalid dc") );
wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") );
int w = -1;
@ -478,11 +488,11 @@ wxCoord wxDC::GetCharWidth() const
return YDEV2LOGREL(w);
}
void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
void wxDFBDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
const wxFont *theFont) const
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxCHECK_RET( m_font.Ok(), wxT("no font selected") );
wxCHECK_RET( !theFont || theFont->Ok(), wxT("invalid font") );
@ -490,7 +500,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
if ( theFont != NULL )
{
oldFont = m_font;
wxConstCast(this, wxDC)->SetFont(*theFont);
wxConstCast(this, wxDFBDCImpl)->SetFont(*theFont);
}
wxCoord xx = 0, yy = 0;
@ -519,7 +529,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
if ( externalLeading ) *externalLeading = 0;
if ( theFont != NULL )
wxConstCast(this, wxDC)->SetFont(oldFont);
wxConstCast(this, wxDFBDCImpl)->SetFont(oldFont);
}
@ -531,15 +541,15 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
// FIXME_DFB: scaling affects pixel size of font, pens, brushes, which
// is not currently implemented here; probably makes sense to
// switch to Cairo instead of implementing everything for DFB
void wxDC::DoGetSize(int *w, int *h) const
void wxDFBDCImpl::DoGetSize(int *w, int *h) const
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
m_surface->GetSize(w, h);
}
void wxDC::DoGetSizeMM(int *width, int *height) const
void wxDFBDCImpl::DoGetSizeMM(int *width, int *height) const
{
#warning "move this to common code?"
int w = 0;
@ -549,7 +559,7 @@ void wxDC::DoGetSizeMM(int *width, int *height) const
if ( height ) *height = int(double(h) / (m_userScaleY*m_mm_to_pix_y));
}
wxSize wxDC::GetPPI() const
wxSize wxDFBDCImpl::GetPPI() const
{
#warning "move this to common code?"
return wxSize(int(double(m_mm_to_pix_x) * inches2mm),
@ -561,13 +571,13 @@ wxSize wxDC::GetPPI() const
// Blitting
// ---------------------------------------------------------------------------
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop, bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask)
bool wxDFBDCImpl::DoBlit(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop, bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask)
{
wxCHECK_MSG( Ok(), false, "invalid dc" );
wxCHECK_MSG( IsOk(), false, "invalid dc" );
wxCHECK_MSG( source, false, "invalid source dc" );
// NB: we could also support XOR here (via DSBLIT_XOR)
@ -596,7 +606,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
wxMemoryDC *sourceAsMemDC = wxDynamicCast(source, wxMemoryDC);
if ( sourceAsMemDC )
{
DoDrawSubBitmap(sourceAsMemDC->GetSelectedObject(),
DoDrawSubBitmap(sourceAsMemDC->GetSelectedBitmap(),
xsrc, ysrc,
width, height,
xdest, ydest,
@ -605,18 +615,22 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
}
else
{
return DoBlitFromSurface(source->GetDirectFBSurface(),
xsrc, ysrc,
width, height,
xdest, ydest);
return DoBlitFromSurface
(
static_cast<wxDFBDCImpl *>(source->GetImpl())
->GetDirectFBSurface(),
xsrc, ysrc,
width, height,
xdest, ydest
);
}
return true;
}
void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
void wxDFBDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
DoDrawSubBitmap(bmp,
@ -625,17 +639,17 @@ void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
m_logicalFunction, useMask);
}
void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
void wxDFBDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
{
// VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
DoDrawBitmap((const wxBitmap&)icon, x, y, true);
}
void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
void wxDFBDCImpl::DoDrawSubBitmap(const wxBitmap &bmp,
wxCoord x, wxCoord y, wxCoord w, wxCoord h,
wxCoord destx, wxCoord desty, int rop, bool useMask)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( IsOk(), wxT("invalid dc") );
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
// NB: we could also support XOR here (via DSBLIT_XOR)
@ -666,10 +680,10 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
destx, desty);
}
bool wxDC::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
wxCoord srcx, wxCoord srcy,
wxCoord w, wxCoord h,
wxCoord dstx, wxCoord dsty)
bool wxDFBDCImpl::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
wxCoord srcx, wxCoord srcy,
wxCoord w, wxCoord h,
wxCoord dstx, wxCoord dsty)
{
// don't do anything if the source rectangle is outside of source surface,
// DirectFB would assert in that case:

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/dfb/dcclient.cpp
// Purpose: wxWindowDC, wxClientDC and wxPaintDC
// Purpose: wxWindowDCImpl, wxClientDCImpl and wxPaintDC
// Author: Vaclav Slavik
// Created: 2006-08-10
// RCS-ID: $Id$
@ -23,13 +23,12 @@
#pragma hdrstop
#endif
#include "wx/dcclient.h"
#ifndef WX_PRECOMP
#include "wx/window.h"
#include "wx/nonownedwnd.h"
#endif
#include "wx/dfb/dcclient.h"
#include "wx/dfb/private.h"
#define TRACE_PAINT "paint"
@ -93,17 +92,18 @@ wxIDirectFBSurfacePtr CreateDummySurface(wxWindow *win, const wxRect *rect)
}
//-----------------------------------------------------------------------------
// wxWindowDC
// wxWindowDCImpl
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxDFBDCImpl)
wxWindowDC::wxWindowDC(wxWindow *win)
wxWindowDCImpl::wxWindowDCImpl(wxDC *owner, wxWindow *win)
: wxDFBDCImpl(owner)
{
InitForWin(win, NULL);
}
void wxWindowDC::InitForWin(wxWindow *win, const wxRect *rect)
void wxWindowDCImpl::InitForWin(wxWindow *win, const wxRect *rect)
{
wxCHECK_RET( win, "invalid window" );
@ -197,7 +197,7 @@ void wxWindowDC::InitForWin(wxWindow *win, const wxRect *rect)
SetDeviceOrigin(origin.x, origin.y);
}
wxWindowDC::~wxWindowDC()
wxWindowDCImpl::~wxWindowDCImpl()
{
wxIDirectFBSurfacePtr surface(GetDirectFBSurface());
if ( !surface )
@ -227,12 +227,13 @@ wxWindowDC::~wxWindowDC()
}
//-----------------------------------------------------------------------------
// wxClientDC
// wxClientDCImpl
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl)
wxClientDC::wxClientDC(wxWindow *win)
wxClientDCImpl::wxClientDCImpl(wxDC *owner, wxWindow *win)
: wxWindowDCImpl(owner, win)
{
wxCHECK_RET( win, "invalid window" );
@ -244,4 +245,4 @@ wxClientDC::wxClientDC(wxWindow *win)
// wxPaintDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxWindowDCImpl)

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/dfb/dcmemory.cpp
// Purpose: wxMemoryDC implementation
// Purpose: wxMemoryDCImpl implementation
// Author: Vaclav Slavik
// Created: 2006-08-16
// RCS-ID: $Id$
@ -19,12 +19,11 @@
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/dcmemory.h"
#ifndef WX_PRECOMP
#include "wx/bitmap.h"
#endif
#include "wx/dfb/dcmemory.h"
#include "wx/dfb/private.h"
// ===========================================================================
@ -32,22 +31,23 @@
// ===========================================================================
//-----------------------------------------------------------------------------
// wxMemoryDC
// wxMemoryDCImpl
//-----------------------------------------------------------------------------
#warning "FIXME: verify/fix that wxMemoryDC works correctly with mono bitmaps"
#warning "FIXME: verify/fix that wxMemoryDCImpl works correctly with mono bitmaps"
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxDFBDCImpl)
void wxMemoryDC::Init()
void wxMemoryDCImpl::Init()
{
}
wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc))
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC *WXUNUSED(dc))
: wxDFBDCImpl(owner)
{
}
void wxMemoryDC::DoSelect(const wxBitmap& bitmap)
void wxMemoryDCImpl::DoSelect(const wxBitmap& bitmap)
{
m_bmp = bitmap;

View File

@ -19,8 +19,7 @@
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/dcscreen.h"
#include "wx/dfb/dcscreen.h"
#include "wx/dfb/private.h"
// ===========================================================================
@ -34,9 +33,10 @@
#warning "FIXME: this doesn't work (neither single app nor multiapp core)
// FIXME: maybe use a subsurface as well?
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxDC)
IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxDFBDCImpl)
wxScreenDC::wxScreenDC()
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC *owner)
: wxDFBDCImpl(owner)
{
DFBInit(wxIDirectFB::Get()->GetPrimarySurface());
}

View File

@ -29,6 +29,7 @@
#endif
#include "wx/private/overlay.h"
#include "wx/dfb/dcclient.h"
#include "wx/dfb/private.h"
// ============================================================================
@ -57,8 +58,12 @@ bool wxOverlayImpl::IsOk()
void wxOverlayImpl::Init(wxWindowDC *dc, int x, int y, int width, int height)
{
wxCHECK_RET( dc, "NULL dc pointer" );
wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
wxDFBDCImpl * const dcimpl = wxDynamicCast(dc->GetImpl(), wxDFBDCImpl);
wxCHECK_RET( dcimpl, "must have a DFB wxDC" );
m_window = dc->GetWindow();
m_rect = wxRect(x, y, width, height);
@ -66,18 +71,22 @@ void wxOverlayImpl::Init(wxWindowDC *dc, int x, int y, int width, int height)
m_rect.Offset(m_window->GetClientAreaOrigin());
// FIXME: create surface with transparency or key color (?)
m_surface =
dc->GetDirectFBSurface()->CreateCompatible
(
m_rect.GetSize(),
wxIDirectFBSurface::CreateCompatible_NoBackBuffer
);
m_surface = dcimpl->GetDirectFBSurface()->CreateCompatible
(
m_rect.GetSize(),
wxIDirectFBSurface::CreateCompatible_NoBackBuffer
);
m_window->AddOverlay(this);
}
void wxOverlayImpl::BeginDrawing(wxWindowDC *dc)
{
wxCHECK_RET( dc, "NULL dc pointer" );
wxWindowDCImpl * const
dcimpl = static_cast<wxWindowDCImpl *>(dc->GetImpl());
wxPoint origin(m_rect.GetPosition());
if ( wxDynamicCast(dc, wxClientDC) )
origin -= m_window->GetClientAreaOrigin();
@ -86,19 +95,19 @@ void wxOverlayImpl::BeginDrawing(wxWindowDC *dc)
// another DC, so we have to change the DC to draw on the overlay's surface.
// Setting m_shouldFlip is done to avoid flipping and drawing of overlays
// in ~wxWindowDC (we do it EndDrawing).
dc->DFBInit(m_surface);
dcimpl->DFBInit(m_surface);
dcimpl->m_shouldFlip = false;
dc->SetDeviceOrigin(-origin.x, -origin.y);
dc->m_shouldFlip = false;
m_isEmpty = false;
}
void wxOverlayImpl::EndDrawing(wxWindowDC *dc)
void wxOverlayImpl::EndDrawing(wxWindowDC *WXUNUSED(dc))
{
m_window->RefreshWindowRect(m_rect);
}
void wxOverlayImpl::Clear(wxWindowDC *dc)
void wxOverlayImpl::Clear(wxWindowDC *WXUNUSED(dc))
{
wxASSERT_MSG( IsOk(),
"You cannot Clear an overlay that is not initialized" );