summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/DasherNode.h
Unidiff
Diffstat (limited to 'inputmethods/dasher/DasherNode.h') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/DasherNode.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/inputmethods/dasher/DasherNode.h b/inputmethods/dasher/DasherNode.h
new file mode 100644
index 0000000..705a9d4
--- a/dev/null
+++ b/inputmethods/dasher/DasherNode.h
@@ -0,0 +1,127 @@
1// DasherNode.h
2//
3/////////////////////////////////////////////////////////////////////////////
4//
5// Copyright (c) 2001-2002 David Ward
6//
7/////////////////////////////////////////////////////////////////////////////
8
9#ifndef __DasherNode_h__
10#define __DasherNode_h__
11
12#include "NoClones.h"
13#include "DasherTypes.h"
14#include "LanguageModel.h"
15
16namespace Dasher {class CDasherNode;}
17class Dasher::CDasherNode : private NoClones
18{
19 // CDasherNode represents a rectangle and character
20 // nodes have children, siblings and parents
21private:
22 const unsigned int m_iLbnd,m_iHbnd;// the cumulative lower and upper bound prob relative to parent
23 const unsigned int m_iGroup; // group membership - e.g. 0=nothing 1=caps 2=punc
24 unsigned int m_iChars, m_iAge;
25 bool m_bAlive; // if true, then display node, else dont bother
26 bool m_bControlNode; // if true, node is a control node
27 bool m_bControlChild; // if true, node is offspring of a control node
28 //bool m_Cscheme; // color scheme for the node - alternates through relatives
29 Opts::ColorSchemes m_ColorScheme;
30 int m_iPhase; // index for coloring
31 int m_iColour; // for the advanced colour mode
32
33 const symbol m_Symbol; // the character to display
34 CLanguageModel *m_languagemodel; // pointer to the language model - in future, could be different for each node
35 CDasherNode **m_Children; // pointer to array of children
36 CDasherNode *m_parent; // pointer to parent - only needed to grab parent context
37 CLanguageModel::CNodeContext *m_context;
38public:
39
40 CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, Opts::ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour);
41 ~CDasherNode();
42 bool m_bForce; // flag to force a node to be drawn - shouldn't be public
43
44 // return private data members - read only
45 CDasherNode ** const Children() const {return m_Children;}
46 unsigned int Lbnd() const {return m_iLbnd;}
47 bool Alive() {return m_bAlive;}
48 bool Control() {return m_bControlChild;}
49 void Kill() {m_bAlive=0;m_iAge=0;}
50 unsigned int Hbnd() const {return m_iHbnd;}
51 unsigned int Group() const {return m_iGroup;}
52 unsigned int Age() const {return m_iAge;}
53 symbol Symbol() const {return m_Symbol;}
54 unsigned int Chars() const {return m_iChars;}
55 int Phase() const {return m_iPhase;}
56 Opts::ColorSchemes Cscheme() const {return m_ColorScheme;}
57 int Colour() const {return m_iColour;}
58
59 CDasherNode* const Get_node_under(int,myint y1,myint y2,myint smousex,myint smousey); // find node under given co-ords
60 void Get_string_under(const int,const myint y1,const myint y2,const myint smousex,const myint smousey,std::vector<symbol>&) const; // get string under given co-ords
61 void Generic_Push_Node(CLanguageModel::CNodeContext *context);
62 void Push_Node(); // give birth to children
63 void Push_Node(CLanguageModel::CNodeContext *context); // give birth to children with this context
64 void Delete_children();
65 void Dump_node() const; // diagnostic
66};
67
68/////////////////////////////////////////////////////////////////////////////
69// Inline functions
70/////////////////////////////////////////////////////////////////////////////
71
72using namespace Dasher;
73using namespace Opts;
74
75/////////////////////////////////////////////////////////////////////////////
76
77inline CDasherNode::CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour=0)
78 : m_parent(parent),m_Symbol(Symbol),m_iGroup(igroup),m_iLbnd(ilbnd),m_iHbnd(ihbnd),m_languagemodel(lm),m_iPhase(iphase),
79 m_context(0), m_iAge(0), m_bAlive(1), m_Children(0), m_bForce(false), m_iChars(0), m_ColorScheme(ColorScheme), m_bControlChild(false), m_iColour(Colour)
80{
81 /*
82 switch (ColorScheme) {
83 case Nodes1:
84 m_ColorScheme = Nodes2;
85 break;
86 case Nodes2:
87 m_ColorScheme = Nodes1;
88 break;
89 case Special1:
90 m_ColorScheme = Special2;
91 break;
92 case Special2:
93 m_ColorScheme = Special1;
94 break;
95 case default:
96 m_ColorScheme = ColorScheme;
97 break;
98 }
99 */
100}
101
102/////////////////////////////////////////////////////////////////////////////
103
104inline void CDasherNode::Delete_children()
105{
106 if (m_Children) {
107 unsigned int i;
108 for (i=1;i<m_iChars;i++)
109 delete m_Children[i];
110 delete [] m_Children;
111 }
112 m_Children=0;
113
114}
115
116/////////////////////////////////////////////////////////////////////////////
117
118inline CDasherNode::~CDasherNode()
119{
120 Delete_children();
121 if (m_context)
122 m_languagemodel->ReleaseNodeContext(m_context);
123}
124
125/////////////////////////////////////////////////////////////////////////////
126
127#endif /* #ifndef __DasherNode_h__ */