Numworks Epsilon  1.4.1
Graphing Calculator Operating System
app.h
Go to the documentation of this file.
1 #ifndef ESCHER_APP_H
2 #define ESCHER_APP_H
3 
5 #include <escher/image.h>
6 #include <escher/i18n.h>
7 #include <escher/responder.h>
8 #include <escher/timer.h>
11 
12 /* An app is fed events and outputs drawing calls.
13  *
14  * To achieve this, it uses a View hierarchy, and modifies it according to the
15  * events received. The View hierarchy keeps a memory of the area that needs to
16  * be redrawn depending on how it's been modified.
17  *
18  * Multiple App can exist at once.
19  * */
20 
21 class Container;
22 
23 class App : public Responder {
24 public:
25  class Descriptor {
26  public:
27  virtual I18n::Message name();
28  virtual I18n::Message upperName();
29  virtual const Image * icon();
30  };
31  class Snapshot {
32  public:
33  virtual App * unpack(Container * container) = 0;
34  void pack(App * app);
35  /* reset all instances to their initial values */
36  virtual void reset();
37  virtual Descriptor * descriptor() = 0;
38 #if EPSILON_GETOPT
39  virtual void setOpt(const char * name, char * value) {}
40 #endif
41  private:
42  /* tidy clean all dynamically-allocated data */
43  virtual void tidy();
44  };
45  virtual ~App() = default;
46  constexpr static uint8_t Magic = 0xA8;
47  Snapshot * snapshot();
48  void setFirstResponder(Responder * responder);
50  virtual bool processEvent(Ion::Events::Event event);
51  void displayModalViewController(ViewController * vc, float verticalAlignment, float horizontalAlignment,
52  KDCoordinate topMargin = 0, KDCoordinate leftMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate rightMargin = 0);
54  void displayWarning(I18n::Message warningMessage);
55  const Container * container() const;
56  uint8_t m_magic; // Poor man's RTTI
57 
58  virtual void didBecomeActive(Window * window);
59  virtual void willBecomeInactive();
60  View * modalView();
61  virtual int numberOfTimers();
62  virtual Timer * timerAtIndex(int i);
63 protected:
64  App(Container * container, Snapshot * snapshot, ViewController * rootViewController, I18n::Message warningMessage = (I18n::Message)0);
66 private:
67  Container * m_container;
68  Responder * m_firstResponder;
69  Snapshot * m_snapshot;
70  WarningController m_warningController;
71 };
72 
73 #endif
74 
virtual void didBecomeActive(Window *window)
Definition: app.cpp:106
Definition: timer.h:15
void displayModalViewController(ViewController *vc, float verticalAlignment, float horizontalAlignment, KDCoordinate topMargin=0, KDCoordinate leftMargin=0, KDCoordinate bottomMargin=0, KDCoordinate rightMargin=0)
Definition: app.cpp:85
Definition: window.h:6
int16_t KDCoordinate
Definition: coordinate.h:6
virtual void willBecomeInactive()
Definition: app.cpp:114
uint8_t m_magic
Definition: app.h:56
Snapshot * snapshot()
Definition: app.cpp:41
virtual ~App()=default
Definition: image.h:6
unsigned char uint8_t
Definition: stdint.h:4
App(Container *container, Snapshot *snapshot, ViewController *rootViewController, I18n::Message warningMessage=(I18n::Message) 0)
Definition: app.cpp:30
virtual bool processEvent(Ion::Events::Event event)
Definition: app.cpp:45
ModalViewController m_modalViewController
Definition: app.h:65
static constexpr uint8_t Magic
Definition: app.h:46
virtual int numberOfTimers()
Definition: app.cpp:126
virtual void reset()
Definition: app.cpp:24
void displayWarning(I18n::Message warningMessage)
Definition: app.cpp:97
virtual App * unpack(Container *container)=0
Responder * firstResponder()
Definition: app.cpp:58
virtual Timer * timerAtIndex(int i)
Definition: app.cpp:130
Definition: app.h:23
virtual const Image * icon()
Definition: app.cpp:15
const Container * container() const
Definition: app.cpp:102
virtual I18n::Message upperName()
Definition: app.cpp:11
virtual Descriptor * descriptor()=0
void setFirstResponder(Responder *responder)
Definition: app.cpp:62
Definition: view.h:23
View * modalView()
Definition: app.cpp:122
App * app()
Definition: responder.cpp:77
void dismissModalViewController()
Definition: app.cpp:93
virtual I18n::Message name()
Definition: app.cpp:7
void pack(App *app)
Definition: app.cpp:19