~ubuntu-branches/ubuntu/warty/dasher/warty

« back to all changes in this revision

Viewing changes to Src/DasherCore/DashEdit.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2003-06-05 11:10:04 UTC
  • Revision ID: james.westby@ubuntu.com-20030605111004-kqiutbrlvs7td9ic
Tags: upstream-3.2.10
ImportĀ upstreamĀ versionĀ 3.2.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//! Class definition for an edit box
 
2
// DashEdit.h
 
3
//
 
4
/////////////////////////////////////////////////////////////////////////////
 
5
//
 
6
// Copyright (c) 2002 Iain Murray
 
7
//
 
8
/////////////////////////////////////////////////////////////////////////////
 
9
 
 
10
/*
 
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
 
15
*/
 
16
 
 
17
#ifndef __DashEdit_h__
 
18
#define __DashEdit_h__
 
19
 
 
20
#include "DasherWidgetInterface.h"
 
21
 
 
22
namespace Dasher {class CDashEditbox;}
 
23
class Dasher::CDashEditbox
 
24
{
 
25
public:
 
26
        CDashEditbox() : m_DasherInterface(0), m_dirty(false) {}
 
27
 
 
28
        virtual ~CDashEditbox() {}
 
29
 
 
30
        //! Provide the Editbox with a widget interface
 
31
        virtual void SetInterface(CDasherWidgetInterface* DasherInterface) {m_DasherInterface = DasherInterface;}
 
32
        
 
33
        //! Write some buffered output to a file
 
34
        virtual void write_to_file()=0;
 
35
        
 
36
        //! Provide context from the editbox for the core
 
37
        //
 
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;
 
42
        
 
43
        //! Enter a the character Symbol into the text box
 
44
        virtual void output(symbol Symbol)=0;
 
45
 
 
46
        //! Send a control command
 
47
        virtual void outputcontrol(void* pointer, int data, int type)=0;
 
48
 
 
49
        //! Delete the previous symbol from the text box
 
50
        virtual void deletetext(symbol Symbol)=0;
 
51
        
 
52
        // File I/O (optional)
 
53
 
 
54
        //! If Value is true, timestamp all new files (optional)
 
55
        //
 
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) {}
 
59
 
 
60
        //! Return true if any text has been modified since the last save (optional)
 
61
        bool IsDirty() {return m_dirty;}
 
62
 
 
63
        //! Generate a new file (optional)
 
64
        //
 
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.
 
69
        
 
70
        //! Open a file (optional)
 
71
        //
 
72
        //! Provide a file open dialogue and set filename to the 
 
73
        //! filename. Return true if a file is chosen and opened successfully,
 
74
        //! false otherwise
 
75
        virtual bool Open(const std::string& filename) {return false;};
 
76
 
 
77
        //! Open a file and append to it (optional)
 
78
        // 
 
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 
 
82
        //! otherwise
 
83
        virtual bool OpenAppendMode(const std::string& filename) {return false;};
 
84
        //! Save a file as a provided filename (optional)
 
85
        // 
 
86
        //! Provide a file save dialogue and set filename to the 
 
87
        //! filename. Return true if a file is chosen and saved successfully,
 
88
        //! false otherwise
 
89
        virtual bool SaveAs(const std::string& filename) {return false;};
 
90
 
 
91
        //! Save the current file (optional)
 
92
        //
 
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
 
96
        
 
97
        // Clipboard (optional)
 
98
        //! Cut selected text (optional)
 
99
        //
 
100
        //! Copy the selected text to the clipboard and remove it from the
 
101
        //! editbox
 
102
        virtual void Cut() {};
 
103
 
 
104
        //! Copy selected text (optional)
 
105
        //
 
106
        //! Copy the selected text to the clipboard
 
107
        virtual void Copy() {};
 
108
 
 
109
        //! Copy all text (optional)
 
110
        //
 
111
        //! Copy all text in the editbox to the clipboard
 
112
        virtual void CopyAll() {};
 
113
 
 
114
        //! Paste text from clipboard (optional)
 
115
        //
 
116
        //! Paste text from the clipboard into the editbox at the current
 
117
        //! position
 
118
        virtual void Paste() {};
 
119
 
 
120
        //! Select all text in the editbox (optional)
 
121
        virtual void SelectAll() {};
 
122
 
 
123
        //! Clear all text from the editbox (REQUIRED)
 
124
        virtual void Clear()=0; // Must at least be able to clear edit box
 
125
 
 
126
        //! Set the file encoding
 
127
        //
 
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;
 
133
 
 
134
        //! Set the font used in the editbox
 
135
        //
 
136
        //! Set the font used in the editbox to Name and size 
 
137
        //! Size (in points)
 
138
        virtual void SetFont(std::string Name, long Size)=0;
 
139
        
 
140
// TODO sort relationship between CDashEditbox and derived classes
 
141
protected:
 
142
        //! Have the contents of the editbox been altered since the last save?
 
143
        bool m_dirty;
 
144
 
 
145
        //! Pointer to a DasherWidgetInterface for communication with the core
 
146
        CDasherWidgetInterface* m_DasherInterface;
 
147
};
 
148
 
 
149
 
 
150
#endif /* #ifndef __DashEdit_h__ */