dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtmail / dtmail / Editor.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  *+SNOTICE
25  *
26  *      $TOG: Editor.hh /main/11 1998/02/03 10:28:56 mgreess $
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42
43 #ifndef EDITOR_H
44 #define EDITOR_H
45
46 #include <Xm/Xm.h>
47 #include "MenuBar.h"
48
49 // Get all the Bento-related API and types (CMContainer, etc.)
50
51 #include <DtMail/DtMail.hh>
52 #include "UIComponent.h"
53
54 extern int use_XmTextEditor;
55
56 class DtMailEditor;
57
58 class Editor : public UIComponent {
59     
60   public:       
61     Editor();
62     virtual ~Editor();
63
64     virtual void        initialize() = 0;
65
66     virtual void        set_contents(
67                                      const char *contents,
68                                      const unsigned long len
69                                      ) = 0;
70
71     virtual void        set_contents(const char * path) = 0;
72
73     virtual char *      get_contents() = 0;
74
75     virtual void        append_to_contents(
76                                            const char *new_contents,
77                                            const unsigned long len
78                                            ) = 0;
79
80     virtual void        append_to_contents(const char * path) = 0;
81
82     virtual void        append_at_cursor(const char *path) = 0;
83     virtual void        append_at_cursor(
84                                      const char *contents, 
85                                      const unsigned long len
86                                      ) = 0;
87
88     enum InsertFormat {
89         IF_NONE,        // No special format
90         IF_INDENTED,    // Indented with indent_prefix
91         IF_BRACKETED    // Bracketed
92     };
93
94     enum BracketFormat {
95         BF_NONE,        // No bracketing
96         BF_INCLUDE,     // As included message,
97         BF_FORWARD      // As forwarded message
98         };
99
100     enum HeaderFormat {
101         HF_NONE,        // Do not insert headers in message body.
102         HF_FULL,        // Insert all headers.
103         HF_ABBREV       // Do not insert ignored headers.
104         };
105
106     virtual void        append_newline_to_contents();
107     virtual DtMailBoolean       set_message(
108                                         DtMail::Message * msg,
109                                         char ** status_string,
110                                         HeaderFormat header_format = HF_ABBREV,
111                                         InsertFormat format = IF_NONE,
112                                         BracketFormat brackets = BF_NONE);
113
114     virtual void                set_attachment(
115                                         DtMail::BodyPart * body_part,
116                                         InsertFormat format = IF_NONE,
117                                         BracketFormat brackets = BF_NONE);
118
119     virtual void        clear_contents() = 0;
120     virtual int         no_text()        = 0;
121
122     virtual Widget      get_editor() = 0;
123     virtual Widget      get_text_widget() = 0;
124     virtual Pixel       get_text_foreground() = 0;
125     virtual Pixel       get_text_background() = 0;
126     virtual Dimension   get_text_width() = 0;    
127     virtual XmFontList  get_text_fontList() = 0;
128
129     virtual int         get_columns() = 0;
130     virtual int         get_rows() = 0;
131     virtual void        set_columns(int ncolumns) = 0;
132     virtual void        set_editable(Boolean value) = 0;
133     virtual void        set_rows(int nrows) = 0;
134     virtual void        update_display_from_props(void);
135
136     virtual void        auto_show_cursor_off() = 0;
137     virtual void        auto_show_cursor_restore() = 0;
138
139     virtual void        set_to_top() = 0;
140     virtual void        set_to_bottom() = 0;
141
142         virtual void    find_change() = 0;
143         virtual void    spell() = 0;
144         virtual void    format() = 0;
145         virtual void    set_word_wrap(Boolean value) = 0;
146         virtual void    undo_edit() = 0;
147     virtual void        cut_selection() = 0;
148     virtual void        copy_selection() = 0;
149     virtual void        paste_from_clipboard() = 0;
150     virtual void        paste_special_from_clipboard(InsertFormat) = 0;
151     virtual void        clear_selection() = 0;
152     virtual void        delete_selection() = 0;
153     virtual void        select_all() = 0;
154
155     virtual void        disable_redisplay() = 0;
156     virtual void        enable_redisplay() = 0;
157
158 };
159
160 class AbstractEditorParent {
161   protected:
162         Widget _attachmentPopupMenu;
163         Widget _textPopupMenu;
164         MenuBar *_menuPopupAtt;
165         MenuBar *_menuPopupText;
166   public:
167
168     AbstractEditorParent();
169     virtual ~AbstractEditorParent();
170
171     virtual     const char *const className() 
172                                 { return "AbstractEditorParent"; }
173
174     virtual DtMailEditor *  get_editor() = 0;
175
176     // Text/attachment (de)selection methods
177
178     virtual void text_selected()   = 0;
179     virtual void text_unselected() = 0;
180     virtual void attachment_selected() = 0;
181     virtual void all_attachments_deselected() = 0;
182     virtual void all_attachments_selected() = 0;
183     virtual void add_att(char *) = 0;
184     virtual void add_att(char *, DtMailBuffer) = 0;
185     virtual void add_att(DtMailBuffer) = 0;
186
187     virtual void postAttachmentPopup(XEvent *event);
188     virtual void postTextPopup(XEvent *event);
189     
190     virtual void addAttachmentActions(
191                         char **,
192                         int
193                 ) = 0;
194     virtual void invokeAttachmentAction(int) = 0;
195     virtual void removeAttachmentActions() = 0;
196
197     virtual void selectAllAttachments() = 0;
198
199     virtual void        showAttachArea() = 0;
200     virtual void        hideAttachArea() = 0;
201
202     virtual void        attachmentFeedback(Boolean) = 0;
203
204 };
205
206     
207 #endif // EDITOR_HH