2006-10-24 08:29:14 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: src/dfb/overlay.cpp
|
|
|
|
// Purpose: wxOverlay implementation for wxDFB
|
|
|
|
// Author: Vaclav Slavik
|
|
|
|
// Created: 2006-10-20
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) wxWidgets team
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
2007-01-24 08:42:46 -05:00
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/window.h"
|
|
|
|
#include "wx/dcclient.h"
|
|
|
|
#endif
|
|
|
|
|
2006-10-24 08:29:14 -04:00
|
|
|
#include "wx/private/overlay.h"
|
2007-12-14 17:41:07 -05:00
|
|
|
#include "wx/dfb/dcclient.h"
|
2006-10-24 08:29:14 -04:00
|
|
|
#include "wx/dfb/private.h"
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxOverlay
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
wxOverlayImpl::wxOverlayImpl()
|
|
|
|
{
|
|
|
|
m_window = NULL;
|
|
|
|
m_isEmpty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxOverlayImpl::~wxOverlayImpl()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxOverlayImpl::IsOk()
|
|
|
|
{
|
|
|
|
return m_window != NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-22 04:16:57 -05:00
|
|
|
void wxOverlayImpl::Init(wxDC *dc, int x, int y, int width, int height)
|
2006-10-24 08:29:14 -04:00
|
|
|
{
|
2007-12-14 17:41:07 -05:00
|
|
|
wxCHECK_RET( dc, "NULL dc pointer" );
|
2006-10-24 08:29:14 -04:00
|
|
|
wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
|
|
|
|
|
2007-12-14 17:41:07 -05:00
|
|
|
wxDFBDCImpl * const dcimpl = wxDynamicCast(dc->GetImpl(), wxDFBDCImpl);
|
|
|
|
wxCHECK_RET( dcimpl, "must have a DFB wxDC" );
|
|
|
|
|
2006-10-24 08:29:14 -04:00
|
|
|
m_window = dc->GetWindow();
|
|
|
|
|
|
|
|
m_rect = wxRect(x, y, width, height);
|
2006-11-08 07:17:56 -05:00
|
|
|
if ( wxDynamicCast(dc, wxClientDC) )
|
|
|
|
m_rect.Offset(m_window->GetClientAreaOrigin());
|
2006-10-24 08:29:14 -04:00
|
|
|
|
|
|
|
// FIXME: create surface with transparency or key color (?)
|
2007-12-14 17:41:07 -05:00
|
|
|
m_surface = dcimpl->GetDirectFBSurface()->CreateCompatible
|
|
|
|
(
|
|
|
|
m_rect.GetSize(),
|
|
|
|
wxIDirectFBSurface::CreateCompatible_NoBackBuffer
|
|
|
|
);
|
2006-10-24 08:29:14 -04:00
|
|
|
|
|
|
|
m_window->AddOverlay(this);
|
|
|
|
}
|
|
|
|
|
2007-12-22 04:16:57 -05:00
|
|
|
void wxOverlayImpl::BeginDrawing(wxDC *dc)
|
2006-10-24 08:29:14 -04:00
|
|
|
{
|
2007-12-14 17:41:07 -05:00
|
|
|
wxCHECK_RET( dc, "NULL dc pointer" );
|
|
|
|
|
|
|
|
wxWindowDCImpl * const
|
|
|
|
dcimpl = static_cast<wxWindowDCImpl *>(dc->GetImpl());
|
|
|
|
|
2006-11-08 07:17:56 -05:00
|
|
|
wxPoint origin(m_rect.GetPosition());
|
|
|
|
if ( wxDynamicCast(dc, wxClientDC) )
|
|
|
|
origin -= m_window->GetClientAreaOrigin();
|
2006-10-24 08:29:14 -04:00
|
|
|
|
|
|
|
// drawing on overlay "hijacks" existing wxWindowDC rather then using
|
|
|
|
// another DC, so we have to change the DC to draw on the overlay's surface.
|
|
|
|
// Setting m_shouldFlip is done to avoid flipping and drawing of overlays
|
|
|
|
// in ~wxWindowDC (we do it EndDrawing).
|
2007-12-14 17:41:07 -05:00
|
|
|
dcimpl->DFBInit(m_surface);
|
|
|
|
dcimpl->m_shouldFlip = false;
|
2006-10-24 08:29:14 -04:00
|
|
|
dc->SetDeviceOrigin(-origin.x, -origin.y);
|
|
|
|
|
|
|
|
m_isEmpty = false;
|
|
|
|
}
|
|
|
|
|
2007-12-22 04:16:57 -05:00
|
|
|
void wxOverlayImpl::EndDrawing(wxDC *WXUNUSED(dc))
|
2006-10-24 08:29:14 -04:00
|
|
|
{
|
|
|
|
m_window->RefreshWindowRect(m_rect);
|
|
|
|
}
|
|
|
|
|
2007-12-22 04:16:57 -05:00
|
|
|
void wxOverlayImpl::Clear(wxDC *WXUNUSED(dc))
|
2006-10-24 08:29:14 -04:00
|
|
|
{
|
|
|
|
wxASSERT_MSG( IsOk(),
|
2007-07-18 06:15:42 -04:00
|
|
|
"You cannot Clear an overlay that is not initialized" );
|
2006-10-24 08:29:14 -04:00
|
|
|
|
|
|
|
m_isEmpty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxOverlayImpl::Reset()
|
|
|
|
{
|
|
|
|
if ( m_window )
|
|
|
|
{
|
|
|
|
m_window->RemoveOverlay(this);
|
|
|
|
m_window = NULL;
|
|
|
|
m_surface.Reset();
|
|
|
|
}
|
|
|
|
}
|