initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/app.h
// Purpose: wxApp class
// Author: Vaclav Slavik
// Created: 2006-08-10
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_APP_H_
#define _WX_DFB_APP_H_
#include "wx/dfb/dfbptr.h"
#include "wx/vidmode.h"
wxDFB_DECLARE_INTERFACE(IDirectFB);
//-----------------------------------------------------------------------------
// wxApp
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxApp: public wxAppBase
{
public:
wxApp();
~wxApp();
// override base class (pure) virtuals
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
virtual void WakeUpIdle();
virtual wxVideoMode GetDisplayMode() const;
virtual bool SetDisplayMode(const wxVideoMode& mode);
private:
wxVideoMode m_videoMode;
wxDECLARE_DYNAMIC_CLASS(wxApp);
};
#endif // _WX_DFB_APP_H_

View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/bitmap.h
// Purpose: wxBitmap class
// Author: Vaclav Slavik
// Created: 2006-08-04
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_BITMAP_H_
#define _WX_DFB_BITMAP_H_
#include "wx/dfb/dfbptr.h"
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmap : public wxBitmapBase
{
public:
wxBitmap() = default;
wxBitmap(const wxIDirectFBSurfacePtr& surface) { Create(surface); }
wxBitmap(int width, int height, int depth = -1) { Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1) { Create(sz, depth); }
wxBitmap(int width, int height, const wxDC& dc) { Create(width, height, dc); }
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
wxBitmap(const char* const* bits);
#if wxUSE_IMAGE
wxBitmap(const wxImage& image, int depth = -1, double scale = 1.0)
{ InitFromImage(image, depth, scale); }
wxBitmap(const wxImage& image, const wxDC& WXUNUSED(dc))
{ InitFromImage(image, -1, 1.0); }
#endif
bool Create(const wxIDirectFBSurfacePtr& surface);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(int width, int height, const wxDC& WXUNUSED(dc))
{ return Create(width,height); }
virtual int GetHeight() const;
virtual int GetWidth() const;
virtual int GetDepth() const;
#if wxUSE_IMAGE
virtual wxImage ConvertToImage() const;
#endif
virtual wxMask *GetMask() const;
virtual void SetMask(wxMask *mask);
virtual wxBitmap GetSubBitmap(const wxRect& rect) const;
virtual bool SaveFile(const wxString &name, wxBitmapType type,
const wxPalette *palette = nullptr) const;
virtual bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
#if wxUSE_PALETTE
virtual wxPalette *GetPalette() const;
virtual void SetPalette(const wxPalette& palette);
#endif
static void InitStandardHandlers();
// raw bitmap access support functions
void *GetRawData(wxPixelDataBase& data, int bpp);
void UngetRawData(wxPixelDataBase& data);
bool HasAlpha() const;
// implementation:
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED(virtual void SetHeight(int height));
wxDEPRECATED(virtual void SetWidth(int width));
wxDEPRECATED(virtual void SetDepth(int depth));
#endif
// get underlying native representation:
wxIDirectFBSurfacePtr GetDirectFBSurface() const;
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
void InitFromImage(const wxImage& image, int depth, double scale);
bool CreateWithFormat(int width, int height, int dfbFormat);
wxDECLARE_DYNAMIC_CLASS(wxBitmap);
};
#endif // _WX_DFB_BITMAP_H_

View File

