moved wxOverlay into overlay.* files and out of dc.h/dcbase.cpp; implemented wxOverlay for wxDirectFB port

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42340 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2006-10-24 12:29:14 +00:00
parent f8bf59a9f2
commit 30c841c84d
28 changed files with 1091 additions and 502 deletions

View File

@@ -199,12 +199,29 @@ private:
#include "wx/generic/caret.h"
#endif // platform
#ifndef wxHAS_CARET_USING_OVERLAYS
#define wxHAS_CARET_USING_OVERLAYS 0
#endif
// ----------------------------------------------------------------------------
// wxCaretSuspend: a simple class which hides the caret in its ctor and
// restores it in the dtor, this should be used when drawing on the screen to
// avoid overdrawing the caret
// ----------------------------------------------------------------------------
#if wxHAS_CARET_USING_OVERLAYS
// we don't need to hide the caret if it's rendered using overlays
class WXDLLEXPORT wxCaretSuspend
{
public:
wxCaretSuspend(wxWindow *WXUNUSED(win)) {}
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
};
#else // !wxHAS_CARET_USING_OVERLAYS
class WXDLLEXPORT wxCaretSuspend
{
public:
@@ -232,6 +249,8 @@ private:
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
};
#endif // wxHAS_CARET_USING_OVERLAYS/!wxHAS_CARET_USING_OVERLAYS
#endif // wxUSE_CARET
#endif // _WX_CARET_H_BASE_

View File

@@ -968,72 +968,4 @@ private:
DECLARE_NO_COPY_CLASS(wxDCClipper)
};
// ----------------------------------------------------------------------------
// creates an overlay over an existing window, allowing for manipulations like
// rubberbanding etc. this API is not stable yet, not to be used outside wx
// internal code
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxOverlayImpl;
class WXDLLEXPORT wxWindowDC;
class WXDLLEXPORT wxOverlay
{
public:
wxOverlay();
~wxOverlay();
// clears the overlay without restoring the former state
// to be done eg when the window content has been changed and repainted
void Reset();
private:
friend class WXDLLEXPORT wxDCOverlay;
// returns true if it has been setup
bool IsOk();
void Init(wxWindowDC* dc, int x , int y , int width , int height);
void BeginDrawing(wxWindowDC* dc);
void EndDrawing(wxWindowDC* dc);
void Clear(wxWindowDC* dc);
wxOverlayImpl* m_impl;
bool m_inDrawing;
DECLARE_NO_COPY_CLASS(wxOverlay)
};
class WXDLLEXPORT wxDCOverlay
{
public:
// connects this overlay to the corresponding drawing dc, if the overlay is not initialized yet
// this call will do so
wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc, int x , int y , int width , int height);
// convenience wrapper that behaves the same using the entire area of the dc
wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc);
// removes the connection between the overlay and the dc
virtual ~wxDCOverlay();
// clears the layer, restoring the state at the last init
void Clear();
private:
void Init(wxWindowDC *dc, int x , int y , int width , int height);
wxOverlay& m_overlay;
wxWindowDC* m_dc;
DECLARE_NO_COPY_CLASS(wxDCOverlay)
};
#endif // _WX_DC_H_BASE_

View File

@@ -216,6 +216,8 @@ protected:
double m_mm_to_pix_x, m_mm_to_pix_y;
friend class WXDLLIMPEXP_CORE wxOverlayImpl; // for Init
DECLARE_DYNAMIC_CLASS(wxDC)
};

View File

@@ -26,14 +26,21 @@ public:
wxWindowDC(wxWindow *win);
virtual ~wxWindowDC();
virtual wxWindow *GetWindow() const { return m_win; }
protected:
// initializes the DC for painting on given window; if rect!=NULL, then
// for painting only on the given region of the window
void InitForWin(wxWindow *win, const wxRect *rect);
private:
wxWindow *m_win;
wxRect m_winRect; // rectangle of the window being painted
bool m_shouldFlip; // flip the surface when done?
friend class wxOverlayImpl; // for m_shouldFlip;
DECLARE_DYNAMIC_CLASS(wxWindowDC)
DECLARE_NO_COPY_CLASS(wxWindowDC)
};

View File

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

View File

