dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtmail / dtmail / AttachArea.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 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  *      $XConsortium: AttachArea.h /main/3 1995/11/06 16:04:04 rswiston $
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 ATTACHAREA_H
44 #define ATTACHAREA_H
45
46 #ifndef I_HAVE_NO_IDENT
47 #endif
48
49 #define TYPETEXT 0              /* unformatted text */
50 #define TYPEMULTIPART 1         /* multiple part */
51 #define TYPEMESSAGE 2           /* encapsulated message */
52 #define TYPEAPPLICATION 3       /* application data */
53 #define TYPEAUDIO 4             /* audio */
54 #define TYPEIMAGE 5             /* static image */
55 #define TYPEVIDEO 6             /* video */
56 #define TYPEOTHER 7             /* unknown */
57
58 #include <Xm/Xm.h>
59 #include "UIComponent.h"
60 #include "UndoCmd.h"
61 #include "CmdList.h"
62 #include "MenuBar.h"
63 #include "DtMailHelp.hh"
64
65 #include <DtMail/DtMailError.hh>
66 #include <DtMail/DtMail.hh>
67
68 typedef enum { NOTSET, ADD, SAVEAS } FSState;
69
70 class Attachment;
71 class DtMailEditor;
72
73 class RoamMenuWindow;
74 class SendMsgDialog;
75 class ViewMsgDialog;
76
77 class AttachArea : public UIComponent {
78
79   private:
80
81     enum   AAreaSState {AA_SEL_NONE=0, AA_SEL_SINGLE=1, AA_SEL_ALL=2};
82     static void inputCallback( Widget, XtPointer, XtPointer );
83     static void MenuButtonHandler(Widget, XtPointer, XEvent *, Boolean *); 
84     static void resizeCallback( Widget, XtPointer, XtPointer );
85
86     void   popupAttachmentMenu(XEvent *event);
87
88     void resize(Dimension);     // Called when the user click a button
89     unsigned int          _iconCount;
90     unsigned int          _iconSelectedCount;
91     unsigned int          _deleteCount;
92     Attachment      **_attachmentList;// The list of attachments
93
94     FSState               _fsState;     // State of the File Selection Box
95     Widget                _fsDialog;
96     Widget                _renameDialog;
97     Widget                _descriptionDialog;
98     Widget                _no_attachments_label;
99     Widget                _attachments_label;
100     Widget                _size_attachments_label;
101     Widget                _no_selected_label;
102     Widget                _selected_label;
103     DtMailEditor          *_myOwner;            // The class that owns it
104     Widget                _parent;              // The parent widget
105     Widget              rowOfAttachmentsStatus;
106     Widget              _attachments_status;
107     Widget              _attachments_summary;
108     RoamMenuWindow      *_myRMW;
109     ViewMsgDialog       *_myVMD;
110     SendMsgDialog       *_mySMD;
111     Boolean             _pendingAction;
112     int                 _numPendingActions;
113
114                 // Selection State of Attach Area
115     AAreaSState         _attach_area_selection_state; 
116     Attachment          *_cache_single_attachment; // single selected attachment 
117     DtMail::MailBox               *_mailbox;
118     Dimension          _attachAreaWidth;        // The width of the AA
119     Dimension          _attachAreaHeight;       // The height of the AA
120     void           valueChanged( XtPointer );
121     static void    valueChangedCallback( Widget, XtPointer, XtPointer );
122     void                   dragSlider( XtPointer );
123     static void            dragCallback( Widget, XtPointer, XtPointer );
124     unsigned int       _lastRow;                // The current last row
125     unsigned int       _currentRow;             // The current row
126     unsigned int           _attachmentsSize;    // Size of all attachments
127     unsigned int           _selectedAttachmentsSize;    // Size of all 
128     XtPointer      _clientData;
129                         // selected attachments
130     char *                  calcKbytes(unsigned int);
131
132   protected:
133
134     Widget               _rc;   // The RowColumn widget that manages 
135                                 // the attachments
136     Widget               _sw;   // The ScrolledWindow widget
137     Widget               _vsb;  // The vertical scrollbar of the ScrolledWindow
138     Widget               _message;
139     Widget               _clipWindow;
140     Cmd         *_open;
141     Cmd         *_saveas;
142     Cmd         *_selectall;
143     Cmd         *_unselectall;
144     MenuBar             *_menuBar;
145     Pixel               _background;
146     Pixel               _foreground;
147     Pixel               _appBackground;
148     Pixel               _appForeground;
149     CmdList*    _fileCmdList;
150     CmdList*    _editCmdList;
151     Widget              _size_selected_label;
152     Widget              _format_button;
153
154   public:
155     AttachArea (Widget, DtMailEditor*, char *);
156     virtual             ~AttachArea();
157
158     void                initialize();
159     void                addToRowOfAttachmentsStatus();
160     void                attachment_summary(int, int);
161         // Inline functions
162     Cmd*                        openCmd()       { return ( _open ); }
163     Widget                      getVerticalSB() { return ( _vsb ); }
164     unsigned int                getIconCount()  { return ( _iconCount ); }
165     unsigned int                getUndeletedIconCount()
166                                         { return (_iconCount - _deleteCount); }
167     unsigned int                getIconSelectedCount()
168                                         { return ( _iconSelectedCount ); }
169
170     unsigned int                getDeleteCount(){ return ( _deleteCount ); }
171     void                        incIconCount()  { _iconCount++; }
172     void                        decIconCount()  { _iconCount--; }
173     void                        incIconSelectedCount()
174                                         { _iconSelectedCount++; }
175     void                        decIconSelectedCount()
176                                                 { _iconSelectedCount--; }
177     void                        incDeleteCount(){ _deleteCount++; }
178     void                        decDeleteCount(){ _deleteCount--; }
179     Attachment**                getList() { return ( _attachmentList ); }
180
181     FSState                     getFsState()    { return (_fsState ); }
182     void                        setFsState( FSState state )
183                                                 { ( _fsState = state ); }
184     void                        setFsDialog( Widget w )
185                                                 {  _fsDialog = w; }
186     void                        setRenameDialog( Widget w )
187                                                 {  _renameDialog = w; }
188     void                        setDescriptionDialog( Widget w )
189                                                 {  _descriptionDialog = w; }
190     Widget                      getFsDialog()   { return (_fsDialog ); }
191     Widget                      getRenameDialog()  { return (_renameDialog ); }
192   
193     Widget                      getDescriptionDialog()  
194                                         { return (_descriptionDialog );}
195     virtual const char *const className()       { return ( "AttachArea" ); }
196
197
198     void                        addToList( Attachment * );
199     void                        addToDeletedList( Attachment *);
200
201 #ifdef DEAD_WOOD
202     void                        undeleteAllDeletedAttachments(DtMailEnv &);
203 #endif /* DEAD_WOOD */
204     void                        undeleteLastDeletedAttachment(DtMailEnv &);
205
206     void                        removeLastDeletedAttachment();
207
208     virtual void                attachmentFeedback(Boolean);
209
210     virtual void                activateDeactivate();
211     Widget                      getRc() { return (_rc ); }
212     Widget                      getClipWindow() { return (_clipWindow ); }
213     Widget                      getSWWindow()   { return (_sw ); }
214     Pixel               getBackground() { return (_background ); }
215     Pixel               getForeground() { return (_foreground ); }
216     Pixel               getAppBackground(){ return (_appBackground ); }
217     Pixel               getAppForeground(){ return (_appForeground ); }
218     Dimension           getAAWidth()    { return (_attachAreaWidth); }
219     Dimension           getAAHeight()   { return (_attachAreaHeight); }
220     DtMailEditor*       owner()   { return ( _myOwner ); }
221     
222     Attachment*         addAttachment(
223                                       DtMail::Message *, 
224                                       DtMail::BodyPart *, 
225                                       char *filename,
226                                       char *
227                                       );
228
229     Attachment*         addAttachment(DtMail::Message *,
230                                         DtMail::BodyPart *,
231                                         String,
232                                         DtMailBuffer);
233
234     Attachment*         addAttachment(String name, DtMail::BodyPart *);
235
236     void                addAttachmentActions(
237                                     char **,
238                                     int
239                            );
240     DtMail::MailBox*    get_mailbox()   { return ( _mailbox ); }
241     String              getRenameMessageString()
242                                 { return ("RenameMessageString"); }
243     String              getDescriptionMessageString()
244                                 { return ("DescriptionMessageString"); }
245     unsigned int        getAttachmentsSize()
246                                         { return ( _attachmentsSize ); }
247     unsigned int        getSelectedAttachmentsSize()
248                                 { return ( _selectedAttachmentsSize ); }
249     void                setAttachmentsSize( unsigned int size )
250                                         { ( _attachmentsSize = size ); }
251     void                setSelectedAttachmentsSize( unsigned int size )
252                                 { ( _selectedAttachmentsSize = size ); }
253
254     void                selectAllAttachments();
255
256     Attachment*         getSelectedAttachment();
257     void                unselectOtherSelectedAttachments(Attachment *);
258 #ifdef DEAD_WOOD
259     void                        deleteAttachments();
260 #endif /* DEAD_WOOD */
261     void                        manageList();
262     void                        CalcSizeOfAttachPane( );
263 #ifdef DEAD_WOOD
264     void                        CalcAttachmentPosition(Attachment *);
265 #endif /* DEAD_WOOD */
266     void                        CalcAllAttachmentPositions();
267     void                        DisplayAttachmentsInRow(unsigned int);
268     void                        calculate_attachment_position(
269                                         Attachment *, 
270                                         Attachment *);
271     void                        CalcLastRow();
272     unsigned int                getLastRow()    { return ( _lastRow); }
273     unsigned int                getCurrentRow() { return ( _currentRow); }
274     void                        SetScrollBarSize(unsigned int );
275     void                        AdjustCurrentRow();
276     void                        initialize(Widget);
277     void                        initialize_send(Widget);
278     void                        initialize_view(Widget);
279 #ifdef DEAD_WOOD
280     void                        setAttachmentsLabel( );
281 #endif /* DEAD_WOOD */
282     int                         getSelectedIconCount();
283 #ifdef DEAD_WOOD
284     void                        CalcAttachmentsSize( );
285     void                        add_attachment( Attachment * );
286 #endif /* DEAD_WOOD */
287
288     // Methods for parsing the attachments in a DtMail::Message
289
290     void                parseAttachments(
291                                        DtMailEnv &,
292                                        DtMail::Message *, 
293                                            Boolean, 
294                                        int);
295
296     // SR -- Added methods below
297
298     void                attachmentSelected(Attachment *);
299     void                manage();
300     void                unmanage();
301     void                removeCurrentAttachments();
302     void                clearAttachArea();
303 #ifdef DEAD_WOOD
304     void                saveAttachmentToFile(DtMailEnv &, char *);
305 #endif /* DEAD_WOOD */
306     void                deleteSelectedAttachments(DtMailEnv &);
307     Widget              ownerShellWidget();
308     void                setOwnerShell(RoamMenuWindow *);
309     void                setOwnerShell(ViewMsgDialog  *);
310     void                setOwnerShell(SendMsgDialog  *);
311     Boolean             isOwnerShellEditable();
312
313     void                setPendingAction(Boolean);
314     void                resetPendingAction();
315     int                 getNumPendingActions();
316
317     XmString            getSelectedAttachName();
318     void                setSelectedAttachName(XmString );
319
320     int                 handleQuestionDialog(char *title, 
321                                                 char *buf,
322                                                 char *helpId = DTMAILHELPERROR);
323
324     int                 handleErrorDialog(char *title, 
325                                             char *buf, 
326                                             char *helpId = DTMAILHELPERROR);
327 };
328 #endif
329