@@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/brush.h
// Purpose: wxBrush class declaration
// Author: Vaclav Slavik
// Created: 2006-08-04
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_BRUSH_H_
#define _WX_DFB_BRUSH_H_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/string.h"
#include "wx/gdiobj.h"
#include "wx/bitmap.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxBrush;
//-----------------------------------------------------------------------------
// wxBrush
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBrush : public wxBrushBase
{
public:
wxBrush() = default;
wxBrush(const wxColour &colour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
wxBrush(const wxBitmap &stippleBitmap);
bool operator==(const wxBrush& brush) const;
bool operator!=(const wxBrush& brush) const { return !(*this == brush); }
wxBrushStyle GetStyle() const;
wxColour GetColour() const;
wxBitmap *GetStipple() const;
void SetColour(const wxColour& col);
void SetColour(unsigned char r, unsigned char g, unsigned char b);
void SetStyle(wxBrushStyle style);
void SetStipple(const wxBitmap& stipple);
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants")
wxBrush(const wxColour& col, int style);
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants")
void SetStyle(int style) { SetStyle((wxBrushStyle)style); }
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
wxDECLARE_DYNAMIC_CLASS(wxBrush);
};
#endif // _WX_DFB_BRUSH_H_

View File

@@ -0,0 +1,41 @@
/*
* Name: wx/dfb/chkconf.h
* Author: Vaclav Slavik
* Purpose: Compiler-specific configuration checking
* Created: 2006-08-10
* Copyright: (c) 2006 REA Elektronik GmbH
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_DFB_CHKCONF_H_
#define _WX_DFB_CHKCONF_H_
#ifndef __WXUNIVERSAL__
# error "wxDirectFB cannot be built without wxUniversal"
#endif
#if !wxUSE_CONFIG
# error "wxFileConfig is required by wxDFB port"
#endif
#if wxUSE_SOCKETS && !wxUSE_CONSOLE_EVENTLOOP
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxSocket requires wxSelectDispatcher in wxDFB"
# else
# undef wxUSE_CONSOLE_EVENTLOOP
# define wxUSE_CONSOLE_EVENTLOOP 1
# endif
#endif
#if wxUSE_DATAOBJ
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxDataObject not supported in wxDFB"
# else
# undef wxUSE_DATAOBJ
# define wxUSE_DATAOBJ 0
# endif
#endif
#endif /* _WX_DFB_CHKCONF_H_ */

View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/cursor.h
// Purpose: wxCursor declaration
// Author: Vaclav Slavik
// Created: 2006-08-08
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_CURSOR_H_
#define _WX_DFB_CURSOR_H_
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxImage;
//-----------------------------------------------------------------------------
// wxCursor
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCursor : public wxCursorBase
{
public:
wxCursor() = default;
wxCursor(wxStockCursor id) { InitFromStock(id); }
wxCursor(const wxBitmap& bitmap, const wxPoint& hotSpot)
: wxCursor(bitmap, hotSpot.x, hotSpot.y) { }
wxCursor(const wxBitmap& bitmap, int hotSpotX = 0, int hotSpotY = 0);
#if wxUSE_IMAGE
wxCursor(const wxImage& image);
wxCursor(const char* const* xpmData);
#endif // wxUSE_IMAGE
wxCursor(const wxString& name, wxBitmapType type, const wxPoint& hotSpot)
: wxCursor(name, type, hotSpot.x, hotSpot.y) { }
wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
// implementation
wxBitmap GetBitmap() const;
protected:
void InitFromStock(wxStockCursor);
// ref counting code
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
wxDECLARE_DYNAMIC_CLASS(wxCursor);
};
#endif // _WX_DFB_CURSOR_H_

View File

@@ -0,0 +1,165 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dc.h
// Purpose: wxDC class
// Author: Vaclav Slavik
// Created: 2006-08-07
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_DC_H_
#define _WX_DFB_DC_H_
#include "wx/defs.h"
#include "wx/region.h"
#include "wx/dc.h"
#include "wx/dfb/dfbptr.h"
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
//-----------------------------------------------------------------------------
// wxDFBDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDFBDCImpl : public wxDCImpl
{
public:
// ctors
wxDFBDCImpl(wxDC *owner) : wxDCImpl(owner) { m_surface = nullptr; }
wxDFBDCImpl(wxDC *owner, const wxIDirectFBSurfacePtr& surface)
: wxDCImpl(owner)
{
DFBInit(surface);
}
bool IsOk() const { return m_surface != nullptr; }
// implement base class pure virtuals
// ----------------------------------
virtual void Clear();
virtual bool StartDoc(const wxString& message);
virtual void EndDoc();
virtual void StartPage();
virtual void EndPage();
virtual void SetFont(const wxFont& font);
virtual void SetPen(const wxPen& pen);
virtual void SetBrush(const wxBrush& brush);
virtual void SetBackground(const wxBrush& brush);
virtual void SetBackgroundMode(int mode);
#if wxUSE_PALETTE
virtual void SetPalette(const wxPalette& palette);
#endif
virtual void SetLogicalFunction(wxRasterOperationMode function);
virtual void DestroyClippingRegion();
virtual wxCoord GetCharHeight() const;
virtual wxCoord GetCharWidth() const;
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = nullptr,
wxCoord *externalLeading = nullptr,
const wxFont *theFont = nullptr) const;
virtual bool CanDrawBitmap() const { return true; }
virtual bool CanGetTextExtent() const { return true; }
virtual int GetDepth() const;
virtual wxSize GetPPI() const;
// Returns the surface (and increases its ref count)
wxIDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; }
protected:
// implementation
wxCoord XDEV2LOG(wxCoord x) const { return DeviceToLogicalX(x); }
wxCoord XDEV2LOGREL(wxCoord x) const { return DeviceToLogicalXRel(x); }
wxCoord YDEV2LOG(wxCoord y) const { return DeviceToLogicalY(y); }
wxCoord YDEV2LOGREL(wxCoord y) const { return DeviceToLogicalYRel(y); }
wxCoord XLOG2DEV(wxCoord x) const { return LogicalToDeviceX(x); }
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);
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
wxFloodFillStyle style = wxFLOOD_SURFACE);
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
virtual void DoDrawPoint(wxCoord x, wxCoord y);
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea);
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius);
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoCrossHair(wxCoord x, wxCoord y);
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = false);
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle);
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetSizeMM(int* width, int* height) const;
virtual void DoDrawLines(int n, const wxPoint points[],
wxCoord xoffset, wxCoord yoffset);
virtual void DoDrawPolygon(int n, const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
// implementation from now on:
protected:
wxIDirectFBFontPtr GetCurrentFont() const;
private:
// Unified implementation of DrawIcon, DrawBitmap and Blit:
void DoDrawSubBitmap(const wxBitmap &bmp,
wxCoord x, wxCoord y, wxCoord w, wxCoord h,
wxCoord destx, wxCoord desty, int rop, bool useMask);
bool DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
wxCoord srcx, wxCoord srcy,
wxCoord w, wxCoord h,
wxCoord dstx, wxCoord dsty);
// selects colour into surface's state
void SelectColour(const wxColour& clr);
protected:
wxIDirectFBSurfacePtr m_surface;
friend class WXDLLIMPEXP_FWD_CORE wxOverlayImpl; // for Init
wxDECLARE_ABSTRACT_CLASS(wxDFBDCImpl);
};
#endif // _WX_DFB_DC_H_

View File

@@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dcclient.h
// Purpose: wxWindowDCImpl, wxClientDCImpl and wxPaintDCImpl
// Author: Vaclav Slavik
// Created: 2006-08-10
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_DCCLIENT_H_
#define _WX_DFB_DCCLIENT_H_
#include "wx/dfb/dc.h"
class WXDLLIMPEXP_FWD_CORE wxWindow;
//-----------------------------------------------------------------------------
// wxWindowDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxDFBDCImpl
{
public:
wxWindowDCImpl(wxDC *owner) : wxDFBDCImpl(owner), m_shouldFlip(false) { }
wxWindowDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxWindowDCImpl();
protected:
// initializes the DC for painting on given window; if rect!=nullptr, then
// for painting only on the given region of the window
void InitForWin(wxWindow *win, const wxRect *rect);
private:
wxRect m_winRect; // rectangle of the window being painted
bool m_shouldFlip; // flip the surface when done?
friend class wxOverlayImpl; // for m_shouldFlip;
wxDECLARE_DYNAMIC_CLASS(wxWindowDCImpl);
wxDECLARE_NO_COPY_CLASS(wxWindowDCImpl);
};
//-----------------------------------------------------------------------------
// wxClientDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClientDCImpl : public wxWindowDCImpl
{
public:
wxClientDCImpl(wxDC *owner) : wxWindowDCImpl(owner) { }
wxClientDCImpl(wxDC *owner, wxWindow *win);
static bool
CanBeUsedForDrawing(const wxWindow* WXUNUSED(window)) { return true; }
wxDECLARE_DYNAMIC_CLASS(wxClientDCImpl);
wxDECLARE_NO_COPY_CLASS(wxClientDCImpl);
};
//-----------------------------------------------------------------------------
// wxPaintDCImpl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl
{
public:
wxPaintDCImpl(wxDC *owner) : wxClientDCImpl(owner) { }
wxPaintDCImpl(wxDC *owner, wxWindow *win) : wxClientDCImpl(owner, win) { }
wxDECLARE_DYNAMIC_CLASS(wxPaintDCImpl);
wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl);
};
#endif // _WX_DFB_DCCLIENT_H_

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dcmemory.h
// Purpose: wxMemoryDC class declaration
// Created: 2006-08-10
// Author: Vaclav Slavik
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_DCMEMORY_H_
#define _WX_DFB_DCMEMORY_H_
#include "wx/dfb/dc.h"
#include "wx/bitmap.h"
class WXDLLIMPEXP_CORE wxMemoryDCImpl : public wxDFBDCImpl
{
public:
wxMemoryDCImpl(wxMemoryDC *owner);
wxMemoryDCImpl(wxMemoryDC *owner, wxBitmap& bitmap);
wxMemoryDCImpl(wxMemoryDC *owner, wxDC *dc); // create compatible DC
// 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:
void Init();
wxBitmap m_bmp;
wxDECLARE_DYNAMIC_CLASS(wxMemoryDCImpl);
};
#endif // _WX_DFB_DCMEMORY_H_

View File

