home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ThreadView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.1 KB  |  254 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* 
  19.    ThreadView.h -- class definition for ThreadView
  20.    Created: Chris Toshok <toshok@netscape.com>, 7-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_threadview_h
  26. #define _xfe_threadview_h
  27.  
  28. #include "MNListView.h"
  29. #include "MNBanner.h"
  30. #include "MsgView.h"
  31. #include "Outlinable.h"
  32. #include "msgcom.h"
  33.  
  34. // commands that are executed after the currently running
  35. // command is through.  That is, when allConnectionsComplete is called.
  36. enum PendingCommand {
  37.     noPendingCommand,
  38.     invalidateThreadAndSelection, /* Used to update the treeinfo and selection for the thread
  39.                                      containing the deleted message. */
  40.     getNewMessages,   /* Used in the thread window to do a get new mail after
  41.                          the summary file is created. */
  42.     selectByIndex,
  43.     selectByKey,
  44.     selectFirstUnread,
  45.     selectLastUnread,
  46.  
  47.     scrollToFirstNew      /* used to scroll the outliner to the first new message,
  48.                               after a get new mail */
  49. };
  50.  
  51. #define HANDLE_CMD_QUEUE 1
  52.  
  53. /* support 5.0 delete model
  54.  */
  55. #define DEL_5_0 1
  56.  
  57. class XFE_ThreadView : public XFE_MNListView
  58. {
  59. public:
  60.   XFE_ThreadView(XFE_Component *toplevel_component, Widget parent, 
  61.          XFE_View *parent_view, MWContext *context,
  62.          MSG_Pane *p = NULL);
  63.  
  64.   virtual ~XFE_ThreadView();
  65.  
  66.   virtual void paneChanged(XP_Bool asynchronous, 
  67.                            MSG_PANE_CHANGED_NOTIFY_CODE code, int32 value);
  68.  
  69. #if defined(DEL_5_0)
  70.   void listChangeStarting(XP_Bool asynchronous, MSG_NOTIFY_CODE notify, 
  71.                           MSG_ViewIndex where, int32 num);
  72. #endif /* DEL_5_0 */
  73.  void listChangeFinished(XP_Bool asynchronous, MSG_NOTIFY_CODE notify, 
  74.                           MSG_ViewIndex where, int32 num);
  75.  
  76.   void loadFolder(MSG_FolderInfo *folderInfo);
  77.   MSG_FolderInfo *getFolderInfo();
  78.  
  79.   void showMessage(int row);
  80.  
  81.   virtual Boolean isCommandEnabled(CommandType command, void *calldata = NULL,
  82.                                    XFE_CommandInfo* i = NULL);
  83.   virtual Boolean isCommandSelected(CommandType command, void *calldata = NULL,
  84.                                    XFE_CommandInfo* i = NULL);
  85.   virtual Boolean handlesCommand(CommandType command, void *calldata = NULL,
  86.                                    XFE_CommandInfo* i = NULL);
  87.   virtual void doCommand(CommandType command, void *calldata = NULL,
  88.                                    XFE_CommandInfo* i = NULL);
  89.  
  90.   virtual char *commandToString(CommandType command, 
  91.                                 void *calldata = NULL,
  92.                                 XFE_CommandInfo* i = NULL);
  93.  
  94.   /* This is static so the message banner can get at it. */
  95.   static fe_icon* flagToIcon(int folder_flags, int message_flags);
  96. #if defined(USE_MOTIF_DND)
  97.   static fe_icon_data* flagToIconData(int folder_flags, int message_flags);
  98. #endif /* USE_MOTIF_DND */
  99.   static void initMessageIcons(Widget widget, Pixel bg_pixel, Pixel fg_pixel);
  100.  
  101.   /* Outlinable interface methods */
  102.   virtual void *ConvFromIndex(int index);
  103.   virtual int ConvToIndex(void *item);
  104.  
  105.   virtual char *getColumnName(int column);
  106.  
  107.   virtual char *getColumnHeaderText(int column);
  108.   virtual fe_icon *getColumnHeaderIcon(int column);
  109.   virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
  110.   virtual void *acquireLineData(int line);
  111.   virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded, int *depth, OutlinerAncestorInfo **ancestor);
  112.   virtual EOutlinerTextStyle getColumnStyle(int column);
  113.   virtual char *getColumnText(int column);
  114.   virtual fe_icon *getColumnIcon(int column);
  115.   virtual void releaseLineData();
  116.   // Get tooltipString & docString; 
  117.   // returned string shall be freed by the callee
  118.   // row < 0 indicates heading row; otherwise it is a content row
  119.   // (starting from 0)
  120.   //
  121.   virtual char *getCellTipString(int /* row */, int /* column */);
  122.   virtual char *getCellDocString(int /* row */, int /* column */);
  123.   char *getColumnTextByMsgLine(MSG_MessageLine* msgLine, int column);
  124.  
  125. #if defined(USE_MOTIF_DND)
  126.   /* motif drag and drop interface. */
  127.   fe_icon_data *GetDragIconData(int row, int column);
  128.   static fe_icon_data *getDragIconData(void *this_ptr,
  129.                                        int row, int column);
  130.  
  131.   void GetDragTargets(int row, int column, Atom **targets, int *num_targets);
  132.   static void getDragTargets(void *this_ptr,
  133.                              int row, int col,
  134.                              Atom **targets, int *num_targets);
  135.  
  136.   char *DragConvert(Atom atom);
  137.   static char* dragConvert(void *this_ptr,
  138.                            Atom atom);
  139. #endif /* USE_MOTIF_DND */
  140.  
  141.   void handlePendingCommand();
  142.   XFE_CALLBACK_DECL(allConnectionsComplete)
  143.  
  144.   virtual void Buttonfunc(const OutlineButtonFuncData *data);
  145.   virtual void Flippyfunc(const OutlineFlippyFuncData *data);
  146.  
  147. #if !defined(USE_MOTIF_DND)
  148.   // needs to be public so the ProxyIcon can get at it.
  149.   static void source_drop_func(fe_dnd_Source *src, fe_dnd_Message msg, void *closure);
  150. #endif /* USE_MOTIF_DND */
  151.  
  152.   void openWithKey(MessageKey key);
  153.   void setPendingCmdSelByKey(PendingCommand cmd, MessageKey key);
  154.  
  155.   // get new msg ?
  156.   void setGetNewMsg(XP_Bool b);
  157.  
  158. #if HANDLE_CMD_QUEUE
  159.   void processCmdQueue();
  160. #endif /* HANDLE_CMD_QUEUE */
  161.  
  162. private:
  163.  
  164.   /* keep track of on loading folders
  165.    */
  166.   int m_nLoadingFolders;
  167.  
  168. #if HANDLE_CMD_QUEUE
  169.   MSG_ViewIndex m_lineChanged;
  170.   MSG_ViewIndex m_lastLoadedInd;  /* which line is being displayed */
  171. #if defined(DEL_5_0)
  172.   MessageKey    m_lastLoadedKey; /* which message is being displayed */
  173. #endif /* DEL_5_0 */
  174.   int     *m_selected;    /* from msgdeleted; */
  175.   int      m_selectedCount;
  176.  
  177.   int     *m_deleted; /* from lsitchange  */
  178.   int      m_deletedCount;
  179.  
  180.   /* This is really stupid..
  181.    */
  182.   int     *m_collapsed;
  183.   int      m_collapsedCount;
  184.   void     addCollapsed(int i);
  185.   XP_Bool  isCollapsed(int i);
  186.  
  187. #endif /* HANDLE_CMD_QUEUE */
  188.  
  189.   /* Hack: use this flag to determine if we need to getNewMessage
  190.    */
  191.   XP_Bool m_getNewMsg;
  192.  
  193.   /* True: ThreadFrame is deleted; 
  194.    * False (default): otherwise
  195.    */
  196.   XP_Bool m_frameDeleted;
  197.  
  198.   XP_Bool m_displayingDraft;
  199.  
  200.   PendingCommand m_commandPending;
  201.  
  202.   MSG_ViewIndex m_selectionAfterDeleting;
  203.   MSG_ViewIndex m_pendingSelectionIndex;
  204.   MessageKey m_pendingSelectionKey;
  205.  
  206.   Widget m_arrowb, m_arrowlabel, m_arrowform;
  207.  
  208.   XFE_MsgView *m_msgview;
  209.   XP_Bool m_msgExpanded;
  210.  
  211.   MSG_FolderInfo *m_folderInfo;
  212.  
  213.   MSG_MessageLine m_messageLine;
  214.   OutlinerAncestorInfo *m_ancestorInfo;
  215.   
  216.   static const int OUTLINER_COLUMN_SUBJECT;
  217.   static const int OUTLINER_COLUMN_UNREADMSG;
  218.   static const int OUTLINER_COLUMN_SENDERRECIPIENT;
  219.   static const int OUTLINER_COLUMN_DATE;
  220.   static const int OUTLINER_COLUMN_PRIORITY;
  221.   static const int OUTLINER_COLUMN_SIZE;
  222.   static const int OUTLINER_COLUMN_STATUS;
  223.   static const int OUTLINER_COLUMN_FLAG;
  224.  
  225.   XFE_CALLBACK_DECL(spaceAtMsgEnd)
  226.   XFE_CALLBACK_DECL(newMessageLoading)
  227.   void updateExpandoFlippyText(int row);
  228.   void toggleMsgExpansion();
  229.   static void toggleMsgExpansionCallback(Widget, XtPointer, XtPointer);
  230.  
  231. #if !defined(USE_MOTIF_DND)
  232.   void dropfunc(Widget dropw, fe_dnd_Event type, fe_dnd_Source *source, XEvent *event);
  233.   static void drop_func(Widget dropw, void *closure, fe_dnd_Event type,
  234.             fe_dnd_Source *source, XEvent* event);
  235.  
  236.   void sourcedropfunc(fe_dnd_Source *src, fe_dnd_Message msg, void *closure);
  237. #endif /* !USE_MOTIF_DND */
  238.  
  239.   // icons for the outliner
  240.   static fe_icon threadonIcon;
  241.   static fe_icon threadoffIcon;
  242.  
  243.   XFE_PopupMenu *m_popup;
  244.  
  245.   static MenuSpec mail_popup_spec[];
  246.   static MenuSpec news_popup_spec[];
  247.   static MenuSpec priority_popup_submenu[];
  248.   static MenuSpec addrbk_submenu_spec[];
  249.  
  250.   void selectThread();
  251. };
  252.  
  253. #endif /* _xfe_threadview_h */
  254.