use C++ wrappers around DirectFB API for easier use
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41029 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,20 +39,15 @@ wxApp::~wxApp()
|
||||
{
|
||||
}
|
||||
|
||||
IDirectFBPtr wxApp::GetDirectFBInterface()
|
||||
{
|
||||
return m_dfb;
|
||||
}
|
||||
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
||||
if ( !DFB_CALL( DirectFBInit(&argc, &argv) ) )
|
||||
if ( !wxDfbCheckReturn(DirectFBInit(&argc, &argv)) )
|
||||
return false;
|
||||
|
||||
if ( !DFB_CALL( DirectFBCreate(&m_dfb) ) )
|
||||
if ( !wxIDirectFB::Get() )
|
||||
return false;
|
||||
|
||||
#warning "FIXME: theme override is temporary"
|
||||
@@ -65,7 +60,7 @@ void wxApp::CleanUp()
|
||||
{
|
||||
wxAppBase::CleanUp();
|
||||
|
||||
m_dfb.Reset();
|
||||
wxIDirectFB::CleanUp();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -76,11 +71,11 @@ static wxVideoMode GetCurrentVideoMode()
|
||||
{
|
||||
wxVideoMode m;
|
||||
|
||||
IDirectFBSurfacePtr surface(wxDfbGetPrimarySurface());
|
||||
wxIDirectFBSurfacePtr surface(wxDfbGetPrimarySurface());
|
||||
if ( !surface )
|
||||
return m; // invalid
|
||||
|
||||
DFB_CALL( surface->GetSize(surface, &m.w, &m.h) );
|
||||
surface->GetSize(&m.w, &m.h);
|
||||
m.bpp = wxDfbGetSurfaceDepth(surface);
|
||||
|
||||
return m;
|
||||
@@ -96,7 +91,7 @@ wxVideoMode wxApp::GetDisplayMode() const
|
||||
|
||||
bool wxApp::SetDisplayMode(const wxVideoMode& mode)
|
||||
{
|
||||
if ( !DFB_CALL( m_dfb->SetVideoMode(m_dfb, mode.w, mode.h, mode.bpp) ) )
|
||||
if ( !wxIDirectFB::Get()->SetVideoMode(mode.w, mode.h, mode.bpp) )
|
||||
return false;
|
||||
|
||||
m_videoMode = mode;
|
||||
|
||||
@@ -174,10 +174,10 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr m_surface;
|
||||
wxMask *m_mask;
|
||||
wxIDirectFBSurfacePtr m_surface;
|
||||
wxMask *m_mask;
|
||||
#if wxUSE_PALETTE
|
||||
wxPalette *m_palette;
|
||||
wxPalette *m_palette;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -208,9 +208,8 @@ bool wxBitmap::Create(int width, int height, int depth)
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
|
||||
IDirectFBSurfacePtr surface;
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
if ( !DFB_CALL( dfb->CreateSurface(dfb, &desc, &surface) ) )
|
||||
wxIDirectFBSurfacePtr surface(wxIDirectFB::Get()->CreateSurface(&desc));
|
||||
if ( !surface )
|
||||
return false;
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
@@ -278,7 +277,7 @@ int wxBitmap::GetHeight() const
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
|
||||
|
||||
int h = -1;
|
||||
DFB_CALL( M_BITMAP->m_surface->GetSize(M_BITMAP->m_surface, NULL, &h) );
|
||||
M_BITMAP->m_surface->GetSize(NULL, &h);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -287,7 +286,7 @@ int wxBitmap::GetWidth() const
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
|
||||
|
||||
int w = -1;
|
||||
DFB_CALL( M_BITMAP->m_surface->GetSize(M_BITMAP->m_surface, &w, NULL) );
|
||||
M_BITMAP->m_surface->GetSize(&w, NULL);
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -424,7 +423,7 @@ void wxBitmap::SetDepth(int depth)
|
||||
#warning "todo"
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr wxBitmap::GetDirectFBSurface() const
|
||||
wxIDirectFBSurfacePtr wxBitmap::GetDirectFBSurface() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ wxDC::wxDC()
|
||||
m_ok = false;
|
||||
}
|
||||
|
||||
wxDC::wxDC(const IDirectFBSurfacePtr& surface)
|
||||
wxDC::wxDC(const wxIDirectFBSurfacePtr& surface)
|
||||
{
|
||||
Init(surface);
|
||||
}
|
||||
|
||||
void wxDC::Init(const IDirectFBSurfacePtr& surface)
|
||||
void wxDC::Init(const wxIDirectFBSurfacePtr& surface)
|
||||
{
|
||||
m_ok = (surface != NULL);
|
||||
wxCHECK_RET( surface != NULL, _T("invalid surface") );
|
||||
@@ -93,7 +93,7 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
|
||||
r.x2 = r.x1 + XLOG2DEVREL(cw) - 1;
|
||||
r.y2 = r.y1 + XLOG2DEVREL(ch) - 1;
|
||||
|
||||
if ( !DFB_CALL( m_surface->SetClip(m_surface, &r) ) )
|
||||
if ( !m_surface->SetClip(&r) )
|
||||
return;
|
||||
|
||||
m_clipX1 = cx;
|
||||
@@ -114,7 +114,7 @@ void wxDC::DestroyClippingRegion()
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
DFB_CALL( m_surface->SetClip(m_surface, NULL) );
|
||||
m_surface->SetClip(NULL);
|
||||
|
||||
ResetClipping();
|
||||
}
|
||||
@@ -140,8 +140,7 @@ void wxDC::Clear()
|
||||
return;
|
||||
|
||||
wxColour clr = m_backgroundBrush.GetColour();
|
||||
DFB_CALL( m_surface->Clear(m_surface,
|
||||
clr.Red(), clr.Green(), clr.Blue(), clr.Alpha()) );
|
||||
m_surface->Clear(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha());
|
||||
}
|
||||
|
||||
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
|
||||
@@ -175,9 +174,8 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
if ( m_pen.GetStyle() == wxTRANSPARENT )
|
||||
return;
|
||||
|
||||
DFB_CALL( m_surface->DrawLine(m_surface,
|
||||
XLOG2DEV(x1), YLOG2DEV(y1),
|
||||
XLOG2DEV(x2), YLOG2DEV(y2)) );
|
||||
m_surface->DrawLine(XLOG2DEV(x1), YLOG2DEV(y1),
|
||||
XLOG2DEV(x2), YLOG2DEV(y2));
|
||||
|
||||
CalcBoundingBox(x1, y1);
|
||||
CalcBoundingBox(x2, y2);
|
||||
@@ -241,14 +239,14 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
if ( m_brush.GetStyle() != wxTRANSPARENT )
|
||||
{
|
||||
SelectColour(m_brush.GetColour());
|
||||
DFB_CALL( m_surface->FillRectangle(m_surface, xx, yy, ww, hh) );
|
||||
m_surface->FillRectangle(xx, yy, ww, hh);
|
||||
// restore pen's colour
|
||||
SelectColour(m_pen.GetColour());
|
||||
}
|
||||
|
||||
if ( m_pen.GetStyle() != wxTRANSPARENT )
|
||||
{
|
||||
DFB_CALL( m_surface->DrawRectangle(m_surface, xx, yy, ww, hh) );
|
||||
m_surface->DrawRectangle(xx, yy, ww, hh);
|
||||
}
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
@@ -295,18 +293,13 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||
wxCHECK_RET( m_backgroundBrush.Ok(), wxT("invalid background brush") );
|
||||
|
||||
SelectColour(m_backgroundBrush.GetColour());
|
||||
DFB_CALL( m_surface->FillRectangle(m_surface,
|
||||
xx, yy,
|
||||
XLOG2DEVREL(w), YLOG2DEVREL(h)) );
|
||||
m_surface->FillRectangle(xx, yy, XLOG2DEVREL(w), YLOG2DEVREL(h));
|
||||
// restore pen's colour
|
||||
SelectColour(m_pen.GetColour());
|
||||
}
|
||||
|
||||
// finally draw the text itself:
|
||||
DFB_CALL(m_surface->DrawString(m_surface,
|
||||
wxSTR_TO_DFB(text), -1,
|
||||
xx, yy,
|
||||
DFBSurfaceTextFlags(DSTF_LEFT | DSTF_TOP)));
|
||||
m_surface->DrawString(wxSTR_TO_DFB(text), -1, xx, yy, DSTF_LEFT | DSTF_TOP);
|
||||
}
|
||||
|
||||
void wxDC::DoDrawRotatedText(const wxString& text,
|
||||
@@ -338,8 +331,7 @@ void wxDC::SetBrush(const wxBrush& brush)
|
||||
|
||||
void wxDC::SelectColour(const wxColour& clr)
|
||||
{
|
||||
DFB_CALL( m_surface->SetColor(m_surface,
|
||||
clr.Red(), clr.Green(), clr.Blue(), clr.Alpha()) );
|
||||
m_surface->SetColor(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha());
|
||||
#warning "use SetColorIndex?"
|
||||
}
|
||||
|
||||
@@ -359,7 +351,7 @@ void wxDC::SetFont(const wxFont& font)
|
||||
if ( !font.Ok() )
|
||||
return;
|
||||
|
||||
if ( !DFB_CALL( m_surface->SetFont(m_surface, font.GetDirectFBFont()) ) )
|
||||
if ( !m_surface->SetFont(font.GetDirectFBFont()) )
|
||||
return;
|
||||
|
||||
m_font = font;
|
||||
@@ -416,8 +408,7 @@ wxCoord wxDC::GetCharHeight() const
|
||||
wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") );
|
||||
|
||||
int h = -1;
|
||||
IDirectFBFontPtr f = m_font.GetDirectFBFont();
|
||||
DFB_CALL( f->GetHeight(f, &h) );
|
||||
m_font.GetDirectFBFont()->GetHeight(&h);
|
||||
return YDEV2LOGREL(h);
|
||||
}
|
||||
|
||||
@@ -427,8 +418,7 @@ wxCoord wxDC::GetCharWidth() const
|
||||
wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") );
|
||||
|
||||
int w = -1;
|
||||
IDirectFBFontPtr f = m_font.GetDirectFBFont();
|
||||
DFB_CALL( f->GetStringWidth(f, "H", 1, &w) );
|
||||
m_font.GetDirectFBFont()->GetStringWidth("H", 1, &w);
|
||||
// VS: YDEV is corrent, it should *not* be XDEV, because font's are only
|
||||
// scaled according to m_scaleY
|
||||
return YDEV2LOGREL(w);
|
||||
@@ -451,9 +441,9 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
|
||||
|
||||
wxCoord xx = 0, yy = 0;
|
||||
DFBRectangle rect;
|
||||
IDirectFBFontPtr f = m_font.GetDirectFBFont();
|
||||
wxIDirectFBFontPtr f = m_font.GetDirectFBFont();
|
||||
|
||||
if (DFB_CALL(f->GetStringExtents(f, wxSTR_TO_DFB(string), -1, &rect, NULL)))
|
||||
if ( f->GetStringExtents(wxSTR_TO_DFB(string), -1, &rect, NULL) )
|
||||
{
|
||||
// VS: YDEV is corrent, it should *not* be XDEV, because font's are
|
||||
// only scaled according to m_scaleY
|
||||
@@ -463,7 +453,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
|
||||
if ( descent )
|
||||
{
|
||||
int d;
|
||||
if ( DFB_CALL( f->GetDescender(f, &d) ) )
|
||||
if ( f->GetDescender(&d) )
|
||||
*descent = YDEV2LOGREL(-d);
|
||||
else
|
||||
*descent = 0;
|
||||
@@ -614,7 +604,7 @@ void wxDC::DoGetSize(int *w, int *h) const
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
DFB_CALL( m_surface->GetSize(m_surface, w, h) );
|
||||
m_surface->GetSize(w, h);
|
||||
}
|
||||
|
||||
void wxDC::DoGetSizeMM(int *width, int *height) const
|
||||
|
||||
@@ -65,9 +65,9 @@ wxClientDCBase::wxClientDCBase(wxWindow *win)
|
||||
wxRect rect = win->GetClientRect();
|
||||
DFBRectangle dfbrect = { rect.x, rect.y, rect.width, rect.height };
|
||||
|
||||
IDirectFBSurfacePtr winsurf(win->GetDfbSurface());
|
||||
IDirectFBSurfacePtr subsurf;
|
||||
if ( !DFB_CALL( winsurf->GetSubSurface(winsurf, &dfbrect, &subsurf) ) )
|
||||
wxIDirectFBSurfacePtr subsurf(
|
||||
win->GetDfbSurface()->GetSubSurface(&dfbrect));
|
||||
if ( !subsurf )
|
||||
return;
|
||||
|
||||
Init(subsurf);
|
||||
@@ -86,9 +86,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
|
||||
wxClientDC::~wxClientDC()
|
||||
{
|
||||
// flip to surface so that the changes become visible
|
||||
IDirectFBSurfacePtr surface(GetDirectFBSurface());
|
||||
wxIDirectFBSurfacePtr surface(GetDirectFBSurface());
|
||||
if ( surface )
|
||||
surface->Flip(surface, NULL, DSFLIP_NONE);
|
||||
surface->Flip(NULL, DSFLIP_NONE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
// wxEventLoop initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBEventBufferPtr wxEventLoop::ms_buffer;
|
||||
wxIDirectFBEventBufferPtr wxEventLoop::ms_buffer;
|
||||
|
||||
wxEventLoop::wxEventLoop()
|
||||
{
|
||||
@@ -49,12 +49,11 @@ wxEventLoop::wxEventLoop()
|
||||
/* static */
|
||||
void wxEventLoop::InitBuffer()
|
||||
{
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
DFB_CALL( dfb->CreateEventBuffer(dfb, &ms_buffer) );
|
||||
ms_buffer = wxIDirectFB::Get()->CreateEventBuffer();
|
||||
}
|
||||
|
||||
/* static */
|
||||
IDirectFBEventBufferPtr wxEventLoop::GetDirectFBEventBuffer()
|
||||
wxIDirectFBEventBufferPtr wxEventLoop::GetDirectFBEventBuffer()
|
||||
{
|
||||
if ( !ms_buffer )
|
||||
InitBuffer();
|
||||
@@ -70,8 +69,7 @@ bool wxEventLoop::Pending() const
|
||||
{
|
||||
wxCHECK_MSG( ms_buffer, false, _T("invalid event buffer") );
|
||||
|
||||
// returns DFB_OK if there is >=1 event, DFB_BUFFER_EMPTY otherwise
|
||||
return ms_buffer->HasEvent(ms_buffer) == DFB_OK;
|
||||
return ms_buffer->HasEvent();
|
||||
}
|
||||
|
||||
bool wxEventLoop::Dispatch()
|
||||
@@ -85,27 +83,28 @@ bool wxEventLoop::Dispatch()
|
||||
// FIXME: call NotifyTimers() from here (and loop) instead?
|
||||
const int TIMEOUT = 100;
|
||||
|
||||
DFBResult ret = ms_buffer->WaitForEventWithTimeout(ms_buffer, 0, TIMEOUT);
|
||||
|
||||
switch ( ret )
|
||||
if ( ms_buffer->WaitForEventWithTimeout(0, TIMEOUT) )
|
||||
{
|
||||
case DFB_OK:
|
||||
switch ( ms_buffer->GetLastResult() )
|
||||
{
|
||||
wxDFBEvent e;
|
||||
ms_buffer->GetEvent(ms_buffer, &e);
|
||||
HandleDFBEvent(e);
|
||||
break;
|
||||
case DFB_OK:
|
||||
{
|
||||
wxDFBEvent e;
|
||||
ms_buffer->GetEvent(e);
|
||||
HandleDFBEvent(e);
|
||||
break;
|
||||
}
|
||||
|
||||
case DFB_TIMEOUT:
|
||||
// timed out, pretend we processed an event so that
|
||||
// OnNextIteration is called
|
||||
break;
|
||||
|
||||
default:
|
||||
// don't terminate the loop due to errors (they were reported
|
||||
// already by ms_buffer)
|
||||
break;
|
||||
}
|
||||
|
||||
case DFB_TIMEOUT:
|
||||
// timed out, pretend we processed an event so that OnNextIteration
|
||||
// is called
|
||||
break;
|
||||
|
||||
default:
|
||||
// report any errors, but don't terminate the loop due to them
|
||||
wxDfbCheckReturn(ret);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -115,7 +114,7 @@ void wxEventLoop::WakeUp()
|
||||
{
|
||||
wxCHECK_RET( ms_buffer, _T("invalid event buffer") );
|
||||
|
||||
DFB_CALL( ms_buffer->WakeUp(ms_buffer) );
|
||||
ms_buffer->WakeUp();
|
||||
}
|
||||
|
||||
void wxEventLoop::OnNextIteration()
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// FIXME: for now, always use single font
|
||||
static IDirectFBFontPtr gs_font = NULL;
|
||||
static wxIDirectFBFontPtr gs_font = NULL;
|
||||
static unsigned gs_fontRefCnt = 0;
|
||||
|
||||
class wxFontRefData : public wxObjectRefData
|
||||
@@ -71,12 +71,10 @@ public:
|
||||
// FIXME: always use default font for now
|
||||
if ( !gs_font )
|
||||
{
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
|
||||
DFBFontDescription desc;
|
||||
desc.flags = (DFBFontDescriptionFlags)0;
|
||||
IDirectFBFontPtr f;
|
||||
if ( DFB_CALL( dfb->CreateFont(dfb, NULL, &desc, &f) ) )
|
||||
wxIDirectFBFontPtr f(wxIDirectFB::Get()->CreateFont(NULL, &desc));
|
||||
if ( f )
|
||||
gs_font = f;
|
||||
}
|
||||
if ( gs_font ) // the above may fail
|
||||
@@ -104,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
wxNativeFontInfo m_info;
|
||||
IDirectFBFontPtr m_font;
|
||||
wxIDirectFBFontPtr m_font;
|
||||
};
|
||||
|
||||
|
||||
@@ -148,7 +146,7 @@ wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
|
||||
// accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBFontPtr wxFont::GetDirectFBFont() const
|
||||
wxIDirectFBFontPtr wxFont::GetDirectFBFont() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/ifacehelpers.cpp
|
||||
// Purpose: helpers for dealing with DFB interfaces
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-09
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
#include <directfb.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDfbPtr
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// NB: We can't call AddRef() and Release() directly from wxDfbPtr<T> because
|
||||
// we don't have full type declarations for them if we don't include
|
||||
// <directfb.h> (which user wx headers can't). Fortunately, all DirectFB
|
||||
// interfaces are structs with common beginning that contains pointers to
|
||||
// AddRef and Release, so we can safely cast interface pointer to void* and
|
||||
// then back to arbitrary interface pointer and these calls will still work
|
||||
// correctly. For this purpose, we declare a dummy DFB interface here.
|
||||
|
||||
DECLARE_INTERFACE(wxDummyDFBInterface)
|
||||
DEFINE_INTERFACE(wxDummyDFBInterface, )
|
||||
|
||||
/* static */
|
||||
void wxDfbPtrBase::DoAddRef(void *ptr)
|
||||
{
|
||||
wxDummyDFBInterface *p = (wxDummyDFBInterface*)ptr;
|
||||
p->AddRef(p);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxDfbPtrBase::DoRelease(void *ptr)
|
||||
{
|
||||
wxDummyDFBInterface *p = (wxDummyDFBInterface*)ptr;
|
||||
p->Release(p);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ bool wxTopLevelWindowDFB::Create(wxWindow *parent,
|
||||
pos.y = 0;
|
||||
|
||||
// create DirectFB window:
|
||||
IDirectFBDisplayLayerPtr layer = wxDfbGetDisplayLayer();
|
||||
wxIDirectFBDisplayLayerPtr layer = wxDfbGetDisplayLayer();
|
||||
wxCHECK_MSG( layer, false, _T("no display layer") );
|
||||
|
||||
DFBWindowDescription desc;
|
||||
@@ -111,17 +111,18 @@ bool wxTopLevelWindowDFB::Create(wxWindow *parent,
|
||||
desc.posy = pos.y;
|
||||
desc.width = size.x;
|
||||
desc.height = size.y;
|
||||
if ( !DFB_CALL( layer->CreateWindow(layer, &desc, &m_dfbwin) ) )
|
||||
m_dfbwin = layer->CreateWindow(&desc);
|
||||
if ( !layer )
|
||||
return false;
|
||||
|
||||
// add the new TLW to DFBWindowID->wxTLW map:
|
||||
DFBWindowID winid;
|
||||
if ( !DFB_CALL( m_dfbwin->GetID(m_dfbwin, &winid) ) )
|
||||
if ( !m_dfbwin->GetID(&winid) )
|
||||
return false;
|
||||
gs_dfbWindowsMap[winid] = this;
|
||||
|
||||
// TLWs are created initially hidden:
|
||||
if ( !DFB_CALL( m_dfbwin->SetOpacity(m_dfbwin, 0) ) )
|
||||
if ( !m_dfbwin->SetOpacity(wxALPHA_TRANSPARENT) )
|
||||
return false;
|
||||
|
||||
wxWindow::Create(NULL, id, pos, size, style, name);
|
||||
@@ -135,12 +136,11 @@ bool wxTopLevelWindowDFB::Create(wxWindow *parent,
|
||||
|
||||
if ( style & (wxSTAY_ON_TOP | wxPOPUP_WINDOW) )
|
||||
{
|
||||
DFB_CALL( m_dfbwin->SetStackingClass(m_dfbwin, DWSC_UPPER) );
|
||||
m_dfbwin->SetStackingClass(DWSC_UPPER);
|
||||
}
|
||||
|
||||
// direct events in this window to the global event buffer:
|
||||
DFB_CALL( m_dfbwin->AttachEventBuffer(
|
||||
m_dfbwin, wxEventLoop::GetDirectFBEventBuffer()) );
|
||||
m_dfbwin->AttachEventBuffer(wxEventLoop::GetDirectFBEventBuffer());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ wxTopLevelWindowDFB::~wxTopLevelWindowDFB()
|
||||
|
||||
// remove the TLW from DFBWindowID->wxTLW map:
|
||||
DFBWindowID winid;
|
||||
if ( DFB_CALL( m_dfbwin->GetID(m_dfbwin, &winid) ) )
|
||||
if ( m_dfbwin->GetID(&winid) )
|
||||
gs_dfbWindowsMap.erase(winid);
|
||||
}
|
||||
|
||||
@@ -174,12 +174,12 @@ wxTopLevelWindowDFB::~wxTopLevelWindowDFB()
|
||||
|
||||
void wxTopLevelWindowDFB::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
DFB_CALL( m_dfbwin->GetPosition(m_dfbwin, x, y) );
|
||||
m_dfbwin->GetPosition(x, y);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
DFB_CALL( m_dfbwin->GetSize(m_dfbwin, width, height) );
|
||||
m_dfbwin->GetSize(width, height);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::DoMoveWindow(int x, int y, int width, int height)
|
||||
@@ -187,13 +187,13 @@ void wxTopLevelWindowDFB::DoMoveWindow(int x, int y, int width, int height)
|
||||
wxPoint curpos = GetPosition();
|
||||
if ( curpos.x != x || curpos.y != y )
|
||||
{
|
||||
DFB_CALL( m_dfbwin->MoveTo(m_dfbwin, x, y) );
|
||||
m_dfbwin->MoveTo(x, y);
|
||||
}
|
||||
|
||||
wxSize cursize = GetSize();
|
||||
if ( cursize.x != width || cursize.y != height )
|
||||
{
|
||||
DFB_CALL( m_dfbwin->Resize(m_dfbwin, width, height) );
|
||||
m_dfbwin->Resize(width, height);
|
||||
// we must repaint the window after it changed size:
|
||||
Refresh();
|
||||
}
|
||||
@@ -242,7 +242,7 @@ bool wxTopLevelWindowDFB::Show(bool show)
|
||||
return false;
|
||||
|
||||
// hide/show the window by setting its opacity to 0/full:
|
||||
DFB_CALL( m_dfbwin->SetOpacity(m_dfbwin, show ? m_opacity : 0) );
|
||||
m_dfbwin->SetOpacity(show ? m_opacity : 0);
|
||||
|
||||
// If this is the first time Show was called, send size event,
|
||||
// so that the frame can adjust itself (think auto layout or single child)
|
||||
@@ -266,7 +266,7 @@ bool wxTopLevelWindowDFB::SetTransparent(wxByte alpha)
|
||||
{
|
||||
if ( IsShown() )
|
||||
{
|
||||
if ( !DFB_CALL( m_dfbwin->SetOpacity(m_dfbwin, alpha) ) )
|
||||
if ( !m_dfbwin->SetOpacity(alpha) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -328,11 +328,9 @@ bool wxTopLevelWindowDFB::IsIconized() const
|
||||
// surfaces and painting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBSurfacePtr wxTopLevelWindowDFB::ObtainDfbSurface() const
|
||||
wxIDirectFBSurfacePtr wxTopLevelWindowDFB::ObtainDfbSurface() const
|
||||
{
|
||||
IDirectFBSurfacePtr surface;
|
||||
DFB_CALL( m_dfbwin->GetSurface(m_dfbwin, &surface) );
|
||||
return surface;
|
||||
return m_dfbwin->GetSurface();
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::HandleQueuedPaintRequests()
|
||||
@@ -380,8 +378,7 @@ void wxTopLevelWindowDFB::HandleQueuedPaintRequests()
|
||||
paintedRect.GetRight(), paintedRect.GetBottom()};
|
||||
DFBRegion *rptr = (winRect == paintedRect) ? NULL : &r;
|
||||
|
||||
IDirectFBSurfacePtr surface(GetDfbSurface());
|
||||
DFB_CALL( surface->Flip(surface, rptr, DSFLIP_NONE) );
|
||||
GetDfbSurface()->Flip(rptr, DSFLIP_NONE);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::DoRefreshRect(const wxRect& rect, bool eraseBack)
|
||||
|
||||
@@ -87,8 +87,8 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||
// surface manipulation helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBSurfacePtr wxDfbCloneSurface(const IDirectFBSurfacePtr& s,
|
||||
wxDfbCloneSurfaceMode mode)
|
||||
wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
|
||||
wxDfbCloneSurfaceMode mode)
|
||||
{
|
||||
if ( !s )
|
||||
return NULL;
|
||||
@@ -96,63 +96,56 @@ IDirectFBSurfacePtr wxDfbCloneSurface(const IDirectFBSurfacePtr& s,
|
||||
DFBSurfaceDescription desc;
|
||||
desc.flags = (DFBSurfaceDescriptionFlags)(
|
||||
DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT);
|
||||
s->GetCapabilities(s, &desc.caps);
|
||||
s->GetSize(s, &desc.width, &desc.height);
|
||||
s->GetPixelFormat(s, &desc.pixelformat);
|
||||
s->GetCapabilities(&desc.caps);
|
||||
s->GetSize(&desc.width, &desc.height);
|
||||
s->GetPixelFormat(&desc.pixelformat);
|
||||
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
|
||||
IDirectFBSurfacePtr snew;
|
||||
if ( !DFB_CALL( dfb->CreateSurface(dfb, &desc, &snew) ) )
|
||||
wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
|
||||
if ( !snew )
|
||||
return NULL;
|
||||
|
||||
IDirectFBPalettePtr pal;
|
||||
if ( s->GetPalette(s, &pal) == DFB_OK )
|
||||
if ( desc.pixelformat == DSPF_LUT8 )
|
||||
{
|
||||
if ( !DFB_CALL( snew->SetPalette(snew, pal) ) )
|
||||
return NULL;
|
||||
wxIDirectFBPalettePtr pal(s->GetPalette());
|
||||
if ( s )
|
||||
{
|
||||
if ( !snew->SetPalette(pal) )
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mode == wxDfbCloneSurface_CopyPixels )
|
||||
{
|
||||
if ( !DFB_CALL( snew->SetBlittingFlags(snew, DSBLIT_NOFX) ) )
|
||||
if ( !snew->SetBlittingFlags(DSBLIT_NOFX) )
|
||||
return NULL;
|
||||
if ( !DFB_CALL( snew->Blit(snew, s, NULL, 0, 0) ) )
|
||||
if ( !snew->Blit(s, NULL, 0, 0) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return snew;
|
||||
}
|
||||
|
||||
int wxDfbGetSurfaceDepth(const IDirectFBSurfacePtr& s)
|
||||
int wxDfbGetSurfaceDepth(const wxIDirectFBSurfacePtr& s)
|
||||
{
|
||||
wxCHECK_MSG( s, -1, _T("invalid surface") );
|
||||
|
||||
DFBSurfacePixelFormat format = DSPF_UNKNOWN;
|
||||
|
||||
if ( !DFB_CALL( s->GetPixelFormat(s, &format) ) )
|
||||
if ( !s->GetPixelFormat(&format) )
|
||||
return -1;
|
||||
|
||||
return DFB_BITS_PER_PIXEL(format);
|
||||
}
|
||||
|
||||
IDirectFBDisplayLayerPtr wxDfbGetDisplayLayer()
|
||||
wxIDirectFBDisplayLayerPtr wxDfbGetDisplayLayer()
|
||||
{
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
|
||||
IDirectFBDisplayLayerPtr layer;
|
||||
if ( !DFB_CALL( dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer) ) )
|
||||
return NULL;
|
||||
|
||||
return layer;
|
||||
return wxIDirectFB::Get()->GetDisplayLayer(DLID_PRIMARY);
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr wxDfbGetPrimarySurface()
|
||||
wxIDirectFBSurfacePtr wxDfbGetPrimarySurface()
|
||||
{
|
||||
IDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
IDirectFBSurfacePtr surface;
|
||||
DFB_CALL( layer->GetSurface(layer, &surface) );
|
||||
return surface;
|
||||
wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
return layer ? layer->GetSurface() : NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,8 +155,9 @@ IDirectFBSurfacePtr wxDfbGetPrimarySurface()
|
||||
|
||||
void wxGetMousePosition(int *x, int *y)
|
||||
{
|
||||
IDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
DFB_CALL( layer->GetCursorPosition(layer, x, y) );
|
||||
wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
if ( layer )
|
||||
layer->GetCursorPosition(x, y);
|
||||
}
|
||||
|
||||
wxPoint wxGetMousePosition()
|
||||
|
||||
@@ -141,23 +141,21 @@ bool wxWindowDFB::Create(wxWindow *parent,
|
||||
// surface access
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
IDirectFBSurfacePtr wxWindowDFB::ObtainDfbSurface() const
|
||||
wxIDirectFBSurfacePtr wxWindowDFB::ObtainDfbSurface() const
|
||||
{
|
||||
wxCHECK_MSG( m_parent, NULL, _T("parentless window?") );
|
||||
|
||||
IDirectFBSurfacePtr parentSurface(m_parent->GetDfbSurface());
|
||||
wxIDirectFBSurfacePtr parentSurface(m_parent->GetDfbSurface());
|
||||
wxCHECK_MSG( parentSurface, NULL, _T("invalid parent surface") );
|
||||
|
||||
wxRect r(GetRect());
|
||||
AdjustForParentClientOrigin(r.x, r.y, 0);
|
||||
DFBRectangle rect = { r.x, r.y, r.width, r.height };
|
||||
|
||||
IDirectFBSurfacePtr surface;
|
||||
DFB_CALL( parentSurface->GetSubSurface(parentSurface, &rect, &surface) );
|
||||
return surface;
|
||||
return parentSurface->GetSubSurface(&rect);
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr wxWindowDFB::GetDfbSurface()
|
||||
wxIDirectFBSurfacePtr wxWindowDFB::GetDfbSurface()
|
||||
{
|
||||
if ( !m_surface )
|
||||
{
|
||||
@@ -192,9 +190,9 @@ void wxWindowDFB::SetFocus()
|
||||
|
||||
#warning "FIXME: implement in terms of DWET_{GOT,LOST}FOCUS"
|
||||
|
||||
IDirectFBWindowPtr dfbwin(m_tlw->GetDirectFBWindow());
|
||||
wxIDirectFBWindowPtr dfbwin(m_tlw->GetDirectFBWindow());
|
||||
#warning "FIXME: RequestFocus() may only be called on visible TLW"
|
||||
if ( !DFB_CALL( dfbwin->RequestFocus(dfbwin) ) )
|
||||
if ( !dfbwin->RequestFocus() )
|
||||
return;
|
||||
|
||||
gs_focusedWindow = this;
|
||||
@@ -368,10 +366,10 @@ void wxWindowDFB::WarpPointer(int x, int y)
|
||||
if ( x >= w ) x = w-1;
|
||||
if ( y >= h ) y = h-1;
|
||||
|
||||
IDirectFBDisplayLayerPtr layer = wxDfbGetDisplayLayer();
|
||||
wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
wxCHECK_RET( layer, _T("no display layer") );
|
||||
|
||||
layer->WarpCursor(layer, x, y);
|
||||
layer->WarpCursor(x, y);
|
||||
}
|
||||
|
||||
// Set this window to be the child of 'parent'.
|
||||
|
||||
97
src/dfb/wrapdfb.cpp
Normal file
97
src/dfb/wrapdfb.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/wrapdfb.cpp
|
||||
// Purpose: wx wrappers for DirectFB interfaces
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-09-04
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/wrapdfb.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDfbCheckReturn
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool wxDfbCheckReturn(DFBResult code)
|
||||
{
|
||||
switch ( code )
|
||||
{
|
||||
case DFB_OK:
|
||||
return true;
|
||||
|
||||
// these are programming errors, assert:
|
||||
#define DFB_ASSERT(code) \
|
||||
case code: \
|
||||
wxFAIL_MSG( _T("DirectFB error: ") _T(#code) ); \
|
||||
return false \
|
||||
|
||||
DFB_ASSERT(DFB_DEAD);
|
||||
DFB_ASSERT(DFB_UNSUPPORTED);
|
||||
DFB_ASSERT(DFB_UNIMPLEMENTED);
|
||||
DFB_ASSERT(DFB_INVARG);
|
||||
DFB_ASSERT(DFB_NOIMPL);
|
||||
DFB_ASSERT(DFB_MISSINGFONT);
|
||||
DFB_ASSERT(DFB_THIZNULL);
|
||||
DFB_ASSERT(DFB_INVAREA);
|
||||
DFB_ASSERT(DFB_DESTROYED);
|
||||
DFB_ASSERT(DFB_NOSUCHMETHOD);
|
||||
DFB_ASSERT(DFB_NOSUCHINSTANCE);
|
||||
DFB_ASSERT(DFB_VERSIONMISMATCH);
|
||||
|
||||
#undef DFB_ASSERT
|
||||
|
||||
// these are not errors, but valid return codes:
|
||||
case DFB_INTERRUPTED:
|
||||
case DFB_BUFFEREMPTY:
|
||||
return true;
|
||||
|
||||
default:
|
||||
// FIXME: should handle the errors individually
|
||||
wxLogError(_("DirectFB error %d occured."), (int)code);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDfbPtrBase
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
void wxDfbPtrBase::DoAddRef(wxDfbWrapperBase *ptr)
|
||||
{
|
||||
ptr->AddRef();
|
||||
}
|
||||
|
||||
void wxDfbPtrBase::DoRelease(wxDfbWrapperBase *ptr)
|
||||
{
|
||||
ptr->Release();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxIDirectFB
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxIDirectFBPtr wxIDirectFB::ms_ptr;
|
||||
|
||||
/* static */
|
||||
void wxIDirectFB::CreateDirectFB()
|
||||
{
|
||||
IDirectFB *dfb;
|
||||
if ( wxDfbCheckReturn(DirectFBCreate(&dfb)) )
|
||||
ms_ptr = new wxIDirectFB(dfb);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxIDirectFB::CleanUp()
|
||||
{
|
||||
ms_ptr.Reset();
|
||||
}
|
||||
Reference in New Issue
Block a user