@@ -0,0 +1,23 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dcscreen.h
// Purpose: wxScreenDCImpl declaration
// Author: Vaclav Slavik
// Created: 2006-08-10
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_DCSCREEN_H_
#define _WX_DFB_DCSCREEN_H_
#include "wx/dfb/dc.h"
class WXDLLIMPEXP_CORE wxScreenDCImpl : public wxDFBDCImpl
{
public:
wxScreenDCImpl(wxScreenDC *owner);
wxDECLARE_DYNAMIC_CLASS(wxScreenDCImpl);
};
#endif // _WX_DFB_DCSCREEN_H_

View File

@@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dfbptr.h
// Purpose: wxDfbPtr<T> for holding objects declared in wrapdfb.h
// Author: Vaclav Slavik
// Created: 2006-08-09
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_DFBPTR_H_
#define _WX_DFB_DFBPTR_H_
//-----------------------------------------------------------------------------
// wxDFB_DECLARE_INTERFACE
//-----------------------------------------------------------------------------
/**
Forward declares wx wrapper around DirectFB interface @a name.
Also declares wx##name##Ptr typedef for wxDfbPtr<wx##name> pointer.
@param name name of the DirectFB interface
*/
#define wxDFB_DECLARE_INTERFACE(name) \
class wx##name; \
typedef wxDfbPtr<wx##name> wx##name##Ptr
//-----------------------------------------------------------------------------
// wxDfbPtr<T>
//-----------------------------------------------------------------------------
class wxDfbWrapperBase;
class WXDLLIMPEXP_CORE wxDfbPtrBase
{
protected:
static void DoAddRef(wxDfbWrapperBase *ptr);
static void DoRelease(wxDfbWrapperBase *ptr);
};
/**
This template implements smart pointer for keeping pointers to DirectFB
wrappers (i.e. wxIFoo classes derived from wxDfbWrapper<T>). Interface's
reference count is increased on copying and the interface is released when
the pointer is deleted.
*/
template<typename T>
class wxDfbPtr : private wxDfbPtrBase
{
public:
/**
Creates the pointer from raw pointer to the wrapper.
Takes ownership of @a ptr, i.e. AddRef() is @em not called on it.
*/
wxDfbPtr(T *ptr = nullptr) : m_ptr(ptr) {}
/// Copy ctor
wxDfbPtr(const wxDfbPtr& ptr) { InitFrom(ptr); }
/// Dtor. Releases the interface
~wxDfbPtr() { Reset(); }
/// Resets the pointer to nullptr, decreasing reference count of the interface.
void Reset()
{
if ( m_ptr )
{
this->DoRelease((wxDfbWrapperBase*)m_ptr);
m_ptr = nullptr;
}
}
/// Cast to the wrapper pointer
operator T*() const { return m_ptr; }
// standard operators:
wxDfbPtr& operator=(T *ptr)
{
Reset();
m_ptr = ptr;
return *this;
}
wxDfbPtr& operator=(const wxDfbPtr& ptr)
{
Reset();
InitFrom(ptr);
return *this;
}
T& operator*() const { return *m_ptr; }
T* operator->() const { return m_ptr; }
private:
void InitFrom(const wxDfbPtr& ptr)
{
m_ptr = ptr.m_ptr;
if ( m_ptr )
this->DoAddRef((wxDfbWrapperBase*)m_ptr);
}
private:
T *m_ptr;
};
#endif // _WX_DFB_DFBPTR_H_

View File

@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/evtloop.h
// Purpose: declares wxEventLoop class
// Author: Vaclav Slavik
// Created: 2006-08-16
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_EVTLOOP_H_
#define _WX_DFB_EVTLOOP_H_
#include "wx/dfb/dfbptr.h"
#include "wx/unix/evtloop.h"
wxDFB_DECLARE_INTERFACE(IDirectFBEventBuffer);
// ----------------------------------------------------------------------------
// wxEventLoop
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxConsoleEventLoop
{
public:
wxGUIEventLoop();
// returns DirectFB event buffer used by wx
static wxIDirectFBEventBufferPtr GetDirectFBEventBuffer();
protected:
virtual void DoYieldFor(long eventsToProcess);
private:
static void InitBuffer();
static void CleanUp();
friend class wxApp; // calls CleanUp()
private:
static wxIDirectFBEventBufferPtr ms_buffer;
static int ms_bufferFd;
wxDECLARE_NO_COPY_CLASS(wxGUIEventLoop);
};
#endif // _WX_DFB_EVTLOOP_H_

View File

@@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/font.h
// Author: Vaclav Slavik
// Purpose: wxFont declaration
// Created: 2006-08-08
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_FONT_H_
#define _WX_DFB_FONT_H_
#include "wx/dfb/dfbptr.h"
wxDFB_DECLARE_INTERFACE(IDirectFBFont);
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
{
public:
wxFont() = default;
wxFont(const wxFontInfo& info)
{
Create(info.GetPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetWeight(),
info.IsUnderlined(),
info.GetFaceName(),
info.GetEncoding());
if ( info.IsUsingSizeInPixels() )
SetPixelSize(info.GetPixelSize());
}
wxFont(const wxNativeFontInfo& info) { Create(info); }
wxFont(const wxString& nativeFontInfoString);
wxFont(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(const wxSize& pixelSize,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Create(10, family, style, weight, underlined, face, encoding);
SetPixelSize(pixelSize);
}
bool Create(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
bool Create(const wxNativeFontInfo& fontinfo);
// implement base class pure virtuals
virtual double GetFractionalPointSize() const;
virtual wxFontStyle GetStyle() const;
virtual int GetNumericWeight() const;
virtual wxString GetFaceName() const;
virtual bool GetUnderlined() const;
virtual wxFontEncoding GetEncoding() const;
virtual bool IsFixedWidth() const;
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
virtual void SetFractionalPointSize(double pointSize);
virtual void SetFamily(wxFontFamily family);
virtual void SetStyle(wxFontStyle style);
virtual void SetNumericWeight(int weight);
virtual bool SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);
wxDECLARE_COMMON_FONT_METHODS();
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
wxFont(int size,
int family,
int style,
int weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
(void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
}
// implementation from now on:
wxIDirectFBFontPtr GetDirectFBFont(bool antialiased) const;
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
virtual wxFontFamily DoGetFamily() const;
private:
wxDECLARE_DYNAMIC_CLASS(wxFont);
};
#endif // _WX_DFB_FONT_H_

View File

@@ -0,0 +1,124 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/nonownedwnd.h
// Purpose: declares wxNonOwnedWindow class
// Author: Vaclav Slavik
// Created: 2006-12-24
// Copyright: (c) 2006 TT-Solutions
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_NONOWNEDWND_H_
#define _WX_DFB_NONOWNEDWND_H_
#include "wx/window.h"
#include "wx/dfb/dfbptr.h"
wxDFB_DECLARE_INTERFACE(IDirectFBWindow);
class wxDfbQueuedPaintRequests;
struct wxDFBWindowEvent;
class wxDFBEventsHandler;
//-----------------------------------------------------------------------------
// wxNonOwnedWindow
//-----------------------------------------------------------------------------
// This class represents "non-owned" window. A window is owned by another
// window if it has a parent and is positioned within the parent. For example,
// wxFrame is non-owned, because even though it can have a parent, it's
// location is independent of it. This class is for internal use only, it's
// the base class for wxTopLevelWindow and wxPopupWindow.
class WXDLLIMPEXP_CORE wxNonOwnedWindow : public wxNonOwnedWindowBase
{
public:
// construction
wxNonOwnedWindow() { Init(); }
wxNonOwnedWindow(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr))
{
Init();
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr));
virtual ~wxNonOwnedWindow();
// implement base class pure virtuals
virtual bool Show(bool show = true);
virtual void Update();
virtual void Raise();
virtual void Lower();
// implementation from now on
// --------------------------
void OnInternalIdle();
wxIDirectFBWindowPtr GetDirectFBWindow() const { return m_dfbwin; }
// Returns true if some invalidated area of the TLW is currently being
// painted
bool IsPainting() const { return m_isPainting; }
protected:
// common part of all ctors
void Init();
virtual wxIDirectFBSurfacePtr ObtainDfbSurface() const;
// overridden wxWindow methods
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoRefreshRect(const wxRect& rect);
// sets DirectFB keyboard focus to this toplevel window (note that DFB
// focus is different from wx: only shown TLWs can have it and not any
// wxWindows as in wx
void SetDfbFocus();
// overridden in wxTopLevelWindowDFB, there's no common handling for wxTLW
// and wxPopupWindow to be done here
virtual void HandleFocusEvent(const wxDFBWindowEvent& WXUNUSED(event_)) {}
private:
// do queued painting in idle time
void HandleQueuedPaintRequests();
// DirectFB events handling
static void HandleDFBWindowEvent(const wxDFBWindowEvent& event_);
protected:
// did we sent wxSizeEvent at least once?
bool m_sizeSet:1;
// window's opacity (0: transparent, 255: opaque)
wxByte m_opacity;
// interface to the underlying DirectFB window
wxIDirectFBWindowPtr m_dfbwin;
private:
// invalidated areas of the TLW that need repainting
wxDfbQueuedPaintRequests *m_toPaint;
// are we currently painting some area of this TLW?
bool m_isPainting;
friend class wxDFBEventsHandler; // for HandleDFBWindowEvent
friend class wxWindowDFB; // for SetDfbFocus
};
#endif // _WX_DFB_NONOWNEDWND_H_

