Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / tt / demo / CoEd / CoEd / CoEditor.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 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: CoEditor.h /main/3 1995/10/20 17:04:44 rswiston $                                                    */
28 #ifndef CoEditor_h
29 #define CoEditor_h
30
31 #include <X11/Intrinsic.h>
32 #include <Xm/Xm.h>
33 #include <Xm/Text.h>
34 #include <Tt/tttk.h>
35
36 class CoEditor {
37     public:
38                                 CoEditor(
39                                         Widget         *parent
40                                 );
41                                 CoEditor(
42                                         Widget         *parent,
43                                         const char     *file
44                                 );
45                                 CoEditor(
46                                         Widget         *parent,
47                                         Tt_message      msg,
48                                         const char     *docname,
49                                         Tt_status      &status
50                                 );
51                                 CoEditor(
52                                         Widget         *parent,
53                                         Tt_message      msg,
54                                         int             readOnly,
55                                         const char     *file,
56                                         const char     *docname,
57                                         Tt_status      &status
58                                 );
59                                 CoEditor(
60                                         Widget         *parent,
61                                         Tt_message      msg,
62                                         int             readOnly,
63                                         unsigned char  *contents,
64                                         int             len,
65                                         const char     *docname,
66                                         Tt_status      &status
67                                 );
68                                 ~CoEditor();
69
70         static Tt_message       loadISOLatin1_(
71                                         Tt_message      msg,
72                                         void           *clientData,
73                                         Tttk_op         op,
74                                         Tt_status       diagnosis,
75                                         unsigned char  *contents,
76                                         int             len,
77                                         char           *file,
78                                         char           *docname
79                                 );
80         static Tt_message       contractCB_(
81                                         Tt_message      msg,
82                                         void           *coEditor,
83                                         Tt_message      contract
84                                 );
85         Tt_message              _contractCB(
86                                         Tt_message      msg,
87                                         Tt_message      contract
88                                 );
89         static Tt_message       subContractCB_(
90                                         Tt_message      msg,
91                                         void           *coEditor,
92                                         Tt_message      subContract
93                                 );
94         Tt_message              _subContractCB(
95                                         Tt_message      msg,
96                                         Tt_message      subContract
97                                 );
98
99     private:
100         void                    _init();
101         Tt_status               _init(
102                                         Tt_message      msg
103                                 );
104         void                    _init(
105                                         Widget         *parent
106                                 );
107         Tt_status               _unload();
108         Tt_status               _load(
109                                         const char     *file
110                                 );
111         Tt_status               _load(
112                                         unsigned char  *contents,
113                                         int             len
114                                 );
115         Tt_status               _save();
116         Tt_status               _revert();
117         static void             _destroyCB_(
118                                         Widget    w,
119                                         XtPointer coEditor,
120                                         XtPointer call_data
121                                 );
122         void                    _destroyCB(
123                                         Widget    w,
124                                         XtPointer call_data
125                                 );
126         int                     _quit(
127                                         int             silent = 0,
128                                         int             force  = 0
129                                 );
130         static int              _quitAll(
131                                         int             silent,
132                                         int             force
133                                 );
134         static void             _wmProtocolCB_(
135                                         Widget    w,
136                                         XtPointer coEditor,
137                                         XmAnyCallbackStruct *cbs
138                                 );
139         void                    _wmProtocolCB();
140         static void             _fileButsCB_(
141                                         Widget    button,
142                                         XtPointer coEditor,
143                                         XtPointer call_data
144                                 );
145         void                    _fileButsCB(
146                                         Widget    button,
147                                         XtPointer call_data
148                                 );
149         static void             _editButsCB_(
150                                         Widget    button,
151                                         XtPointer coEditor,
152                                         XtPointer call_data
153                                 );
154         void                    _editButsCB(
155                                         Widget    button,
156                                         XtPointer call_data
157                                 );
158         char                   *_contents(
159                                         int            *len
160                                 );
161         char                   *_selection(
162                                         int            *len
163                                 );
164         Tt_status               _acceptContract(
165                                         Tt_message      msg
166                                 );
167         static Tt_message       _mediaLoadMsgCB_(
168                                         Tt_message      msg,
169                                         void           *clientData,
170                                         Tttk_op         op,
171                                         unsigned char  *contents,
172                                         int             len,
173                                         char           *file
174                                 );
175         Tt_message              _mediaLoadMsgCB(
176                                         Tt_message      msg,
177                                         Tttk_op         op,
178                                         unsigned char  *contents,
179                                         int             len,
180                                         char           *file
181                                 );
182         static void             _textUpdateCB_(
183                                         Widget                  coEditor,
184                                         XtPointer               pTextBuffer,
185                                         XmTextVerifyCallbackStruct *cbs
186                                 );
187         void                    _textUpdateCB();
188         static Tt_message       _fileCB_(
189                                         Tt_message      msg,
190                                         Tttk_op         op,
191                                         char           *pathname,
192                                         void           *clientData,
193                                         int             trust,
194                                         int             me
195                                 );
196         Tt_message              _fileCB(
197                                         Tt_message      msg,
198                                         Tttk_op         op,
199                                         char           *pathname,
200                                         int             trust,
201                                         int             me
202                                 );
203         static void             _textModifyCB_(
204                                         Widget          text,
205                                         XtPointer       ,
206                                         XmTextVerifyCallbackStruct *mod
207                                 );
208         void                    _textModifyCB(
209                                         XmTextVerifyCallbackStruct *mod
210                                 );
211         void                    _adviseUser(
212                                         const char     *msg,
213                                         Tt_status       status
214                                 );
215         Tt_status               _read_file(
216                                         Widget  widget,
217                                         char    *file
218                                 );
219         Tt_status               _write_file(
220                                         Widget widget,
221                                         char    *file
222                                 );
223     public:
224         Widget                  shell;
225         static CoEditor        *editors[];
226         static int              numEditors;
227
228     private:
229         Widget                  _baseFrame;
230         Widget                  _controls;
231         Widget                  _fileBut;
232         Widget                  _editBut;
233         Widget                  _text;
234         Boolean                 _modifiedByMe;
235         int                     _modifiedByOther; // >1 == user has been asked
236         Tt_message              _contract;
237         Tt_message              _subContract;
238         Tt_pattern             *_contractPats;
239         Tt_pattern             *_filePats;
240         char                   *_file;          // free w/ free()
241         int                     _x;             // geometry of parent
242         int                     _y;
243         int                     _w;
244         int                     _h;
245 };
246
247 #endif