Diffstat (limited to 'inputmethods/dasher/DasherInterface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dasher/DasherInterface.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/inputmethods/dasher/DasherInterface.cpp b/inputmethods/dasher/DasherInterface.cpp index bb5b85e..4699687 100644 --- a/inputmethods/dasher/DasherInterface.cpp +++ b/inputmethods/dasher/DasherInterface.cpp | |||
@@ -1,128 +1,145 @@ | |||
1 | // DasherInterface.cpp | 1 | // DasherInterface.cpp |
2 | // | 2 | // |
3 | ///////////////////////////////////////////////////////////////////////////// | 3 | ///////////////////////////////////////////////////////////////////////////// |
4 | // | 4 | // |
5 | // Copyright (c) 2002 Iain Murray | 5 | // Copyright (c) 2002 Iain Murray |
6 | // | 6 | // |
7 | ///////////////////////////////////////////////////////////////////////////// | 7 | ///////////////////////////////////////////////////////////////////////////// |
8 | 8 | ||
9 | 9 | ||
10 | 10 | ||
11 | #include "DasherInterface.h" | 11 | #include "DasherInterface.h" |
12 | //#include "EnglishAlphabet.h" | 12 | //#include "EnglishAlphabet.h" |
13 | #include "CustomAlphabet.h" | 13 | #include "CustomAlphabet.h" |
14 | #include "DasherViewSquare.h" | 14 | #include "DasherViewSquare.h" |
15 | #include "PPMLanguageModel.h" | 15 | #include "PPMLanguageModel.h" |
16 | #include <iostream> | 16 | #include <iostream> |
17 | namespace { | 17 | namespace { |
18 | #include "stdio.h" | 18 | #include "stdio.h" |
19 | } | 19 | } |
20 | using namespace Dasher; | 20 | using namespace Dasher; |
21 | using namespace std; | 21 | using namespace std; |
22 | 22 | ||
23 | 23 | ||
24 | const string CDasherInterface::EmptyString = ""; | 24 | const string CDasherInterface::EmptyString = ""; |
25 | 25 | ||
26 | 26 | ||
27 | CDasherInterface::CDasherInterface() | 27 | CDasherInterface::CDasherInterface() |
28 | : m_DashEditbox(0), m_DasherScreen(0), m_LanguageModel(0), TrainContext(0), m_Alphabet(0), | 28 | : m_Alphabet(0), |
29 | m_DasherModel(0), m_DasherView(0), AlphabetID(""), LanguageModelID(-1), ViewID(-1), | 29 | m_LanguageModel(0), |
30 | m_MaxBitRate(-1), m_Orientation(Opts::LeftToRight), m_SettingsStore(0), m_SettingsUI(0), | 30 | m_DasherModel(0), |
31 | m_UserLocation("usr_"), m_SystemLocation("sys_"), m_AlphIO(0), m_TrainFile(""), | 31 | m_DashEditbox(0), |
32 | m_DasherFont(""), m_EditFont(""), m_EditFontSize(0), m_DrawKeyboard(false) | 32 | m_DasherScreen(0), |
33 | m_DasherView(0), | ||
34 | m_SettingsStore(0), | ||
35 | m_SettingsUI(0), | ||
36 | m_AlphIO(0), | ||
37 | TrainContext(0), | ||
38 | AlphabetID(""), | ||
39 | LanguageModelID(-1), | ||
40 | ViewID(-1), | ||
41 | m_MaxBitRate(-1), | ||
42 | m_DrawKeyboard(false), | ||
43 | m_Orientation(Opts::LeftToRight), | ||
44 | m_UserLocation("usr_"), | ||
45 | m_SystemLocation("sys_"), | ||
46 | m_TrainFile(""), | ||
47 | m_DasherFont(""), | ||
48 | m_EditFont(""), | ||
49 | m_EditFontSize(0) | ||
33 | { | 50 | { |
34 | } | 51 | } |
35 | 52 | ||
36 | 53 | ||
37 | CDasherInterface::~CDasherInterface() | 54 | CDasherInterface::~CDasherInterface() |
38 | { | 55 | { |
39 | if (m_LanguageModel) | 56 | if (m_LanguageModel) |
40 | m_LanguageModel->ReleaseNodeContext(TrainContext); | 57 | m_LanguageModel->ReleaseNodeContext(TrainContext); |
41 | delete m_DasherModel; // The order of some of these deletions matters | 58 | delete m_DasherModel; // The order of some of these deletions matters |
42 | delete m_LanguageModel; // eg DasherModel has a pointer to LanguageModel. | 59 | delete m_LanguageModel; // eg DasherModel has a pointer to LanguageModel. |
43 | delete m_Alphabet; // DM baulks if LM is deleted before it is. | 60 | delete m_Alphabet; // DM baulks if LM is deleted before it is. |
44 | delete m_DasherView; | 61 | delete m_DasherView; |
45 | // Do NOT delete Edit box or Screen. This class did not create them. | 62 | // Do NOT delete Edit box or Screen. This class did not create them. |
46 | } | 63 | } |
47 | 64 | ||
48 | 65 | ||
49 | void CDasherInterface::SetSettingsStore(CSettingsStore* SettingsStore) | 66 | void CDasherInterface::SetSettingsStore(CSettingsStore* SettingsStore) |
50 | { | 67 | { |
51 | delete m_SettingsStore; | 68 | delete m_SettingsStore; |
52 | m_SettingsStore = SettingsStore; | 69 | m_SettingsStore = SettingsStore; |
53 | this->SettingsDefaults(m_SettingsStore); | 70 | this->SettingsDefaults(m_SettingsStore); |
54 | } | 71 | } |
55 | 72 | ||
56 | 73 | ||
57 | void CDasherInterface::SetSettingsUI(CDasherSettingsInterface* SettingsUI) | 74 | void CDasherInterface::SetSettingsUI(CDasherSettingsInterface* SettingsUI) |
58 | { | 75 | { |
59 | delete m_SettingsUI; | 76 | delete m_SettingsUI; |
60 | m_SettingsUI = SettingsUI; | 77 | m_SettingsUI = SettingsUI; |
61 | //this->SettingsDefaults(m_SettingsStore); | 78 | //this->SettingsDefaults(m_SettingsStore); |
62 | m_SettingsUI->SettingsDefaults(m_SettingsStore); | 79 | m_SettingsUI->SettingsDefaults(m_SettingsStore); |
63 | } | 80 | } |
64 | 81 | ||
65 | 82 | ||
66 | void CDasherInterface::SetUserLocation(std::string UserLocation) | 83 | void CDasherInterface::SetUserLocation(std::string UserLocation) |
67 | { | 84 | { |
68 | // Nothing clever updates. (At the moment) it is assumed that | 85 | // Nothing clever updates. (At the moment) it is assumed that |
69 | // this is set before anything much happens and that it does | 86 | // this is set before anything much happens and that it does |
70 | // not require changing. | 87 | // not require changing. |
71 | m_UserLocation = UserLocation; | 88 | m_UserLocation = UserLocation; |
72 | if (m_Alphabet!=0) | 89 | if (m_Alphabet!=0) |
73 | m_TrainFile = m_UserLocation + m_Alphabet->GetTrainingFile(); | 90 | m_TrainFile = m_UserLocation + m_Alphabet->GetTrainingFile(); |
74 | } | 91 | } |
75 | 92 | ||
76 | 93 | ||
77 | void CDasherInterface::SetSystemLocation(std::string SystemLocation) | 94 | void CDasherInterface::SetSystemLocation(std::string SystemLocation) |
78 | { | 95 | { |
79 | // Nothing clever updates. (At the moment) it is assumed that | 96 | // Nothing clever updates. (At the moment) it is assumed that |
80 | // this is set before anything much happens and that it does | 97 | // this is set before anything much happens and that it does |
81 | // not require changing. | 98 | // not require changing. |
82 | m_SystemLocation = SystemLocation; | 99 | m_SystemLocation = SystemLocation; |
83 | } | 100 | } |
84 | 101 | ||
85 | 102 | ||
86 | void CDasherInterface::CreateDasherModel() | 103 | void CDasherInterface::CreateDasherModel() |
87 | { | 104 | { |
88 | 105 | ||
89 | if (m_DashEditbox!=0 && m_LanguageModel!=0) { | 106 | if (m_DashEditbox!=0 && m_LanguageModel!=0) { |
90 | delete m_DasherModel; | 107 | delete m_DasherModel; |
91 | m_DasherModel = new CDasherModel(m_DashEditbox, m_LanguageModel, m_Dimensions); | 108 | m_DasherModel = new CDasherModel(m_DashEditbox, m_LanguageModel, m_Dimensions); |
92 | if (m_MaxBitRate>=0) | 109 | if (m_MaxBitRate>=0) |
93 | m_DasherModel->SetMaxBitrate(m_MaxBitRate); | 110 | m_DasherModel->SetMaxBitrate(m_MaxBitRate); |
94 | if (ViewID!=-1) | 111 | if (ViewID!=-1) |
95 | ChangeView(ViewID); | 112 | ChangeView(ViewID); |
96 | } | 113 | } |
97 | 114 | ||
98 | 115 | ||
99 | } | 116 | } |
100 | 117 | ||
101 | 118 | ||
102 | void CDasherInterface::Start() | 119 | void CDasherInterface::Start() |
103 | { | 120 | { |
104 | if (m_DasherModel!=0) | 121 | if (m_DasherModel!=0) |
105 | m_DasherModel->Start(); | 122 | m_DasherModel->Start(); |
106 | } | 123 | } |
107 | 124 | ||
108 | 125 | ||
109 | void CDasherInterface::PauseAt(int MouseX, int MouseY) | 126 | void CDasherInterface::PauseAt(int MouseX, int MouseY) |
110 | { | 127 | { |
111 | if (m_DasherView!=0) | 128 | if (m_DasherView!=0) |
112 | m_DasherView->FlushAt(MouseX, MouseY); | 129 | m_DasherView->FlushAt(MouseX, MouseY); |
113 | if (m_DashEditbox!=0) { | 130 | if (m_DashEditbox!=0) { |
114 | m_DashEditbox->write_to_file(); | 131 | m_DashEditbox->write_to_file(); |
115 | if (m_CopyAllOnStop) | 132 | if (m_CopyAllOnStop) |
116 | m_DashEditbox->CopyAll(); | 133 | m_DashEditbox->CopyAll(); |
117 | } | 134 | } |
118 | } | 135 | } |
119 | 136 | ||
120 | 137 | ||
121 | void CDasherInterface::Unpause(unsigned long Time) | 138 | void CDasherInterface::Unpause(unsigned long Time) |
122 | { | 139 | { |
123 | if (m_DashEditbox!=0) | 140 | if (m_DashEditbox!=0) |
124 | m_DashEditbox->unflush(); | 141 | m_DashEditbox->unflush(); |
125 | if (m_DasherModel!=0) | 142 | if (m_DasherModel!=0) |
126 | m_DasherModel->Reset_framerate(Time); | 143 | m_DasherModel->Reset_framerate(Time); |
127 | } | 144 | } |
128 | 145 | ||