View File

@@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/pen.h
// Purpose: wxPen class declaration
// Author: Vaclav Slavik
// Created: 2006-08-04
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_PEN_H_
#define _WX_DFB_PEN_H_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/string.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxPen;
//-----------------------------------------------------------------------------
// wxPen
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPen: public wxPenBase
{
public:
wxPen() = default;
wxPen(const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
wxPen(const wxBitmap& stipple, int width);
wxPen(const wxPenInfo& info);
bool operator==(const wxPen& pen) const;
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
void SetColour(const wxColour &colour);
void SetColour(unsigned char red, unsigned char green, unsigned char blue);
void SetCap(wxPenCap capStyle);
void SetJoin(wxPenJoin joinStyle);
void SetStyle(wxPenStyle style);
void SetWidth(int width);
void SetDashes(int number_of_dashes, const wxDash *dash);
void SetStipple(const wxBitmap& stipple);
wxColour GetColour() const;
wxPenCap GetCap() const;
wxPenJoin GetJoin() const;
wxPenStyle GetStyle() const;
int GetWidth() const;
int GetDashes(wxDash **ptr) const;
int GetDashCount() const;
wxDash* GetDash() const;
wxBitmap *GetStipple() const;
wxDEPRECATED_MSG("use wxPENSTYLE_XXX constants")
wxPen(const wxColour& col, int width, int style);
wxDEPRECATED_MSG("use wxPENSTYLE_XXX constants")
void SetStyle(int style) { SetStyle((wxPenStyle)style); }
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
wxDECLARE_DYNAMIC_CLASS(wxPen);
};
#endif // _WX_DFB_PEN_H_

View File

@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/popupwin.h
// Purpose: wxPopupWindow class for wxDFB
// Author: Vaclav Slavik
// Created: 2006-12-24
// Copyright: (c) 2006 TT-Solutions
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_POPUPWIN_H_
#define _WX_DFB_POPUPWIN_H_
// ----------------------------------------------------------------------------
// wxPopupWindow
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPopupWindow : public wxPopupWindowBase
{
public:
wxPopupWindow() = default;
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
{ Create(parent, flags); }
bool Create(wxWindow *parent, int flags = wxBORDER_NONE)
{
if ( !wxPopupWindowBase::Create(parent) )
return false;
return wxNonOwnedWindow::Create
(
parent,
-1,
// DFB windows must have valid pos & size:
wxPoint(0, 0), wxSize(1, 1),
(flags & wxBORDER_MASK) | wxPOPUP_WINDOW
);
}
wxDECLARE_DYNAMIC_CLASS(wxPopupWindow);
};
#endif // _WX_DFB_POPUPWIN_H_

View File

@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/private.h
// Purpose: private helpers for wxDFB implementation
// Author: Vaclav Slavik
// Created: 2006-08-09
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_PRIVATE_H_
#define _WX_DFB_PRIVATE_H_
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/dfb/wrapdfb.h"
#include <directfb_version.h>
//-----------------------------------------------------------------------------
// misc helpers
//-----------------------------------------------------------------------------
/// Convert DirectFB timestamp to wxEvent one:
#define wxDFB_EVENT_TIMESTAMP(event) \
((event).timestamp.tv_sec * 1000 + (event).timestamp.tv_usec / 1000)
/**
Check if DirectFB library version is at least @a major.@a minor.@a release.
@see wxCHECK_VERSION
*/
#define wxCHECK_DFB_VERSION(major,minor,release) \
(DIRECTFB_MAJOR_VERSION > (major) || \
(DIRECTFB_MAJOR_VERSION == (major) && \
DIRECTFB_MINOR_VERSION > (minor)) || \
(DIRECTFB_MAJOR_VERSION == (major) && \
DIRECTFB_MINOR_VERSION == (minor) && \
DIRECTFB_MICRO_VERSION >= (release)))
#endif // _WX_DFB_PRIVATE_H_

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/private/fontmgr.h
// Purpose: font management for wxDFB
// Author: Vaclav Slavik
// Created: 2006-11-18
// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
// (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_PRIVATE_FONTMGR_H_
#define _WX_DFB_PRIVATE_FONTMGR_H_
#include "wx/dfb/wrapdfb.h"
class wxFileConfig;
class wxFontInstance : public wxFontInstanceBase
{
public:
wxFontInstance(float ptSize, bool aa, const wxString& filename);
wxIDirectFBFontPtr GetDirectFBFont() const { return m_font; }
private:
wxIDirectFBFontPtr m_font;
};
class wxFontFace : public wxFontFaceBase
{
public:
wxFontFace(const wxString& filename) : m_fileName(filename) {}
protected:
wxFontInstance *CreateFontInstance(float ptSize, bool aa);
private:
wxString m_fileName;
};
class wxFontBundle : public wxFontBundleBase
{
public:
wxFontBundle(const wxString& name,
const wxString& fileRegular,
const wxString& fileBold,
const wxString& fileItalic,
const wxString& fileBoldItalic,
bool isFixed);
/// Returns name of the family
virtual wxString GetName() const { return m_name; }
virtual bool IsFixed() const { return m_isFixed; }
private:
wxString m_name;
bool m_isFixed;
};
class wxFontsManager : public wxFontsManagerBase
{
public:
wxFontsManager() { AddAllFonts(); }
virtual wxString GetDefaultFacename(wxFontFamily family) const
{
return m_defaultFacenames[family];
}
private:
// adds all fonts using AddBundle()
void AddAllFonts();
void AddFontsFromDir(const wxString& indexFile);
void AddFont(const wxString& dir, const wxString& name, wxFileConfig& cfg);
void SetDefaultFonts(wxFileConfig& cfg);
private:
// default facenames
wxString m_defaultFacenames[wxFONTFAMILY_MAX];
};
#endif // _WX_DFB_PRIVATE_FONTMGR_H_

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/private/overlay.h
// Purpose: wxOverlayImpl declaration
// Author: Vaclav Slavik
// Created: 2006-10-20
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_PRIVATE_OVERLAY_H_
#define _WX_DFB_PRIVATE_OVERLAY_H_
#include "wx/dfb/dfbptr.h"
#include "wx/gdicmn.h"
#include "wx/private/overlay.h"
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxDC;
class wxOverlayImpl: public wxOverlay::Impl
{
public:
wxOverlayImpl();
~wxOverlayImpl();
virtual void Reset() override;
virtual bool IsOk() override;
virtual void Init(wxDC* dc, int x, int y, int width, int height) override;
virtual void BeginDrawing(wxDC* dc) override;
virtual void EndDrawing(wxDC* dc) override;
virtual void Clear(wxDC* dc) override;
// wxDFB specific methods:
bool IsEmpty() const { return m_isEmpty; }
wxRect GetRect() const { return m_rect; }
wxIDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; }
public:
// window the overlay is associated with
wxWindow *m_window;
// rectangle covered by the overlay, in m_window's window coordinates
wxRect m_rect;
// surface of the overlay, same size as m_rect
wxIDirectFBSurfacePtr m_surface;
// this flag is set to true if nothing was drawn on the overlay (either
// initially or Clear() was called)
bool m_isEmpty;
};
#endif // _WX_DFB_PRIVATE_OVERLAY_H_