@@ -23,6 +23,9 @@ struct wxDFBWindowEvent;
class WXDLLIMPEXP_CORE wxFont;
class WXDLLIMPEXP_CORE wxTopLevelWindowDFB;
class wxOverlayImpl;
class wxDfbOverlaysList;
// ---------------------------------------------------------------------------
// wxWindow
// ---------------------------------------------------------------------------
@@ -144,10 +147,21 @@ protected:
// called by parent to render (part of) the window
void PaintWindow(const wxRect& rect);
// paint window's overlays (if any) on top of window's surface
void PaintOverlays(const wxRect& rect);
// refreshes the entire window (including non-client areas)
void DoRefreshWindow();
// refreshes given rectangle of the window (in window, _not_ client coords)
virtual void DoRefreshRect(const wxRect& rect);
// refreshes given rectangle; unlike RefreshRect(), the argument is in
// window, not client, coords and unlike DoRefreshRect() and like Refresh(),
// does nothing if the window is hidden or frozen
void RefreshWindowRect(const wxRect& rect);
// add/remove overlay for this window
void AddOverlay(wxOverlayImpl *overlay);
void RemoveOverlay(wxOverlayImpl *overlay);
// DirectFB events handling
void HandleKeyEvent(const wxDFBWindowEvent& event_);
@@ -173,7 +187,12 @@ private:
// number of calls to Freeze() minus number of calls to Thaw()
unsigned m_frozenness;
// overlays for this window (or NULL if it doesn't have any)
wxDfbOverlaysList *m_overlays;
friend class wxTopLevelWindowDFB; // for HandleXXXEvent
friend class wxOverlayImpl; // for Add/RemoveOverlay
friend class wxWindowDC; // for PaintOverlays
DECLARE_DYNAMIC_CLASS(wxWindowDFB)
DECLARE_NO_COPY_CLASS(wxWindowDFB)

View File

