dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtmail / dtmail / DtEditor.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: DtEditor.hh /main/9 1998/02/03 10:28:23 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 DTEDITOR_HH
44 #define DTEDITOR_HH
45
46 // Include the DtWidgetEditor .h file given by HP.
47
48 #include <Dt/Editor.h>
49
50 #include "Editor.hh"
51 #include "DtMailEditor.hh"
52
53 class CDEM_DtWidgetEditor : public Editor
54 {
55
56   public:
57     CDEM_DtWidgetEditor(
58                 Widget parent, 
59                 DtMailEditor *owner_of_editor);
60     ~CDEM_DtWidgetEditor();
61     
62         // Pure virtual functions of class Editor
63     //
64     virtual void        initialize();
65
66     virtual void        set_contents(
67                                 const char *contents,
68                                 const unsigned long len
69                                 );
70
71     virtual void        set_contents(const char *path);
72                                 
73     virtual char*       get_contents();
74
75     virtual void        append_to_contents(
76                                 const char *new_contents,
77                                 const unsigned long len
78                                 );
79
80     virtual void        append_to_contents(const char *path);
81
82     virtual void        append_at_cursor(const char *path);
83
84     virtual void        append_at_cursor(
85                                 const char *contents,
86                                 const unsigned long len
87                                 );
88
89     virtual void        clear_contents();
90     virtual int         no_text();
91
92     virtual Widget      get_text_widget();
93     virtual Pixel       get_text_foreground();
94     virtual Pixel       get_text_background();
95     virtual Dimension   get_text_width();
96     virtual XmFontList  get_text_fontList();
97     virtual Widget      get_editor();
98     
99     virtual int         get_columns();
100     virtual int         get_rows();
101     virtual void        set_columns(int ncolumns);
102     virtual void        set_editable(Boolean value);
103     virtual void        set_rows(int nrows);
104
105     virtual void        auto_show_cursor_off();
106     virtual void        auto_show_cursor_restore();
107
108     virtual void        set_to_top();
109     virtual void        set_to_bottom();
110
111     virtual void        cut_selection();
112     virtual void        copy_selection();
113     virtual void        paste_from_clipboard();
114     virtual void        paste_special_from_clipboard(Editor::InsertFormat);
115     virtual void        clear_selection();
116     virtual void        delete_selection();
117     virtual void        select_all();
118
119     virtual void        disable_redisplay();
120     virtual void        enable_redisplay();
121
122     //
123         // End of Pure virtual functions for class Editor.
124
125         // Pure virtual functions of class AbstractEditorParent
126     virtual void        text_selected();
127     virtual void        text_unselected();
128
129         // Functions specific to DtEditor
130     virtual void        set_word_wrap(Boolean value);
131     virtual void        undo_edit();
132     virtual void        find_change();
133     virtual void    spell();
134     virtual void    format();
135
136     static void MenuButtonHandler(Widget, XtPointer, XEvent *, Boolean *); 
137                         
138   protected:
139
140     // modify verify callback used during Paste Special
141     static void modify_verify_callback(Widget, XtPointer, XtPointer);
142
143     static void text_selected_callback(Widget, void *, void *);
144     static void text_unselected_callback(Widget, void *, void *);
145         
146
147   private:
148     struct PSClientData {
149         CDEM_DtWidgetEditor *obj;
150         Editor::InsertFormat insert_format;
151     };
152     XmTextBlockRec      *_modified_text; 
153     size_t              _modified_text_buflen;
154     enum PasteSpecBuf { MAXBUFSZ = 2048, BUFINC = 512};
155     void modifyData(char *, int, Editor::InsertFormat);
156     void reallocPasteBuf(size_t size_req) {
157                 _modified_text->ptr = 
158                         (char *)realloc((void *)_modified_text->ptr, size_req);
159                 _modified_text_buflen = size_req; 
160     }
161
162     const char *indent_str;
163     const char *begin_ins_bracket;
164     const char *end_ins_bracket;
165
166     Widget my_parent;
167     Widget my_text;
168     Widget my_text_core;
169
170     DtMailEditor *my_owner;
171     Boolean text_already_selected;
172     Boolean             _auto_show_cursor;
173
174     char * _buffer;
175     unsigned long _buf_len;
176
177 };
178
179 #endif // DTEDITOR_HH