View File

@@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/region.h
// Purpose: wxRegion class
// Author: Vaclav Slavik
// Created: 2006-08-08
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_REGION_H_
#define _WX_DFB_REGION_H_
class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{
public:
wxRegion();
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect);
wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
wxRegion(const wxBitmap& bmp)
{
Union(bmp);
}
wxRegion(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
virtual ~wxRegion();
// wxRegionBase methods
virtual void Clear();
virtual bool IsEmpty() const;
// NB: implementation detail of DirectFB, should be removed if full
// (i.e. not rect-only version is implemented) so that all code that
// assumes region==rect breaks
wxRect AsRect() const { return GetBox(); }
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
friend class WXDLLIMPEXP_FWD_CORE wxRegionIterator;
wxDECLARE_DYNAMIC_CLASS(wxRegion);
};
class WXDLLIMPEXP_CORE wxRegionIterator : public wxObject
{
public:
wxRegionIterator() = default;
wxRegionIterator(const wxRegion& region) { Reset(region); }
void Reset() { m_rect = wxRect(); }
void Reset(const wxRegion& region);
bool HaveRects() const { return !m_rect.IsEmpty(); }
operator bool() const { return HaveRects(); }
wxRegionIterator& operator++();
wxRegionIterator operator++(int);
wxCoord GetX() const { return m_rect.GetX(); }
wxCoord GetY() const { return m_rect.GetY(); }
wxCoord GetW() const { return m_rect.GetWidth(); }
wxCoord GetWidth() const { return GetW(); }
wxCoord GetH() const { return m_rect.GetHeight(); }
wxCoord GetHeight() const { return GetH(); }
wxRect GetRect() const { return m_rect; }
private:
wxRect m_rect;
wxDECLARE_DYNAMIC_CLASS(wxRegionIterator);
};
#endif // _WX_DFB_REGION_H_

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/toplevel.h
// Purpose: Top level window, abstraction of wxFrame and wxDialog
// Author: Vaclav Slavik
// Created: 2006-08-10
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_TOPLEVEL_H_
#define _WX_DFB_TOPLEVEL_H_
//-----------------------------------------------------------------------------
// wxTopLevelWindowDFB
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxTopLevelWindowDFB : public wxTopLevelWindowBase
{
public:
// construction
wxTopLevelWindowDFB() { Init(); }
wxTopLevelWindowDFB(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
Init();
Create(parent, id, title, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr));
// implement base class pure virtuals
virtual void Maximize(bool maximize = true);
virtual bool IsMaximized() const;
virtual void Iconize(bool iconize = true);
virtual bool IsIconized() const;
virtual void Restore();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; }
virtual bool CanSetTransparent() { return true; }
virtual bool SetTransparent(wxByte alpha);
virtual void SetTitle(const wxString &title) { m_title = title; }
virtual wxString GetTitle() const { return m_title; }
protected:
// common part of all ctors
void Init();
virtual void HandleFocusEvent(const wxDFBWindowEvent& event_);
protected:
wxString m_title;
bool m_fsIsShowing:1; /* full screen */
long m_fsSaveStyle;
long m_fsSaveFlag;
wxRect m_fsSaveFrame;
// is the frame currently maximized?
bool m_isMaximized:1;
wxRect m_savedFrame;
};
#endif // _WX_DFB_TOPLEVEL_H_

View File