@@ -13,6 +13,12 @@
#define _WX_CARET_H_
#include "wx/timer.h"
#include "wx/dc.h"
#include "wx/overlay.h"
#if wxHAS_NATIVE_OVERLAY
#define wxHAS_CARET_USING_OVERLAYS 1
#endif
class WXDLLIMPEXP_CORE wxCaret;
@@ -26,18 +32,6 @@ private:
wxCaret *m_caret;
};
#ifndef wxUSE_OVERLAY
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#define wxUSE_OVERLAY 1
#else
#define wxUSE_OVERLAY 0
#endif
#endif
#if wxUSE_OVERLAY
#include "wx/dc.h"
#endif
class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase
{
public:
@@ -82,7 +76,7 @@ private:
// GTK specific initialization
void InitGeneric();
#if wxUSE_OVERLAY
#if wxHAS_CARET_USING_OVERLAYS
// the overlay for displaying the caret
wxOverlay m_overlay;
#else

View File

@@ -19,10 +19,7 @@
#include "wx/treectrl.h"
#include "wx/listctrl.h"
#include "wx/log.h"
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#include "wx/dc.h"
#endif
#include "wx/overlay.h"
/*
To use this class, create a wxDragImage when you start dragging, for example:
@@ -163,8 +160,7 @@ public:
// For efficiency, tell wxGenericDragImage to use a bitmap that's already
// created (e.g. from last drag)
void SetBackingBitmap(wxBitmap* bitmap) {
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#else
#if !wxHAS_NATIVE_OVERLAY
m_pBackingBitmap = bitmap;
#endif
}
@@ -251,7 +247,7 @@ protected:
wxWindow* m_window;
wxDC* m_windowDC;
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#if wxHAS_NATIVE_OVERLAY
wxOverlay m_overlay;
wxDCOverlay* m_dcOverlay;
#else
@@ -261,7 +257,7 @@ protected:
// (pass to wxGenericDragImage as an efficiency measure)
// A temporary bitmap for repairing/redrawing
wxBitmap m_repairBitmap;
#endif
#endif // !wxHAS_NATIVE_OVERLAY
wxRect m_boundingRect;
bool m_fullScreen;

View File

@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/mac/carbon/private/overlay.h
// Purpose: wxOverlayImpl declaration
// Author: Stefan Csomor
// Modified by:
// Created: 2006-10-20
// RCS-ID: $Id$
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_CARBON_PRIVATE_OVERLAY_H_
#define _WX_MAC_CARBON_PRIVATE_OVERLAY_H_
#include "wx/mac/private.h"
#include "wx/toplevel.h"
#include "wx/graphics.h"
class wxOverlayImpl
{
public:
wxOverlayImpl() ;
~wxOverlayImpl() ;
// clears the overlay without restoring the former state
// to be done eg when the window content has been changed and repainted
void Reset();
// returns true if it has been setup
bool IsOk();
void Init( wxWindowDC* dc, int x , int y , int width , int height );
void BeginDrawing( wxWindowDC* dc);
void EndDrawing( wxWindowDC* dc);
void Clear( wxWindowDC* dc);
private:
OSStatus CreateOverlayWindow();
void MacGetBounds( Rect *bounds );
WindowRef m_overlayWindow;
WindowRef m_overlayParentWindow;
CGContextRef m_overlayContext ;
// we store the window in case we would have to issue a Refresh()
wxWindow* m_window ;
int m_x ;
int m_y ;
int m_width ;
int m_height ;
} ;
#endif // _WX_MAC_CARBON_PRIVATE_OVERLAY_H_

99
include/wx/overlay.h Normal file
View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/overlay.h
// Purpose: wxOverlay class
// Author: Stefan Csomor
// Modified by:
// Created: 2006-10-20
// RCS-ID: $Id$
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OVERLAY_H_
#define _WX_OVERLAY_H_
#include "wx/defs.h"
#ifndef wxHAS_NATIVE_OVERLAY
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#define wxHAS_NATIVE_OVERLAY 1
#elif defined(__WXDFB__)
#define wxHAS_NATIVE_OVERLAY 1
#else
#define wxHAS_NATIVE_OVERLAY 0
#endif
#endif
// ----------------------------------------------------------------------------
// creates an overlay over an existing window, allowing for manipulations like
// rubberbanding etc. This API is not stable yet, not to be used outside wx
// internal code
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxOverlayImpl;
class WXDLLEXPORT wxWindowDC;
class WXDLLEXPORT wxOverlay
{
public:
wxOverlay();
~wxOverlay();
// clears the overlay without restoring the former state
// to be done eg when the window content has been changed and repainted
void Reset();
// returns (port-specific) implementation of the overlay
wxOverlayImpl *GetImpl() { return m_impl; }
private:
friend class WXDLLEXPORT wxDCOverlay;
// returns true if it has been setup
bool IsOk();
void Init(wxWindowDC* dc, int x , int y , int width , int height);
void BeginDrawing(wxWindowDC* dc);
void EndDrawing(wxWindowDC* dc);
void Clear(wxWindowDC* dc);
wxOverlayImpl* m_impl;
bool m_inDrawing;
DECLARE_NO_COPY_CLASS(wxOverlay)
};
class WXDLLEXPORT wxDCOverlay
{
public:
// connects this overlay to the corresponding drawing dc, if the overlay is
// not initialized yet this call will do so
wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc, int x , int y , int width , int height);
// convenience wrapper that behaves the same using the entire area of the dc
wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc);
// removes the connection between the overlay and the dc
virtual ~wxDCOverlay();
// clears the layer, restoring the state at the last init
void Clear();
private:
void Init(wxWindowDC *dc, int x , int y , int width , int height);
wxOverlay& m_overlay;
wxWindowDC* m_dc;
DECLARE_NO_COPY_CLASS(wxDCOverlay)
};
#endif // _WX_OVERLAY_H_

View File

@@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/private/overlay.h
// Purpose: wxOverlayImpl declaration
// Author: Stefan Csomor
// Modified by:
// Created: 2006-10-20
// RCS-ID: $Id$
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_OVERLAY_H_
#define _WX_PRIVATE_OVERLAY_H_
#include "wx/overlay.h"
#if wxHAS_NATIVE_OVERLAY
#if defined(__WXMAC__)
#include "wx/mac/carbon/private/overlay.h"
#elif defined(__WXDFB__)
#include "wx/dfb/private/overlay.h"
#else
#error "unknown native wxOverlay implementation"
#endif
#else // !wxHAS_NATIVE_OVERLAY
// generic implementation of wxOverlay
class wxOverlayImpl
{
public:
wxOverlayImpl();
~wxOverlayImpl();
// clears the overlay without restoring the former state
// to be done eg when the window content has been changed and repainted
void Reset();
// returns true if it has been setup
bool IsOk();
void Init(wxWindowDC* dc, int x , int y , int width , int height);
void BeginDrawing(wxWindowDC* dc);
void EndDrawing(wxWindowDC* dc);
void Clear(wxWindowDC* dc);
private:
wxBitmap m_bmpSaved ;
int m_x ;
int m_y ;
int m_width ;
int m_height ;
// this is to enable wxMOTIF and UNIV to compile....
// currently (10 oct 06) we don't use m_window
// ce - how do we fix this
#if defined(__WXGTK__) || defined(__WXMSW__)
wxWindow* m_window ;
#endif
} ;
#endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY
#endif // _WX_PRIVATE_OVERLAY_H_