Ginga  0.13.6.1771-df200
The iTV middleware.
Formatter.h
Go to the documentation of this file.
1 /* Copyright (C) 2006-2017 PUC-Rio/Laboratorio TeleMidia
2 
3 This file is part of Ginga (Ginga-NCL).
4 
5 Ginga is free software: you can redistribute it and/or modify it
6 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.
9 
10 Ginga is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13 License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with Ginga. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #ifndef FORMATTER_H
19 #define FORMATTER_H
20 
21 #include "ginga.h"
22 #include "aux-ginga.h"
23 
24 #include "Document.h"
25 #include "ncl/Ncl.h"
26 
28 
29 class Context;
30 class Event;
31 class Media;
32 class MediaSettings;
33 class Object;
34 
35 class Formatter: public Ginga
36 {
37  public:
38  // External API.
40 
41  bool start (const string &, string *);
42  bool stop ();
43 
44  void resize (int, int);
45  void redraw (cairo_t *);
46 
47  bool sendKeyEvent (const string &, bool);
48  bool sendTickEvent (uint64_t, uint64_t, uint64_t);
49 
50  const GingaOptions *getOptions ();
51  bool getOptionBool (const string &);
52  void setOptionBool (const string &, bool);
53  int getOptionInt (const string &);
54  void setOptionInt (const string &, int);
55  string getOptionString (const string &);
56  void setOptionString (const string &, string);
57 
58  // Internal API.
59  Formatter (int, char **, GingaOptions *);
60  ~Formatter ();
61 
62  bool getEOS ();
63  void setEOS (bool);
64 
65  static void setOptionBackground (Formatter *, const string &, string);
66  static void setOptionDebug (Formatter *, const string &, bool);
67  static void setOptionExperimental (Formatter *, const string &, bool);
68  static void setOptionOpenGL (Formatter *, const string &, bool);
69  static void setOptionSize (Formatter *, const string &, int);
70 
71  private:
72  GingaState _state; // current state
73  GingaOptions _opts; // current options
74  Color _background; // current background color
75 
76  uint64_t _last_tick_total; // last total informed via sendTickEvent
77  uint64_t _last_tick_diff; // last diff informed via sendTickEvent
78  uint64_t _last_tick_frameno; // last frameno informed via sendTickEvent
79  string _saved_G_MESSAGES_DEBUG; // saved G_MESSAGES_DEBUG value
80 
81  Document *_doc; // current document
82  NclDocument *_docLegacy; // current document (legacy)
83  string _docPath; // path to current document
84  bool _eos; // true if EOS was reached
85 
86  list<Object *> getObjectList (Event::State);
87 
88  // fixme:
89  Object *obtainExecutionObject (const string &);
90  Event *obtainEvent (Object *, Event::Type, NclAnchor *, const string &);
92  pair<list<Action>,list<Action>> obtainFormatterLink (NclLink *);
93 };
94 
96 
97 #endif // FORMATTER_H
Definition: Object.h:29
Ginga object.
Definition: ginga.h:61
GdkRGBA Color
Definition: aux-ginga.h:113
void setOptionInt(const string &, int)
Definition: NclDocument.h:25
bool start(const string &, string *)
Definition: Formatter.cpp:114
void setOptionString(const string &, string)
void setEOS(bool)
Definition: Formatter.cpp:498
const GingaOptions * getOptions()
Definition: Formatter.cpp:415
GingaOptions _opts
Definition: Formatter.h:73
Definition: NclBind.h:27
Definition: Context.h:26
bool _eos
Definition: Formatter.h:84
NclDocument * _docLegacy
Definition: Formatter.h:82
GingaState _state
Definition: Formatter.h:72
list< Object * > getObjectList(Event::State)
Definition: Formatter.cpp:576
~Formatter()
Definition: Formatter.cpp:486
uint64_t _last_tick_total
Definition: Formatter.h:76
Color _background
Definition: Formatter.h:74
static void setOptionExperimental(Formatter *, const string &, bool)
Definition: Formatter.cpp:539
bool stop()
Definition: Formatter.cpp:256
static void setOptionSize(Formatter *, const string &, int)
Definition: Formatter.cpp:562
State
Definition: Event.h:37
Ginga options.
Definition: ginga.h:39
static void setOptionBackground(Formatter *, const string &, string)
Definition: Formatter.cpp:507
#define GINGA_NAMESPACE_END
Definition: aux-ginga.h:62
GingaState getState()
Definition: Formatter.cpp:108
int getOptionInt(const string &)
Definition: Formatter.h:35
bool sendKeyEvent(const string &, bool)
Definition: Formatter.cpp:376
string _docPath
Definition: Formatter.h:83
Definition: MediaSettings.h:25
static void setOptionOpenGL(Formatter *, const string &, bool)
Definition: Formatter.cpp:547
Definition: NclAnchor.h:25
uint64_t _last_tick_frameno
Definition: Formatter.h:78
#define GINGA_NAMESPACE_BEGIN
Definition: aux-ginga.h:61
void redraw(cairo_t *)
Definition: Formatter.cpp:288
Formatter(int, char **, GingaOptions *)
Definition: Formatter.cpp:459
void setOptionBool(const string &, bool)
Definition: Media.h:26
Object * obtainExecutionObject(const string &)
Definition: Formatter.cpp:589
Definition: Document.h:29
pair< list< Action >, list< Action > > obtainFormatterLink(NclLink *)
Definition: Formatter.cpp:821
static void setOptionDebug(Formatter *, const string &, bool)
Definition: Formatter.cpp:519
GingaState
Ginga states.
Definition: ginga.h:52
Document * _doc
Definition: Formatter.h:81
Definition: Event.h:27
Type
Definition: Event.h:30
Event * obtainEvent(Object *, Event::Type, NclAnchor *, const string &)
Definition: Formatter.cpp:723
uint64_t _last_tick_diff
Definition: Formatter.h:77
bool getEOS()
Definition: Formatter.cpp:492
Event * obtainFormatterEventFromBind(NclBind *)
Definition: Formatter.cpp:778
bool getOptionBool(const string &)
void resize(int, int)
Definition: Formatter.cpp:267
string _saved_G_MESSAGES_DEBUG
Definition: Formatter.h:79
string getOptionString(const string &)
bool sendTickEvent(uint64_t, uint64_t, uint64_t)
Definition: Formatter.cpp:389