@@ -0,0 +1,193 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/window.h
// Purpose: wxWindow class
// Author: Vaclav Slavik
// Created: 2006-08-10
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_WINDOW_H_
#define _WX_DFB_WINDOW_H_
// ---------------------------------------------------------------------------
// headers
// ---------------------------------------------------------------------------
#include "wx/dfb/dfbptr.h"
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
struct wxDFBWindowEvent;
class WXDLLIMPEXP_FWD_CORE wxFont;
class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
class wxOverlayImpl;
class wxDfbOverlaysList;
// ---------------------------------------------------------------------------
// wxWindow
// ---------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowDFB : public wxWindowBase
{
public:
wxWindowDFB() { Init(); }
wxWindowDFB(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr))
{
Init();
Create(parent, id, pos, size, style, name);
}
virtual ~wxWindowDFB();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr));
// implement base class (pure) virtual methods
// -------------------------------------------
virtual void SetLabel( const wxString &WXUNUSED(label) ) {}
virtual wxString GetLabel() const { return wxEmptyString; }
virtual void Raise();
virtual void Lower();
virtual bool Show(bool show = true);
virtual void SetFocus();
virtual bool Reparent(wxWindowBase *newParent);
virtual void WarpPointer(int x, int y);
virtual void Refresh(bool eraseBackground = true,
const wxRect *rect = nullptr);
virtual void Update();
virtual bool SetCursor(const wxCursor &cursor);
virtual bool SetFont(const wxFont &font) { m_font = font; return true; }
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget(wxDropTarget *dropTarget);
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
#endif // wxUSE_DRAG_AND_DROP
virtual WXWidget GetHandle() const { return this; }
// implementation from now on
// --------------------------
// Returns DirectFB surface used for rendering of this window
wxIDirectFBSurfacePtr GetDfbSurface();
// returns toplevel window the window belongs to
wxNonOwnedWindow *GetTLW() const { return m_tlw; }
virtual bool IsDoubleBuffered() const { return true; }
protected:
// implement the base class pure virtuals
virtual void DoGetTextExtent(const wxString& string,
int *x, int *y,
int *descent = nullptr,
int *externalLeading = nullptr,
const wxFont *theFont = nullptr) const;
virtual void DoClientToScreen(int *x, int *y) const;
virtual void DoScreenToClient(int *x, int *y) const;
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
virtual void DoCaptureMouse();
virtual void DoReleaseMouse();
virtual void DoThaw();
// move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange
// themselves inside the given rectangle
virtual void DoMoveWindow(int x, int y, int width, int height);
// return DFB surface used to render this window (will be assigned to
// m_surface if the window is visible)
virtual wxIDirectFBSurfacePtr ObtainDfbSurface() const;
// this method must be called when window's position, size or visibility
// changes; it resets m_surface so that ObtainDfbSurface has to be called
// next time GetDfbSurface is called
void InvalidateDfbSurface();
// called by parent to render (part of) the window
void PaintWindow(const wxRect& rect);
// paint window's overlays (if any) on top of window's surface
void PaintOverlays(const wxRect& rect);
// refreshes the entire window (including non-client areas)
void DoRefreshWindow();
// refreshes given rectangle of the window (in window, _not_ client coords)
virtual void DoRefreshRect(const wxRect& rect);
// refreshes given rectangle; unlike RefreshRect(), the argument is in
// window, not client, coords and unlike DoRefreshRect() and like Refresh(),
// does nothing if the window is hidden or frozen
void RefreshWindowRect(const wxRect& rect);
// add/remove overlay for this window
void AddOverlay(wxOverlayImpl *overlay);
void RemoveOverlay(wxOverlayImpl *overlay);
// DirectFB events handling
void HandleKeyEvent(const wxDFBWindowEvent& event_);
private:
// common part of all ctors
void Init();
// counterpart to SetFocus
void DFBKillFocus();
protected:
// toplevel window (i.e. DirectFB window) this window belongs to
wxNonOwnedWindow *m_tlw;
private:
// subsurface of TLW's surface covered by this window
wxIDirectFBSurfacePtr m_surface;
// position of the window (relative to the parent, not used by wxTLW, so
// don't access it directly)
wxRect m_rect;
// overlays for this window (or nullptr if it doesn't have any)
wxDfbOverlaysList *m_overlays;
friend class wxNonOwnedWindow; // for HandleXXXEvent
friend class wxOverlayImpl; // for Add/RemoveOverlay
friend class wxWindowDCImpl; // for PaintOverlays
wxDECLARE_DYNAMIC_CLASS(wxWindowDFB);
wxDECLARE_NO_COPY_CLASS(wxWindowDFB);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_DFB_WINDOW_H_

View File

