2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
26 * $XConsortium: AttachArea.h /main/3 1995/11/06 16:04:04 rswiston $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
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
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
46 #ifndef I_HAVE_NO_IDENT
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 */
59 #include "UIComponent.h"
63 #include "DtMailHelp.hh"
65 #include <DtMail/DtMailError.hh>
66 #include <DtMail/DtMail.hh>
68 typedef enum { NOTSET, ADD, SAVEAS } FSState;
77 class AttachArea : public UIComponent {
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 );
86 void popupAttachmentMenu(XEvent *event);
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
94 FSState _fsState; // State of the File Selection Box
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;
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);
134 Widget _rc; // The RowColumn widget that manages
136 Widget _sw; // The ScrolledWindow widget
137 Widget _vsb; // The vertical scrollbar of the ScrolledWindow
147 Pixel _appBackground;
148 Pixel _appForeground;
149 CmdList* _fileCmdList;
150 CmdList* _editCmdList;
151 Widget _size_selected_label;
152 Widget _format_button;
155 AttachArea (Widget, DtMailEditor*, char *);
156 virtual ~AttachArea();
159 void addToRowOfAttachmentsStatus();
160 void attachment_summary(int, int);
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 ); }
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 ); }
181 FSState getFsState() { return (_fsState ); }
182 void setFsState( FSState state )
183 { ( _fsState = state ); }
184 void setFsDialog( Widget 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 ); }
193 Widget getDescriptionDialog()
194 { return (_descriptionDialog );}
195 virtual const char *const className() { return ( "AttachArea" ); }
198 void addToList( Attachment * );
199 void addToDeletedList( Attachment *);
202 void undeleteAllDeletedAttachments(DtMailEnv &);
203 #endif /* DEAD_WOOD */
204 void undeleteLastDeletedAttachment(DtMailEnv &);
206 void removeLastDeletedAttachment();
208 virtual void attachmentFeedback(Boolean);
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 ); }
222 Attachment* addAttachment(
229 Attachment* addAttachment(DtMail::Message *,
234 Attachment* addAttachment(String name, DtMail::BodyPart *);
236 void addAttachmentActions(
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 ); }
254 void selectAllAttachments();
256 Attachment* getSelectedAttachment();
257 void unselectOtherSelectedAttachments(Attachment *);
259 void deleteAttachments();
260 #endif /* DEAD_WOOD */
262 void CalcSizeOfAttachPane( );
264 void CalcAttachmentPosition(Attachment *);
265 #endif /* DEAD_WOOD */
266 void CalcAllAttachmentPositions();
267 void DisplayAttachmentsInRow(unsigned int);
268 void calculate_attachment_position(
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);
280 void setAttachmentsLabel( );
281 #endif /* DEAD_WOOD */
282 int getSelectedIconCount();
284 void CalcAttachmentsSize( );
285 void add_attachment( Attachment * );
286 #endif /* DEAD_WOOD */
288 // Methods for parsing the attachments in a DtMail::Message
290 void parseAttachments(
296 // SR -- Added methods below
298 void attachmentSelected(Attachment *);
301 void removeCurrentAttachments();
302 void clearAttachArea();
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();
313 void setPendingAction(Boolean);
314 void resetPendingAction();
315 int getNumPendingActions();
317 XmString getSelectedAttachName();
318 void setSelectedAttachName(XmString );
320 int handleQuestionDialog(char *title,
322 char *helpId = DTMAILHELPERROR);
324 int handleErrorDialog(char *title,
326 char *helpId = DTMAILHELPERROR);