1
//! Class definition for an edit box
4
/////////////////////////////////////////////////////////////////////////////
6
// Copyright (c) 2002 Iain Murray
8
/////////////////////////////////////////////////////////////////////////////
11
An abstract DashEditbox class is described here.
12
An implementation will handle interaction between Dasher and an actual Edit control.
13
e.g. - output characters to the edit control
14
- tapping on the edit box updates the Dasher display
17
#ifndef __DashEdit_h__
18
#define __DashEdit_h__
20
#include "DasherWidgetInterface.h"
22
namespace Dasher {class CDashEditbox;}
23
class Dasher::CDashEditbox
26
CDashEditbox() : m_DasherInterface(0), m_dirty(false) {}
28
virtual ~CDashEditbox() {}
30
//! Provide the Editbox with a widget interface
31
virtual void SetInterface(CDasherWidgetInterface* DasherInterface) {m_DasherInterface = DasherInterface;}
33
//! Write some buffered output to a file
34
virtual void write_to_file()=0;
36
//! Provide context from the editbox for the core
38
//! Provide the context at the current position within the editbox to
39
//! the core. Set str to up to max characters before
40
//! the cursor position within the editbox.
41
virtual void get_new_context(std::string& str, int max)=0;
43
//! Enter a the character Symbol into the text box
44
virtual void output(symbol Symbol)=0;
46
//! Send a control command
47
virtual void outputcontrol(void* pointer, int data, int type)=0;
49
//! Delete the previous symbol from the text box
50
virtual void deletetext(symbol Symbol)=0;
52
// File I/O (optional)
54
//! If Value is true, timestamp all new files (optional)
56
//! If switched on, all new files should be timestamped, either in the
57
//! filename or in file metadata
58
virtual void TimeStampNewFiles(bool Value) {}
60
//! Return true if any text has been modified since the last save (optional)
61
bool IsDirty() {return m_dirty;}
63
//! Generate a new file (optional)
65
//! New file - provide a file save dialogue and return the filename in
66
//! filename, or provide a blank filename and present a file
67
//! save dialogue when Save() is called
68
virtual void New(const std::string& filename) {}; // filename can be "", but you cannot call Save() without having set a filename.
70
//! Open a file (optional)
72
//! Provide a file open dialogue and set filename to the
73
//! filename. Return true if a file is chosen and opened successfully,
75
virtual bool Open(const std::string& filename) {return false;};
77
//! Open a file and append to it (optional)
79
//! Provide a file open dialogue and set filename to the
80
//! filename. The file will then have any new text appended to it.
81
//! Return true if a file is chosen and opened successfully, false
83
virtual bool OpenAppendMode(const std::string& filename) {return false;};
84
//! Save a file as a provided filename (optional)
86
//! Provide a file save dialogue and set filename to the
87
//! filename. Return true if a file is chosen and saved successfully,
89
virtual bool SaveAs(const std::string& filename) {return false;};
91
//! Save the current file (optional)
93
//! Save file to the current filename. If there is no current filename,
94
//! or if saving fails, return false
95
virtual bool Save() {return false;}; // returns false if there is no filename set, or if saving fails
97
// Clipboard (optional)
98
//! Cut selected text (optional)
100
//! Copy the selected text to the clipboard and remove it from the
102
virtual void Cut() {};
104
//! Copy selected text (optional)
106
//! Copy the selected text to the clipboard
107
virtual void Copy() {};
109
//! Copy all text (optional)
111
//! Copy all text in the editbox to the clipboard
112
virtual void CopyAll() {};
114
//! Paste text from clipboard (optional)
116
//! Paste text from the clipboard into the editbox at the current
118
virtual void Paste() {};
120
//! Select all text in the editbox (optional)
121
virtual void SelectAll() {};
123
//! Clear all text from the editbox (REQUIRED)
124
virtual void Clear()=0; // Must at least be able to clear edit box
126
//! Set the file encoding
128
//! Set the file encoding to the provided encoding Encoding.
129
//! The editbox is responsible for saving the file in the encoding
130
//! desired by the user. As Dasher is internally UTF8, it may well be
131
//! necessary to save in an alternative format based on locale and OS.
132
virtual void SetEncoding(Opts::FileEncodingFormats Encoding)=0;
134
//! Set the font used in the editbox
136
//! Set the font used in the editbox to Name and size
138
virtual void SetFont(std::string Name, long Size)=0;
140
// TODO sort relationship between CDashEditbox and derived classes
142
//! Have the contents of the editbox been altered since the last save?
145
//! Pointer to a DasherWidgetInterface for communication with the core
146
CDasherWidgetInterface* m_DasherInterface;
150
#endif /* #ifndef __DashEdit_h__ */