@@ -0,0 +1,541 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/wrapdfb.h
// Purpose: wx wrappers for DirectFB interfaces
// Author: Vaclav Slavik
// Created: 2006-08-23
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_WRAPDFB_H_
#define _WX_DFB_WRAPDFB_H_
#include "wx/dfb/dfbptr.h"
#include "wx/gdicmn.h"
#include "wx/vidmode.h"
// "register" is removed in C++17 but used inside these headers.
#define register
#include <directfb.h>
#include <directfb_version.h>
#undef register
// DFB < 1.0 didn't have u8 type, only __u8
#if DIRECTFB_MAJOR_VERSION == 0
typedef __u8 u8;
#endif
wxDFB_DECLARE_INTERFACE(IDirectFB);
wxDFB_DECLARE_INTERFACE(IDirectFBDisplayLayer);
wxDFB_DECLARE_INTERFACE(IDirectFBFont);
wxDFB_DECLARE_INTERFACE(IDirectFBWindow);
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
wxDFB_DECLARE_INTERFACE(IDirectFBPalette);
wxDFB_DECLARE_INTERFACE(IDirectFBEventBuffer);
/**
Checks the @a code of a DirectFB call and returns true if it was
successful and false if it failed, logging the errors as appropriate
(asserts for programming errors, wxLogError for runtime failures).
*/
bool wxDfbCheckReturn(DFBResult code);
//-----------------------------------------------------------------------------
// wxDfbEvent
//-----------------------------------------------------------------------------
/**
The struct defined by this macro is a thin wrapper around DFB*Event type.
It is needed because DFB*Event are typedefs and so we can't forward declare
them, but we need to pass them to methods declared in public headers where
<directfb.h> cannot be included. So this struct just holds the event value,
it's sole purpose is that it can be forward declared.
*/
#define WXDFB_DEFINE_EVENT_WRAPPER(T) \
struct wx##T \
{ \
wx##T() = default; \
wx##T(const T& event) : m_event(event) {} \
\
operator T&() { return m_event; } \
operator const T&() const { return m_event; } \
T* operator&() { return &m_event; } \
\
DFBEventClass GetClass() const { return m_event.clazz; } \
\
private: \
T m_event; \
};
WXDFB_DEFINE_EVENT_WRAPPER(DFBEvent)
WXDFB_DEFINE_EVENT_WRAPPER(DFBWindowEvent)
//-----------------------------------------------------------------------------
// wxDfbWrapper<T>
//-----------------------------------------------------------------------------
/// Base class for wxDfbWrapper<T>
class wxDfbWrapperBase
{
public:
/// Increases reference count of the object
void AddRef()
{
m_refCnt++;
}
/// Decreases reference count and if it reaches zero, deletes the object
void Release()
{
if ( --m_refCnt == 0 )
delete this;
}
/// Returns result code of the last call
DFBResult GetLastResult() const { return m_lastResult; }
protected:
wxDfbWrapperBase() : m_refCnt(1), m_lastResult(DFB_OK) {}
/// Dtor may only be called from Release()
virtual ~wxDfbWrapperBase() = default;
/**
Checks the @a result of a DirectFB call and returns true if it was
successful and false if it failed. Also stores result of the call
so that it can be obtained by calling GetLastResult().
*/
bool Check(DFBResult result)
{
m_lastResult = result;
return wxDfbCheckReturn(result);
}
protected:
/// Reference count
unsigned m_refCnt;
/// Result of the last DirectFB call
DFBResult m_lastResult;
};
/**
This template is base class for friendly C++ wrapper around DirectFB
interface T.
The wrapper provides same API as DirectFB, with a few exceptions:
- methods return true/false instead of error code
- methods that return or create another interface return pointer to the
interface (or nullptr on failure) instead of storing it in the last
argument
- interface arguments use wxFooPtr type instead of raw DirectFB pointer
- methods taking flags use int type instead of an enum when the flags
can be or-combination of enum elements (this is workaround for
C++-unfriendly DirectFB API)
*/
template<typename T>
class wxDfbWrapper : public wxDfbWrapperBase
{
public:
/// "Raw" DirectFB interface type
typedef T DirectFBIface;
/// Returns raw DirectFB pointer
T *GetRaw() const { return m_ptr; }
protected:
/// To be called from ctor. Takes ownership of raw object.
void Init(T *ptr) { m_ptr = ptr; }
/// Dtor may only be used from Release
~wxDfbWrapper()
{
if ( m_ptr )
m_ptr->Release(m_ptr);
}
protected:
// pointer to DirectFB object
T *m_ptr;
};
//-----------------------------------------------------------------------------
// wxIDirectFBFont
//-----------------------------------------------------------------------------
struct wxIDirectFBFont : public wxDfbWrapper<IDirectFBFont>
{
wxIDirectFBFont(IDirectFBFont *s) { Init(s); }
bool GetStringWidth(const char *text, int bytes, int *w)
{ return Check(m_ptr->GetStringWidth(m_ptr, text, bytes, w)); }
bool GetStringExtents(const char *text, int bytes,
DFBRectangle *logicalRect, DFBRectangle *inkRect)
{
return Check(m_ptr->GetStringExtents(m_ptr, text, bytes,
logicalRect, inkRect));
}
bool GetHeight(int *h)
{ return Check(m_ptr->GetHeight(m_ptr, h)); }
bool GetDescender(int *descender)
{ return Check(m_ptr->GetDescender(m_ptr, descender)); }
};
//-----------------------------------------------------------------------------
// wxIDirectFBPalette
//-----------------------------------------------------------------------------
struct wxIDirectFBPalette : public wxDfbWrapper<IDirectFBPalette>
{
wxIDirectFBPalette(IDirectFBPalette *s) { Init(s); }
};
//-----------------------------------------------------------------------------
// wxIDirectFBSurface
//-----------------------------------------------------------------------------
struct wxIDirectFBSurface : public wxDfbWrapper<IDirectFBSurface>
{
wxIDirectFBSurface(IDirectFBSurface *s) { Init(s); }
bool GetSize(int *w, int *h)
{ return Check(m_ptr->GetSize(m_ptr, w, h)); }
bool GetCapabilities(DFBSurfaceCapabilities *caps)
{ return Check(m_ptr->GetCapabilities(m_ptr, caps)); }
bool GetPixelFormat(DFBSurfacePixelFormat *caps)
{ return Check(m_ptr->GetPixelFormat(m_ptr, caps)); }
// convenience version of GetPixelFormat, returns DSPF_UNKNOWN if fails
DFBSurfacePixelFormat GetPixelFormat();
bool SetClip(const DFBRegion *clip)
{ return Check(m_ptr->SetClip(m_ptr, clip)); }
bool SetColor(u8 r, u8 g, u8 b, u8 a)
{ return Check(m_ptr->SetColor(m_ptr, r, g, b, a)); }
bool Clear(u8 r, u8 g, u8 b, u8 a)
{ return Check(m_ptr->Clear(m_ptr, r, g, b, a)); }
bool DrawLine(int x1, int y1, int x2, int y2)
{ return Check(m_ptr->DrawLine(m_ptr, x1, y1, x2, y2)); }
bool DrawRectangle(int x, int y, int w, int h)
{ return Check(m_ptr->DrawRectangle(m_ptr, x, y, w, h)); }
bool FillRectangle(int x, int y, int w, int h)
{ return Check(m_ptr->FillRectangle(m_ptr, x, y, w, h)); }
bool SetFont(const wxIDirectFBFontPtr& font)
{ return Check(m_ptr->SetFont(m_ptr, font->GetRaw())); }
bool DrawString(const char *text, int bytes, int x, int y, int flags)
{
return Check(m_ptr->DrawString(m_ptr, text, bytes, x, y,
(DFBSurfaceTextFlags)flags));
}
/**
Updates the front buffer from the back buffer. If @a region is not
nullptr, only given rectangle is updated.
*/
bool FlipToFront(const DFBRegion *region = nullptr);
wxIDirectFBSurfacePtr GetSubSurface(const DFBRectangle *rect)
{
IDirectFBSurface *s;
if ( Check(m_ptr->GetSubSurface(m_ptr, rect, &s)) )
return new wxIDirectFBSurface(s);
else
return nullptr;
}
wxIDirectFBPalettePtr GetPalette()
{
IDirectFBPalette *s;
if ( Check(m_ptr->GetPalette(m_ptr, &s)) )
return new wxIDirectFBPalette(s);
else
return nullptr;
}
bool SetPalette(const wxIDirectFBPalettePtr& pal)
{ return Check(m_ptr->SetPalette(m_ptr, pal->GetRaw())); }
bool SetBlittingFlags(int flags)
{
return Check(
m_ptr->SetBlittingFlags(m_ptr, (DFBSurfaceBlittingFlags)flags));
}
bool Blit(const wxIDirectFBSurfacePtr& source,
const DFBRectangle *source_rect,
int x, int y)
{ return Blit(source->GetRaw(), source_rect, x, y); }
bool Blit(IDirectFBSurface *source,
const DFBRectangle *source_rect,
int x, int y)
{ return Check(m_ptr->Blit(m_ptr, source, source_rect, x, y)); }
bool StretchBlit(const wxIDirectFBSurfacePtr& source,
const DFBRectangle *source_rect,
const DFBRectangle *dest_rect)
{
return Check(m_ptr->StretchBlit(m_ptr, source->GetRaw(),
source_rect, dest_rect));
}
/// Returns bit depth used by the surface or -1 on error
int GetDepth();
/**
Creates a new surface by cloning this one. New surface will have same
capabilities, pixel format and pixel data as the existing one.
@see CreateCompatible
*/
wxIDirectFBSurfacePtr Clone();
/// Flags for CreateCompatible()
enum CreateCompatibleFlags
{
/// Don't create double-buffered surface
CreateCompatible_NoBackBuffer = 1
};
/**
Creates a surface compatible with this one, i.e. surface with the same
capabilities and pixel format, but with different and size.
@param size Size of the surface to create. If wxDefaultSize, use the
size of this surface.
@param flags Or-combination of CreateCompatibleFlags values
*/
wxIDirectFBSurfacePtr CreateCompatible(const wxSize& size = wxDefaultSize,
int flags = 0);
bool Lock(DFBSurfaceLockFlags flags, void **ret_ptr, int *ret_pitch)
{ return Check(m_ptr->Lock(m_ptr, flags, ret_ptr, ret_pitch)); }
bool Unlock()
{ return Check(m_ptr->Unlock(m_ptr)); }
/// Helper struct for safe locking & unlocking of surfaces
struct Locked
{
Locked(const wxIDirectFBSurfacePtr& surface, DFBSurfaceLockFlags flags)
: m_surface(surface)
{
if ( !surface->Lock(flags, &ptr, &pitch) )
ptr = nullptr;
}
~Locked()
{
if ( ptr )
m_surface->Unlock();
}
void *ptr;
int pitch;
private:
wxIDirectFBSurfacePtr m_surface;
};
private:
// this is private because we want user code to use FlipToFront()
bool Flip(const DFBRegion *region, int flags);
};
//-----------------------------------------------------------------------------
// wxIDirectFBEventBuffer
//-----------------------------------------------------------------------------
struct wxIDirectFBEventBuffer : public wxDfbWrapper<IDirectFBEventBuffer>
{
wxIDirectFBEventBuffer(IDirectFBEventBuffer *s) { Init(s); }
bool CreateFileDescriptor(int *ret_fd)
{
return Check(m_ptr->CreateFileDescriptor(m_ptr, ret_fd));
}
};
//-----------------------------------------------------------------------------
// wxIDirectFBWindow
//-----------------------------------------------------------------------------
struct wxIDirectFBWindow : public wxDfbWrapper<IDirectFBWindow>
{
wxIDirectFBWindow(IDirectFBWindow *s) { Init(s); }
bool GetID(DFBWindowID *id)
{ return Check(m_ptr->GetID(m_ptr, id)); }
bool GetPosition(int *x, int *y)
{ return Check(m_ptr->GetPosition(m_ptr, x, y)); }
bool GetSize(int *w, int *h)
{ return Check(m_ptr->GetSize(m_ptr, w, h)); }
bool MoveTo(int x, int y)
{ return Check(m_ptr->MoveTo(m_ptr, x, y)); }
bool Resize(int w, int h)
{ return Check(m_ptr->Resize(m_ptr, w, h)); }
bool SetOpacity(u8 opacity)
{ return Check(m_ptr->SetOpacity(m_ptr, opacity)); }
bool SetStackingClass(DFBWindowStackingClass klass)
{ return Check(m_ptr->SetStackingClass(m_ptr, klass)); }
bool RaiseToTop()
{ return Check(m_ptr->RaiseToTop(m_ptr)); }
bool LowerToBottom()
{ return Check(m_ptr->LowerToBottom(m_ptr)); }
wxIDirectFBSurfacePtr GetSurface()
{
IDirectFBSurface *s;
if ( Check(m_ptr->GetSurface(m_ptr, &s)) )
return new wxIDirectFBSurface(s);
else
return nullptr;
}
bool AttachEventBuffer(const wxIDirectFBEventBufferPtr& buffer)
{ return Check(m_ptr->AttachEventBuffer(m_ptr, buffer->GetRaw())); }
bool RequestFocus()
{ return Check(m_ptr->RequestFocus(m_ptr)); }
bool Destroy()
{ return Check(m_ptr->Destroy(m_ptr)); }
};
//-----------------------------------------------------------------------------
// wxIDirectFBDisplayLayer
//-----------------------------------------------------------------------------
struct wxIDirectFBDisplayLayer : public wxDfbWrapper<IDirectFBDisplayLayer>
{
wxIDirectFBDisplayLayer(IDirectFBDisplayLayer *s) { Init(s); }
wxIDirectFBWindowPtr CreateWindow(const DFBWindowDescription *desc)
{
IDirectFBWindow *w;
if ( Check(m_ptr->CreateWindow(m_ptr, desc, &w)) )
return new wxIDirectFBWindow(w);
else
return nullptr;
}
bool GetConfiguration(DFBDisplayLayerConfig *config)
{ return Check(m_ptr->GetConfiguration(m_ptr, config)); }
wxVideoMode GetVideoMode();
bool GetCursorPosition(int *x, int *y)
{ return Check(m_ptr->GetCursorPosition(m_ptr, x, y)); }
bool WarpCursor(int x, int y)
{ return Check(m_ptr->WarpCursor(m_ptr, x, y)); }
};
//-----------------------------------------------------------------------------
// wxIDirectFB
//-----------------------------------------------------------------------------
struct wxIDirectFB : public wxDfbWrapper<IDirectFB>
{
/**
Returns pointer to DirectFB singleton object, it never returns nullptr
after wxApp was initialized. The object is cached, so calling this
method is cheap.
*/
static wxIDirectFBPtr Get()
{
if ( !ms_ptr ) CreateDirectFB();
return ms_ptr;
}
bool SetVideoMode(int w, int h, int bpp)
{ return Check(m_ptr->SetVideoMode(m_ptr, w, h, bpp)); }
wxIDirectFBSurfacePtr CreateSurface(const DFBSurfaceDescription *desc)
{
IDirectFBSurface *s;
if ( Check(m_ptr->CreateSurface(m_ptr, desc, &s)) )
return new wxIDirectFBSurface(s);
else
return nullptr;
}
wxIDirectFBEventBufferPtr CreateEventBuffer()
{
IDirectFBEventBuffer *b;
if ( Check(m_ptr->CreateEventBuffer(m_ptr, &b)) )
return new wxIDirectFBEventBuffer(b);
else
return nullptr;
}
wxIDirectFBFontPtr CreateFont(const char *filename,
const DFBFontDescription *desc)
{
IDirectFBFont *f;
if ( Check(m_ptr->CreateFont(m_ptr, filename, desc, &f)) )
return new wxIDirectFBFont(f);
else
return nullptr;
}
wxIDirectFBDisplayLayerPtr
GetDisplayLayer(DFBDisplayLayerID id = DLID_PRIMARY)
{
IDirectFBDisplayLayer *l;
if ( Check(m_ptr->GetDisplayLayer(m_ptr, id, &l)) )
return new wxIDirectFBDisplayLayer(l);
else
return nullptr;
}
/// Returns primary surface
wxIDirectFBSurfacePtr GetPrimarySurface();
private:
wxIDirectFB(IDirectFB *ptr) { Init(ptr); }
// creates ms_ptr instance
static void CreateDirectFB();
static void CleanUp();
friend class wxApp; // calls CleanUp
// pointer to the singleton IDirectFB object
static wxIDirectFBPtr ms_ptr;
};
#endif // _WX_DFB_WRAPDFB_H_