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