summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/DashEdit.h
Unidiff
Diffstat (limited to 'inputmethods/dasher/DashEdit.h') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/DashEdit.h163
1 files changed, 163 insertions, 0 deletions
diff --git a/inputmethods/dasher/DashEdit.h b/inputmethods/dasher/DashEdit.h
new file mode 100644
index 0000000..dc14d15
--- a/dev/null
+++ b/inputmethods/dasher/DashEdit.h
@@ -0,0 +1,163 @@
1//! Class definition for an edit box
2// DashEdit.h
3//
4/////////////////////////////////////////////////////////////////////////////
5//
6// Copyright (c) 2002 Iain Murray
7//
8/////////////////////////////////////////////////////////////////////////////
9
10/*
11An abstract DashEditbox class is described here.
12An implementation will handle interaction between Dasher and an actual Edit control.
13e.g. - output characters to the edit control
14 - tapping on the edit box updates the Dasher display
15*/
16
17#ifndef __DashEdit_h__
18#define __DashEdit_h__
19
20#include "DasherWidgetInterface.h"
21
22namespace Dasher {class CDashEditbox;}
23class Dasher::CDashEditbox
24{
25public:
26 CDashEditbox() : m_iFlushed(0), m_DasherInterface(0), m_dirty(false) {}
27
28 //! Provide the Editbox with a widget interface
29 virtual void SetInterface(CDasherWidgetInterface* DasherInterface) {m_DasherInterface = DasherInterface;}
30
31 //! Write some buffered output to a file
32 virtual void write_to_file()=0;
33
34 //! Set the number of flushed characters
35 //
36 //! Set the number of flushed characters to an arbitrary number.
37 //! Usually used to reset it to 0 after unflushing
38 void set_flushed(int i) {m_iFlushed=i;}
39
40 //! Provide context from the editbox for the core
41 //
42 //! Provide the context at the current position within the editbox to
43 //! the core. Set str to up to max characters before
44 //! the cursor position within the editbox.
45 virtual void get_new_context(std::string& str, int max)=0;
46
47 //! Delete flushed text from the editbox
48 virtual inline void unflush()=0;
49
50 //! Enter a the character Symbol into the text box
51 virtual void output(symbol Symbol)=0;
52
53 //! Delete the previous symbol from the text box
54 virtual void deletetext()=0;
55
56 //! Enter a character into the text box and remember that it is flushed
57 //
58 //! Output the character and increment m_iFlushed. When unflush is
59 //! called, remove the previous m_iFlushed characters
60 virtual void flush(symbol Symbol)=0;
61
62 // File I/O (optional)
63
64 //! If Value is true, timestamp all new files (optional)
65 //
66 //! If switched on, all new files should be timestamped, either in the
67 //! filename or in file metadata
68 virtual void TimeStampNewFiles(bool Value) {}
69
70 //! Return true if any text has been modified since the last save (optional)
71 bool IsDirty() {return m_dirty;}
72
73 //! Generate a new file (optional)
74 //
75 //! New file - provide a file save dialogue and return the filename in
76 //! filename, or provide a blank filename and present a file
77 //! save dialogue when Save() is called
78 virtual void New(const std::string& filename) {}; // filename can be "", but you cannot call Save() without having set a filename.
79
80 //! Open a file (optional)
81 //
82 //! Provide a file open dialogue and set filename to the
83 //! filename. Return true if a file is chosen and opened successfully,
84 //! false otherwise
85 virtual bool Open(const std::string& filename) {return false;};
86
87 //! Open a file and append to it (optional)
88 //
89 //! Provide a file open dialogue and set filename to the
90 //! filename. The file will then have any new text appended to it.
91 //! Return true if a file is chosen and opened successfully, false
92 //! otherwise
93 virtual bool OpenAppendMode(const std::string& filename) {return false;};
94 //! Save a file as a provided filename (optional)
95 //
96 //! Provide a file save dialogue and set filename to the
97 //! filename. Return true if a file is chosen and saved successfully,
98 //! false otherwise
99 virtual bool SaveAs(const std::string& filename) {return false;};
100
101 //! Save the current file (optional)
102 //
103 //! Save file to the current filename. If there is no current filename,
104 //! or if saving fails, return false
105 virtual bool Save() {return false;}; // returns false if there is no filename set, or if saving fails
106
107 // Clipboard (optional)
108 //! Cut selected text (optional)
109 //
110 //! Copy the selected text to the clipboard and remove it from the
111 //! editbox
112 virtual void Cut() {};
113
114 //! Copy selected text (optional)
115 //
116 //! Copy the selected text to the clipboard
117 virtual void Copy() {};
118
119 //! Copy all text (optional)
120 //
121 //! Copy all text in the editbox to the clipboard
122 virtual void CopyAll() {};
123
124 //! Paste text from clipboard (optional)
125 //
126 //! Paste text from the clipboard into the editbox at the current
127 //! position
128 virtual void Paste() {};
129
130 //! Select all text in the editbox (optional)
131 virtual void SelectAll() {};
132
133 //! Clear all text from the editbox (REQUIRED)
134 virtual void Clear()=0; // Must at least be able to clear edit box
135
136 //! Set the file encoding
137 //
138 //! Set the file encoding to the provided encoding Encoding.
139 //! The editbox is responsible for saving the file in the encoding
140 //! desired by the user. As Dasher is internally UTF8, it may well be
141 //! necessary to save in an alternative format based on locale and OS.
142 virtual void SetEncoding(Opts::FileEncodingFormats Encoding)=0;
143
144 //! Set the font used in the editbox
145 //
146 //! Set the font used in the editbox to Name and size
147 //! Size (in points)
148 virtual void SetFont(std::string Name, long Size)=0;
149
150// TODO sort relationship between CDashEditbox and derived classes
151protected:
152 //! Have the contents of the editbox been altered since the last save?
153 bool m_dirty;
154
155 //! Record the number of characters that have been flushed
156 int m_iFlushed; // how many characters have been flushed
157
158 //! Pointer to a DasherWidgetInterface for communication with the core
159 CDasherWidgetInterface* m_DasherInterface;
160};
161
162
163#endif /* #ifndef __DashEdit_h__ */