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 NamedSprite
setPiece(const Point
& p
, const typename
Variant::Piece
& piece
, bool show
) {
47 WrappedPiece
<Variant
> wpiece(piece
);
48 return m_graphical_api
->setPiece(p
, &wpiece
, show
);
51 virtual NamedSprite
createPiece(const Point
& p
, const typename
Variant::Piece
& piece
, bool show
) {
52 WrappedPiece
<Variant
> wpiece(piece
);
53 return m_graphical_api
->createPiece(p
, &wpiece
, show
);
56 virtual void setSprite(const Point
& p
, const NamedSprite
& s
) {
57 m_graphical_api
->setSprite(p
, s
);
60 virtual NamedSprite
getSprite(const Point
& p
) {
61 return m_graphical_api
->getSprite(p
);
64 virtual NamedSprite
takeSprite(const Point
& p
) {
65 return m_graphical_api
->takeSprite(p
);
68 virtual int poolSize(int pool
) const {
69 return m_graphical_api
->poolSize(pool
);
72 virtual NamedSprite
insertPoolPiece(int pool
, int index
, const typename
Variant::Piece
& piece
) {
73 WrappedPiece
<Variant
> wpiece(piece
);
74 return m_graphical_api
->insertPoolPiece(pool
, index
, &wpiece
);
77 // virtual NamedSprite getPoolSprite(int pool, int index) {
78 // return m_graphical_api->getPoolSprite(pool, index);
81 virtual void removePoolSprite(int pool
, int index
) {
82 m_graphical_api
->removePoolSprite(pool
, index
);
85 virtual NamedSprite
takePoolSprite(int pool
, int index
) {
86 return m_graphical_api
->takePoolSprite(pool
, index
);
89 virtual std::pair
<int, int> droppedPoolPiece() {
90 return m_graphical_api
->droppedPoolPiece();
93 virtual AnimationPtr
animate(const Animate::Scheme
& scheme
, Animate::AnimationType type
= Animate::Normal
) {
94 return m_graphical_api
->animate(scheme
, type
);
97 GraphicalAPI
* inner() const { return m_graphical_api
; }
100 #endif //UNWRAPPEDGRAPHICALAPI_H