dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtmail / dtmail / MsgScrollingList.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: MsgScrollingList.hh /main/12 1998/10/22 19:56:25 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 MSGSCROLLINGLIST_H
44 #define MSGSCROLLINGLIST_H
45
46 #ifdef DEAD_WOOD
47 #include "Image.h"
48 #endif /* DEAD_WOOD */
49 #include "MsgHndArray.hh"
50 #include "RoamCmds.h"
51 #include "ScrollingList.h"
52 #include "UIComponent.h"
53 #include "XmStrCollector.h"
54 #include "XtArgCollector.h"
55
56
57 //#include "UndeleteMessageFromListDialog.h"
58
59 extern "C" {
60 #include <X11/Intrinsic.h>
61 #include <X11/Xatom.h>
62 }
63
64 #include <Xm/Xm.h>
65
66 /* MSGLIST_*       msgid 200 -299
67  */
68 #define MSGLIST_SELMV    200
69 #define MSGLIST_SELCP    201
70 #define MSGLIST_NORC     202
71 #define MSGLIST_NOBOX    203
72 #define MSGLIST_NOOPEN   204
73 #define MSGLIST_MSGMV    205
74 #define MSGLIST_MSGSMV   206
75 #define MSGLIST_MSGCP    207
76 #define MSGLIST_MSGSCP   208
77 #define MSGLIST_NOSEL    209
78 #define MSGLIST_RAISE    210
79 #define MSGLIST_EXIT     211
80 #define MSGLIST_OKBUT    212
81 #define MSGLIST_DLGTTL   213
82
83 class Sort;
84 class MsgScrollingList : public ScrollingList {
85     
86   public:
87     
88     MsgScrollingList ( RoamMenuWindow *, Widget, char * );    
89     ~MsgScrollingList ();
90     
91     // Accesors
92     int  selected_item_position() { return _selected_item_position; }
93     RoamMenuWindow *parent() { return _parent; }
94
95 #ifdef DEAD_WOOD
96     void addChooseCommand( ChooseCmd * );
97     void addDeleteCommand( DeleteCmd * );
98 #endif /* DEAD_WOOD */
99     void select_next_item();
100     void select_prev_item();
101
102     DtMailMessageHandle msgno(int index);
103     MsgStruct* get_message_struct(int index);
104
105     DtMailMessageHandle current_msg_handle();
106     int       position(DtMailMessageHandle msgno);
107 #ifdef DEAD_WOOD
108     int       position(MsgStruct* a_msg_struct);
109 #endif /* DEAD_WOOD */
110     
111     virtual const char *const className() {return ("MsgScrollingList");}
112     virtual void insertMsg(DtMailMessageHandle);
113     virtual void insertDeletedMsg(DtMailMessageHandle);
114     virtual void deleteSelected(Boolean silent = TRUE);
115
116     int copySelected(DtMailEnv &, char *, int delete_after_copy, int silent);
117     void items( XmString [], int );
118
119 #ifdef DEAD_WOOD
120     void appendMsg(DtMailMessageHandle msg_hndl, int sess_num);
121
122     void appendMsg(DtMailMessageHandle msgno);
123
124     DtMailMessageHandle lastMsg();
125 #endif /* DEAD_WOOD */
126
127     void clearMsgs();
128
129     void updateListItems(int current,
130                          Boolean renumber_only = TRUE,
131                          MsgHndArray *selected = NULL);
132     DtMailBoolean senderIsToHeaderWhenMailFromMe(void);
133     void checkDisplayProp(void);
134
135     XmString formatHeader(DtMailHeaderLine & retrieved, 
136                           int sess_num,
137                           DtMailBoolean has_attachments,
138                           DtMailBoolean new_msg);
139
140     void visibleItems(int n_vis)
141     {
142         XtVaSetValues(_w, XmNvisibleItemCount, n_vis, NULL);
143     }
144
145     int visibleItems(void)
146     {
147         int n_vis;
148         XtVaGetValues(_w, XmNvisibleItemCount, &n_vis, NULL);
149         return(n_vis);
150     }
151
152     Widget get_scrolling_list();
153     MsgHndArray   *selected();
154     DtMailBoolean show_with_attachments(DtMailMessageHandle);
155     DtMailBoolean show_with_attachments(DtMail::Message * msg);
156
157     void        display_message( DtMailEnv &, DtMailMessageHandle );
158     void        display_and_select_message(DtMailEnv &, DtMailMessageHandle );
159
160     // Select all of the messages in the list and display the last one.
161     void        select_all_and_display_last(DtMailEnv &);
162
163     //
164     // Select all of the messages in the array[] of DtMailMessageHandle.
165     // 'array' is NULL terminated list.
166     //
167     void        select_all_and_display_last(DtMailEnv &,
168                                             DtMailMessageHandle *array,
169                                             unsigned int        elements);
170
171     void        display_no_message();
172     void        scroll_to_bottom();
173     void        scroll_to_position( int );
174     virtual void        extended_selection( DtMailEnv &, int );
175     int         get_selected_item();
176     int         get_displayed_item();
177     int         get_num_new_messages() { return num_new_messages; }
178     int         get_num_deleted_messages() { return num_deleted_messages; }
179     void        expunge(void);
180     int         resetIndexNums(void);
181     int         resetSessionNums(void);
182     void        layoutLabels();
183     void        layoutLabels(Widget, Widget, Widget, Widget);
184     int         get_num_messages() { return _msgs->length(); }
185     MsgHndArray *get_deleted_messages() { return _deleted_messages; }
186     MsgHndArray *get_messages() { return _msgs; }
187     void        sort_messages();
188     
189     void        viewInSeparateWindow(DtMailEnv &);
190     void        shutdown();
191
192     void        undelete_messages(MsgHndArray *);
193     void        undelete_last_deleted();
194     void        display_message_summary();
195 #ifdef DEAD_WOOD
196     void        display_message_selected();
197 #endif /* DEAD_WOOD */
198     void        display_message(DtMailEnv &, int a_position);
199
200     int         load_headers(DtMailEnv &);
201     void        load_headers(DtMailEnv &, DtMailMessageHandle last);
202     void        do_list_vis_adjustment();
203     
204     // Save these to adjust as msg numbers changed ON/OFF.
205     Widget  _sender_lbl;
206     Widget  _subject_lbl;
207     Widget  _date_lbl;
208     Widget  _size_lbl;
209
210   protected:
211     virtual void defaultAction( Widget, XtPointer, XmListCallbackStruct * );
212     static void extendedSelectionCallback( Widget, XtPointer, XmListCallbackStruct * );
213     MsgHndArray *_msgs;
214     DtMailHeaderRequest _header_info;
215    
216     // Msgs Popup  stuff.
217     Widget   _msgsPopupMenu;
218     MenuBar  *_menuPopupMsgs;
219
220   private:
221 #ifdef DEAD_WOOD
222     Image *_attach_image;
223     Image *_letter_image;
224 #endif /* DEAD_WOOD */
225     RoamMenuWindow *_parent;
226     ChooseCmd *_choose;  
227     DeleteCmd *_delete;
228     int _selected_item_position;
229     int _displayed_item_position;
230     int session_message_number;
231
232     int  num_new_messages;
233     int  num_deleted_messages;
234     MsgHndArray *_deleted_messages;
235
236     DtMailBoolean        _numbered;
237     Boolean              _selection_on;
238     Sort                *_sorter;
239
240     // Collect the arguments to SetValues in load_headers
241     // This prevents multiple redisplays of the XmList widget
242     XtArgCollector      *_xtarg_collector;
243
244     // Collect the XmString items in load_headers
245     XmStrCollector      *_xmstr_collector;
246
247     // Save the XmString that was allocated so that we can
248     // free it later.  It would probably be better to add this
249     // to the XtArgCollector class, but since it's only one
250     // item it's easier to do it this way.
251     XmString            _selected_items;
252 };
253
254 #endif