2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #ifndef UNWRAPPEDGRAPHICALAPI_H
12 #define UNWRAPPEDGRAPHICALAPI_H
14 #include "graphicalapi.h"
17 * This class moves the interface that will be used by the animator to modify
18 * kboard graphics into the variant's semantics.
20 template <typename Variant
>
21 class UnwrappedGraphicalAPI
{
22 GraphicalAPI
* m_graphical_api
;
24 typedef boost::shared_ptr
<UnwrappedGraphicalAPI
> Ptr
;
26 UnwrappedGraphicalAPI(GraphicalAPI
* interface
)
27 : m_graphical_api(interface
) {
30 virtual ~UnwrappedGraphicalAPI(){}
32 virtual const PointConverter
* converter() {
33 return m_graphical_api
->converter();
36 virtual const typename
Variant::Position
* position() {
37 const WrappedPosition
<Variant
> *p
= dynamic_cast<const WrappedPosition
<Variant
>*>(m_graphical_api
->position().get());
41 MISMATCH(m_graphical_api
->position(), WrappedPosition
<Variant
>);
46 virtual SpritePtr
setSprite(const Point
& p
, const typename
Variant::Piece
& piece
, bool use_drop
, bool show
) {
47 WrappedPiece
<Variant
> wpiece(piece
);
48 return m_graphical_api
->setSprite(p
, &wpiece
, use_drop
, show
);
51 virtual SpritePtr
getSprite(const Point
& p
) {
52 return m_graphical_api
->getSprite(p
);
55 virtual SpritePtr
takeSprite(const Point
& p
) {
56 return m_graphical_api
->takeSprite(p
);
59 virtual int poolSize(int pool
) const {
60 return m_graphical_api
->poolSize(pool
);
63 virtual SpritePtr
insertPoolSprite(int pool
, int index
, const typename
Variant::Piece
& piece
) {
64 WrappedPiece
<Variant
> wpiece(piece
);
65 return m_graphical_api
->insertPoolSprite(pool
, index
, &wpiece
);
68 virtual SpritePtr
getPoolSprite(int pool
, int index
) {
69 return m_graphical_api
->getPoolSprite(pool
, index
);
72 virtual SpritePtr
takePoolSprite(int pool
, int index
) {
73 return m_graphical_api
->takePoolSprite(pool
, index
);
77 #endif //UNWRAPPEDGRAPHICALAPI_H