initial (not yet working) code for DirectFB port
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
480
Makefile.in
480
Makefile.in
File diff suppressed because it is too large
Load Diff
@@ -536,6 +536,18 @@ dnl ### begin block 20_COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0[wx.bkl] ###
|
||||
COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0=""
|
||||
fi
|
||||
AC_SUBST(COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0)
|
||||
dnl ### begin block 20_COND_TOOLKIT_DFB[wx.bkl] ###
|
||||
COND_TOOLKIT_DFB="#"
|
||||
if test "x$TOOLKIT" = "xDFB" ; then
|
||||
COND_TOOLKIT_DFB=""
|
||||
fi
|
||||
AC_SUBST(COND_TOOLKIT_DFB)
|
||||
dnl ### begin block 20_COND_TOOLKIT_DFB_USE_GUI_1[wx.bkl] ###
|
||||
COND_TOOLKIT_DFB_USE_GUI_1="#"
|
||||
if test "x$TOOLKIT" = "xDFB" -a "x$USE_GUI" = "x1" ; then
|
||||
COND_TOOLKIT_DFB_USE_GUI_1=""
|
||||
fi
|
||||
AC_SUBST(COND_TOOLKIT_DFB_USE_GUI_1)
|
||||
dnl ### begin block 20_COND_TOOLKIT_GTK[wx.bkl] ###
|
||||
COND_TOOLKIT_GTK="#"
|
||||
if test "x$TOOLKIT" = "xGTK" ; then
|
||||
|
@@ -1773,6 +1773,61 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
</set>
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
<!-- wxDFB -->
|
||||
<!-- ====================================================================== -->
|
||||
|
||||
<set var="DFB_LOWLEVEL_SRC" hints="files">
|
||||
src/dfb/app.cpp
|
||||
src/dfb/bitmap.cpp
|
||||
src/dfb/brush.cpp
|
||||
src/dfb/cursor.cpp
|
||||
<!-- src/dfb/data.cpp -->
|
||||
src/dfb/dc.cpp
|
||||
src/dfb/dcclient.cpp
|
||||
src/dfb/dcmemory.cpp
|
||||
src/dfb/dcscreen.cpp
|
||||
src/dfb/evtloop.cpp
|
||||
src/dfb/font.cpp
|
||||
src/dfb/fontenum.cpp
|
||||
src/dfb/ifacehelpers.cpp
|
||||
src/dfb/pen.cpp
|
||||
src/dfb/region.cpp
|
||||
src/dfb/settings.cpp
|
||||
src/dfb/toplevel.cpp
|
||||
src/dfb/utils.cpp
|
||||
src/dfb/window.cpp
|
||||
src/generic/caret.cpp
|
||||
src/generic/colour.cpp
|
||||
src/generic/icon.cpp
|
||||
src/generic/timer.cpp
|
||||
</set>
|
||||
<set var="DFB_LOWLEVEL_HDR" hints="files">
|
||||
wx/dfb/app.h
|
||||
wx/dfb/bitmap.h
|
||||
wx/dfb/brush.h
|
||||
wx/dfb/chkconf.h
|
||||
wx/dfb/cursor.h
|
||||
wx/dfb/dc.h
|
||||
wx/dfb/dcclient.h
|
||||
wx/dfb/dcmemory.h
|
||||
wx/dfb/dcscreen.h
|
||||
wx/dfb/evtloop.h
|
||||
wx/dfb/font.h
|
||||
wx/dfb/ifacehelpers.h
|
||||
wx/dfb/pen.h
|
||||
wx/dfb/popupwin.h
|
||||
wx/dfb/private.h
|
||||
wx/dfb/region.h
|
||||
wx/dfb/toplevel.h
|
||||
wx/dfb/window.h
|
||||
wx/generic/caret.h
|
||||
wx/generic/colour.h
|
||||
wx/generic/icon.h
|
||||
wx/generic/timer.h
|
||||
</set>
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
<!-- wxOS/2 -->
|
||||
<!-- ====================================================================== -->
|
||||
@@ -3128,6 +3183,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
<if cond="TOOLKIT=='PM'">$(OS2_LOWLEVEL_SRC)</if>
|
||||
<if cond="TOOLKIT=='X11'">$(X11_LOWLEVEL_SRC)</if>
|
||||
<if cond="TOOLKIT=='MGL'">$(MGL_LOWLEVEL_SRC)</if>
|
||||
<if cond="TOOLKIT=='DFB'">$(DFB_LOWLEVEL_SRC)</if>
|
||||
</set>
|
||||
<set var="LOWLEVEL_HDR" hints="files">
|
||||
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(GTK_LOWLEVEL_HDR)</if>
|
||||
@@ -3140,6 +3196,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
<if cond="TOOLKIT=='PM'">$(OS2_LOWLEVEL_HDR)</if>
|
||||
<if cond="TOOLKIT=='X11'">$(X11_LOWLEVEL_HDR)</if>
|
||||
<if cond="TOOLKIT=='MGL'">$(MGL_LOWLEVEL_HDR)</if>
|
||||
<if cond="TOOLKIT=='DFB'">$(DFB_LOWLEVEL_HDR)</if>
|
||||
</set>
|
||||
|
||||
<set var="GUI_SRC" hints="files">
|
||||
|
23
configure.in
23
configure.in
@@ -89,7 +89,7 @@ NEEDS_D_REENTRANT_FOR_R_FUNCS=0
|
||||
dnl the list of all available toolkits
|
||||
dnl
|
||||
dnl update NUM_TOOLKITS calculation below when adding a new toolkit here!
|
||||
ALL_TOOLKITS="COCOA GTK MAC MGL MICROWIN MOTIF MSW PM X11"
|
||||
ALL_TOOLKITS="COCOA GTK MAC MGL MICROWIN MOTIF MSW PM X11 DFB"
|
||||
|
||||
dnl NB: these wxUSE_XXX constants have value of 0 or 1 unlike all the other ones
|
||||
dnl which are either yes or no
|
||||
@@ -102,6 +102,7 @@ DEFAULT_wxUSE_MOTIF=0
|
||||
DEFAULT_wxUSE_MSW=0
|
||||
DEFAULT_wxUSE_PM=0
|
||||
DEFAULT_wxUSE_X11=0
|
||||
DEFAULT_wxUSE_DFB=0
|
||||
|
||||
dnl these are the values which are really default for the given platform -
|
||||
dnl they're not cached and are only used if no --with-toolkit was given *and*
|
||||
@@ -115,6 +116,7 @@ DEFAULT_DEFAULT_wxUSE_MOTIF=0
|
||||
DEFAULT_DEFAULT_wxUSE_MSW=0
|
||||
DEFAULT_DEFAULT_wxUSE_PM=0
|
||||
DEFAULT_DEFAULT_wxUSE_X11=0
|
||||
DEFAULT_DEFAULT_wxUSE_DFB=0
|
||||
|
||||
PROGRAM_EXT=
|
||||
SO_SUFFIX=so
|
||||
@@ -839,6 +841,7 @@ AC_ARG_WITH(wine, [ --with-wine use Wine], [wxUSE_WINE="$w
|
||||
AC_ARG_WITH(msw, [ --with-msw use MS-Windows], [wxUSE_MSW="$withval" CACHE_MSW=1 TOOLKIT_GIVEN=1])
|
||||
AC_ARG_WITH(pm, [ --with-pm use OS/2 Presentation Manager], [wxUSE_PM="$withval" CACHE_PM=1 TOOLKIT_GIVEN=1])
|
||||
AC_ARG_WITH(mgl, [ --with-mgl use SciTech MGL], [wxUSE_MGL="$withval" wxUSE_UNIVERSAL="yes" CACHE_MGL=1 TOOLKIT_GIVEN=1])
|
||||
AC_ARG_WITH(directfb, [ --with-directfb use DirectFB], [wxUSE_DFB="$withval" wxUSE_UNIVERSAL="yes" CACHE_DFB=1 TOOLKIT_GIVEN=1])
|
||||
AC_ARG_WITH(microwin, [ --with-microwin use MicroWindows], [wxUSE_MICROWIN="$withval" CACHE_MICROWIN=1 TOOLKIT_GIVEN=1])
|
||||
AC_ARG_WITH(x11, [ --with-x11 use X11], [wxUSE_X11="$withval" wxUSE_UNIVERSAL="yes" CACHE_X11=1 TOOLKIT_GIVEN=1])
|
||||
WX_ARG_ENABLE(nanox, [ --enable-nanox use NanoX], wxUSE_NANOX)
|
||||
@@ -1320,7 +1323,7 @@ if test "$wxUSE_GUI" = "yes"; then
|
||||
dnl we suppose that expr is available (maybe there is a better way to do
|
||||
dnl this? what about using ALL_TOOLKITS? TODO)
|
||||
NUM_TOOLKITS=`expr ${wxUSE_COCOA:-0} + ${wxUSE_GTK:-0} + ${wxUSE_MAC:-0} \
|
||||
+ ${wxUSE_MGL:-0} + ${wxUSE_MICROWIN:-0} \
|
||||
+ ${wxUSE_MGL:-0} + ${wxUSE_DFB:-0} + ${wxUSE_MICROWIN:-0} \
|
||||
+ ${wxUSE_MOTIF:-0} + ${wxUSE_MSW:-0} + ${wxUSE_X11:-0}`
|
||||
|
||||
dnl Allow wxUSE_PM only for OS/2 with EMX.
|
||||
@@ -3154,6 +3157,22 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
|
||||
GUIDIST=MGL_DIST
|
||||
fi
|
||||
|
||||
if test "$wxUSE_DFB" = 1; then
|
||||
PKG_CHECK_MODULES(DIRECTFB,
|
||||
[directfb >= 0.9.25],
|
||||
[
|
||||
wxUSE_UNIVERSAL="yes"
|
||||
TOOLKIT_INCLUDE="$DIRECTFB_CFLAGS"
|
||||
GUI_TK_LIBRARY="$DIRECTFB_LIBS"
|
||||
TOOLKIT=DFB
|
||||
GUIDIST=DFB_DIST
|
||||
],
|
||||
[
|
||||
AC_MSG_ERROR([DirectFB not found.])
|
||||
]
|
||||
)
|
||||
fi
|
||||
|
||||
if test "$wxUSE_MICROWIN" = 1; then
|
||||
AC_MSG_CHECKING(for MicroWindows)
|
||||
if test "x$MICROWINDOWS" = x ; then
|
||||
|
@@ -468,10 +468,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// Get display mode that is used use. This is only used in framebuffer
|
||||
// wxWin ports (such as wxMGL).
|
||||
// wxWin ports (such as wxMGL or wxDFB).
|
||||
virtual wxVideoMode GetDisplayMode() const { return wxVideoMode(); }
|
||||
// Set display mode to use. This is only used in framebuffer wxWin
|
||||
// ports (such as wxMGL). This method should be called from
|
||||
// ports (such as wxMGL or wxDFB). This method should be called from
|
||||
// wxApp::OnInitGui
|
||||
virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; }
|
||||
|
||||
@@ -570,6 +570,8 @@ protected:
|
||||
#include "wx/motif/app.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/app.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/app.h"
|
||||
#elif defined(__WXGTK20__)
|
||||
#include "wx/gtk/app.h"
|
||||
#elif defined(__WXGTK__)
|
||||
|
@@ -29,6 +29,7 @@ class WXDLLEXPORT wxMask;
|
||||
class WXDLLEXPORT wxPalette;
|
||||
|
||||
#if defined(__WXMGL__) || \
|
||||
defined(__WXDFB__) || \
|
||||
defined(__WXMAC__) || \
|
||||
defined(__WXGTK__) || \
|
||||
defined(__WXCOCOA__) || \
|
||||
@@ -170,6 +171,8 @@ protected:
|
||||
#include "wx/x11/bitmap.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/bitmap.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/bitmap.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/bitmap.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -40,6 +40,8 @@ public:
|
||||
#include "wx/gtk1/brush.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/brush.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/brush.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/brush.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -27,6 +27,8 @@
|
||||
# include "wx/os2/chkconf.h"
|
||||
#elif defined(__WXMGL__)
|
||||
# include "wx/mgl/chkconf.h"
|
||||
#elif defined(__WXDFB__)
|
||||
# include "wx/dfb/chkconf.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
# include "wx/motif/chkconf.h"
|
||||
#elif defined(__WXX11__)
|
||||
|
@@ -126,6 +126,8 @@ public:
|
||||
#include "wx/gtk1/colour.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/generic/colour.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/generic/colour.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/colour.h"
|
||||
#elif defined(__WXMAC__)
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "wx/x11/cursor.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/cursor.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/cursor.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/cursor.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -827,6 +827,8 @@ private:
|
||||
#include "wx/x11/dc.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/dc.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/dc.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dc.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "wx/x11/dcclient.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/dcclient.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/dcclient.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dcclient.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "wx/x11/dcmemory.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/dcmemory.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/dcmemory.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dcmemory.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "wx/x11/dcscreen.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/dcscreen.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/dcscreen.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dcscreen.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -35,6 +35,7 @@
|
||||
!defined(__WXCOCOA__) && \
|
||||
!defined(__X__) && \
|
||||
!defined(__WXMGL__) && \
|
||||
!defined(__WXDFB__) && \
|
||||
!defined(__WXX11__) && \
|
||||
wxUSE_GUI
|
||||
# ifdef __UNIX__
|
||||
@@ -2891,6 +2892,12 @@ typedef struct _PangoFontDescription PangoFontDescription;
|
||||
typedef struct window_t *WXWidget;
|
||||
#endif /* MGL */
|
||||
|
||||
#ifdef __WXDFB__
|
||||
/* DirectFB doesn't have the concept of non-TLW window, so use
|
||||
something arbitrary */
|
||||
typedef const void* WXWidget;
|
||||
#endif /* DFB */
|
||||
|
||||
/* This is required because of clashing macros in windows.h, which may be */
|
||||
/* included before or after wxWidgets classes, and therefore must be */
|
||||
/* disabled here before any significant wxWidgets headers are included. */
|
||||
|
49
include/wx/dfb/app.h
Normal file
49
include/wx/dfb/app.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/app.h
|
||||
// Purpose: wxApp class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_APP_H_
|
||||
#define _WX_DFB_APP_H_
|
||||
|
||||
#include "wx/dfb/ifacehelpers.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 bool Yield(bool onlyIfNeeded = false);
|
||||
|
||||
virtual wxVideoMode GetDisplayMode() const;
|
||||
virtual bool SetDisplayMode(const wxVideoMode& mode);
|
||||
|
||||
// implementation - get singleton DirectFB interface
|
||||
IDirectFBPtr GetDirectFBInterface();
|
||||
|
||||
private:
|
||||
IDirectFBPtr m_dfb;
|
||||
wxVideoMode m_videoMode;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxApp)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_APP_H_
|
125
include/wx/dfb/bitmap.h
Normal file
125
include/wx/dfb/bitmap.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/bitmap.h
|
||||
// Purpose: wxBitmap class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-04
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_BITMAP_H_
|
||||
#define _WX_DFB_BITMAP_H_
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMask
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#warning "FIXME: move wxMask to common code"
|
||||
class WXDLLIMPEXP_CORE wxMask: public wxObject
|
||||
{
|
||||
public:
|
||||
wxMask();
|
||||
wxMask(const wxBitmap& bitmap);
|
||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
||||
#if wxUSE_PALETTE
|
||||
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
||||
#endif
|
||||
wxMask(const wxMask& mask);
|
||||
~wxMask();
|
||||
|
||||
bool Create(const wxBitmap& bitmap);
|
||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
||||
#if wxUSE_PALETTE
|
||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
||||
#endif
|
||||
|
||||
// implementation
|
||||
const wxBitmap& GetBitmap() const;
|
||||
|
||||
private:
|
||||
wxBitmap *m_bitmap;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBitmap
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxBitmapHandler : public wxBitmapHandlerBase
|
||||
{
|
||||
public:
|
||||
wxBitmapHandler() : wxBitmapHandlerBase() {}
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
|
||||
{
|
||||
public:
|
||||
wxBitmap() {}
|
||||
wxBitmap(int width, int height, int depth = -1);
|
||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
||||
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE);
|
||||
wxBitmap(const char **bits) { CreateFromXpm(bits); }
|
||||
wxBitmap(char **bits) { CreateFromXpm((const char **)bits); }
|
||||
#if wxUSE_IMAGE
|
||||
wxBitmap(const wxImage& image, int depth = -1);
|
||||
#endif
|
||||
|
||||
bool Ok() const;
|
||||
bool operator==(const wxBitmap& bmp) const;
|
||||
bool operator!=(const wxBitmap& bmp) const { return !(*this == bmp); }
|
||||
|
||||
bool Create(int width, int height, int depth = -1);
|
||||
|
||||
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 = (wxPalette *) NULL) const;
|
||||
virtual bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_RESOURCE);
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
virtual wxPalette *GetPalette() const;
|
||||
virtual void SetPalette(const wxPalette& palette);
|
||||
#endif
|
||||
|
||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||
virtual bool CopyFromIcon(const wxIcon& icon);
|
||||
|
||||
static void InitStandardHandlers();
|
||||
|
||||
// implementation:
|
||||
virtual void SetHeight(int height);
|
||||
virtual void SetWidth(int width);
|
||||
virtual void SetDepth(int depth);
|
||||
|
||||
// get underlying native representation:
|
||||
IDirectFBSurfacePtr GetDirectFBSurface() const;
|
||||
|
||||
protected:
|
||||
bool CreateFromXpm(const char **bits);
|
||||
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_BITMAP_H_
|
59
include/wx/dfb/brush.h
Normal file
59
include/wx/dfb/brush.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/brush.h
|
||||
// Purpose: wxBrush class declaration
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-04
|
||||
// RCS-ID: $Id$
|
||||
// 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_CORE wxBitmap;
|
||||
class WXDLLIMPEXP_CORE wxBrush;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBrush
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxBrush: public wxBrushBase
|
||||
{
|
||||
public:
|
||||
wxBrush() {}
|
||||
wxBrush(const wxColour &colour, int style = wxSOLID);
|
||||
wxBrush(const wxBitmap &stippleBitmap);
|
||||
|
||||
bool Ok() const;
|
||||
bool operator==(const wxBrush& brush) const;
|
||||
bool operator!=(const wxBrush& brush) const { return !(*this == brush); }
|
||||
|
||||
virtual int 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(int style);
|
||||
void SetStipple(const wxBitmap& stipple);
|
||||
|
||||
protected:
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxBrush)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_BRUSH_H_
|
20
include/wx/dfb/chkconf.h
Normal file
20
include/wx/dfb/chkconf.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Name: wx/dfb/chkconf.h
|
||||
* Author: Vaclav Slavik
|
||||
* Purpose: Compiler-specific configuration checking
|
||||
* Created: 2006-08-10
|
||||
* RCS-ID: $Id$
|
||||
* 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
|
||||
|
||||
#endif /* _WX_DFB_CHKCONF_H_ */
|
50
include/wx/dfb/cursor.h
Normal file
50
include/wx/dfb/cursor.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/cursor.h
|
||||
// Purpose: wxCursor declaration
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_CURSOR_H_
|
||||
#define _WX_DFB_CURSOR_H_
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
class WXDLLIMPEXP_CORE wxBitmap;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxCursor
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxCursor: public wxObject
|
||||
{
|
||||
public:
|
||||
wxCursor() {}
|
||||
wxCursor(int cursorId);
|
||||
wxCursor(const char bits[], int width, int height,
|
||||
int hotSpotX=-1, int hotSpotY=-1,
|
||||
const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0);
|
||||
wxCursor(const wxString& name,
|
||||
long flags = wxBITMAP_TYPE_CUR_RESOURCE,
|
||||
int hotSpotX = 0, int hotSpotY = 0);
|
||||
|
||||
bool Ok() const;
|
||||
bool operator==(const wxCursor& cursor) const;
|
||||
bool operator!=(const wxCursor& cursor) const { return !(*this == cursor); }
|
||||
|
||||
// implementation
|
||||
wxBitmap GetBitmap() const;
|
||||
|
||||
protected:
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxCursor)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_CURSOR_H_
|
220
include/wx/dfb/dc.h
Normal file
220
include/wx/dfb/dc.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/dc.h
|
||||
// Purpose: wxDC class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-07
|
||||
// RCS-ID: $Id$
|
||||
// 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/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxDC : public wxDCBase
|
||||
{
|
||||
public:
|
||||
wxDC();
|
||||
|
||||
// Ctor.
|
||||
// Takes ownership of the surface, i.e. does not call AddRef() on it
|
||||
// but calls Release() on it from dtor.
|
||||
wxDC(const IDirectFBSurfacePtr& surface);
|
||||
|
||||
public:
|
||||
// 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 DestroyClippingRegion();
|
||||
|
||||
virtual wxCoord GetCharHeight() const;
|
||||
virtual wxCoord GetCharWidth() const;
|
||||
virtual void DoGetTextExtent(const wxString& string,
|
||||
wxCoord *x, wxCoord *y,
|
||||
wxCoord *descent = NULL,
|
||||
wxCoord *externalLeading = NULL,
|
||||
wxFont *theFont = NULL) const;
|
||||
|
||||
virtual bool CanDrawBitmap() const { return true; }
|
||||
virtual bool CanGetTextExtent() const { return true; }
|
||||
virtual int GetDepth() const;
|
||||
virtual wxSize GetPPI() const;
|
||||
|
||||
virtual void SetMapMode(int mode);
|
||||
virtual void SetUserScale(double x, double y);
|
||||
virtual void SetLogicalScale(double x, double y);
|
||||
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
|
||||
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
|
||||
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
|
||||
virtual void SetLogicalFunction(int function);
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
virtual void ComputeScaleAndOrigin();
|
||||
|
||||
wxCoord XDEV2LOG(wxCoord x) const
|
||||
{
|
||||
wxCoord new_x = x - m_deviceOriginX;
|
||||
if (new_x > 0)
|
||||
return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
|
||||
else
|
||||
return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
|
||||
}
|
||||
wxCoord XDEV2LOGREL(wxCoord x) const
|
||||
{
|
||||
if (x > 0)
|
||||
return (wxCoord)((double)(x) / m_scaleX + 0.5);
|
||||
else
|
||||
return (wxCoord)((double)(x) / m_scaleX - 0.5);
|
||||
}
|
||||
wxCoord YDEV2LOG(wxCoord y) const
|
||||
{
|
||||
wxCoord new_y = y - m_deviceOriginY;
|
||||
if (new_y > 0)
|
||||
return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
|
||||
else
|
||||
return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
|
||||
}
|
||||
wxCoord YDEV2LOGREL(wxCoord y) const
|
||||
{
|
||||
if (y > 0)
|
||||
return (wxCoord)((double)(y) / m_scaleY + 0.5);
|
||||
else
|
||||
return (wxCoord)((double)(y) / m_scaleY - 0.5);
|
||||
}
|
||||
wxCoord XLOG2DEV(wxCoord x) const
|
||||
{
|
||||
wxCoord new_x = x - m_logicalOriginX;
|
||||
if (new_x > 0)
|
||||
return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
|
||||
else
|
||||
return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
|
||||
}
|
||||
wxCoord XLOG2DEVREL(wxCoord x) const
|
||||
{
|
||||
if (x > 0)
|
||||
return (wxCoord)((double)(x) * m_scaleX + 0.5);
|
||||
else
|
||||
return (wxCoord)((double)(x) * m_scaleX - 0.5);
|
||||
}
|
||||
wxCoord YLOG2DEV(wxCoord y) const
|
||||
{
|
||||
wxCoord new_y = y - m_logicalOriginY;
|
||||
if (new_y > 0)
|
||||
return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
|
||||
else
|
||||
return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
|
||||
}
|
||||
wxCoord YLOG2DEVREL(wxCoord y) const
|
||||
{
|
||||
if (y > 0)
|
||||
return (wxCoord)((double)(y) * m_scaleY + 0.5);
|
||||
else
|
||||
return (wxCoord)((double)(y) * m_scaleY - 0.5);
|
||||
}
|
||||
|
||||
// Returns the surface (and increases its ref count)
|
||||
IDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; }
|
||||
|
||||
protected:
|
||||
// initializes the DC from a surface, must be called if default ctor
|
||||
// was used
|
||||
void Init(const IDirectFBSurfacePtr& surface);
|
||||
|
||||
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
||||
int 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,
|
||||
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
|
||||
|
||||
// this is gnarly - we can't even call this function DoSetClippingRegion()
|
||||
// because of virtual function hiding
|
||||
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
|
||||
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height);
|
||||
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
virtual void DoGetSizeMM(int* width, int* height) const;
|
||||
|
||||
virtual void DoDrawLines(int n, wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset);
|
||||
virtual void DoDrawPolygon(int n, wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
int fillStyle = wxODDEVEN_RULE);
|
||||
|
||||
// implementation from now on:
|
||||
|
||||
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);
|
||||
|
||||
// selects colour into surface's state
|
||||
void SelectColour(const wxColour& clr);
|
||||
|
||||
protected:
|
||||
IDirectFBSurfacePtr m_surface;
|
||||
|
||||
double m_mm_to_pix_x, m_mm_to_pix_y;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxDC)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_DC_H_
|
77
include/wx/dfb/dcclient.h
Normal file
77
include/wx/dfb/dcclient.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/dcclient.h
|
||||
// Purpose: wxWindowDC, wxClientDC and wxPaintDC
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_DCCLIENT_H_
|
||||
#define _WX_DFB_DCCLIENT_H_
|
||||
|
||||
#include "wx/dc.h"
|
||||
|
||||
class WXDLLIMPEXP_CORE wxWindow;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxWindowDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxWindowDC : public wxDC
|
||||
{
|
||||
public:
|
||||
wxWindowDC() {}
|
||||
wxWindowDC(wxWindow *win);
|
||||
|
||||
protected:
|
||||
void InitForWin(wxWindow *win);
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
||||
DECLARE_NO_COPY_CLASS(wxWindowDC)
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// base class for wxClientDC and wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxClientDCBase : public wxWindowDC
|
||||
{
|
||||
public:
|
||||
wxClientDCBase() {}
|
||||
wxClientDCBase(wxWindow *win);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxClientDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxClientDC : public wxClientDCBase
|
||||
{
|
||||
public:
|
||||
wxClientDC() {}
|
||||
wxClientDC(wxWindow *win) : wxClientDCBase(win) {}
|
||||
~wxClientDC();
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
||||
DECLARE_NO_COPY_CLASS(wxClientDC)
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDCBase
|
||||
{
|
||||
public:
|
||||
wxPaintDC() {}
|
||||
wxPaintDC(wxWindow *win) : wxClientDCBase(win) {}
|
||||
~wxPaintDC();
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxPaintDC)
|
||||
DECLARE_NO_COPY_CLASS(wxPaintDC)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_DCCLIENT_H_
|
29
include/wx/dfb/dcmemory.h
Normal file
29
include/wx/dfb/dcmemory.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/dcmemory.h
|
||||
// Purpose: wxMemoryDC class declaration
|
||||
// Created: 2006-08-10
|
||||
// Author: Vaclav Slavik
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_DCMEMORY_H_
|
||||
#define _WX_DFB_DCMEMORY_H_
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC
|
||||
{
|
||||
public:
|
||||
wxMemoryDC();
|
||||
wxMemoryDC(wxDC *dc); // create compatible DC
|
||||
|
||||
virtual void SelectObject(const wxBitmap& bitmap);
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_DCMEMORY_H_
|
||||
|
31
include/wx/dfb/dcscreen.h
Normal file
31
include/wx/dfb/dcscreen.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/dcscreen.h
|
||||
// Purpose: wxScreenDC declaration
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_DCSCREEN_H_
|
||||
#define _WX_DFB_DCSCREEN_H_
|
||||
|
||||
#include "wx/dc.h"
|
||||
|
||||
class WXDLLIMPEXP_CORE wxScreenDC: public wxDC
|
||||
{
|
||||
public:
|
||||
wxScreenDC();
|
||||
|
||||
static bool StartDrawingOnTop(wxWindow *WXUNUSED(window))
|
||||
{ return true; }
|
||||
static bool StartDrawingOnTop(wxRect *WXUNUSED(rect) = NULL)
|
||||
{ return true; }
|
||||
static bool EndDrawingOnTop()
|
||||
{ return true; }
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxScreenDC)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_DCSCREEN_H_
|
51
include/wx/dfb/evtloop.h
Normal file
51
include/wx/dfb/evtloop.h
Normal file
@@ -0,0 +1,51 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/evtloop.h
|
||||
// Purpose: declares wxEventLoop class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_EVTLOOP_H_
|
||||
#define _WX_DFB_EVTLOOP_H_
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBEventBuffer);
|
||||
struct wxDFBEvent;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoop
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxEventLoop : public wxEventLoopManual
|
||||
{
|
||||
public:
|
||||
wxEventLoop();
|
||||
|
||||
virtual bool Pending() const;
|
||||
virtual bool Dispatch();
|
||||
|
||||
// returns DirectFB event buffer used by wx
|
||||
static IDirectFBEventBufferPtr GetDirectFBEventBuffer();
|
||||
|
||||
protected:
|
||||
virtual void WakeUp();
|
||||
virtual void OnNextIteration();
|
||||
|
||||
virtual void HandleDFBEvent(const wxDFBEvent& event);
|
||||
|
||||
private:
|
||||
static void InitBuffer();
|
||||
|
||||
private:
|
||||
static IDirectFBEventBufferPtr ms_buffer;
|
||||
|
||||
friend class wxApp; // calls WakeUp()
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxEventLoop)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_EVTLOOP_H_
|
78
include/wx/dfb/font.h
Normal file
78
include/wx/dfb/font.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/font.h
|
||||
// Author: Vaclav Slavik
|
||||
// Purpose: wxFont declaration
|
||||
// Created: 2006-08-08
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_FONT_H_
|
||||
#define _WX_DFB_FONT_H_
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBFont);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
||||
{
|
||||
public:
|
||||
wxFont() {}
|
||||
wxFont(const wxNativeFontInfo& info) { Create(info); }
|
||||
wxFont(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined = false,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(size, family, style, weight, underlined, face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined = false,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
bool Create(const wxNativeFontInfo& fontinfo);
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual int GetPointSize() const;
|
||||
virtual int GetFamily() const;
|
||||
virtual int GetStyle() const;
|
||||
virtual int GetWeight() const;
|
||||
virtual wxString GetFaceName() const;
|
||||
virtual bool GetUnderlined() const;
|
||||
virtual wxFontEncoding GetEncoding() const;
|
||||
virtual bool IsFixedWidth() const;
|
||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||
|
||||
virtual void SetPointSize(int pointSize);
|
||||
virtual void SetFamily(int family);
|
||||
virtual void SetStyle(int style);
|
||||
virtual void SetWeight(int weight);
|
||||
virtual bool SetFaceName(const wxString& faceName);
|
||||
virtual void SetUnderlined(bool underlined);
|
||||
virtual void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
// implementation from now on:
|
||||
IDirectFBFontPtr GetDirectFBFont() const;
|
||||
|
||||
protected:
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_FONT_H_
|
116
include/wx/dfb/ifacehelpers.h
Normal file
116
include/wx/dfb/ifacehelpers.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/ifacehelpers.h
|
||||
// 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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_IFACEHELPERS_H_
|
||||
#define _WX_DFB_IFACEHELPERS_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDFB_DECLARE_INTERFACE
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Forward declares DirectFB interface @a name.
|
||||
|
||||
Also declares name##Ptr typedef for wxDfbPtr<name> pointer.
|
||||
|
||||
@param name name of the DirectFB interface
|
||||
*/
|
||||
#define wxDFB_DECLARE_INTERFACE(name) \
|
||||
struct _##name; \
|
||||
typedef _##name name; \
|
||||
typedef wxDfbPtr<name> name##Ptr;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDfbPtr
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// base class for wxDfbPtr
|
||||
class wxDfbPtrBase
|
||||
{
|
||||
protected:
|
||||
// increment/decrement refcount; see ifacehelpers.cpp for why using
|
||||
// void* is safe
|
||||
static void DoAddRef(void *ptr);
|
||||
static void DoRelease(void *ptr);
|
||||
};
|
||||
|
||||
/**
|
||||
This template implements smart pointer for keeping pointers to DirectFB
|
||||
interfaces. 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 interface pointer.
|
||||
|
||||
Takes ownership of @a ptr, i.e. AddRef() is @em not called on it.
|
||||
*/
|
||||
wxDfbPtr(T *ptr = NULL) : m_ptr(ptr) {}
|
||||
|
||||
/// Copy ctor
|
||||
wxDfbPtr(const wxDfbPtr& ptr) { InitFrom(ptr); }
|
||||
|
||||
/// Dtor. Releases the interface
|
||||
~wxDfbPtr() { Reset(); }
|
||||
|
||||
/// Resets the pointer to NULL, decreasing reference count of the interface.
|
||||
void Reset()
|
||||
{
|
||||
if ( m_ptr )
|
||||
{
|
||||
DoRelease(m_ptr);
|
||||
m_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// Cast to raw pointer
|
||||
operator T*() const { return m_ptr; }
|
||||
|
||||
/**
|
||||
Cast to @em writeable raw pointer so that code like
|
||||
"dfb->CreateFont(dfb, NULL, &desc, &fontPtr)" works.
|
||||
|
||||
Note that this operator calls Reset(), so using it looses the value.
|
||||
*/
|
||||
T** operator&()
|
||||
{
|
||||
Reset();
|
||||
return &m_ptr;
|
||||
}
|
||||
|
||||
// standard operators:
|
||||
|
||||
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 )
|
||||
DoAddRef(m_ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
T *m_ptr;
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_IFACEHELPERS_H_
|
70
include/wx/dfb/pen.h
Normal file
70
include/wx/dfb/pen.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/pen.h
|
||||
// Purpose: wxPen class declaration
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-04
|
||||
// RCS-ID: $Id$
|
||||
// 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_CORE wxBitmap;
|
||||
class WXDLLIMPEXP_CORE wxPen;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPen
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxPen: public wxGDIObject
|
||||
{
|
||||
public:
|
||||
wxPen() {}
|
||||
wxPen(const wxColour &colour, int width = 1, int style = wxSOLID);
|
||||
wxPen(const wxBitmap& stipple, int width);
|
||||
|
||||
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(int capStyle);
|
||||
void SetJoin(int joinStyle);
|
||||
void SetStyle(int style);
|
||||
void SetWidth(int width);
|
||||
void SetDashes(int number_of_dashes, const wxDash *dash);
|
||||
void SetStipple(const wxBitmap& stipple);
|
||||
|
||||
wxColour &GetColour() const;
|
||||
int GetCap() const;
|
||||
int GetJoin() const;
|
||||
int GetStyle() const;
|
||||
int GetWidth() const;
|
||||
int GetDashes(wxDash **ptr) const;
|
||||
int GetDashCount() const;
|
||||
wxDash* GetDash() const;
|
||||
wxBitmap *GetStipple() const;
|
||||
|
||||
bool Ok() const;
|
||||
|
||||
protected:
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxPen)
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_PEN_H_
|
156
include/wx/dfb/private.h
Normal file
156
include/wx/dfb/private.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/private.h
|
||||
// Purpose: private helpers for wxDFB implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-09
|
||||
// RCS-ID: $Id$
|
||||
// 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 <directfb.h>
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFB);
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBDisplayLayer);
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBPalette);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// strings conversion
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// convert string from wxString to UTF-8 encoded const char*
|
||||
#if wxUSE_UNICODE
|
||||
#define wxSTR_TO_DFB(s) (s).mb_str(wxConvUTF8)
|
||||
#else
|
||||
#define wxSTR_TO_DFB(s) wxConvUTF8.cWC2MB((s).wc_str(*wxConvUI))
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// error checking
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Wrap all calls to DirectFB in this macro so that the return value is
|
||||
checked and errors reported as appropriate.
|
||||
|
||||
Returns true if the call succeeded, false otherwise.
|
||||
*/
|
||||
#define DFB_CALL(call) (wxDfbCheckReturn(call))
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// surface manipulation helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// Mode of wxDfbCloneSurface() call
|
||||
enum wxDfbCloneSurfaceMode
|
||||
{
|
||||
/// Don't copy surface pixels, just clone surface size and attributes
|
||||
wxDfbCloneSurface_NoPixels = 0,
|
||||
/// Make exact copy, including the pixels
|
||||
wxDfbCloneSurface_CopyPixels
|
||||
};
|
||||
|
||||
/**
|
||||
Creates a new surface by cloning existing one. Depending on @a mode,
|
||||
either makes exact copy (wxDfbCloneSurface_CopyPixels) or only creates a
|
||||
new surface with the same size and attributes (wxDfbCloneSurface_NoPixels).
|
||||
*/
|
||||
IDirectFBSurfacePtr wxDfbCloneSurface(const IDirectFBSurfacePtr& s,
|
||||
wxDfbCloneSurfaceMode mode);
|
||||
|
||||
/// Returns bit depth used by the surface
|
||||
int wxDfbGetSurfaceDepth(const IDirectFBSurfacePtr& s);
|
||||
|
||||
/// Returns interface to the primary display layer:
|
||||
IDirectFBDisplayLayerPtr wxDfbGetDisplayLayer();
|
||||
|
||||
/// Returns interface to the primary surface:
|
||||
IDirectFBSurfacePtr wxDfbGetPrimarySurface();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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() {} \
|
||||
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)
|
||||
|
||||
/// Convert DirectFB timestamp to wxEvent one:
|
||||
#define wxDFB_EVENT_TIMESTAMP(event) \
|
||||
((event).timestamp.tv_sec * 1000 + (event).timestamp.tv_usec / 1000)
|
||||
|
||||
|
||||
#endif // _WX_DFB_PRIVATE_H_
|
156
include/wx/dfb/region.h
Normal file
156
include/wx/dfb/region.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/region.h
|
||||
// Purpose: wxRegion class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_REGION_H_
|
||||
#define _WX_DFB_REGION_H_
|
||||
|
||||
#include "wx/gdiobj.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#warning "Move these to wx/region.h when common code is moved there"
|
||||
class WXDLLIMPEXP_CORE wxBitmap;
|
||||
class WXDLLIMPEXP_CORE wxColour;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
|
||||
{
|
||||
|
||||
public:
|
||||
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
|
||||
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
|
||||
wxRegion(const wxRect& rect);
|
||||
wxRegion(const wxBitmap& bmp)
|
||||
{
|
||||
Union(bmp);
|
||||
}
|
||||
wxRegion(const wxBitmap& bmp,
|
||||
const wxColour& transColour, int tolerance = 0)
|
||||
{
|
||||
Union(bmp, transColour, tolerance);
|
||||
}
|
||||
|
||||
wxRegion();
|
||||
~wxRegion();
|
||||
|
||||
#warning "FIXME: move this to common code? at least Ok()"
|
||||
bool Ok() const { return m_refData != NULL; }
|
||||
|
||||
bool operator==(const wxRegion& region) const;
|
||||
bool operator!=(const wxRegion& region) const { return !(*this == region); }
|
||||
|
||||
// Clear current region
|
||||
void Clear();
|
||||
|
||||
bool Offset(wxCoord x, wxCoord y);
|
||||
|
||||
// Union rectangle or region with this.
|
||||
bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ return Union(wxRect(x, y, width, height)); }
|
||||
bool Union(const wxRect& rect);
|
||||
bool Union(const wxRegion& region);
|
||||
|
||||
// Intersect rectangle or region with this.
|
||||
bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ return Intersect(wxRect(x, y, width, height)); }
|
||||
bool Intersect(const wxRect& rect);
|
||||
bool Intersect(const wxRegion& region);
|
||||
|
||||
// Subtract rectangle or region from this:
|
||||
// Combines the parts of 'this' that are not part of the second region.
|
||||
bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ return Subtract(wxRect(x, y, width, height)); }
|
||||
bool Subtract(const wxRect& rect);
|
||||
bool Subtract(const wxRegion& region);
|
||||
|
||||
// XOR: the union of two combined regions except for any overlapping areas.
|
||||
bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ return Xor(wxRect(x, y, width, height)); }
|
||||
bool Xor(const wxRect& rect);
|
||||
bool Xor(const wxRegion& region);
|
||||
|
||||
// Outer bounds of region
|
||||
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
|
||||
wxRect GetBox(void) const;
|
||||
|
||||
// Is region empty?
|
||||
bool Empty(void) const;
|
||||
inline bool IsEmpty(void) const { return Empty(); }
|
||||
|
||||
// Does the region contain the point (x,y)?
|
||||
wxRegionContain Contains(wxCoord x, wxCoord y) const;
|
||||
// Does the region contain the point pt?
|
||||
wxRegionContain Contains(const wxPoint& pt) const
|
||||
{ return Contains(pt.x, pt.y); }
|
||||
// Does the region contain the rectangle rect?
|
||||
wxRegionContain Contains(const wxRect& rect) const;
|
||||
// Does the region contain the rectangle (x, y, w, h)?
|
||||
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const
|
||||
{ return Contains(wxRect(x, y, w, h)); }
|
||||
|
||||
|
||||
#warning "Move these union versions + ConvertToBitmap to wxRegionBase"
|
||||
// Convert the region to a B&W bitmap with the white pixels being inside
|
||||
// the region.
|
||||
wxBitmap ConvertToBitmap() const;
|
||||
|
||||
// Use the non-transparent pixels of a wxBitmap for the region to combine
|
||||
// with this region. First version takes transparency from bitmap's mask,
|
||||
// second lets the user specify the colour to be treated as transparent
|
||||
// along with an optional tolerance value.
|
||||
// NOTE: implemented in common/rgncmn.cpp
|
||||
bool Union(const wxBitmap& bmp);
|
||||
bool Union(const wxBitmap& bmp,
|
||||
const wxColour& transColour, int tolerance = 0);
|
||||
|
||||
// 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:
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
friend class WXDLLIMPEXP_CORE wxRegionIterator;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxRegion);
|
||||
};
|
||||
|
||||
|
||||
class WXDLLIMPEXP_CORE wxRegionIterator : public wxObject
|
||||
{
|
||||
public:
|
||||
wxRegionIterator() {}
|
||||
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;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxRegionIterator);
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_REGION_H_
|
127
include/wx/dfb/toplevel.h
Normal file
127
include/wx/dfb/toplevel.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/toplevel.h
|
||||
// Purpose: Top level window, abstraction of wxFrame and wxDialog
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_TOPLEVEL_H_
|
||||
#define _WX_DFB_TOPLEVEL_H_
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBWindow);
|
||||
|
||||
class wxDfbQueuedPaintRequests;
|
||||
struct wxDFBWindowEvent;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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 = 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 = wxFrameNameStr);
|
||||
|
||||
virtual ~wxTopLevelWindowDFB();
|
||||
|
||||
// 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 Show(bool show = true);
|
||||
|
||||
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; }
|
||||
|
||||
virtual void Update();
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
void OnInternalIdle();
|
||||
|
||||
IDirectFBWindowPtr GetDirectFBWindow() const { return m_dfbwin; }
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
virtual IDirectFBSurfacePtr ObtainDfbSurface() const;
|
||||
|
||||
// overriden 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, bool eraseBack = true);
|
||||
|
||||
private:
|
||||
// do queued painting in idle time
|
||||
void HandleQueuedPaintRequests();
|
||||
|
||||
// DirectFB events handling
|
||||
static void HandleDFBWindowEvent(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;
|
||||
|
||||
// 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
|
||||
IDirectFBWindowPtr m_dfbwin;
|
||||
|
||||
private:
|
||||
wxDfbQueuedPaintRequests *m_toPaint;
|
||||
|
||||
friend class wxEventLoop; // for HandleDFBWindowEvent
|
||||
};
|
||||
|
||||
#endif // _WX_DFB_TOPLEVEL_H_
|
181
include/wx/dfb/window.h
Normal file
181
include/wx/dfb/window.h
Normal file
@@ -0,0 +1,181 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dfb/window.h
|
||||
// Purpose: wxWindow class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DFB_WINDOW_H_
|
||||
#define _WX_DFB_WINDOW_H_
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "wx/dfb/ifacehelpers.h"
|
||||
|
||||
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
|
||||
struct wxDFBWindowEvent;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxFont;
|
||||
class WXDLLIMPEXP_CORE wxTopLevelWindowDFB;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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 = 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 = 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 = (const wxRect *) NULL);
|
||||
virtual void Update();
|
||||
virtual void Clear();
|
||||
virtual void Freeze();
|
||||
virtual void Thaw();
|
||||
bool IsFrozen() const { return m_frozenness > 0; }
|
||||
|
||||
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;
|
||||
virtual void GetTextExtent(const wxString& string,
|
||||
int *x, int *y,
|
||||
int *descent = (int *) NULL,
|
||||
int *externalLeading = (int *) NULL,
|
||||
const wxFont *theFont = (const wxFont *) NULL)
|
||||
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
|
||||
IDirectFBSurfacePtr GetDfbSurface();
|
||||
|
||||
// returns toplevel window the window belongs to
|
||||
wxTopLevelWindowDFB *GetTLW() const { return m_tlw; }
|
||||
|
||||
void OnInternalIdle();
|
||||
|
||||
protected:
|
||||
// implement the base class pure virtuals
|
||||
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();
|
||||
|
||||
// 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 IDirectFBSurfacePtr 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, bool eraseBackground);
|
||||
|
||||
// implementation of Refresh()
|
||||
void DoRefreshWindow(bool eraseBack = true);
|
||||
virtual void DoRefreshRect(const wxRect& rect, bool eraseBack = true);
|
||||
|
||||
// DirectFB events handling
|
||||
void HandleKeyEvent(const wxDFBWindowEvent& event_);
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
// counterpart to SetFocus
|
||||
void KillFocus();
|
||||
|
||||
protected:
|
||||
// toplevel window (i.e. DirectFB window) this window belongs to
|
||||
wxTopLevelWindowDFB *m_tlw;
|
||||
|
||||
private:
|
||||
// subsurface of TLW's surface covered by this window
|
||||
IDirectFBSurfacePtr m_surface;
|
||||
|
||||
// position of the window (relative to the parent, not used by wxTLW, so
|
||||
// don't access it directly)
|
||||
wxRect m_rect;
|
||||
|
||||
// number of calls to Freeze() minus number of calls to Thaw()
|
||||
unsigned m_frozenness;
|
||||
|
||||
friend class wxTopLevelWindowDFB; // for HandleXXXEvent
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxWindowDFB)
|
||||
DECLARE_NO_COPY_CLASS(wxWindowDFB)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_DFB_WINDOW_H_
|
@@ -58,10 +58,12 @@ struct WXDLLEXPORT wxNativeEncodingInfo
|
||||
// seems to be handled internally.
|
||||
#elif defined(__WXMGL__)
|
||||
int mglEncoding;
|
||||
#elif defined(__WXDFB__)
|
||||
// DirectFB uses UTF-8 internally, doesn't use font encodings
|
||||
#else
|
||||
#error "Unsupported toolkit"
|
||||
#endif
|
||||
#endif
|
||||
#endif // !__WXPALMOS__
|
||||
// this struct is saved in config by wxFontMapper, so it should know to
|
||||
// serialise itself (implemented in platform-specific code)
|
||||
bool FromString(const wxString& s);
|
||||
|
@@ -66,7 +66,7 @@ protected:
|
||||
DECLARE_NO_COPY_CLASS(wxEventLoopBase)
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXDFB__)
|
||||
|
||||
// this class can be used to implement a standard event loop logic using
|
||||
// Pending() and Dispatch()
|
||||
@@ -115,6 +115,8 @@ protected:
|
||||
#include "wx/msw/evtloop.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/evtloop.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/evtloop.h"
|
||||
#else // other platform
|
||||
|
||||
class WXDLLEXPORT wxEventLoopImpl;
|
||||
|
@@ -25,7 +25,8 @@
|
||||
#endif
|
||||
|
||||
/* the raw keyboard codes are generated under wxGTK and wxMSW only */
|
||||
#if defined(__WXGTK__) || defined(__WXMSW__) || defined(__WXMAC__)
|
||||
#if defined(__WXGTK__) || defined(__WXMSW__) || defined(__WXMAC__) \
|
||||
|| defined(__WXDFB__)
|
||||
#define wxHAS_RAW_KEY_CODES
|
||||
#else
|
||||
#undef wxHAS_RAW_KEY_CODES
|
||||
|
@@ -241,6 +241,8 @@ private:
|
||||
#include "wx/x11/font.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/font.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/font.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/font.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#elif defined(__WXMGL__)
|
||||
#define wxICON_DEFAULT_BITMAP_TYPE wxBITMAP_TYPE_ICO_RESOURCE
|
||||
#include "wx/generic/icon.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/generic/icon.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/icon.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -26,6 +26,8 @@
|
||||
#include "wx/gtk1/pen.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/pen.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/pen.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/pen.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -78,7 +78,8 @@ enum wxPortId
|
||||
wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
|
||||
wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
|
||||
wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
|
||||
wxPORT_PALMOS = 1 << 10 // wxPalmOS, toolkit is PalmOS API
|
||||
wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
|
||||
wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
|
||||
};
|
||||
|
||||
// architecture of the operating system
|
||||
|
@@ -33,6 +33,8 @@ enum wxRegionContain
|
||||
#include "wx/x11/region.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/region.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/region.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/region.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
|
@@ -113,7 +113,7 @@ protected:
|
||||
#include "wx/gtk/timer.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk1/timer.h"
|
||||
#elif defined(__WXX11__) || defined(__WXMGL__)
|
||||
#elif defined(__WXX11__) || defined(__WXMGL__) || defined(__WXDFB__)
|
||||
#include "wx/generic/timer.h"
|
||||
#elif defined (__WXCOCOA__)
|
||||
#include "wx/cocoa/timer.h"
|
||||
|
@@ -316,6 +316,9 @@ protected:
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/toplevel.h"
|
||||
#define wxTopLevelWindowNative wxTopLevelWindowMGL
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/toplevel.h"
|
||||
#define wxTopLevelWindowNative wxTopLevelWindowDFB
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/toplevel.h"
|
||||
#define wxTopLevelWindowNative wxTopLevelWindowMac
|
||||
|
@@ -1397,12 +1397,11 @@ private:
|
||||
#endif // wxUniv
|
||||
#include "wx/x11/window.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#ifdef __WXUNIVERSAL__
|
||||
#define wxWindowNative wxWindowMGL
|
||||
#else // !wxUniv
|
||||
#define wxWindowMGL wxWindow
|
||||
#endif // wxUniv
|
||||
#include "wx/mgl/window.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#define wxWindowNative wxWindowDFB
|
||||
#include "wx/dfb/window.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#ifdef __WXUNIVERSAL__
|
||||
#define wxWindowNative wxWindowMac
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(__WXMGL__) || \
|
||||
defined(__WXDFB__) || \
|
||||
defined(__WXMAC__) || \
|
||||
defined(__WXGTK__) || \
|
||||
defined(__WXMOTIF__) || \
|
||||
|
@@ -37,7 +37,7 @@
|
||||
wxEventLoop *wxEventLoopBase::ms_activeLoop = NULL;
|
||||
|
||||
// wxEventLoopManual is unused in the other ports
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXDFB__)
|
||||
|
||||
// ============================================================================
|
||||
// wxEventLoopManual implementation
|
||||
@@ -152,4 +152,4 @@ void wxEventLoopManual::Exit(int rc)
|
||||
WakeUp();
|
||||
}
|
||||
|
||||
#endif // __WXMSW__ || __WXMAC__
|
||||
#endif // __WXMSW__ || __WXMAC__ || __WXDFB__
|
||||
|
@@ -72,7 +72,8 @@ static const wxChar* const wxPortIdNames[] =
|
||||
_T("wxMac"),
|
||||
_T("wxCocoa"),
|
||||
_T("wxWinCE"),
|
||||
_T("wxPalmOS")
|
||||
_T("wxPalmOS"),
|
||||
_T("wxDFB")
|
||||
};
|
||||
|
||||
static const wxChar* const wxArchitectureNames[] =
|
||||
|
165
src/dfb/app.cpp
Normal file
165
src/dfb/app.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/app.cpp
|
||||
// Purpose: wxApp implementation
|
||||
// Author: Vaclav Slavik
|
||||
// based on MGL implementation
|
||||
// Created: 2006-08-16
|
||||
// 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/app.h"
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxApp initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxAppBase::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
}
|
||||
|
||||
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) ) )
|
||||
return false;
|
||||
|
||||
if ( !DFB_CALL( DirectFBCreate(&m_dfb) ) )
|
||||
return false;
|
||||
|
||||
#warning "FIXME: theme override is temporary"
|
||||
wxTheme::Set(wxTheme::Create(_T("gtk")));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
wxAppBase::CleanUp();
|
||||
|
||||
m_dfb.Reset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// display mode
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static wxVideoMode GetCurrentVideoMode()
|
||||
{
|
||||
wxVideoMode m;
|
||||
|
||||
IDirectFBSurfacePtr surface(wxDfbGetPrimarySurface());
|
||||
if ( !surface )
|
||||
return m; // invalid
|
||||
|
||||
DFB_CALL( surface->GetSize(surface, &m.w, &m.h) );
|
||||
m.bpp = wxDfbGetSurfaceDepth(surface);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
wxVideoMode wxApp::GetDisplayMode() const
|
||||
{
|
||||
if ( !m_videoMode.IsOk() )
|
||||
wxConstCast(this, wxApp)->m_videoMode = GetCurrentVideoMode();
|
||||
|
||||
return m_videoMode;
|
||||
}
|
||||
|
||||
bool wxApp::SetDisplayMode(const wxVideoMode& mode)
|
||||
{
|
||||
if ( !DFB_CALL( m_dfb->SetVideoMode(m_dfb, mode.w, mode.h, mode.bpp) ) )
|
||||
return false;
|
||||
|
||||
m_videoMode = mode;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// events processing related
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
|
||||
wxEventLoop::GetActive()->WakeUp();
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
wxMutexGuiLeave();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool wxApp::Yield(bool onlyIfNeeded)
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if ( !wxThread::IsMain() )
|
||||
return true; // can't process events from other threads
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
static bool s_inYield = false;
|
||||
|
||||
if ( s_inYield )
|
||||
{
|
||||
if ( !onlyIfNeeded )
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxYield called recursively" ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
s_inYield = true;
|
||||
|
||||
wxLog::Suspend();
|
||||
|
||||
if ( wxEventLoop::GetActive() )
|
||||
{
|
||||
while (wxEventLoop::GetActive()->Pending())
|
||||
wxEventLoop::GetActive()->Dispatch();
|
||||
}
|
||||
|
||||
// it's necessary to call ProcessIdle() to update the frames sizes which
|
||||
// might have been changed (it also will update other things set from
|
||||
// OnUpdateUI() which is a nice (and desired) side effect)
|
||||
while ( ProcessIdle() ) {}
|
||||
|
||||
wxLog::Resume();
|
||||
|
||||
s_inYield = false;
|
||||
|
||||
return true;
|
||||
}
|
449
src/dfb/bitmap.cpp
Normal file
449
src/dfb/bitmap.cpp
Normal file
@@ -0,0 +1,449 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/bitmap.cpp
|
||||
// Purpose: wxBitmap implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-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
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/colour.h"
|
||||
#include "wx/image.h"
|
||||
|
||||
#warning "move this to common"
|
||||
#include "wx/xpmdecod.h"
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Convert wxColour into it's quantized value in lower-precision
|
||||
// pixel format (needed for masking by colour).
|
||||
static wxColour wxQuantizeColour(const wxColour& clr, const wxBitmap& bmp)
|
||||
{
|
||||
#if 0
|
||||
pixel_format_t *pf = bmp.GetMGLbitmap_t()->pf;
|
||||
|
||||
if ( pf->redAdjust == 0 && pf->greenAdjust == 0 && pf->blueAdjust == 0 )
|
||||
return clr;
|
||||
else
|
||||
return wxColour((unsigned char)((clr.Red() >> pf->redAdjust) << pf->redAdjust),
|
||||
(unsigned char)((clr.Green() >> pf->greenAdjust) << pf->greenAdjust),
|
||||
(unsigned char)((clr.Blue() >> pf->blueAdjust) << pf->blueAdjust));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMask
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||
|
||||
wxMask::wxMask() : m_bitmap(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
wxMask::wxMask(const wxBitmap& bitmap)
|
||||
: m_bitmap(NULL)
|
||||
{
|
||||
Create(bitmap);
|
||||
}
|
||||
|
||||
wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
|
||||
: m_bitmap(NULL)
|
||||
{
|
||||
Create(bitmap, colour);
|
||||
}
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
|
||||
: m_bitmap(NULL)
|
||||
{
|
||||
Create(bitmap, paletteIndex);
|
||||
}
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
wxMask::wxMask(const wxMask& mask)
|
||||
{
|
||||
m_bitmap = mask.m_bitmap ? new wxBitmap(*mask.m_bitmap) : NULL;
|
||||
}
|
||||
|
||||
wxMask::~wxMask()
|
||||
{
|
||||
delete m_bitmap;
|
||||
}
|
||||
|
||||
#warning "move this to common code"
|
||||
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
||||
{
|
||||
delete m_bitmap;
|
||||
m_bitmap = NULL;
|
||||
|
||||
wxColour clr(wxQuantizeColour(colour, bitmap));
|
||||
|
||||
wxImage imgSrc(bitmap.ConvertToImage());
|
||||
imgSrc.SetMask(false);
|
||||
wxImage image(imgSrc.ConvertToMono(clr.Red(), clr.Green(), clr.Blue()));
|
||||
if ( !image.Ok() )
|
||||
return false;
|
||||
|
||||
m_bitmap = new wxBitmap(image, 1);
|
||||
|
||||
return m_bitmap->Ok();
|
||||
}
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
|
||||
{
|
||||
unsigned char r,g,b;
|
||||
wxPalette *pal = bitmap.GetPalette();
|
||||
|
||||
wxCHECK_MSG( pal, false, wxT("Cannot create mask from bitmap without palette") );
|
||||
|
||||
pal->GetRGB(paletteIndex, &r, &g, &b);
|
||||
|
||||
return Create(bitmap, wxColour(r, g, b));
|
||||
}
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
bool wxMask::Create(const wxBitmap& bitmap)
|
||||
{
|
||||
delete m_bitmap;
|
||||
m_bitmap = NULL;
|
||||
|
||||
wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap") );
|
||||
wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
|
||||
|
||||
m_bitmap = new wxBitmap(bitmap);
|
||||
return true;
|
||||
}
|
||||
|
||||
const wxBitmap& wxMask::GetBitmap() const
|
||||
{
|
||||
return m_bitmap ? *m_bitmap : wxNullBitmap;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBitmapRefData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxBitmapRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxBitmapRefData()
|
||||
{
|
||||
m_mask = NULL;
|
||||
#if wxUSE_PALETTE
|
||||
m_palette = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxBitmapRefData(const wxBitmapRefData& data)
|
||||
{
|
||||
m_surface = wxDfbCloneSurface(data.m_surface,
|
||||
wxDfbCloneSurface_NoPixels);
|
||||
m_mask = data.m_mask ? new wxMask(*data.m_mask) : NULL;
|
||||
#if wxUSE_PALETTE
|
||||
m_palette = data.m_palette ? new wxPalette(*data.m_palette) : NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
~wxBitmapRefData()
|
||||
{
|
||||
delete m_mask;
|
||||
#if wxUSE_PALETTE
|
||||
delete m_palette;
|
||||
#endif
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr m_surface;
|
||||
wxMask *m_mask;
|
||||
#if wxUSE_PALETTE
|
||||
wxPalette *m_palette;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define M_BITMAP ((wxBitmapRefData *)m_refData)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBitmap
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxBitmapBase)
|
||||
|
||||
wxBitmap::wxBitmap(int width, int height, int depth)
|
||||
{
|
||||
Create(width, height, depth);
|
||||
}
|
||||
|
||||
bool wxBitmap::Create(int width, int height, int depth)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
wxCHECK_MSG( width > 0 && height > 0, false, wxT("invalid bitmap size") );
|
||||
|
||||
DFBSurfaceDescription desc;
|
||||
desc.flags = (DFBSurfaceDescriptionFlags)(
|
||||
DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT);
|
||||
desc.caps = DSCAPS_NONE;
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
|
||||
IDirectFBSurfacePtr surface;
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
if ( !DFB_CALL( dfb->CreateSurface(dfb, &desc, &surface) ) )
|
||||
return false;
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
M_BITMAP->m_surface = surface;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#warning "FIXME: move this to common code"
|
||||
bool wxBitmap::CreateFromXpm(const char **bits)
|
||||
{
|
||||
wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") );
|
||||
|
||||
#if wxUSE_IMAGE && wxUSE_XPM
|
||||
wxXPMDecoder decoder;
|
||||
wxImage img = decoder.ReadData(bits);
|
||||
wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") );
|
||||
|
||||
*this = wxBitmap(img);
|
||||
|
||||
return true;
|
||||
#else
|
||||
wxFAIL_MSG( _T("creating bitmaps from XPMs not supported") );
|
||||
return false;
|
||||
#endif // wxUSE_IMAGE && wxUSE_XPM
|
||||
}
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
wxBitmap::wxBitmap(const wxImage& image, int depth)
|
||||
{
|
||||
wxCHECK_RET( image.Ok(), wxT("invalid image") );
|
||||
}
|
||||
|
||||
wxImage wxBitmap::ConvertToImage() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
||||
|
||||
return wxNullImage; // FIXME
|
||||
}
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
|
||||
{
|
||||
LoadFile(filename, type);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
|
||||
{
|
||||
wxCHECK_RET( depth == 1, wxT("can only create mono bitmap from XBM data") );
|
||||
}
|
||||
|
||||
bool wxBitmap::Ok() const
|
||||
{
|
||||
return (m_refData != NULL && M_BITMAP->m_surface);
|
||||
}
|
||||
|
||||
bool wxBitmap::operator==(const wxBitmap& bmp) const
|
||||
{
|
||||
// FIXME: is this the right way to compare bitmaps?
|
||||
return (m_refData == bmp.m_refData);
|
||||
}
|
||||
|
||||
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) );
|
||||
return h;
|
||||
}
|
||||
|
||||
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) );
|
||||
return w;
|
||||
}
|
||||
|
||||
int wxBitmap::GetDepth() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
|
||||
|
||||
return wxDfbGetSurfaceDepth(M_BITMAP->m_surface);
|
||||
}
|
||||
|
||||
wxMask *wxBitmap::GetMask() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
|
||||
|
||||
return M_BITMAP->m_mask;
|
||||
}
|
||||
|
||||
void wxBitmap::SetMask(wxMask *mask)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
|
||||
|
||||
delete M_BITMAP->m_mask;
|
||||
M_BITMAP->m_mask = mask;
|
||||
}
|
||||
|
||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
||||
{
|
||||
*this = *((wxBitmap*)(&icon));
|
||||
return true;
|
||||
}
|
||||
|
||||
wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const
|
||||
{
|
||||
wxCHECK_MSG( Ok() &&
|
||||
rect.x >= 0 && rect.y >= 0 &&
|
||||
rect.x+rect.width <= GetWidth() &&
|
||||
rect.y+rect.height <= GetHeight(),
|
||||
wxNullBitmap,
|
||||
wxT("invalid bitmap or bitmap region") );
|
||||
|
||||
}
|
||||
|
||||
#warning "to common code"
|
||||
bool wxBitmap::LoadFile(const wxString &name, wxBitmapType type)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
if ( handler == NULL )
|
||||
{
|
||||
wxImage image;
|
||||
if ( !image.LoadFile(name, type) || !image.Ok() )
|
||||
{
|
||||
wxLogError("no bitmap handler for type %d defined.", type);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
*this = wxBitmap(image);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
return handler->LoadFile(this, name, type, -1, -1);
|
||||
}
|
||||
|
||||
#warning "to common code"
|
||||
bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, const wxPalette *palette) const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
if ( handler == NULL )
|
||||
{
|
||||
wxImage image = ConvertToImage();
|
||||
#if wxUSE_PALETTE
|
||||
if ( palette )
|
||||
image.SetPalette(*palette);
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
if ( image.Ok() )
|
||||
return image.SaveFile(filename, type);
|
||||
else
|
||||
{
|
||||
wxLogError("no bitmap handler for type %d defined.", type);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return handler->SaveFile(this, filename, type, palette);
|
||||
}
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
wxPalette *wxBitmap::GetPalette() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
|
||||
|
||||
return M_BITMAP->m_palette;
|
||||
}
|
||||
|
||||
void wxBitmap::SetPalette(const wxPalette& palette)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
|
||||
wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") );
|
||||
|
||||
delete M_BITMAP->m_palette;
|
||||
M_BITMAP->m_palette = NULL;
|
||||
|
||||
if ( !palette.Ok() ) return;
|
||||
|
||||
M_BITMAP->m_palette = new wxPalette(palette);
|
||||
}
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
void wxBitmap::SetHeight(int height)
|
||||
{
|
||||
AllocExclusive();
|
||||
#warning "todo"
|
||||
}
|
||||
|
||||
void wxBitmap::SetWidth(int width)
|
||||
{
|
||||
AllocExclusive();
|
||||
#warning "todo"
|
||||
}
|
||||
|
||||
void wxBitmap::SetDepth(int depth)
|
||||
{
|
||||
AllocExclusive();
|
||||
#warning "todo"
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr wxBitmap::GetDirectFBSurface() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
|
||||
|
||||
return M_BITMAP->m_surface;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxBitmap::CreateRefData() const
|
||||
{
|
||||
return new wxBitmapRefData;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxBitmap::CloneRefData(const wxObjectRefData *data) const
|
||||
{
|
||||
return new wxBitmapRefData(*(wxBitmapRefData *)data);
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
void wxBitmap::InitStandardHandlers()
|
||||
{
|
||||
// not wxBitmap handlers, we rely on wxImage
|
||||
}
|
147
src/dfb/brush.cpp
Normal file
147
src/dfb/brush.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/brush.cpp
|
||||
// Purpose: wxBrush class implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-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/brush.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/colour.h"
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBrush
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxBrushRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxBrushRefData(const wxColour& clr = wxNullColour, int style = wxSOLID)
|
||||
{
|
||||
m_colour = clr;
|
||||
SetStyle(style);
|
||||
}
|
||||
|
||||
wxBrushRefData(const wxBrushRefData& data)
|
||||
{
|
||||
m_colour = data.m_colour;
|
||||
m_style = data.m_style;
|
||||
}
|
||||
|
||||
void SetStyle(int style)
|
||||
{
|
||||
if ( m_style != wxSOLID && m_style == wxTRANSPARENT )
|
||||
{
|
||||
wxFAIL_MSG( _T("only wxSOLID and wxTRANSPARENT styles are supported") );
|
||||
style = wxSOLID;
|
||||
}
|
||||
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
wxColour m_colour;
|
||||
int m_style;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
||||
|
||||
wxBrush::wxBrush(const wxColour &colour, int style)
|
||||
{
|
||||
m_refData = new wxBrushRefData(colour, style);
|
||||
}
|
||||
|
||||
wxBrush::wxBrush(const wxBitmap &stippleBitmap)
|
||||
{
|
||||
wxFAIL_MSG( "brushes with stipple bitmaps not implemented" );
|
||||
|
||||
m_refData = new wxBrushRefData(*wxBLACK);
|
||||
}
|
||||
|
||||
bool wxBrush::operator==(const wxBrush& brush) const
|
||||
{
|
||||
#warning "this is incorrect (MGL too)"
|
||||
return m_refData == brush.m_refData;
|
||||
}
|
||||
|
||||
bool wxBrush::Ok() const
|
||||
{
|
||||
return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
|
||||
}
|
||||
|
||||
int wxBrush::GetStyle() const
|
||||
{
|
||||
if (m_refData == NULL)
|
||||
{
|
||||
wxFAIL_MSG( wxT("invalid brush") );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return M_BRUSHDATA->m_style;
|
||||
}
|
||||
|
||||
wxColour& wxBrush::GetColour() const
|
||||
{
|
||||
if (m_refData == NULL)
|
||||
{
|
||||
wxFAIL_MSG( wxT("invalid brush") );
|
||||
return wxNullColour;
|
||||
}
|
||||
|
||||
return M_BRUSHDATA->m_colour;
|
||||
}
|
||||
|
||||
wxBitmap *wxBrush::GetStipple() const
|
||||
{
|
||||
wxFAIL_MSG( "brushes with stipple bitmaps not implemented" );
|
||||
return &wxNullBitmap;
|
||||
}
|
||||
|
||||
void wxBrush::SetColour(const wxColour& col)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_BRUSHDATA->m_colour = col;
|
||||
}
|
||||
|
||||
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_BRUSHDATA->m_colour.Set(r, g, b);
|
||||
}
|
||||
|
||||
void wxBrush::SetStyle(int style)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_BRUSHDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxBrush::SetStipple(const wxBitmap& WXUNUSED(stipple))
|
||||
{
|
||||
wxFAIL_MSG( "brushes with stipple bitmaps not implemented" );
|
||||
}
|
||||
|
||||
wxObjectRefData *wxBrush::CreateRefData() const
|
||||
{
|
||||
return new wxBrushRefData;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
|
||||
{
|
||||
return new wxBrushRefData(*(wxBrushRefData *)data);
|
||||
}
|
146
src/dfb/cursor.cpp
Normal file
146
src/dfb/cursor.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/cursor.cpp
|
||||
// Purpose: wxCursor implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// 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/cursor.h"
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxCursorRefData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxCursorRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxCursorRefData(const wxBitmap& bmp = wxNullBitmap, int id = -1)
|
||||
: m_id(id), m_bitmap(bmp) {}
|
||||
|
||||
int m_id;
|
||||
wxBitmap m_bitmap;
|
||||
};
|
||||
|
||||
#define M_CURSOR_OF(c) ((wxCursorRefData*)((c).m_refData))
|
||||
#define M_CURSOR M_CURSOR_OF(*this)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxCursor
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxObject)
|
||||
|
||||
wxCursor::wxCursor(int cursorId)
|
||||
{
|
||||
#warning "FIXME -- implement the cursor as bitmaps (that's what DFB uses)"
|
||||
}
|
||||
|
||||
wxCursor::wxCursor(const char WXUNUSED(bits)[],
|
||||
int WXUNUSED(width),
|
||||
int WXUNUSED(height),
|
||||
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY),
|
||||
const char WXUNUSED(maskBits)[],
|
||||
wxColour * WXUNUSED(fg), wxColour * WXUNUSED(bg) )
|
||||
{
|
||||
#warning "FIXME"
|
||||
}
|
||||
|
||||
wxCursor::wxCursor(const wxString& cursor_file,
|
||||
long flags,
|
||||
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY))
|
||||
{
|
||||
#warning "FIXME"
|
||||
}
|
||||
|
||||
bool wxCursor::Ok() const
|
||||
{
|
||||
return m_refData && M_CURSOR->m_bitmap.Ok();
|
||||
}
|
||||
|
||||
bool wxCursor::operator==(const wxCursor& cursor) const
|
||||
{
|
||||
if ( Ok() )
|
||||
{
|
||||
if ( !cursor.Ok() )
|
||||
return false;
|
||||
else if ( M_CURSOR->m_id != M_CURSOR_OF(cursor)->m_id )
|
||||
return false;
|
||||
else if ( M_CURSOR->m_id == -1 ) // non-stock cursor
|
||||
return (m_refData == cursor.m_refData);
|
||||
else
|
||||
return true; // IDs != -1 and are the same
|
||||
}
|
||||
else
|
||||
{
|
||||
return !cursor.Ok();
|
||||
}
|
||||
}
|
||||
|
||||
wxObjectRefData *wxCursor::CreateRefData() const
|
||||
{
|
||||
return new wxCursorRefData;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxCursor::CloneRefData(const wxObjectRefData *data) const
|
||||
{
|
||||
return new wxCursorRefData(*(wxCursorRefData *)data);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Global cursor setting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxSetCursor(const wxCursor& cursor)
|
||||
{
|
||||
#warning "FIXME: implement"
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// busy cursor routines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#warning "FIXME: this should be common code"
|
||||
#if 0
|
||||
static wxCursor gs_savedCursor = wxNullCursor;
|
||||
static int gs_busyCount = 0;
|
||||
|
||||
const wxCursor &wxBusyCursor::GetStoredCursor()
|
||||
{
|
||||
return gs_savedCursor;
|
||||
}
|
||||
|
||||
const wxCursor wxBusyCursor::GetBusyCursor()
|
||||
{
|
||||
return gs_globalCursor;
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxEndBusyCursor()
|
||||
{
|
||||
#warning "FIXME - do this logic in common code?"
|
||||
}
|
||||
|
||||
void wxBeginBusyCursor(const wxCursor *cursor)
|
||||
{
|
||||
#warning "FIXME"
|
||||
}
|
||||
|
||||
bool wxIsBusy()
|
||||
{
|
||||
#warning "FIXME"
|
||||
return false;
|
||||
}
|
807
src/dfb/dc.cpp
Normal file
807
src/dfb/dc.cpp
Normal file
@@ -0,0 +1,807 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/dc.cpp
|
||||
// Purpose: wxDC class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-07
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
|
||||
|
||||
// Default constructor
|
||||
wxDC::wxDC()
|
||||
{
|
||||
m_ok = false;
|
||||
}
|
||||
|
||||
wxDC::wxDC(const IDirectFBSurfacePtr& surface)
|
||||
{
|
||||
Init(surface);
|
||||
}
|
||||
|
||||
void wxDC::Init(const IDirectFBSurfacePtr& surface)
|
||||
{
|
||||
m_ok = (surface != NULL);
|
||||
wxCHECK_RET( surface != NULL, _T("invalid surface") );
|
||||
|
||||
m_surface = surface;
|
||||
|
||||
m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
|
||||
(double)wxGetDisplaySizeMM().GetWidth();
|
||||
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
|
||||
(double)wxGetDisplaySizeMM().GetHeight();
|
||||
|
||||
SetFont(*wxNORMAL_FONT);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// clipping
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define DO_SET_CLIPPING_BOX(rg) \
|
||||
{ \
|
||||
wxRect rect = rg.GetBox(); \
|
||||
m_clipX1 = (wxCoord) XDEV2LOG(rect.GetLeft()); \
|
||||
m_clipY1 = (wxCoord) YDEV2LOG(rect.GetTop()); \
|
||||
m_clipX2 = (wxCoord) XDEV2LOG(rect.GetRight()); \
|
||||
m_clipY2 = (wxCoord) YDEV2LOG(rect.GetBottom()); \
|
||||
}
|
||||
|
||||
void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
DFBRegion r;
|
||||
r.x1 = XLOG2DEV(cx);
|
||||
r.y1 = YLOG2DEV(cy);
|
||||
r.x2 = r.x1 + XLOG2DEVREL(cw) - 1;
|
||||
r.y2 = r.y1 + XLOG2DEVREL(ch) - 1;
|
||||
|
||||
if ( !DFB_CALL( m_surface->SetClip(m_surface, &r) ) )
|
||||
return;
|
||||
|
||||
m_clipX1 = cx;
|
||||
m_clipY1 = cy;
|
||||
m_clipX2 = cx + cw - 1;
|
||||
m_clipY2 = cy + ch -1;
|
||||
m_clipping = true;
|
||||
}
|
||||
|
||||
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
|
||||
{
|
||||
// NB: this can be done because wxDFB only supports
|
||||
// rectangular regions
|
||||
SetClippingRegion(region.AsRect());
|
||||
}
|
||||
|
||||
void wxDC::DestroyClippingRegion()
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
DFB_CALL( m_surface->SetClip(m_surface, NULL) );
|
||||
|
||||
ResetClipping();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// query capabilities
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
int wxDC::GetDepth() const
|
||||
{
|
||||
return wxDfbGetSurfaceDepth(m_surface);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// drawing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxDC::Clear()
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
if ( m_backgroundBrush.GetStyle() == wxTRANSPARENT )
|
||||
return;
|
||||
|
||||
wxColour clr = m_backgroundBrush.GetColour();
|
||||
DFB_CALL( m_surface->Clear(m_surface,
|
||||
clr.Red(), clr.Green(), clr.Blue(), 255) );
|
||||
}
|
||||
|
||||
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
|
||||
const wxColour & col, int style);
|
||||
|
||||
bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
|
||||
const wxColour& col, int style)
|
||||
{
|
||||
return wxDoFloodFill(this, x, y, col, style);
|
||||
}
|
||||
|
||||
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
|
||||
{
|
||||
wxCHECK_MSG( col, false, _T("NULL colour parameter in wxDC::GetPixel"));
|
||||
|
||||
wxFAIL_MSG( _T("GetPixel not implemented") );
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxDC::DoCrossHair(wxCoord x, wxCoord y)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("CrossHair not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
if ( m_pen.GetStyle() == wxTRANSPARENT )
|
||||
return;
|
||||
|
||||
DFB_CALL( m_surface->DrawLine(m_surface,
|
||||
XLOG2DEV(x1), YLOG2DEV(y1),
|
||||
XLOG2DEV(x2), YLOG2DEV(y2)) );
|
||||
|
||||
CalcBoundingBox(x1, y1);
|
||||
CalcBoundingBox(x2, y2);
|
||||
}
|
||||
|
||||
// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
|
||||
// and ending at (x2, y2)
|
||||
void wxDC::DoDrawArc(wxCoord x1, wxCoord y1,
|
||||
wxCoord x2, wxCoord y2,
|
||||
wxCoord xc, wxCoord yc)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawArc not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawPoint not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int WXUNUSED(fillStyle))
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawPolygon not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
// TODO: impl. using DirectDB's DrawLines
|
||||
wxFAIL_MSG( _T("DrawLines not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxCoord xx = XLOG2DEV(x);
|
||||
wxCoord yy = YLOG2DEV(y);
|
||||
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
||||
wxCoord hh = m_signY * YLOG2DEVREL(height);
|
||||
|
||||
if ( ww == 0 || hh == 0 ) return;
|
||||
|
||||
if ( ww < 0 )
|
||||
{
|
||||
ww = -ww;
|
||||
xx = xx - ww;
|
||||
}
|
||||
if ( hh < 0 )
|
||||
{
|
||||
hh = -hh;
|
||||
yy = yy - hh;
|
||||
}
|
||||
|
||||
if ( m_brush.GetStyle() != wxTRANSPARENT )
|
||||
{
|
||||
SelectColour(m_brush.GetColour());
|
||||
DFB_CALL( m_surface->FillRectangle(m_surface, 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) );
|
||||
}
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + width, y + height);
|
||||
}
|
||||
|
||||
void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawRoundedRectangle not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawElipse not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawElipticArc not implemented") );
|
||||
}
|
||||
|
||||
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxCoord xx = XLOG2DEV(x);
|
||||
wxCoord yy = XLOG2DEV(y);
|
||||
|
||||
// update the bounding box
|
||||
wxCoord w, h;
|
||||
CalcBoundingBox(x, y);
|
||||
GetTextExtent(text, &w, &h);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
|
||||
// if background mode is solid, DrawText must paint text's background:
|
||||
if ( m_backgroundMode == wxSOLID )
|
||||
{
|
||||
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)) );
|
||||
// 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)));
|
||||
}
|
||||
|
||||
void wxDC::DoDrawRotatedText(const wxString& text,
|
||||
wxCoord x, wxCoord y,
|
||||
double angle)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("DrawRotatedText not implemented") );
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// set GDI objects
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxDC::SetPen(const wxPen& pen)
|
||||
{
|
||||
if ( !pen.Ok() ) return;
|
||||
m_pen = pen;
|
||||
|
||||
SelectColour(m_pen.GetColour());
|
||||
}
|
||||
|
||||
void wxDC::SetBrush(const wxBrush& brush)
|
||||
{
|
||||
if ( !brush.Ok() ) return;
|
||||
m_brush = brush;
|
||||
}
|
||||
|
||||
void wxDC::SelectColour(const wxColour& clr)
|
||||
{
|
||||
DFB_CALL( m_surface->SetColor(m_surface,
|
||||
clr.Red(), clr.Green(), clr.Blue(), 255) );
|
||||
#warning "use SetColorIndex?"
|
||||
}
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
void wxDC::SetPalette(const wxPalette& WXUNUSED(palette))
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("SetPalette not implemented") );
|
||||
}
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
void wxDC::SetFont(const wxFont& font)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
if ( !font.Ok() )
|
||||
return;
|
||||
|
||||
if ( !DFB_CALL( m_surface->SetFont(m_surface, font.GetDirectFBFont()) ) )
|
||||
return;
|
||||
|
||||
m_font = font;
|
||||
}
|
||||
|
||||
void wxDC::SetBackground(const wxBrush& brush)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
if (!brush.Ok()) return;
|
||||
|
||||
m_backgroundBrush = brush;
|
||||
}
|
||||
|
||||
void wxDC::SetBackgroundMode(int mode)
|
||||
{
|
||||
m_backgroundMode = mode;
|
||||
}
|
||||
|
||||
void wxDC::SetLogicalFunction(int function)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
wxFAIL_MSG( _T("SetLogicalFunction not implemented") );
|
||||
|
||||
m_logicalFunction = function;
|
||||
}
|
||||
|
||||
bool wxDC::StartDoc(const wxString& WXUNUSED(message))
|
||||
{
|
||||
// We might be previewing, so return true to let it continue.
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDC::EndDoc()
|
||||
{
|
||||
}
|
||||
|
||||
void wxDC::StartPage()
|
||||
{
|
||||
}
|
||||
|
||||
void wxDC::EndPage()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// text metrics
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxCoord wxDC::GetCharHeight() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
|
||||
wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") );
|
||||
|
||||
int h = -1;
|
||||
IDirectFBFontPtr f = m_font.GetDirectFBFont();
|
||||
DFB_CALL( f->GetHeight(f, &h) );
|
||||
return YDEV2LOGREL(h);
|
||||
}
|
||||
|
||||
wxCoord wxDC::GetCharWidth() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
|
||||
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) );
|
||||
// VS: YDEV is corrent, it should *not* be XDEV, because font's are only
|
||||
// scaled according to m_scaleY
|
||||
return YDEV2LOGREL(w);
|
||||
}
|
||||
|
||||
void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
|
||||
wxCoord *descent, wxCoord *externalLeading,
|
||||
wxFont *theFont) const
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
wxCHECK_RET( m_font.Ok(), wxT("no font selected") );
|
||||
wxCHECK_RET( !theFont || theFont->Ok(), wxT("invalid font") );
|
||||
|
||||
wxFont oldFont;
|
||||
if ( theFont != NULL )
|
||||
{
|
||||
oldFont = m_font;
|
||||
wxConstCast(this, wxDC)->SetFont(*theFont);
|
||||
}
|
||||
|
||||
wxCoord xx = 0, yy = 0;
|
||||
DFBRectangle rect;
|
||||
IDirectFBFontPtr f = m_font.GetDirectFBFont();
|
||||
|
||||
if (DFB_CALL(f->GetStringExtents(f, 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
|
||||
xx = YDEV2LOGREL(rect.w);
|
||||
yy = YDEV2LOGREL(rect.h);
|
||||
|
||||
if ( descent )
|
||||
{
|
||||
int d;
|
||||
if ( DFB_CALL( f->GetDescender(f, &d) ) )
|
||||
*descent = YDEV2LOGREL(-d);
|
||||
else
|
||||
*descent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( x ) *x = xx;
|
||||
if ( y ) *y = yy;
|
||||
if ( externalLeading ) *externalLeading = 0;
|
||||
|
||||
if ( theFont != NULL )
|
||||
wxConstCast(this, wxDC)->SetFont(oldFont);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// mapping modes
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxDC::ComputeScaleAndOrigin()
|
||||
{
|
||||
m_scaleX = m_logicalScaleX * m_userScaleX;
|
||||
m_scaleY = m_logicalScaleY * m_userScaleY;
|
||||
|
||||
// FIXME_DFB: scaling affects pixel size of font, pens, brushes, which
|
||||
// is not currently implemented here; probably makes sense to
|
||||
// switch to Cairo instead of implementing everything for DFB
|
||||
wxASSERT_MSG( m_scaleX == 1.0 && m_scaleY == 1.0,
|
||||
_T("scaling is not implemented in wxDFB") );
|
||||
}
|
||||
|
||||
void wxDC::SetMapMode(int mode)
|
||||
{
|
||||
#warning "move this to common code, it's shared by almost all ports!"
|
||||
switch (mode)
|
||||
{
|
||||
case wxMM_TWIPS:
|
||||
SetLogicalScale(twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y);
|
||||
break;
|
||||
case wxMM_POINTS:
|
||||
SetLogicalScale(pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y);
|
||||
break;
|
||||
case wxMM_METRIC:
|
||||
SetLogicalScale(m_mm_to_pix_x, m_mm_to_pix_y);
|
||||
break;
|
||||
case wxMM_LOMETRIC:
|
||||
SetLogicalScale(m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0);
|
||||
break;
|
||||
default:
|
||||
case wxMM_TEXT:
|
||||
SetLogicalScale(1.0, 1.0);
|
||||
break;
|
||||
}
|
||||
m_mappingMode = mode;
|
||||
}
|
||||
|
||||
void wxDC::SetUserScale(double x, double y)
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
// allow negative ? -> no
|
||||
m_userScaleX = x;
|
||||
m_userScaleY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
}
|
||||
|
||||
void wxDC::SetLogicalScale(double x, double y)
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
// allow negative ?
|
||||
m_logicalScaleX = x;
|
||||
m_logicalScaleY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
}
|
||||
|
||||
void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
m_logicalOriginX = x * m_signX; // is this still correct ?
|
||||
m_logicalOriginY = y * m_signY;
|
||||
ComputeScaleAndOrigin();
|
||||
}
|
||||
|
||||
void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
// only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
|
||||
m_deviceOriginX = x;
|
||||
m_deviceOriginY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
}
|
||||
|
||||
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
// only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
|
||||
m_signX = (xLeftRight ? 1 : -1);
|
||||
m_signY = (yBottomUp ? -1 : 1);
|
||||
ComputeScaleAndOrigin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// coordinates transformations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
|
||||
{
|
||||
return ((wxDC *)this)->XDEV2LOG(x);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
|
||||
{
|
||||
return ((wxDC *)this)->YDEV2LOG(y);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
|
||||
{
|
||||
return ((wxDC *)this)->XDEV2LOGREL(x);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
|
||||
{
|
||||
return ((wxDC *)this)->YDEV2LOGREL(y);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
|
||||
{
|
||||
return ((wxDC *)this)->XLOG2DEV(x);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
|
||||
{
|
||||
return ((wxDC *)this)->YLOG2DEV(y);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
|
||||
{
|
||||
return ((wxDC *)this)->XLOG2DEVREL(x);
|
||||
}
|
||||
|
||||
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
|
||||
{
|
||||
return ((wxDC *)this)->YLOG2DEVREL(y);
|
||||
}
|
||||
|
||||
|
||||
void wxDC::DoGetSize(int *w, int *h) const
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
|
||||
DFB_CALL( m_surface->GetSize(m_surface, w, h) );
|
||||
}
|
||||
|
||||
void wxDC::DoGetSizeMM(int *width, int *height) const
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
GetSize(&w, &h);
|
||||
if ( width ) *width = int(double(w) / (m_userScaleX*m_mm_to_pix_x));
|
||||
if ( height ) *height = int(double(h) / (m_userScaleY*m_mm_to_pix_y));
|
||||
}
|
||||
|
||||
wxSize wxDC::GetPPI() const
|
||||
{
|
||||
#warning "move this to common code?"
|
||||
return wxSize(int(double(m_mm_to_pix_x) * inches2mm),
|
||||
int(double(m_mm_to_pix_y) * inches2mm));
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Blitting
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
|
||||
wxCoord width, wxCoord height,
|
||||
wxDC *source, wxCoord xsrc, wxCoord ysrc,
|
||||
int rop, bool useMask,
|
||||
wxCoord xsrcMask, wxCoord ysrcMask)
|
||||
{
|
||||
#warning "FIXME"
|
||||
return false;
|
||||
#if 0
|
||||
wxCHECK_MSG( Ok(), false, wxT("invalid dc") );
|
||||
wxCHECK_MSG( source, false, wxT("invalid source dc") );
|
||||
|
||||
// transform the source DC coords to the device ones
|
||||
xsrc = source->LogicalToDeviceX(xsrc);
|
||||
ysrc = source->LogicalToDeviceY(ysrc);
|
||||
|
||||
/* FIXME_MGL: use the mask origin when drawing transparently */
|
||||
if (xsrcMask == -1 && ysrcMask == -1)
|
||||
{
|
||||
xsrcMask = xsrc; ysrcMask = ysrc;
|
||||
}
|
||||
else
|
||||
{
|
||||
xsrcMask = source->LogicalToDeviceX(xsrcMask);
|
||||
ysrcMask = source->LogicalToDeviceY(ysrcMask);
|
||||
}
|
||||
|
||||
CalcBoundingBox(xdest, ydest);
|
||||
CalcBoundingBox(xdest + width, ydest + height);
|
||||
|
||||
/* scale/translate size and position */
|
||||
wxCoord xx = XLOG2DEV(xdest);
|
||||
wxCoord yy = YLOG2DEV(ydest);
|
||||
wxCoord ww = XLOG2DEVREL(width);
|
||||
wxCoord hh = YLOG2DEVREL(height);
|
||||
|
||||
if ( source->m_isMemDC )
|
||||
{
|
||||
wxMemoryDC *memDC = (wxMemoryDC*) source;
|
||||
DoDrawSubBitmap(memDC->GetSelectedObject(), xsrc, ysrc, ww, hh,
|
||||
xdest, ydest, rop, useMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MGLDC->makeCurrent(); // will go away with MGL6.0
|
||||
m_MGLDC->bitBlt(*source->GetMGLDC(),
|
||||
xsrc, ysrc, xsrc + ww, ysrc + hh,
|
||||
xx, yy, LogicalFunctionToMGLRop(rop));
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
|
||||
{
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
|
||||
|
||||
wxCoord w = bmp.GetWidth();
|
||||
wxCoord h = bmp.GetHeight();
|
||||
|
||||
DoDrawSubBitmap(bmp, 0, 0, w, h, x, y, m_logicalFunction, useMask);
|
||||
}
|
||||
|
||||
void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
|
||||
{
|
||||
// VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
|
||||
DoDrawBitmap((const wxBitmap&)icon, x, y, true);
|
||||
}
|
||||
|
||||
void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
|
||||
wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
wxCoord destx, wxCoord desty, int rop, bool useMask)
|
||||
{
|
||||
#if 0
|
||||
wxCHECK_RET( Ok(), wxT("invalid dc") );
|
||||
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
|
||||
wxCoord dx = XLOG2DEV(destx);
|
||||
wxCoord dy = YLOG2DEV(desty);
|
||||
wxCoord dw = XLOG2DEVREL(w);
|
||||
wxCoord dh = YLOG2DEVREL(h);
|
||||
|
||||
m_MGLDC->makeCurrent(); // will go away with MGL6.0
|
||||
|
||||
bool useStretching = ((w != dw) || (h != dh));
|
||||
bool putSection = (w != bmp.GetWidth() || h != bmp.GetHeight());
|
||||
MGL_writeModeType mglRop = (MGL_writeModeType)LogicalFunctionToMGLRop(rop);
|
||||
|
||||
if ( bmp.GetDepth() == 1 )
|
||||
{
|
||||
// Mono bitmaps are handled in special way -- all 1s are drawn in
|
||||
// foreground colours, all 0s in background colour.
|
||||
|
||||
((wxBitmap&)bmp).SetMonoPalette(m_textForegroundColour, m_textBackgroundColour);
|
||||
}
|
||||
|
||||
if ( useMask && bmp.GetMask() )
|
||||
{
|
||||
// Since MGL does not support masks directly (in MGL, mask is handled
|
||||
// in same way as in wxImage, i.e. there is one "key" color), we
|
||||
// simulate masked bitblt in 6 steps (same as in MSW):
|
||||
//
|
||||
// 1. Create a temporary bitmap and copy the destination area into it.
|
||||
// 2. Copy the source area into the temporary bitmap using the
|
||||
// specified logical function.
|
||||
// 3. Set the masked area in the temporary bitmap to BLACK by ANDing
|
||||
// the mask bitmap with the temp bitmap with the foreground colour
|
||||
// set to WHITE and the bg colour set to BLACK.
|
||||
// 4. Set the unmasked area in the destination area to BLACK by
|
||||
// ANDing the mask bitmap with the destination area with the
|
||||
// foreground colour set to BLACK and the background colour set
|
||||
// to WHITE.
|
||||
// 5. OR the temporary bitmap with the destination area.
|
||||
// 6. Delete the temporary bitmap.
|
||||
//
|
||||
// This sequence of operations ensures that the source's transparent
|
||||
// area need not be black, and logical functions are supported.
|
||||
|
||||
wxBitmap *mask = bmp.GetMask()->GetBitmap();
|
||||
|
||||
MGLMemoryDC *temp;
|
||||
|
||||
if ( GetDepth() <= 8 )
|
||||
{
|
||||
temp = new MGLMemoryDC(dw, dh, GetDepth(), NULL);
|
||||
wxDC tempdc;
|
||||
tempdc.SetMGLDC(temp, false);
|
||||
tempdc.SetPalette(m_palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel_format_t pf;
|
||||
m_MGLDC->getPixelFormat(pf);
|
||||
temp = new MGLMemoryDC(dw, dh, GetDepth(), &pf);
|
||||
}
|
||||
|
||||
wxCHECK_RET( temp->isValid(), wxT("cannot create temporary dc") );
|
||||
|
||||
temp->bitBlt(*m_MGLDC, dx, dy, dx + dw, dy + dh, 0, 0, MGL_REPLACE_MODE);
|
||||
|
||||
DoBitBlt(bmp, temp, x, y, w, h, 0, 0, dw, dh, mglRop,
|
||||
useStretching, putSection);
|
||||
|
||||
mask->SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255));
|
||||
DoBitBlt(*mask, temp, x, y, w, h, 0, 0, dw, dh, MGL_R2_MASKSRC,
|
||||
useStretching, putSection);
|
||||
DoBitBlt(*mask, m_MGLDC, x, y, w, h, dx, dy, dw, dh, MGL_R2_MASKNOTSRC,
|
||||
useStretching, putSection);
|
||||
|
||||
m_MGLDC->bitBlt(*temp, 0, 0, dw, dh, dx, dy, MGL_OR_MODE);
|
||||
|
||||
delete temp;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
DoBitBlt(bmp, m_MGLDC, x, y, w, h, dx, dy, dw, dh, mglRop,
|
||||
useStretching, putSection);
|
||||
}
|
||||
#endif
|
||||
}
|
107
src/dfb/dcclient.cpp
Normal file
107
src/dfb/dcclient.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/dcclient.cpp
|
||||
// Purpose: wxWindowDC, wxClientDC and wxPaintDC
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/window.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxWindowDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
||||
|
||||
wxWindowDC::wxWindowDC(wxWindow *win)
|
||||
: wxDC(win ? win->GetDfbSurface() : NULL)
|
||||
{
|
||||
InitForWin(win);
|
||||
}
|
||||
|
||||
void wxWindowDC::InitForWin(wxWindow *win)
|
||||
{
|
||||
wxCHECK_RET( win, _T("invalid window") );
|
||||
|
||||
SetFont(win->GetFont());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// base class for wxClientDC and wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxClientDCBase::wxClientDCBase(wxWindow *win)
|
||||
{
|
||||
wxCHECK_RET( win, _T("invalid window") );
|
||||
|
||||
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) ) )
|
||||
return;
|
||||
|
||||
Init(subsurf);
|
||||
InitForWin(win);
|
||||
|
||||
// offset coordinates to account for subsurface's origin coordinates:
|
||||
SetDeviceOrigin(rect.x, rect.y);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxClientDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
|
||||
|
||||
wxClientDC::~wxClientDC()
|
||||
{
|
||||
// flip to surface so that the changes become visible
|
||||
IDirectFBSurfacePtr surface(GetDirectFBSurface());
|
||||
if ( surface )
|
||||
surface->Flip(surface, NULL, DSFLIP_NONE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
|
||||
#warning "wxPaintDC ctor must respect m_updateRegion"
|
||||
|
||||
wxPaintDC::~wxPaintDC()
|
||||
{
|
||||
// NB: do *not* flip the surface: wxPaintDC is used with EVT_PAINT and the
|
||||
// surface will be flipped for the entire TLW once all children are
|
||||
// repainted
|
||||
}
|
61
src/dfb/dcmemory.cpp
Normal file
61
src/dfb/dcmemory.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/dcmemory.cpp
|
||||
// Purpose: wxMemoryDC implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/dcmemory.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/bitmap.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMemoryDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#warning "FIXME: verify/fix that wxMemoryDC works correctly with mono bitmaps"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
|
||||
|
||||
wxMemoryDC::wxMemoryDC()
|
||||
{
|
||||
}
|
||||
|
||||
wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc))
|
||||
{
|
||||
}
|
||||
|
||||
void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
|
||||
{
|
||||
if ( !bitmap.Ok() )
|
||||
{
|
||||
// select the bitmap out of the DC
|
||||
m_surface = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
// init the DC for drawing to this bitmap
|
||||
Init(bitmap.GetDirectFBSurface());
|
||||
}
|
44
src/dfb/dcscreen.cpp
Normal file
44
src/dfb/dcscreen.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/dcscreen.cpp
|
||||
// Purpose: wxScreenDC implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/dcscreen.h"
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxScreenDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#warning "FIXME: verify that wxScreenDC works in 2nd DirectFB app started"
|
||||
// FIXME: maybe use a subsurface as well?
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxDC)
|
||||
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
Init(wxDfbGetPrimarySurface());
|
||||
}
|
||||
|
||||
#warning "FIXME: does wxScreenDC need Flip call in dtor?"
|
157
src/dfb/evtloop.cpp
Normal file
157
src/dfb/evtloop.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/evtloop.cpp
|
||||
// Purpose: wxEventLoop implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/timer.h"
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
#define TRACE_EVENTS _T("events")
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxEventLoop initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBEventBufferPtr wxEventLoop::ms_buffer;
|
||||
|
||||
wxEventLoop::wxEventLoop()
|
||||
{
|
||||
if ( !ms_buffer )
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxEventLoop::InitBuffer()
|
||||
{
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
DFB_CALL( dfb->CreateEventBuffer(dfb, &ms_buffer) );
|
||||
}
|
||||
|
||||
/* static */
|
||||
IDirectFBEventBufferPtr wxEventLoop::GetDirectFBEventBuffer()
|
||||
{
|
||||
if ( !ms_buffer )
|
||||
InitBuffer();
|
||||
|
||||
return ms_buffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// events dispatch and loop handling
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool wxEventLoop::Dispatch()
|
||||
{
|
||||
wxCHECK_MSG( ms_buffer, false, _T("invalid event buffer") );
|
||||
|
||||
// NB: we don't block indefinitely waiting for an event, but instead
|
||||
// time out after a brief period in order to make sure that
|
||||
// OnNextIteration() will be called frequently enough
|
||||
//
|
||||
// FIXME: call NotifyTimers() from here (and loop) instead?
|
||||
const int TIMEOUT = 100;
|
||||
|
||||
DFBResult ret = ms_buffer->WaitForEventWithTimeout(ms_buffer, 0, TIMEOUT);
|
||||
|
||||
switch ( ret )
|
||||
{
|
||||
case DFB_OK:
|
||||
{
|
||||
wxDFBEvent e;
|
||||
ms_buffer->GetEvent(ms_buffer, &e);
|
||||
HandleDFBEvent(e);
|
||||
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;
|
||||
}
|
||||
|
||||
void wxEventLoop::WakeUp()
|
||||
{
|
||||
wxCHECK_RET( ms_buffer, _T("invalid event buffer") );
|
||||
|
||||
DFB_CALL( ms_buffer->WakeUp(ms_buffer) );
|
||||
}
|
||||
|
||||
void wxEventLoop::OnNextIteration()
|
||||
{
|
||||
#if wxUSE_TIMER
|
||||
// see the comment in Dispatch
|
||||
wxTimer::NotifyTimers();
|
||||
#endif
|
||||
}
|
||||
|
||||
#warning "FIXME: cleanup wxEventLoop::ms_buffer before exiting"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DirectFB -> wxWidgets events translation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxEventLoop::HandleDFBEvent(const wxDFBEvent& event)
|
||||
{
|
||||
switch ( event.GetClass() )
|
||||
{
|
||||
case DFEC_WINDOW:
|
||||
{
|
||||
wxDFBWindowEvent winevent(((const DFBEvent&)event).window);
|
||||
wxTopLevelWindowDFB::HandleDFBWindowEvent(winevent);
|
||||
break;
|
||||
}
|
||||
|
||||
case DFEC_NONE:
|
||||
case DFEC_INPUT:
|
||||
case DFEC_USER:
|
||||
case DFEC_UNIVERSAL:
|
||||
{
|
||||
wxLogTrace(TRACE_EVENTS,
|
||||
_T("ignoring event of unsupported class %i"),
|
||||
(int)event.GetClass());
|
||||
}
|
||||
}
|
||||
}
|
275
src/dfb/font.cpp
Normal file
275
src/dfb/font.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/font.cpp
|
||||
// Purpose: wxFont implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/font.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// FIXME: for now, always use single font
|
||||
static IDirectFBFontPtr gs_font = NULL;
|
||||
static unsigned gs_fontRefCnt = 0;
|
||||
|
||||
class wxFontRefData : public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxFontRefData(int size = wxDEFAULT,
|
||||
int family = wxDEFAULT,
|
||||
int style = wxDEFAULT,
|
||||
int weight = wxDEFAULT,
|
||||
bool underlined = false,
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
if ( family == wxDEFAULT )
|
||||
family = wxSWISS;
|
||||
if ( style == wxDEFAULT )
|
||||
style = wxNORMAL;
|
||||
if ( weight == wxDEFAULT )
|
||||
weight = wxNORMAL;
|
||||
if ( size == wxDEFAULT )
|
||||
size = 12;
|
||||
|
||||
m_info.family = (wxFontFamily)family;
|
||||
m_info.faceName = faceName;
|
||||
m_info.style = (wxFontStyle)style;
|
||||
m_info.weight = (wxFontWeight)weight;
|
||||
m_info.pointSize = size;
|
||||
m_info.underlined = underlined;
|
||||
m_info.encoding = encoding;
|
||||
|
||||
// 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) ) )
|
||||
gs_font = f;
|
||||
}
|
||||
if ( gs_font ) // the above may fail
|
||||
{
|
||||
gs_fontRefCnt++;
|
||||
m_font = gs_font;
|
||||
}
|
||||
}
|
||||
|
||||
wxFontRefData(const wxFontRefData& data)
|
||||
{
|
||||
m_info = data.m_info;
|
||||
m_font = data.m_font;
|
||||
}
|
||||
|
||||
~wxFontRefData()
|
||||
{
|
||||
if ( m_font )
|
||||
{
|
||||
m_font.Reset();
|
||||
// FIXME
|
||||
if ( --gs_fontRefCnt == 0 )
|
||||
gs_font = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
wxNativeFontInfo m_info;
|
||||
IDirectFBFontPtr m_font;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
|
||||
bool wxFont::Create(const wxNativeFontInfo& info)
|
||||
{
|
||||
return Create(info.pointSize, info.family, info.style, info.weight,
|
||||
info.underlined, info.faceName, info.encoding);
|
||||
}
|
||||
|
||||
bool wxFont::Create(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, face, encoding);
|
||||
return true;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxFont::CreateRefData() const
|
||||
{
|
||||
return new wxFontRefData;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
|
||||
{
|
||||
return new wxFontRefData(*(wxFontRefData *)data);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBFontPtr wxFont::GetDirectFBFont() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_font;
|
||||
}
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.pointSize;
|
||||
}
|
||||
|
||||
wxString wxFont::GetFaceName() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.faceName;
|
||||
}
|
||||
|
||||
int wxFont::GetFamily() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.family;
|
||||
}
|
||||
|
||||
int wxFont::GetStyle() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.style;
|
||||
}
|
||||
|
||||
int wxFont::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.weight;
|
||||
}
|
||||
|
||||
bool wxFont::GetUnderlined() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.underlined;
|
||||
}
|
||||
|
||||
|
||||
wxFontEncoding wxFont::GetEncoding() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_info.encoding;
|
||||
}
|
||||
|
||||
bool wxFont::IsFixedWidth() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
|
||||
|
||||
return true; // FIXME_DFB
|
||||
}
|
||||
|
||||
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||
|
||||
return &(M_FONTDATA->m_info);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// change font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.pointSize = pointSize;
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(int family)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.family = (wxFontFamily)family;
|
||||
}
|
||||
|
||||
void wxFont::SetStyle(int style)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.style = (wxFontStyle)style;
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.weight = (wxFontWeight)weight;
|
||||
}
|
||||
|
||||
bool wxFont::SetFaceName(const wxString& faceName)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.faceName = faceName;
|
||||
|
||||
return wxFontBase::SetFaceName(faceName);
|
||||
}
|
||||
|
||||
void wxFont::SetUnderlined(bool underlined)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.underlined = underlined;
|
||||
}
|
||||
|
||||
void wxFont::SetEncoding(wxFontEncoding encoding)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->m_info.encoding = encoding;
|
||||
}
|
36
src/dfb/fontenum.cpp
Normal file
36
src/dfb/fontenum.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/fontenum.cpp
|
||||
// Purpose: wxFontEnumerator class
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// 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/fontenum.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontEnumerator
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding WXUNUSED(encoding),
|
||||
bool WXUNUSED(fixedWidthOnly))
|
||||
{
|
||||
// FIXME_DFB
|
||||
OnFacename(_T("Default"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFontEnumerator::EnumerateEncodings(const wxString& WXUNUSED(family))
|
||||
{
|
||||
// FIXME_DFB
|
||||
return false;
|
||||
}
|
48
src/dfb/ifacehelpers.cpp
Normal file
48
src/dfb/ifacehelpers.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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);
|
||||
}
|
205
src/dfb/pen.cpp
Normal file
205
src/dfb/pen.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/pen.cpp
|
||||
// Purpose: wxPen class implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-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/pen.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/colour.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPen
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxPenRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxPenRefData(const wxColour& clr = wxNullColour, int style = wxSOLID)
|
||||
{
|
||||
m_colour = clr;
|
||||
SetStyle(style);
|
||||
}
|
||||
|
||||
wxPenRefData(const wxPenRefData& data)
|
||||
: m_style(data.m_style), m_colour(data.m_colour) {}
|
||||
|
||||
void SetStyle(int style)
|
||||
{
|
||||
if ( m_style != wxSOLID && m_style == wxTRANSPARENT )
|
||||
{
|
||||
wxFAIL_MSG( _T("only wxSOLID and wxTRANSPARENT styles are supported") );
|
||||
style = wxSOLID;
|
||||
}
|
||||
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
int m_style;
|
||||
wxColour m_colour;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define M_PENDATA ((wxPenRefData *)m_refData)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
||||
|
||||
wxPen::wxPen(const wxColour &colour, int width, int style)
|
||||
{
|
||||
wxASSERT_MSG( width <= 1, _T("only width=0,1 are supported") );
|
||||
|
||||
m_refData = new wxPenRefData(colour, style);
|
||||
}
|
||||
|
||||
wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
|
||||
{
|
||||
wxFAIL_MSG( _T("stipple pens not supported") );
|
||||
|
||||
m_refData = new wxPenRefData();
|
||||
}
|
||||
|
||||
bool wxPen::operator==(const wxPen& pen) const
|
||||
{
|
||||
#warning "this is incorrect (MGL too)"
|
||||
return m_refData == pen.m_refData;
|
||||
}
|
||||
|
||||
void wxPen::SetColour(const wxColour &colour)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_PENDATA->m_colour = colour;
|
||||
}
|
||||
|
||||
void wxPen::SetDashes(int WXUNUSED(number_of_dashes), const wxDash *WXUNUSED(dash))
|
||||
{
|
||||
wxFAIL_MSG( _T("SetDashes not implemented") );
|
||||
}
|
||||
|
||||
void wxPen::SetColour(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_PENDATA->m_colour.Set(red, green, blue);
|
||||
}
|
||||
|
||||
void wxPen::SetCap(int WXUNUSED(capStyle))
|
||||
{
|
||||
wxFAIL_MSG( _T("SetCap not implemented") );
|
||||
}
|
||||
|
||||
void wxPen::SetJoin(int WXUNUSED(joinStyle))
|
||||
{
|
||||
wxFAIL_MSG( _T("SetJoin not implemented") );
|
||||
}
|
||||
|
||||
void wxPen::SetStyle(int style)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_PENDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple))
|
||||
{
|
||||
wxFAIL_MSG( _T("SetStipple not implemented") );
|
||||
}
|
||||
|
||||
void wxPen::SetWidth(int width)
|
||||
{
|
||||
wxASSERT_MSG( width <= 1, _T("only width=0,1 are implemented") );
|
||||
}
|
||||
|
||||
int wxPen::GetDashes(wxDash **ptr) const
|
||||
{
|
||||
wxFAIL_MSG( _T("GetDashes not implemented") );
|
||||
|
||||
*ptr = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxPen::GetDashCount() const
|
||||
{
|
||||
wxFAIL_MSG( _T("GetDashCount not implemented") );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxDash* wxPen::GetDash() const
|
||||
{
|
||||
wxFAIL_MSG( _T("GetDash not implemented") );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int wxPen::GetCap() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||
|
||||
wxFAIL_MSG( _T("GetCap not implemented") );
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxPen::GetJoin() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||
|
||||
wxFAIL_MSG( _T("GetJoin not implemented") );
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxPen::GetStyle() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||
|
||||
return M_PENDATA->m_style;
|
||||
}
|
||||
|
||||
int wxPen::GetWidth() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
wxColour &wxPen::GetColour() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
|
||||
|
||||
return M_PENDATA->m_colour;
|
||||
}
|
||||
|
||||
wxBitmap *wxPen::GetStipple() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") );
|
||||
|
||||
wxFAIL_MSG( _T("GetStipple not implemented") );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool wxPen::Ok() const
|
||||
{
|
||||
return ((m_refData) && M_PENDATA->m_colour.Ok());
|
||||
}
|
||||
|
||||
wxObjectRefData *wxPen::CreateRefData() const
|
||||
{
|
||||
return new wxPenRefData;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
|
||||
{
|
||||
return new wxPenRefData(*(wxPenRefData *)data);
|
||||
}
|
275
src/dfb/region.cpp
Normal file
275
src/dfb/region.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/mgl/region.cpp
|
||||
// Purpose: Region handling for wxWidgets/DFB
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// 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/region.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxRegionRefData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxRegionRefData : public wxGDIRefData
|
||||
{
|
||||
public:
|
||||
wxRegionRefData() {}
|
||||
wxRegionRefData(const wxRect& rect) : m_rect(rect) {}
|
||||
wxRegionRefData(const wxRegionRefData& data) : m_rect(data.m_rect) {}
|
||||
|
||||
~wxRegionRefData() {}
|
||||
|
||||
wxRect m_rect;
|
||||
};
|
||||
|
||||
#define M_REGION_OF(r) ((wxRegionRefData*)((r).m_refData))
|
||||
#define M_REGION M_REGION_OF(*this)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxRegion
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxObjectRefData *wxRegion::CreateRefData() const
|
||||
{
|
||||
return new wxRegionRefData;
|
||||
}
|
||||
|
||||
wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
|
||||
{
|
||||
return new wxRegionRefData(*(wxRegionRefData *)data);
|
||||
}
|
||||
|
||||
wxRegion::wxRegion()
|
||||
{
|
||||
m_refData = NULL;
|
||||
}
|
||||
|
||||
wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
{
|
||||
m_refData = new wxRegionRefData(wxRect(x, y, w, h));
|
||||
}
|
||||
|
||||
wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
|
||||
{
|
||||
m_refData = new wxRegionRefData(wxRect(topLeft, bottomRight));
|
||||
}
|
||||
|
||||
wxRegion::wxRegion(const wxRect& r)
|
||||
{
|
||||
m_refData = new wxRegionRefData(r);
|
||||
}
|
||||
|
||||
wxRegion::~wxRegion()
|
||||
{
|
||||
// m_refData unrefed in ~wxObject
|
||||
}
|
||||
|
||||
bool wxRegion::operator==(const wxRegion& region) const
|
||||
{
|
||||
if ( m_refData != region.m_refData )
|
||||
return false;
|
||||
|
||||
if ( !Ok() )
|
||||
return true; // both invalid
|
||||
|
||||
return M_REGION->m_rect == M_REGION_OF(region)->m_rect;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Information about the region
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
|
||||
{
|
||||
wxRect r = GetBox();
|
||||
x = r.GetX();
|
||||
y = r.GetY();
|
||||
w = r.GetWidth();
|
||||
h = r.GetHeight();
|
||||
}
|
||||
|
||||
wxRect wxRegion::GetBox() const
|
||||
{
|
||||
if (m_refData)
|
||||
return M_REGION->m_rect;
|
||||
else
|
||||
return wxRect();
|
||||
}
|
||||
|
||||
bool wxRegion::Empty() const
|
||||
{
|
||||
if (!m_refData)
|
||||
return true;
|
||||
|
||||
return M_REGION->m_rect.IsEmpty();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Modifications
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxRegion::Clear()
|
||||
{
|
||||
UnRef();
|
||||
}
|
||||
|
||||
bool wxRegion::Offset(wxCoord x, wxCoord y)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_REGION->m_rect.Offset(x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxRegion::Union(const wxRect& rect)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
if ( M_REGION->m_rect.Inside(rect) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( rect.Inside(M_REGION->m_rect) )
|
||||
{
|
||||
M_REGION->m_rect = rect;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( _T("only rectangular regions are supported") );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxRegion::Union(const wxRegion& region)
|
||||
{
|
||||
wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
|
||||
return Union(M_REGION_OF(region)->m_rect);
|
||||
}
|
||||
|
||||
bool wxRegion::Intersect(const wxRect& rect)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_REGION->m_rect.Intersect(rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxRegion::Intersect(const wxRegion& region)
|
||||
{
|
||||
wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
|
||||
return Intersect(M_REGION_OF(region)->m_rect);
|
||||
}
|
||||
|
||||
bool wxRegion::Subtract(const wxRect& rect)
|
||||
{
|
||||
wxCHECK_MSG( Ok(), false, _T("invalid region") );
|
||||
|
||||
if ( rect.Inside(M_REGION->m_rect) )
|
||||
{
|
||||
// subtracted rectangle contains this one, so the result is empty
|
||||
// rectangle
|
||||
M_REGION->m_rect = wxRect();
|
||||
return true;
|
||||
}
|
||||
else if ( !M_REGION->m_rect.Intersects(rect) )
|
||||
{
|
||||
// the rectangles are disjoint, so substracting has no effect
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( _T("only rectangular regions implemented") );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxRegion::Subtract(const wxRegion& region)
|
||||
{
|
||||
wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
|
||||
return Subtract(M_REGION_OF(region)->m_rect);
|
||||
}
|
||||
|
||||
bool wxRegion::Xor(const wxRect& rect)
|
||||
{
|
||||
wxFAIL_MSG( _T("Xor not implemented") );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxRegion::Xor(const wxRegion& region)
|
||||
{
|
||||
wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
|
||||
return Xor(M_REGION_OF(region)->m_rect);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Tests
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") );
|
||||
|
||||
if (M_REGION->m_rect.Inside(x, y))
|
||||
return wxInRegion;
|
||||
else
|
||||
return wxOutRegion;
|
||||
}
|
||||
|
||||
wxRegionContain wxRegion::Contains(const wxRect& rect) const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") );
|
||||
|
||||
// 1) is the rectangle entirely covered by the region?
|
||||
if (M_REGION->m_rect.Inside(rect))
|
||||
return wxInRegion;
|
||||
|
||||
// 2) is the rectangle completely outside the region?
|
||||
if (!M_REGION->m_rect.Intersects(rect))
|
||||
return wxOutRegion;
|
||||
|
||||
// 3) neither case happened => it is partially covered:
|
||||
return wxPartRegion;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxRegionIterator
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxRegionIterator::Reset(const wxRegion& region)
|
||||
{
|
||||
wxRegionRefData *d = M_REGION_OF(region);
|
||||
m_rect = d ? d->m_rect : wxRect();
|
||||
}
|
||||
|
||||
wxRegionIterator& wxRegionIterator::operator++()
|
||||
{
|
||||
// there's only one rectangle in the iterator, so iterating always
|
||||
// reaches the end:
|
||||
Reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxRegionIterator wxRegionIterator::operator++(int)
|
||||
{
|
||||
wxRegionIterator tmp = *this;
|
||||
|
||||
// there's only one rectangle in the iterator, so iterating always
|
||||
// reaches the end:
|
||||
Reset();
|
||||
|
||||
return tmp;
|
||||
}
|
108
src/dfb/settings.cpp
Normal file
108
src/dfb/settings.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/settings.cpp
|
||||
// Purpose: wxSystemSettings implementation
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// 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/settings.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/colour.h"
|
||||
#include "wx/font.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
|
||||
wxColour wxSystemSettingsNative::GetColour(wxSystemColour WXUNUSED(index))
|
||||
{
|
||||
// not implemented, the mean is in wxUniversal
|
||||
return wxColour(0,0,0);
|
||||
}
|
||||
|
||||
wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case wxSYS_OEM_FIXED_FONT:
|
||||
case wxSYS_ANSI_FIXED_FONT:
|
||||
case wxSYS_SYSTEM_FIXED_FONT:
|
||||
{
|
||||
// FIXME_DFB
|
||||
return wxFont(12,
|
||||
wxFONTFAMILY_TELETYPE,
|
||||
wxFONTSTYLE_NORMAL,
|
||||
wxFONTWEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
case wxSYS_ANSI_VAR_FONT:
|
||||
case wxSYS_SYSTEM_FONT:
|
||||
case wxSYS_DEVICE_DEFAULT_FONT:
|
||||
case wxSYS_DEFAULT_GUI_FONT:
|
||||
{
|
||||
// FIXME_DFB
|
||||
return wxFont(12,
|
||||
wxFONTFAMILY_DEFAULT,
|
||||
wxFONTSTYLE_NORMAL,
|
||||
wxFONTWEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( _T("unknown font type") );
|
||||
return wxNullFont;
|
||||
}
|
||||
}
|
||||
|
||||
int wxSystemSettingsNative::GetMetric(wxSystemMetric index,
|
||||
wxWindow* WXUNUSED(win))
|
||||
{
|
||||
int val;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case wxSYS_SCREEN_X:
|
||||
wxDisplaySize(&val, NULL);
|
||||
return val;
|
||||
case wxSYS_SCREEN_Y:
|
||||
wxDisplaySize(NULL, &val);
|
||||
return val;
|
||||
|
||||
#warning "FIXME this"
|
||||
#if 0
|
||||
case wxSYS_VSCROLL_X:
|
||||
case wxSYS_HSCROLL_Y:
|
||||
return 15;
|
||||
#endif
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( _T("unsupported metric") );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case wxSYS_CAN_ICONIZE_FRAME:
|
||||
case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
|
||||
case wxSYS_TABLET_PRESENT:
|
||||
return false;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( _T("unknown feature") );
|
||||
return false;
|
||||
}
|
||||
}
|
457
src/dfb/toplevel.cpp
Normal file
457
src/dfb/toplevel.cpp
Normal file
@@ -0,0 +1,457 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/toplevel.cpp
|
||||
// Purpose: Top level window, abstraction of wxFrame and wxDialog
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/toplevel.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/dynarray.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/evtloop.h"
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
#define TRACE_EVENTS _T("events")
|
||||
#define TRACE_PAINT _T("paint")
|
||||
|
||||
// ============================================================================
|
||||
// globals
|
||||
// ============================================================================
|
||||
|
||||
// mapping of DirectFB windows to wxTLWs:
|
||||
WX_DECLARE_HASH_MAP(DFBWindowID, wxTopLevelWindowDFB*,
|
||||
wxIntegerHash, wxIntegerEqual,
|
||||
wxDfbWindowsMap);
|
||||
static wxDfbWindowsMap gs_dfbWindowsMap;
|
||||
|
||||
// ============================================================================
|
||||
// helpers
|
||||
// ============================================================================
|
||||
|
||||
struct wxDfbPaintRequest
|
||||
{
|
||||
wxDfbPaintRequest(const wxRect& rect, bool eraseBackground)
|
||||
: m_rect(rect), m_eraseBackground(eraseBackground) {}
|
||||
wxDfbPaintRequest(const wxDfbPaintRequest& r)
|
||||
: m_rect(r.m_rect), m_eraseBackground(r.m_eraseBackground) {}
|
||||
|
||||
wxRect m_rect;
|
||||
bool m_eraseBackground;
|
||||
};
|
||||
|
||||
WX_DEFINE_ARRAY_PTR(wxDfbPaintRequest*, wxDfbQueuedPaintRequests);
|
||||
|
||||
// ============================================================================
|
||||
// wxTopLevelWindowDFB
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation & destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowDFB::Init()
|
||||
{
|
||||
m_isShown = false;
|
||||
m_isMaximized = false;
|
||||
m_fsIsShowing = false;
|
||||
m_sizeSet = false;
|
||||
m_opacity = 255;
|
||||
m_toPaint = new wxDfbQueuedPaintRequests;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowDFB::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& posOrig,
|
||||
const wxSize& sizeOrig,
|
||||
long style,
|
||||
const wxString &name)
|
||||
{
|
||||
m_tlw = this;
|
||||
|
||||
// always create a frame of some reasonable, even if arbitrary, size (at
|
||||
// least for MSW compatibility)
|
||||
wxSize size(sizeOrig);
|
||||
if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord )
|
||||
{
|
||||
wxSize sizeDefault = GetDefaultSize();
|
||||
if ( size.x == wxDefaultCoord )
|
||||
size.x = sizeDefault.x;
|
||||
if ( size.y == wxDefaultCoord )
|
||||
size.y = sizeDefault.y;
|
||||
}
|
||||
|
||||
wxPoint pos(posOrig);
|
||||
if ( pos.x == wxDefaultCoord )
|
||||
pos.x = 0;
|
||||
if ( pos.y == wxDefaultCoord )
|
||||
pos.y = 0;
|
||||
|
||||
// create DirectFB window:
|
||||
IDirectFBDisplayLayerPtr layer = wxDfbGetDisplayLayer();
|
||||
wxCHECK_MSG( layer, false, _T("no display layer") );
|
||||
|
||||
DFBWindowDescription desc;
|
||||
desc.flags = (DFBWindowDescriptionFlags)
|
||||
(DWDESC_CAPS |
|
||||
DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY);
|
||||
desc.caps = DWCAPS_DOUBLEBUFFER;
|
||||
desc.posx = pos.x;
|
||||
desc.posy = pos.y;
|
||||
desc.width = size.x;
|
||||
desc.height = size.y;
|
||||
if ( !DFB_CALL( layer->CreateWindow(layer, &desc, &m_dfbwin) ) )
|
||||
return false;
|
||||
|
||||
// add the new TLW to DFBWindowID->wxTLW map:
|
||||
DFBWindowID winid;
|
||||
if ( !DFB_CALL( m_dfbwin->GetID(m_dfbwin, &winid) ) )
|
||||
return false;
|
||||
gs_dfbWindowsMap[winid] = this;
|
||||
|
||||
// TLWs are created initially hidden:
|
||||
if ( !DFB_CALL( m_dfbwin->SetOpacity(m_dfbwin, 0) ) )
|
||||
return false;
|
||||
|
||||
wxWindow::Create(NULL, id, pos, size, style, name);
|
||||
|
||||
SetParent(parent);
|
||||
if ( parent )
|
||||
parent->AddChild(this);
|
||||
|
||||
wxTopLevelWindows.Append(this);
|
||||
m_title = title;
|
||||
|
||||
if ( style & (wxSTAY_ON_TOP | wxPOPUP_WINDOW) )
|
||||
{
|
||||
DFB_CALL( m_dfbwin->SetStackingClass(m_dfbwin, DWSC_UPPER) );
|
||||
}
|
||||
|
||||
// direct events in this window to the global event buffer:
|
||||
DFB_CALL( m_dfbwin->AttachEventBuffer(
|
||||
m_dfbwin, wxEventLoop::GetDirectFBEventBuffer()) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxTopLevelWindowDFB::~wxTopLevelWindowDFB()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
if ( wxTheApp->GetTopWindow() == this )
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
|
||||
if ( wxTopLevelWindows.empty() && wxTheApp->GetExitOnFrameDelete() )
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
|
||||
WX_CLEAR_ARRAY(*m_toPaint);
|
||||
wxDELETE(m_toPaint);
|
||||
|
||||
// remove the TLW from DFBWindowID->wxTLW map:
|
||||
DFBWindowID winid;
|
||||
if ( DFB_CALL( m_dfbwin->GetID(m_dfbwin, &winid) ) )
|
||||
gs_dfbWindowsMap.erase(winid);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// window size & position
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowDFB::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
DFB_CALL( m_dfbwin->GetPosition(m_dfbwin, x, y) );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
DFB_CALL( m_dfbwin->GetSize(m_dfbwin, width, height) );
|
||||
}
|
||||
|
||||
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) );
|
||||
}
|
||||
|
||||
wxSize cursize = GetSize();
|
||||
if ( cursize.x != width || cursize.y != height )
|
||||
{
|
||||
DFB_CALL( m_dfbwin->Resize(m_dfbwin, width, height) );
|
||||
// we must repaint the window after it changed size:
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// showing and hiding
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#warning "FIXME: the rest of this file is almost same as for MGL, merge it"
|
||||
bool wxTopLevelWindowDFB::ShowFullScreen(bool show, long style)
|
||||
{
|
||||
if (show == m_fsIsShowing) return false; // return what?
|
||||
|
||||
m_fsIsShowing = show;
|
||||
|
||||
if (show)
|
||||
{
|
||||
m_fsSaveStyle = m_windowStyle;
|
||||
m_fsSaveFlag = style;
|
||||
GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y);
|
||||
GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height);
|
||||
|
||||
if ( style & wxFULLSCREEN_NOCAPTION )
|
||||
m_windowStyle &= ~wxCAPTION;
|
||||
if ( style & wxFULLSCREEN_NOBORDER )
|
||||
m_windowStyle = wxSIMPLE_BORDER;
|
||||
|
||||
int x, y;
|
||||
wxDisplaySize(&x, &y);
|
||||
SetSize(0, 0, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_windowStyle = m_fsSaveStyle;
|
||||
SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
|
||||
m_fsSaveFrame.width, m_fsSaveFrame.height);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowDFB::Show(bool show)
|
||||
{
|
||||
if ( !wxTopLevelWindowBase::Show(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) );
|
||||
|
||||
// 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)
|
||||
if ( !m_sizeSet )
|
||||
{
|
||||
m_sizeSet = true;
|
||||
wxSizeEvent event(GetSize(), GetId());
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
// FIXME_DFB: do this at all?
|
||||
if ( show && AcceptsFocus() )
|
||||
SetFocus();
|
||||
// FIXME_DFB -- don't do this for popup windows?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowDFB::SetTransparent(wxByte alpha)
|
||||
{
|
||||
if ( IsShown() )
|
||||
{
|
||||
if ( !DFB_CALL( m_dfbwin->SetOpacity(m_dfbwin, alpha) ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
m_opacity = alpha;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// maximize, minimize etc.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowDFB::Maximize(bool maximize)
|
||||
{
|
||||
int x, y, w, h;
|
||||
wxClientDisplayRect(&x, &y, &w, &h);
|
||||
|
||||
if ( maximize && !m_isMaximized )
|
||||
{
|
||||
m_isMaximized = true;
|
||||
|
||||
GetPosition(&m_savedFrame.x, &m_savedFrame.y);
|
||||
GetSize(&m_savedFrame.width, &m_savedFrame.height);
|
||||
|
||||
SetSize(x, y, w, h);
|
||||
}
|
||||
else if ( !maximize && m_isMaximized )
|
||||
{
|
||||
m_isMaximized = false;
|
||||
SetSize(m_savedFrame.x, m_savedFrame.y,
|
||||
m_savedFrame.width, m_savedFrame.height);
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowDFB::IsMaximized() const
|
||||
{
|
||||
return m_isMaximized;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::Restore()
|
||||
{
|
||||
if ( IsMaximized() )
|
||||
{
|
||||
Maximize(false);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::Iconize(bool WXUNUSED(iconize))
|
||||
{
|
||||
wxFAIL_MSG(wxT("Iconize not supported under wxDFB"));
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowDFB::IsIconized() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// surfaces and painting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBSurfacePtr wxTopLevelWindowDFB::ObtainDfbSurface() const
|
||||
{
|
||||
IDirectFBSurfacePtr surface;
|
||||
DFB_CALL( m_dfbwin->GetSurface(m_dfbwin, &surface) );
|
||||
return surface;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::HandleQueuedPaintRequests()
|
||||
{
|
||||
wxDfbQueuedPaintRequests& toPaint = *m_toPaint;
|
||||
if ( toPaint.empty() )
|
||||
return; // nothing to do
|
||||
|
||||
// process queued paint requests:
|
||||
wxRect winRect(wxPoint(0, 0), GetSize());
|
||||
wxRect paintedRect;
|
||||
|
||||
size_t cnt = toPaint.size();
|
||||
for ( size_t i = 0; i < cnt; ++i )
|
||||
{
|
||||
const wxDfbPaintRequest& request = *toPaint[i];
|
||||
|
||||
wxRect clipped(request.m_rect);
|
||||
|
||||
wxLogTrace(TRACE_PAINT,
|
||||
_T("%p ('%s'): processing paint request [x=%i,y=%i,w=%i,h=%i]"),
|
||||
this, GetName().c_str(),
|
||||
clipped.x, clipped.y, clipped.width, clipped.height);
|
||||
|
||||
clipped.Intersect(winRect);
|
||||
if ( clipped.IsEmpty() )
|
||||
continue; // nothing to refresh
|
||||
|
||||
PaintWindow(clipped, request.m_eraseBackground);
|
||||
|
||||
// remember rectangle covering all repainted areas:
|
||||
if ( paintedRect.IsEmpty() )
|
||||
paintedRect = clipped;
|
||||
else
|
||||
paintedRect.Union(clipped);
|
||||
}
|
||||
|
||||
WX_CLEAR_ARRAY(toPaint);
|
||||
|
||||
if ( paintedRect.IsEmpty() )
|
||||
return; // no painting occurred, no need to flip
|
||||
|
||||
// flip the surface to make the changes visible:
|
||||
DFBRegion r = {paintedRect.GetLeft(), paintedRect.GetTop(),
|
||||
paintedRect.GetRight(), paintedRect.GetBottom()};
|
||||
DFBRegion *rptr = (winRect == paintedRect) ? NULL : &r;
|
||||
|
||||
IDirectFBSurfacePtr surface(GetDfbSurface());
|
||||
DFB_CALL( surface->Flip(surface, rptr, DSFLIP_NONE) );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::DoRefreshRect(const wxRect& rect, bool eraseBack)
|
||||
{
|
||||
// defer paiting until idle time or until Update() is called:
|
||||
m_toPaint->push_back(new wxDfbPaintRequest(rect, eraseBack));
|
||||
}
|
||||
|
||||
void wxTopLevelWindowDFB::Update()
|
||||
{
|
||||
HandleQueuedPaintRequests();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// events handling
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
void wxTopLevelWindowDFB::HandleDFBWindowEvent(const wxDFBWindowEvent& event_)
|
||||
{
|
||||
const DFBWindowEvent& event = event_;
|
||||
|
||||
if ( gs_dfbWindowsMap.find(event.window_id) == gs_dfbWindowsMap.end() )
|
||||
{
|
||||
wxLogTrace(TRACE_EVENTS,
|
||||
_T("received event for unknown DirectFB window, ignoring"));
|
||||
return;
|
||||
}
|
||||
|
||||
wxTopLevelWindowDFB *tlw = gs_dfbWindowsMap[event.window_id];
|
||||
wxWindow *recipient = NULL;
|
||||
void (wxWindow::*handlerFunc)(const wxDFBWindowEvent&) = NULL;
|
||||
|
||||
switch ( event.type )
|
||||
{
|
||||
case DWET_KEYDOWN:
|
||||
case DWET_KEYUP:
|
||||
{
|
||||
recipient = wxWindow::FindFocus();
|
||||
handlerFunc = &wxWindowDFB::HandleKeyEvent;
|
||||
break;
|
||||
}
|
||||
|
||||
case DWET_NONE:
|
||||
case DWET_ALL:
|
||||
{
|
||||
wxFAIL_MSG( _T("invalid event type") );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !recipient )
|
||||
{
|
||||
wxLogTrace(TRACE_EVENTS, _T("ignoring event: no recipient window"));
|
||||
return;
|
||||
}
|
||||
|
||||
wxCHECK_RET( recipient && recipient->GetTLW() == tlw,
|
||||
_T("event recipient not in TLW which received the event") );
|
||||
|
||||
// process the event:
|
||||
(recipient->*handlerFunc)(event_);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// idle events processing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowDFB::OnInternalIdle()
|
||||
{
|
||||
wxTopLevelWindowBase::OnInternalIdle();
|
||||
HandleQueuedPaintRequests();
|
||||
}
|
200
src/dfb/utils.cpp
Normal file
200
src/dfb/utils.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/utils.cpp
|
||||
// Purpose: Miscellaneous utility functions and classes
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-08-08
|
||||
// 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/utils.h"
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/unix/execute.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
#include <directfb_version.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// toolkit info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION;
|
||||
if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION;
|
||||
|
||||
return wxPORT_DFB;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// display characteristics
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxColourDisplay()
|
||||
{
|
||||
#warning "FIXME: wxColourDisplay"
|
||||
return true;
|
||||
}
|
||||
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
return wxTheApp->GetDisplayMode().bpp;
|
||||
}
|
||||
|
||||
void wxDisplaySize(int *width, int *height)
|
||||
{
|
||||
wxVideoMode mode(wxTheApp->GetDisplayMode());
|
||||
if ( width ) *width = mode.w;
|
||||
if ( height ) *height = mode.h;
|
||||
}
|
||||
|
||||
void wxDisplaySizeMM(int *width, int *height)
|
||||
{
|
||||
// FIXME: there's no way to get physical resolution using the DirectDB
|
||||
// API, we hardcode a commonly used value of 72dpi
|
||||
#define DPI 72.0
|
||||
#define PX_TO_MM(x) (int(((x) / DPI) * inches2mm))
|
||||
|
||||
wxDisplaySize(width, height);
|
||||
if ( width ) *width = PX_TO_MM(*width);
|
||||
if ( height ) *height = PX_TO_MM(*height);
|
||||
|
||||
#undef DPI
|
||||
#undef PX_TO_MM
|
||||
}
|
||||
|
||||
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||
{
|
||||
// return desktop dimensions minus any panels, menus, trays:
|
||||
if (x) *x = 0;
|
||||
if (y) *y = 0;
|
||||
wxDisplaySize(width, height);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// surface manipulation helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IDirectFBSurfacePtr wxDfbCloneSurface(const IDirectFBSurfacePtr& s,
|
||||
wxDfbCloneSurfaceMode mode)
|
||||
{
|
||||
if ( !s )
|
||||
return NULL;
|
||||
|
||||
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);
|
||||
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
|
||||
IDirectFBSurfacePtr snew;
|
||||
if ( !DFB_CALL( dfb->CreateSurface(dfb, &desc, &snew) ) )
|
||||
return NULL;
|
||||
|
||||
IDirectFBPalettePtr pal;
|
||||
if ( s->GetPalette(s, &pal) == DFB_OK )
|
||||
{
|
||||
if ( !DFB_CALL( snew->SetPalette(snew, pal) ) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( mode == wxDfbCloneSurface_CopyPixels )
|
||||
{
|
||||
if ( !DFB_CALL( snew->SetBlittingFlags(snew, DSBLIT_NOFX) ) )
|
||||
return NULL;
|
||||
if ( !DFB_CALL( snew->Blit(snew, s, NULL, 0, 0) ) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return snew;
|
||||
}
|
||||
|
||||
int wxDfbGetSurfaceDepth(const IDirectFBSurfacePtr& s)
|
||||
{
|
||||
wxCHECK_MSG( s, -1, _T("invalid surface") );
|
||||
|
||||
DFBSurfacePixelFormat format = DSPF_UNKNOWN;
|
||||
|
||||
if ( !DFB_CALL( s->GetPixelFormat(s, &format) ) )
|
||||
return -1;
|
||||
|
||||
return DFB_BITS_PER_PIXEL(format);
|
||||
}
|
||||
|
||||
IDirectFBDisplayLayerPtr wxDfbGetDisplayLayer()
|
||||
{
|
||||
IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface());
|
||||
|
||||
IDirectFBDisplayLayerPtr layer;
|
||||
if ( !DFB_CALL( dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer) ) )
|
||||
return NULL;
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr wxDfbGetPrimarySurface()
|
||||
{
|
||||
IDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
IDirectFBSurfacePtr surface;
|
||||
DFB_CALL( layer->GetSurface(layer, &surface) );
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// mouse
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxGetMousePosition(int *x, int *y)
|
||||
{
|
||||
IDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
|
||||
DFB_CALL( layer->GetCursorPosition(layer, x, y) );
|
||||
}
|
||||
|
||||
wxPoint wxGetMousePosition()
|
||||
{
|
||||
wxPoint pt;
|
||||
wxGetMousePosition(&pt.x, &pt.y);
|
||||
return pt;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// keyboard
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool wxGetKeyState(wxKeyCode key)
|
||||
{
|
||||
wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON,
|
||||
_T("can't use wxGetKeyState() for mouse buttons"));
|
||||
|
||||
return false; // FIXME
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// misc.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void wxBell()
|
||||
{
|
||||
}
|
||||
|
||||
int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
|
||||
{
|
||||
wxFAIL_MSG( _T("wxAddProcessCallback not implemented") );
|
||||
return 0;
|
||||
}
|
993
src/dfb/window.cpp
Normal file
993
src/dfb/window.cpp
Normal file
@@ -0,0 +1,993 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/dfb/window.cpp
|
||||
// Purpose: wxWindow
|
||||
// Author: Vaclav Slavik
|
||||
// (based on GTK, MSW, MGL implementations)
|
||||
// Created: 2006-80-10
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/window.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dcclient.h"
|
||||
#endif
|
||||
|
||||
#include "wx/caret.h"
|
||||
|
||||
#include "wx/dfb/private.h"
|
||||
|
||||
#define TRACE_EVENTS _T("events")
|
||||
#define TRACE_PAINT _T("paint")
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// the window that has keyboard focus:
|
||||
static wxWindowDFB *gs_focusedWindow = NULL;
|
||||
// the window that is about to be focused after currently focused
|
||||
// one looses focus:
|
||||
static wxWindow *gs_toBeFocusedWindow = NULL;
|
||||
// the window that has mouse capture
|
||||
static wxWindowDFB *gs_mouseCapture = NULL;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// event tables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// in wxUniv this class is abstract because it doesn't have DoPopupMenu()
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxWindowDFB, wxWindowBase)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxWindowDFB, wxWindowBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constructors and such
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxWindowDFB::Init()
|
||||
{
|
||||
m_isShown = true;
|
||||
m_frozenness = 0;
|
||||
m_tlw = NULL;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
wxWindowDFB::~wxWindowDFB()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
if ( gs_mouseCapture == this )
|
||||
ReleaseMouse();
|
||||
|
||||
#warning "FIXME: what to do with gs_activeFrame here and elsewhere?"
|
||||
#if 0
|
||||
if (gs_activeFrame == this)
|
||||
{
|
||||
gs_activeFrame = NULL;
|
||||
// activate next frame in Z-order:
|
||||
if ( m_wnd->prev )
|
||||
{
|
||||
wxWindowDFB *win = (wxWindowDFB*)m_wnd->prev->userData;
|
||||
win->SetFocus();
|
||||
}
|
||||
else if ( m_wnd->next )
|
||||
{
|
||||
wxWindowDFB *win = (wxWindowDFB*)m_wnd->next->userData;
|
||||
win->SetFocus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( gs_focusedWindow == this )
|
||||
KillFocus();
|
||||
|
||||
DestroyChildren();
|
||||
}
|
||||
|
||||
// real construction (Init() must have been called before!)
|
||||
bool wxWindowDFB::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !m_tlw && parent )
|
||||
m_tlw = parent->GetTLW();
|
||||
|
||||
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||
return false;
|
||||
|
||||
if ( parent )
|
||||
parent->AddChild(this);
|
||||
|
||||
int x, y, w, h;
|
||||
x = pos.x, y = pos.y;
|
||||
if ( x == -1 ) x = 0;
|
||||
if ( y == -1 ) y = 0;
|
||||
w = WidthDefault(size.x);
|
||||
h = HeightDefault(size.y);
|
||||
SetSize(x, y, w, h);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// surface access
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
IDirectFBSurfacePtr wxWindowDFB::ObtainDfbSurface() const
|
||||
{
|
||||
wxCHECK_MSG( m_parent, NULL, _T("parentless window?") );
|
||||
|
||||
IDirectFBSurfacePtr 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;
|
||||
}
|
||||
|
||||
IDirectFBSurfacePtr wxWindowDFB::GetDfbSurface()
|
||||
{
|
||||
if ( !m_surface )
|
||||
{
|
||||
m_surface = ObtainDfbSurface();
|
||||
wxASSERT_MSG( m_surface, _T("invalid DirectFB surface") );
|
||||
}
|
||||
|
||||
return m_surface;
|
||||
}
|
||||
|
||||
void wxWindowDFB::InvalidateDfbSurface()
|
||||
{
|
||||
m_surface = NULL;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// basic operations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxWindowDFB::SetFocus()
|
||||
{
|
||||
if ( gs_focusedWindow == this ) return;
|
||||
|
||||
wxWindowDFB *oldFocusedWindow = gs_focusedWindow;
|
||||
|
||||
if ( gs_focusedWindow )
|
||||
{
|
||||
gs_toBeFocusedWindow = (wxWindow*)this;
|
||||
gs_focusedWindow->KillFocus();
|
||||
gs_toBeFocusedWindow = NULL;
|
||||
}
|
||||
|
||||
#warning "FIXME: implement in terms of DWET_{GOT,LOST}FOCUS"
|
||||
|
||||
IDirectFBWindowPtr dfbwin(m_tlw->GetDirectFBWindow());
|
||||
#warning "FIXME: RequestFocus() may only be called on visible TLW"
|
||||
if ( !DFB_CALL( dfbwin->RequestFocus(dfbwin) ) )
|
||||
return;
|
||||
|
||||
gs_focusedWindow = this;
|
||||
|
||||
#warning "FIXME: keep this or not? not, think multiapp core"
|
||||
#if 0
|
||||
wxWindowDFB *active = wxGetTopLevelParent((wxWindow*)this);
|
||||
if ( !(m_windowStyle & wxPOPUP_WINDOW) && active != gs_activeFrame )
|
||||
{
|
||||
if ( gs_activeFrame )
|
||||
{
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, false, gs_activeFrame->GetId());
|
||||
event.SetEventObject(gs_activeFrame);
|
||||
gs_activeFrame->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
gs_activeFrame = active;
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, true, gs_activeFrame->GetId());
|
||||
event.SetEventObject(gs_activeFrame);
|
||||
gs_activeFrame->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
|
||||
event.SetEventObject(this);
|
||||
event.SetWindow((wxWindow*)oldFocusedWindow);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
#if wxUSE_CARET
|
||||
// caret needs to be informed about focus change
|
||||
wxCaret *caret = GetCaret();
|
||||
if ( caret )
|
||||
caret->OnSetFocus();
|
||||
#endif // wxUSE_CARET
|
||||
}
|
||||
|
||||
void wxWindowDFB::KillFocus()
|
||||
{
|
||||
if ( gs_focusedWindow != this ) return;
|
||||
gs_focusedWindow = NULL;
|
||||
|
||||
if ( m_isBeingDeleted ) return;
|
||||
|
||||
#if wxUSE_CARET
|
||||
// caret needs to be informed about focus change
|
||||
wxCaret *caret = GetCaret();
|
||||
if ( caret )
|
||||
caret->OnKillFocus();
|
||||
#endif // wxUSE_CARET
|
||||
|
||||
wxFocusEvent event(wxEVT_KILL_FOCUS, GetId());
|
||||
event.SetEventObject(this);
|
||||
event.SetWindow(gs_toBeFocusedWindow);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// this wxWindowBase function is implemented here (in platform-specific file)
|
||||
// because it is static and so couldn't be made virtual
|
||||
// ----------------------------------------------------------------------------
|
||||
wxWindow *wxWindowBase::DoFindFocus()
|
||||
{
|
||||
return (wxWindow*)gs_focusedWindow;
|
||||
}
|
||||
|
||||
bool wxWindowDFB::Show(bool show)
|
||||
{
|
||||
if ( !wxWindowBase::Show(show) )
|
||||
return false;
|
||||
|
||||
// Unlike Refresh(), DoRefreshWindow() doesn't check visibility, so
|
||||
// call it to force refresh of either this window (if showing) or its
|
||||
// parent area at the place of this window (if hiding):
|
||||
DoRefreshWindow();
|
||||
|
||||
#warning "FIXME: all of this must be implemented for DFB"
|
||||
#if 0
|
||||
DFB_wmShowWindow(m_wnd, show);
|
||||
|
||||
if (!show && gs_activeFrame == this)
|
||||
{
|
||||
// activate next frame in Z-order:
|
||||
if ( m_wnd->prev )
|
||||
{
|
||||
wxWindowDFB *win = (wxWindowDFB*)m_wnd->prev->userData;
|
||||
win->SetFocus();
|
||||
}
|
||||
else if ( m_wnd->next )
|
||||
{
|
||||
wxWindowDFB *win = (wxWindowDFB*)m_wnd->next->userData;
|
||||
win->SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
gs_activeFrame = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Raise the window to the top of the Z order
|
||||
void wxWindowDFB::Raise()
|
||||
{
|
||||
wxFAIL_MSG( _T("Raise() not implemented") );
|
||||
}
|
||||
|
||||
// Lower the window to the bottom of the Z order
|
||||
void wxWindowDFB::Lower()
|
||||
{
|
||||
wxFAIL_MSG( _T("Lower() not implemented") );
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoCaptureMouse()
|
||||
{
|
||||
#warning "implement this"
|
||||
#if 0
|
||||
if ( gs_mouseCapture )
|
||||
DFB_wmUncaptureEvents(gs_mouseCapture->m_wnd, wxDFB_CAPTURE_MOUSE);
|
||||
#endif
|
||||
gs_mouseCapture = this;
|
||||
#if 0
|
||||
DFB_wmCaptureEvents(m_wnd, EVT_MOUSEEVT, wxDFB_CAPTURE_MOUSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoReleaseMouse()
|
||||
{
|
||||
wxASSERT_MSG( gs_mouseCapture == this, wxT("attempt to release mouse, but this window hasn't captured it") );
|
||||
|
||||
#warning "implement this"
|
||||
#if 0
|
||||
DFB_wmUncaptureEvents(m_wnd, wxDFB_CAPTURE_MOUSE);
|
||||
#endif
|
||||
gs_mouseCapture = NULL;
|
||||
}
|
||||
|
||||
/* static */ wxWindow *wxWindowBase::GetCapture()
|
||||
{
|
||||
return (wxWindow*)gs_mouseCapture;
|
||||
}
|
||||
|
||||
bool wxWindowDFB::SetCursor(const wxCursor& cursor)
|
||||
{
|
||||
if ( !wxWindowBase::SetCursor(cursor) )
|
||||
{
|
||||
// no change
|
||||
return false;
|
||||
}
|
||||
|
||||
#warning "implement this"
|
||||
#if 0
|
||||
if ( m_cursor.Ok() )
|
||||
DFB_wmSetWindowCursor(m_wnd, *m_cursor.GetDFBCursor());
|
||||
else
|
||||
DFB_wmSetWindowCursor(m_wnd, *wxSTANDARD_CURSOR->GetDFBCursor());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxWindowDFB::WarpPointer(int x, int y)
|
||||
{
|
||||
int w, h;
|
||||
wxDisplaySize(&w, &h);
|
||||
|
||||
ClientToScreen(&x, &y);
|
||||
if ( x < 0 ) x = 0;
|
||||
if ( y < 0 ) y = 0;
|
||||
if ( x >= w ) x = w-1;
|
||||
if ( y >= h ) y = h-1;
|
||||
|
||||
IDirectFBDisplayLayerPtr layer = wxDfbGetDisplayLayer();
|
||||
wxCHECK_RET( layer, _T("no display layer") );
|
||||
|
||||
layer->WarpCursor(layer, x, y);
|
||||
}
|
||||
|
||||
// Set this window to be the child of 'parent'.
|
||||
bool wxWindowDFB::Reparent(wxWindowBase *parent)
|
||||
{
|
||||
if ( !wxWindowBase::Reparent(parent) )
|
||||
return false;
|
||||
|
||||
#warning "implement this"
|
||||
wxFAIL_MSG( _T("reparenting not yet implemented") );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// moving and resizing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Get total size
|
||||
void wxWindowDFB::DoGetSize(int *x, int *y) const
|
||||
{
|
||||
if (x) *x = m_rect.width;
|
||||
if (y) *y = m_rect.height;
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
if (x) *x = m_rect.x;
|
||||
if (y) *y = m_rect.y;
|
||||
}
|
||||
|
||||
static wxPoint GetScreenPosOfClientOrigin(const wxWindowDFB *win)
|
||||
{
|
||||
wxCHECK_MSG( win, wxPoint(0, 0), _T("no window provided") );
|
||||
|
||||
wxPoint pt(win->GetPosition() + win->GetClientAreaOrigin());
|
||||
|
||||
if ( !win->IsTopLevel() )
|
||||
pt += GetScreenPosOfClientOrigin(win->GetParent());
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoScreenToClient(int *x, int *y) const
|
||||
{
|
||||
wxPoint o = GetScreenPosOfClientOrigin(this);
|
||||
|
||||
if (x) *x -= o.x;
|
||||
if (y) *y -= o.y;
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoClientToScreen(int *x, int *y) const
|
||||
{
|
||||
wxPoint o = GetScreenPosOfClientOrigin(this);
|
||||
|
||||
if (x) *x += o.x;
|
||||
if (y) *y += o.y;
|
||||
}
|
||||
|
||||
// Get size *available for subwindows* i.e. excluding menu bar etc.
|
||||
void wxWindowDFB::DoGetClientSize(int *x, int *y) const
|
||||
{
|
||||
DoGetSize(x, y);
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
wxRect oldpos(m_rect);
|
||||
wxRect newpos(x, y, width, height);
|
||||
|
||||
m_rect = newpos;
|
||||
|
||||
// window's position+size changed and so did the subsurface that covers it
|
||||
InvalidateDfbSurface();
|
||||
|
||||
if ( IsShown() )
|
||||
{
|
||||
// queue both former and new position of the window for repainting:
|
||||
wxWindow *parent = GetParent();
|
||||
wxPoint origin(parent->GetClientAreaOrigin());
|
||||
oldpos.Offset(origin);
|
||||
newpos.Offset(origin);
|
||||
parent->RefreshRect(oldpos);
|
||||
parent->RefreshRect(newpos);
|
||||
}
|
||||
}
|
||||
|
||||
// set the size of the window: if the dimensions are positive, just use them,
|
||||
// but if any of them is equal to -1, it means that we must find the value for
|
||||
// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
|
||||
// which case -1 is a valid value for x and y)
|
||||
//
|
||||
// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
|
||||
// the width/height to best suit our contents, otherwise we reuse the current
|
||||
// width/height
|
||||
void wxWindowDFB::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
// get the current size and position...
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int currentW,currentH;
|
||||
GetSize(¤tW, ¤tH);
|
||||
|
||||
if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
||||
x = currentX;
|
||||
if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
||||
y = currentY;
|
||||
|
||||
// ... and don't do anything (avoiding flicker) if it's already ok
|
||||
if ( x == currentX && y == currentY &&
|
||||
width == currentW && height == currentH )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AdjustForParentClientOrigin(x, y, sizeFlags);
|
||||
|
||||
wxSize size(-1, -1);
|
||||
if ( width == -1 )
|
||||
{
|
||||
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
|
||||
{
|
||||
size = DoGetBestSize();
|
||||
width = size.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
// just take the current one
|
||||
width = currentW;
|
||||
}
|
||||
}
|
||||
|
||||
if ( height == -1 )
|
||||
{
|
||||
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
|
||||
{
|
||||
if ( size.x == -1 )
|
||||
{
|
||||
size = DoGetBestSize();
|
||||
}
|
||||
//else: already called DoGetBestSize() above
|
||||
|
||||
height = size.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
// just take the current one
|
||||
height = currentH;
|
||||
}
|
||||
}
|
||||
|
||||
int maxWidth = GetMaxWidth(),
|
||||
minWidth = GetMinWidth(),
|
||||
maxHeight = GetMaxHeight(),
|
||||
minHeight = GetMinHeight();
|
||||
|
||||
if ( minWidth != -1 && width < minWidth ) width = minWidth;
|
||||
if ( maxWidth != -1 && width > maxWidth ) width = maxWidth;
|
||||
if ( minHeight != -1 && height < minHeight ) height = minHeight;
|
||||
if ( maxHeight != -1 && height > maxHeight ) height = maxHeight;
|
||||
|
||||
if ( m_rect.x != x || m_rect.y != y ||
|
||||
m_rect.width != width || m_rect.height != height )
|
||||
{
|
||||
DoMoveWindow(x, y, width, height);
|
||||
|
||||
wxSize newSize(width, height);
|
||||
wxSizeEvent event(newSize, GetId());
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoSetClientSize(int width, int height)
|
||||
{
|
||||
SetSize(width, height);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// text metrics
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
int wxWindowDFB::GetCharHeight() const
|
||||
{
|
||||
wxWindowDC dc((wxWindow*)this);
|
||||
return dc.GetCharHeight();
|
||||
}
|
||||
|
||||
int wxWindowDFB::GetCharWidth() const
|
||||
{
|
||||
wxWindowDC dc((wxWindow*)this);
|
||||
return dc.GetCharWidth();
|
||||
}
|
||||
|
||||
void wxWindowDFB::GetTextExtent(const wxString& string,
|
||||
int *x, int *y,
|
||||
int *descent, int *externalLeading,
|
||||
const wxFont *theFont) const
|
||||
{
|
||||
wxWindowDC dc((wxWindow*)this);
|
||||
dc.GetTextExtent(string, x, y, descent, externalLeading, (wxFont*)theFont);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// painting
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxWindowDFB::Clear()
|
||||
{
|
||||
wxClientDC dc((wxWindow *)this);
|
||||
wxBrush brush(GetBackgroundColour(), wxSOLID);
|
||||
dc.SetBackground(brush);
|
||||
dc.Clear();
|
||||
}
|
||||
|
||||
void wxWindowDFB::Refresh(bool eraseBack, const wxRect *rect)
|
||||
{
|
||||
if ( !IsShown() || IsFrozen() )
|
||||
return;
|
||||
|
||||
if ( rect )
|
||||
DoRefreshRect(*rect, eraseBack);
|
||||
else
|
||||
DoRefreshWindow(eraseBack);
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoRefreshWindow(bool eraseBack)
|
||||
{
|
||||
DoRefreshRect(wxRect(wxPoint(0, 0), GetSize()), eraseBack);
|
||||
}
|
||||
|
||||
void wxWindowDFB::DoRefreshRect(const wxRect& rect, bool eraseBack)
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
wxCHECK_RET( parent, _T("no parent") );
|
||||
|
||||
// convert the refresh rectangle to parent's coordinates and
|
||||
// recursively refresh the parent:
|
||||
wxRect r(rect);
|
||||
r.Offset(GetPosition());
|
||||
r.Offset(parent->GetClientAreaOrigin());
|
||||
|
||||
parent->DoRefreshRect(r, eraseBack);
|
||||
}
|
||||
|
||||
void wxWindowDFB::Update()
|
||||
{
|
||||
if ( !IsShown() || IsFrozen() )
|
||||
return;
|
||||
|
||||
GetParent()->Update();
|
||||
}
|
||||
|
||||
void wxWindowDFB::Freeze()
|
||||
{
|
||||
m_frozenness++;
|
||||
}
|
||||
|
||||
void wxWindowDFB::Thaw()
|
||||
{
|
||||
wxASSERT_MSG( IsFrozen(), _T("Thaw() without matching Freeze()") );
|
||||
|
||||
if ( --m_frozenness == 0 )
|
||||
{
|
||||
if ( IsShown() )
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindowDFB::PaintWindow(const wxRect& rect, bool eraseBackground)
|
||||
{
|
||||
if ( IsFrozen() )
|
||||
return; // don't paint anything if the window is frozen
|
||||
|
||||
wxLogTrace(TRACE_PAINT,
|
||||
_T("%p ('%s'): paiting region [x=%i,y=%i,w=%i,h=%i]"),
|
||||
this, GetName().c_str(),
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
m_updateRegion = rect;
|
||||
|
||||
// FIXME_DFB: don't waste time rendering the area if it's fully covered
|
||||
// by some children, go directly to rendering the children
|
||||
|
||||
#if wxUSE_CARET
|
||||
// must hide caret temporarily, otherwise we'd get rendering artifacts
|
||||
wxCaret *caret = GetCaret();
|
||||
if ( caret )
|
||||
caret->Hide();
|
||||
#endif // wxUSE_CARET
|
||||
|
||||
if ( eraseBackground )
|
||||
{
|
||||
wxWindowDC dc((wxWindow*)this);
|
||||
wxEraseEvent eventEr(m_windowId, &dc);
|
||||
eventEr.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(eventEr);
|
||||
}
|
||||
|
||||
wxNcPaintEvent eventNc(GetId());
|
||||
eventNc.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(eventNc);
|
||||
|
||||
wxPaintEvent eventPt(GetId());
|
||||
eventPt.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(eventPt);
|
||||
|
||||
#if wxUSE_CARET
|
||||
if ( caret )
|
||||
caret->Show();
|
||||
#endif // wxUSE_CARET
|
||||
|
||||
wxPoint origin = GetClientAreaOrigin();
|
||||
wxWindowList& children = GetChildren();
|
||||
for ( wxWindowList::iterator i = children.begin();
|
||||
i != children.end(); ++i )
|
||||
{
|
||||
wxWindow *child = *i;
|
||||
|
||||
// compute child's area to repaint
|
||||
wxRect childrect(child->GetRect());
|
||||
childrect.Offset(origin);
|
||||
childrect.Intersect(rect);
|
||||
if ( childrect.IsEmpty() )
|
||||
continue;
|
||||
|
||||
// and repaint it:
|
||||
wxPoint childpos(child->GetPosition());
|
||||
childrect.Offset(-childpos.x, -childpos.y);
|
||||
childrect.Offset(-origin.x, -origin.y);
|
||||
child->PaintWindow(childrect, eraseBackground);
|
||||
}
|
||||
|
||||
m_updateRegion.Clear();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// events handling
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#define KEY(dfb, wx) \
|
||||
case dfb: \
|
||||
wxLogTrace(TRACE_EVENTS, \
|
||||
_T("key " #dfb " mapped to " #wx)); \
|
||||
return wx
|
||||
|
||||
// returns translated keycode, i.e. the one for KEYUP/KEYDOWN where 'a'..'z' is
|
||||
// translated to 'A'..'Z'
|
||||
static long GetTranslatedKeyCode(DFBInputDeviceKeyIdentifier key_id)
|
||||
{
|
||||
switch ( key_id )
|
||||
{
|
||||
KEY(DIKI_UNKNOWN, 0);
|
||||
|
||||
KEY(DIKI_A, 'A');
|
||||
KEY(DIKI_B, 'B');
|
||||
KEY(DIKI_C, 'C');
|
||||
KEY(DIKI_D, 'D');
|
||||
KEY(DIKI_E, 'E');
|
||||
KEY(DIKI_F, 'F');
|
||||
KEY(DIKI_G, 'G');
|
||||
KEY(DIKI_H, 'H');
|
||||
KEY(DIKI_I, 'I');
|
||||
KEY(DIKI_J, 'J');
|
||||
KEY(DIKI_K, 'K');
|
||||
KEY(DIKI_L, 'L');
|
||||
KEY(DIKI_M, 'M');
|
||||
KEY(DIKI_N, 'N');
|
||||
KEY(DIKI_O, 'O');
|
||||
KEY(DIKI_P, 'P');
|
||||
KEY(DIKI_Q, 'Q');
|
||||
KEY(DIKI_R, 'R');
|
||||
KEY(DIKI_S, 'S');
|
||||
KEY(DIKI_T, 'T');
|
||||
KEY(DIKI_U, 'U');
|
||||
KEY(DIKI_V, 'V');
|
||||
KEY(DIKI_W, 'W');
|
||||
KEY(DIKI_X, 'X');
|
||||
KEY(DIKI_Y, 'Y');
|
||||
KEY(DIKI_Z, 'Z');
|
||||
|
||||
KEY(DIKI_0, '0');
|
||||
KEY(DIKI_1, '1');
|
||||
KEY(DIKI_2, '2');
|
||||
KEY(DIKI_3, '3');
|
||||
KEY(DIKI_4, '4');
|
||||
KEY(DIKI_5, '5');
|
||||
KEY(DIKI_6, '6');
|
||||
KEY(DIKI_7, '7');
|
||||
KEY(DIKI_8, '8');
|
||||
KEY(DIKI_9, '9');
|
||||
|
||||
KEY(DIKI_F1, WXK_F1);
|
||||
KEY(DIKI_F2, WXK_F2);
|
||||
KEY(DIKI_F3, WXK_F3);
|
||||
KEY(DIKI_F4, WXK_F4);
|
||||
KEY(DIKI_F5, WXK_F5);
|
||||
KEY(DIKI_F6, WXK_F6);
|
||||
KEY(DIKI_F7, WXK_F7);
|
||||
KEY(DIKI_F8, WXK_F8);
|
||||
KEY(DIKI_F9, WXK_F9);
|
||||
KEY(DIKI_F10, WXK_F10);
|
||||
KEY(DIKI_F11, WXK_F11);
|
||||
KEY(DIKI_F12, WXK_F12);
|
||||
|
||||
KEY(DIKI_SHIFT_L, WXK_SHIFT);
|
||||
KEY(DIKI_SHIFT_R, WXK_SHIFT);
|
||||
KEY(DIKI_CONTROL_L, WXK_CONTROL);
|
||||
KEY(DIKI_CONTROL_R, WXK_CONTROL);
|
||||
KEY(DIKI_ALT_L, WXK_ALT);
|
||||
KEY(DIKI_ALT_R, WXK_ALT);
|
||||
KEY(DIKI_META_L, 0);
|
||||
KEY(DIKI_META_R, 0);
|
||||
KEY(DIKI_SUPER_L, 0);
|
||||
KEY(DIKI_SUPER_R, 0);
|
||||
KEY(DIKI_HYPER_L, 0);
|
||||
KEY(DIKI_HYPER_R, 0);
|
||||
|
||||
KEY(DIKI_CAPS_LOCK, 0);
|
||||
KEY(DIKI_NUM_LOCK, WXK_NUMLOCK);
|
||||
KEY(DIKI_SCROLL_LOCK, 0);
|
||||
|
||||
KEY(DIKI_ESCAPE, WXK_ESCAPE);
|
||||
KEY(DIKI_LEFT, WXK_LEFT);
|
||||
KEY(DIKI_RIGHT, WXK_RIGHT);
|
||||
KEY(DIKI_UP, WXK_UP);
|
||||
KEY(DIKI_DOWN, WXK_DOWN);
|
||||
KEY(DIKI_TAB, WXK_TAB);
|
||||
KEY(DIKI_ENTER, WXK_RETURN);
|
||||
KEY(DIKI_SPACE, WXK_SPACE);
|
||||
KEY(DIKI_BACKSPACE, WXK_BACK);
|
||||
KEY(DIKI_INSERT, WXK_INSERT);
|
||||
KEY(DIKI_DELETE, WXK_DELETE);
|
||||
KEY(DIKI_HOME, WXK_HOME);
|
||||
KEY(DIKI_END, WXK_END);
|
||||
KEY(DIKI_PAGE_UP, WXK_PAGEUP);
|
||||
KEY(DIKI_PAGE_DOWN, WXK_PAGEDOWN);
|
||||
KEY(DIKI_PRINT, WXK_PRINT);
|
||||
KEY(DIKI_PAUSE, WXK_PAUSE);
|
||||
|
||||
KEY(DIKI_QUOTE_LEFT, '`');
|
||||
KEY(DIKI_MINUS_SIGN, '-');
|
||||
KEY(DIKI_EQUALS_SIGN, '=');
|
||||
KEY(DIKI_BRACKET_LEFT, '[');
|
||||
KEY(DIKI_BRACKET_RIGHT, ']');
|
||||
KEY(DIKI_BACKSLASH, '\\');
|
||||
KEY(DIKI_SEMICOLON, ';');
|
||||
KEY(DIKI_QUOTE_RIGHT, '\'');
|
||||
KEY(DIKI_COMMA, ',');
|
||||
KEY(DIKI_PERIOD, '.');
|
||||
KEY(DIKI_SLASH, '/');
|
||||
|
||||
KEY(DIKI_LESS_SIGN, '<');
|
||||
|
||||
KEY(DIKI_KP_DIV, WXK_NUMPAD_DIVIDE);
|
||||
KEY(DIKI_KP_MULT, WXK_NUMPAD_MULTIPLY);
|
||||
KEY(DIKI_KP_MINUS, WXK_NUMPAD_SUBTRACT);
|
||||
KEY(DIKI_KP_PLUS, WXK_NUMPAD_ADD);
|
||||
KEY(DIKI_KP_ENTER, WXK_NUMPAD_ENTER);
|
||||
KEY(DIKI_KP_SPACE, WXK_NUMPAD_SPACE);
|
||||
KEY(DIKI_KP_TAB, WXK_NUMPAD_TAB);
|
||||
KEY(DIKI_KP_F1, WXK_NUMPAD_F1);
|
||||
KEY(DIKI_KP_F2, WXK_NUMPAD_F2);
|
||||
KEY(DIKI_KP_F3, WXK_NUMPAD_F3);
|
||||
KEY(DIKI_KP_F4, WXK_NUMPAD_F4);
|
||||
KEY(DIKI_KP_EQUAL, WXK_NUMPAD_EQUAL);
|
||||
KEY(DIKI_KP_SEPARATOR, WXK_NUMPAD_SEPARATOR);
|
||||
|
||||
KEY(DIKI_KP_DECIMAL, WXK_NUMPAD_DECIMAL);
|
||||
KEY(DIKI_KP_0, WXK_NUMPAD0);
|
||||
KEY(DIKI_KP_1, WXK_NUMPAD1);
|
||||
KEY(DIKI_KP_2, WXK_NUMPAD2);
|
||||
KEY(DIKI_KP_3, WXK_NUMPAD3);
|
||||
KEY(DIKI_KP_4, WXK_NUMPAD4);
|
||||
KEY(DIKI_KP_5, WXK_NUMPAD5);
|
||||
KEY(DIKI_KP_6, WXK_NUMPAD6);
|
||||
KEY(DIKI_KP_7, WXK_NUMPAD7);
|
||||
KEY(DIKI_KP_8, WXK_NUMPAD8);
|
||||
KEY(DIKI_KP_9, WXK_NUMPAD9);
|
||||
|
||||
case DIKI_KEYDEF_END:
|
||||
case DIKI_NUMBER_OF_KEYS:
|
||||
wxFAIL_MSG( _T("invalid key_id value") );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0; // silence compiler warnings
|
||||
}
|
||||
|
||||
// returns untranslated keycode, i.e. for EVT_CHAR, where characters are left in
|
||||
// the form they were entered (lowercase, diacritics etc.)
|
||||
static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id,
|
||||
DFBInputDeviceKeySymbol key_symbol)
|
||||
{
|
||||
switch ( DFB_KEY_TYPE(key_symbol) )
|
||||
{
|
||||
case DIKT_UNICODE:
|
||||
#if wxUSE_UNICODE
|
||||
return key_symbol;
|
||||
#else
|
||||
if ( key_symbol < 128 )
|
||||
return key_symbol;
|
||||
else
|
||||
{
|
||||
#if wxUSE_WCHAR_T
|
||||
wchar_t chr = key_symbol;
|
||||
wxCharBuffer buf(wxConvUI->cWC2MB(&chr, 1, NULL));
|
||||
if ( buf )
|
||||
return *buf; // may be 0 if failed
|
||||
else
|
||||
#endif // wxUSE_WCHAR_T
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
return GetTranslatedKeyCode(key_id);
|
||||
}
|
||||
}
|
||||
|
||||
#undef KEY
|
||||
|
||||
void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent& event_)
|
||||
{
|
||||
if ( !IsEnabled() )
|
||||
return;
|
||||
|
||||
const DFBWindowEvent& e = event_;
|
||||
|
||||
wxLogTrace(TRACE_EVENTS,
|
||||
_T("handling key %s event for window %p ('%s')"),
|
||||
e.type == DWET_KEYUP ? _T("up") : _T("down"),
|
||||
this, GetName().c_str());
|
||||
|
||||
// fill in wxKeyEvent fields:
|
||||
wxKeyEvent event;
|
||||
event.SetEventObject(this);
|
||||
event.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e));
|
||||
event.m_rawCode = e.key_code;
|
||||
event.m_keyCode = GetTranslatedKeyCode(e.key_id);
|
||||
event.m_scanCode = 0; // not used by wx at all
|
||||
#if wxUSE_UNICODE
|
||||
event.m_uniChar = e.key_symbol;
|
||||
#endif
|
||||
event.m_shiftDown = ( e.modifiers & DIMM_SHIFT ) != 0;
|
||||
event.m_controlDown = ( e.modifiers & DIMM_CONTROL ) != 0;
|
||||
event.m_altDown = ( e.modifiers & DIMM_ALT ) != 0;
|
||||
event.m_metaDown = ( e.modifiers & DIMM_META ) != 0;
|
||||
|
||||
// translate coordinates from TLW-relative to this window-relative:
|
||||
event.m_x = e.x;
|
||||
event.m_y = e.y;
|
||||
GetTLW()->ClientToScreen(&event.m_x, &event.m_y);
|
||||
this->ScreenToClient(&event.m_x, &event.m_y);
|
||||
|
||||
if ( e.type == DWET_KEYUP )
|
||||
{
|
||||
event.SetEventType(wxEVT_KEY_UP);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isTab = (event.m_keyCode == WXK_TAB);
|
||||
|
||||
event.SetEventType(wxEVT_KEY_DOWN);
|
||||
|
||||
if ( GetEventHandler()->ProcessEvent(event) )
|
||||
return;
|
||||
|
||||
// only send wxEVT_CHAR event if not processed yet:
|
||||
event.m_keyCode = GetUntraslatedKeyCode(e.key_id, e.key_symbol);
|
||||
if ( event.m_keyCode != 0 )
|
||||
{
|
||||
event.SetEventType(wxEVT_CHAR);
|
||||
if ( GetEventHandler()->ProcessEvent(event) )
|
||||
return;
|
||||
}
|
||||
|
||||
// Synthetize navigation key event, but do it only if the TAB key
|
||||
// wasn't handled yet:
|
||||
if ( isTab && GetParent() && GetParent()->HasFlag(wxTAB_TRAVERSAL) )
|
||||
{
|
||||
wxNavigationKeyEvent navEvent;
|
||||
navEvent.SetEventObject(GetParent());
|
||||
// Shift-TAB goes in reverse direction:
|
||||
navEvent.SetDirection(!event.m_shiftDown);
|
||||
// Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
|
||||
navEvent.SetWindowChange(event.m_controlDown);
|
||||
navEvent.SetCurrentFocus(wxStaticCast(this, wxWindow));
|
||||
GetParent()->GetEventHandler()->ProcessEvent(navEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// idle events processing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void wxWindowDFB::OnInternalIdle()
|
||||
{
|
||||
if (wxUpdateUIEvent::CanUpdate(this))
|
||||
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
|
||||
}
|
||||
|
||||
|
||||
// Find the wxWindow at the current mouse position, returning the mouse
|
||||
// position.
|
||||
wxWindow* wxFindWindowAtPointer(wxPoint& pt)
|
||||
{
|
||||
return wxFindWindowAtPoint(pt = wxGetMousePosition());
|
||||
}
|
||||
|
||||
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||
{
|
||||
wxFAIL_MSG( _T("wxFindWindowAtPoint not implemented") );
|
||||
return NULL;
|
||||
}
|
@@ -71,6 +71,8 @@
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowGTK)
|
||||
#elif defined(__WXMGL__)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowMGL)
|
||||
#elif defined(__WXDFB__)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowDFB)
|
||||
#elif defined(__WXX11__)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowX11)
|
||||
#elif defined(__WXPM__)
|
||||
|
Reference in New Issue
Block a user