-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / MsgScrollingList.hh
1 /*
2  *+SNOTICE
3  *
4  *      $TOG: MsgScrollingList.hh /main/12 1998/10/22 19:56:25 mgreess $
5  *
6  *      RESTRICTED CONFIDENTIAL INFORMATION:
7  *      
8  *      The information in this document is subject to special
9  *      restrictions in a confidential disclosure agreement between
10  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
11  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
12  *      Sun's specific written approval.  This document and all copies
13  *      and derivative works thereof must be returned or destroyed at
14  *      Sun's request.
15  *
16  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
17  *
18  *+ENOTICE
19  */
20
21 #ifndef MSGSCROLLINGLIST_H
22 #define MSGSCROLLINGLIST_H
23
24 #ifdef DEAD_WOOD
25 #include "Image.h"
26 #endif /* DEAD_WOOD */
27 #include "MsgHndArray.hh"
28 #include "RoamCmds.h"
29 #include "ScrollingList.h"
30 #include "UIComponent.h"
31 #include "XmStrCollector.h"
32 #include "XtArgCollector.h"
33
34
35 //#include "UndeleteMessageFromListDialog.h"
36
37 extern "C" {
38 #include <X11/Intrinsic.h>
39 #include <X11/Xatom.h>
40 }
41
42 #include <Xm/Xm.h>
43
44 /* MSGLIST_*       msgid 200 -299
45  */
46 #define MSGLIST_SELMV    200
47 #define MSGLIST_SELCP    201
48 #define MSGLIST_NORC     202
49 #define MSGLIST_NOBOX    203
50 #define MSGLIST_NOOPEN   204
51 #define MSGLIST_MSGMV    205
52 #define MSGLIST_MSGSMV   206
53 #define MSGLIST_MSGCP    207
54 #define MSGLIST_MSGSCP   208
55 #define MSGLIST_NOSEL    209
56 #define MSGLIST_RAISE    210
57 #define MSGLIST_EXIT     211
58 #define MSGLIST_OKBUT    212
59 #define MSGLIST_DLGTTL   213
60
61 class Sort;
62 class MsgScrollingList : public ScrollingList {
63     
64   public:
65     
66     MsgScrollingList ( RoamMenuWindow *, Widget, char * );    
67     ~MsgScrollingList ();
68     
69     // Accesors
70     int  selected_item_position() { return _selected_item_position; }
71     RoamMenuWindow *parent() { return _parent; }
72
73 #ifdef DEAD_WOOD
74     void addChooseCommand( ChooseCmd * );
75     void addDeleteCommand( DeleteCmd * );
76 #endif /* DEAD_WOOD */
77     void select_next_item();
78     void select_prev_item();
79
80     DtMailMessageHandle msgno(int index);
81     MsgStruct* get_message_struct(int index);
82
83     DtMailMessageHandle current_msg_handle();
84     int       position(DtMailMessageHandle msgno);
85 #ifdef DEAD_WOOD
86     int       position(MsgStruct* a_msg_struct);
87 #endif /* DEAD_WOOD */
88     
89     virtual const char *const className() {return ("MsgScrollingList");}
90     virtual void insertMsg(DtMailMessageHandle);
91     virtual void insertDeletedMsg(DtMailMessageHandle);
92     virtual void deleteSelected(Boolean silent = TRUE);
93
94     int copySelected(DtMailEnv &, char *, int delete_after_copy, int silent);
95     void items( XmString [], int );
96
97 #ifdef DEAD_WOOD
98     void appendMsg(DtMailMessageHandle msg_hndl, int sess_num);
99
100     void appendMsg(DtMailMessageHandle msgno);
101
102     DtMailMessageHandle lastMsg();
103 #endif /* DEAD_WOOD */
104
105     void clearMsgs();
106
107     void updateListItems(int current,
108                          Boolean renumber_only = TRUE,
109                          MsgHndArray *selected = NULL);
110     DtMailBoolean senderIsToHeaderWhenMailFromMe(void);
111     void checkDisplayProp(void);
112
113     XmString formatHeader(DtMailHeaderLine & retrieved, 
114                           int sess_num,
115                           DtMailBoolean has_attachments,
116                           DtMailBoolean new_msg);
117
118     void visibleItems(int n_vis)
119     {
120         XtVaSetValues(_w, XmNvisibleItemCount, n_vis, NULL);
121     }
122
123     int visibleItems(void)
124     {
125         int n_vis;
126         XtVaGetValues(_w, XmNvisibleItemCount, &n_vis, NULL);
127         return(n_vis);
128     }
129
130     Widget get_scrolling_list();
131     MsgHndArray   *selected();
132     DtMailBoolean show_with_attachments(DtMailMessageHandle);
133     DtMailBoolean show_with_attachments(DtMail::Message * msg);
134
135     void        display_message( DtMailEnv &, DtMailMessageHandle );
136     void        display_and_select_message(DtMailEnv &, DtMailMessageHandle );
137
138     // Select all of the messages in the list and display the last one.
139     void        select_all_and_display_last(DtMailEnv &);
140
141     //
142     // Select all of the messages in the array[] of DtMailMessageHandle.
143     // 'array' is NULL terminated list.
144     //
145     void        select_all_and_display_last(DtMailEnv &,
146                                             DtMailMessageHandle *array,
147                                             unsigned int        elements);
148
149     void        display_no_message();
150     void        scroll_to_bottom();
151     void        scroll_to_position( int );
152     virtual void        extended_selection( DtMailEnv &, int );
153     int         get_selected_item();
154     int         get_displayed_item();
155     int         get_num_new_messages() { return num_new_messages; }
156     int         get_num_deleted_messages() { return num_deleted_messages; }
157     void        expunge(void);
158     int         resetIndexNums(void);
159     int         resetSessionNums(void);
160     void        layoutLabels();
161     void        layoutLabels(Widget, Widget, Widget, Widget);
162     int         get_num_messages() { return _msgs->length(); }
163     MsgHndArray *get_deleted_messages() { return _deleted_messages; }
164     MsgHndArray *get_messages() { return _msgs; }
165     void        sort_messages();
166     
167     void        viewInSeparateWindow(DtMailEnv &);
168     void        shutdown();
169
170     void        undelete_messages(MsgHndArray *);
171     void        undelete_last_deleted();
172     void        display_message_summary();
173 #ifdef DEAD_WOOD
174     void        display_message_selected();
175 #endif /* DEAD_WOOD */
176     void        display_message(DtMailEnv &, int a_position);
177
178     int         load_headers(DtMailEnv &);
179     void        load_headers(DtMailEnv &, DtMailMessageHandle last);
180     void        do_list_vis_adjustment();
181     
182     // Save these to adjust as msg numbers changed ON/OFF.
183     Widget  _sender_lbl;
184     Widget  _subject_lbl;
185     Widget  _date_lbl;
186     Widget  _size_lbl;
187
188   protected:
189     virtual void defaultAction( Widget, XtPointer, XmListCallbackStruct * );
190     static void extendedSelectionCallback( Widget, XtPointer, XmListCallbackStruct * );
191     MsgHndArray *_msgs;
192     DtMailHeaderRequest _header_info;
193    
194     // Msgs Popup  stuff.
195     Widget   _msgsPopupMenu;
196     MenuBar  *_menuPopupMsgs;
197
198   private:
199 #ifdef DEAD_WOOD
200     Image *_attach_image;
201     Image *_letter_image;
202 #endif /* DEAD_WOOD */
203     RoamMenuWindow *_parent;
204     ChooseCmd *_choose;  
205     DeleteCmd *_delete;
206     int _selected_item_position;
207     int _displayed_item_position;
208     int session_message_number;
209
210     int  num_new_messages;
211     int  num_deleted_messages;
212     MsgHndArray *_deleted_messages;
213
214     DtMailBoolean        _numbered;
215     Boolean              _selection_on;
216     Sort                *_sorter;
217
218     // Collect the arguments to SetValues in load_headers
219     // This prevents multiple redisplays of the XmList widget
220     XtArgCollector      *_xtarg_collector;
221
222     // Collect the XmString items in load_headers
223     XmStrCollector      *_xmstr_collector;
224
225     // Save the XmString that was allocated so that we can
226     // free it later.  It would probably be better to add this
227     // to the XtArgCollector class, but since it's only one
228     // item it's easier to do it this way.
229     XmString            _selected_items;
230 };
231
232 #endif