-
Notifications
You must be signed in to change notification settings - Fork 0
/
Document.h
62 lines (59 loc) · 1.5 KB
/
Document.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#ifndef DOCUMENT_H_
#define DOCUMENT_H_
#include <list>
#include <vector>
#include <string>
#include <wx/wx.h>
#include "Iterator.h"
#include "DocumentObserver.h"
#include "Symbol.h"
#include "SimpleCalculator.h"
#include "Key.h"
#include "Expression.h"
#define MIN(a,b) (a < b ? a:b)
#define COL 4
class Document
{
typedef std::list<DocumentObserver*>::iterator observer_iter;
typedef std::vector<Key*>::iterator key_iter;
public:
Document(wxSize size);
~Document(void);
void AddObserver(DocumentObserver *listener);
void RemoveObserver(DocumentObserver *listener);
void Draw(wxPaintDC *dc);
void UpdateObservers();
wxSize &GetSize(){return _size;}
std::string const& GetExpressionAsString();
void Evaluate();
friend class KeyIterator;
class KeyIterator:public Iterator<Key*>
{
public:
KeyIterator(Document *doc){_document = doc;_iter = _document->_keys.begin();}
virtual void First(){_iter = _document->_keys.begin();}
virtual void Next(){_iter++;}
virtual bool IsDone(){return _iter ==_document->_keys.end();}
virtual Key *Current(){return *_iter;}
private:
KeyIterator(){}
Document *_document;
key_iter _iter;
};
KeyIterator *GetKeys(){return new KeyIterator(this);}
void HitKey(Key *key);
void ReleaseKey();
void ClearExpression();
void BackExpression();
private:
void CreateKeys();
void ClearKeys();
wxSize _size;
std::list<DocumentObserver*> _listeners;
std::vector<Key*> _keys;
Key* _lastHitKey;
SimpleCalculator *_calculator;
Expression _expression;
};
#endif