2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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.
16 #include <boost/shared_ptr.hpp>
18 #include <QFontMetrics>
22 #include "decoratedmove.h"
23 #include "kgamecanvas.h"
27 typedef boost::shared_ptr
<class Entry
> EntryPtr
;
28 typedef boost::shared_ptr
<class Brace
> BracePtr
;
29 typedef boost::shared_ptr
<class Text
> TextPtr
;
30 typedef boost::shared_ptr
<class Comment
> CommentPtr
;
31 typedef std::vector
<EntryPtr
> History
;
32 typedef std::map
<int, History
> Variations
;
33 typedef std::map
<int, BracePtr
> Braces
;
34 typedef std::map
<int, CommentPtr
> VComments
;
52 QFontMetrics mv_fmetrics
;
54 QFontMetrics sel_mv_fmetrics
;
56 QFontMetrics comm_fmetrics
;
59 : mv_fmetrics(QFont())
60 , sel_mv_fmetrics(QFont())
61 , comm_fmetrics(QFont()) {}
67 class FancyItem
: public KGameCanvasItem
{
83 FancyItem(KGameCanvasAbstract
* c
= NULL
)
89 , time_highlight(-1) { }
93 void goTo(QPoint pos
);
94 void setHighlight(bool h
);
95 virtual bool canStop() { return time_highlight
==-1 && time_pos
==-1 && time_opacity
==-1; }
96 virtual void advance(int time
);
97 virtual bool layered() const;
100 class Brace
: public FancyItem
{
111 virtual void paint (QPainter
*p
);
112 virtual QRect
rect () const;
113 void setHeight(int h
);
114 virtual bool canStop() { return time_height
==-1 && FancyItem::canStop(); }
115 virtual void advance(int time
);
117 Brace(Entry
* e
, int var
, KGameCanvasAbstract
* c
= NULL
)
127 class Text
: public FancyItem
{
138 virtual void paint (QPainter
*p
);
139 virtual QRect
rect () const;
141 Text(Entry
* e
, int t
, KGameCanvasAbstract
* c
= NULL
)
148 , needs_update(true) {}
151 class Comment
: public FancyItem
{
161 virtual void paint (QPainter
*p
);
162 virtual QRect
rect () const;
164 Comment(Entry
* e
, KGameCanvasAbstract
* c
= NULL
, int v
= -1)
170 , needs_update(true) {}
173 class Entry
: public FancyItem
{
190 Variations variations
;
195 virtual void paint (QPainter
*p
);
196 virtual QRect
rect () const;
197 virtual bool canStop() { return time_highlight
==-1 && FancyItem::canStop(); }
199 Entry(int turn
, const DecoratedMove
& m
, const Index
& i
, KGameCanvasAbstract
* c
= NULL
)
207 , needs_update(true) {}
212 #endif //MOVELIST_P_H