home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / subnews.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  12.9 KB  |  467 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. #ifndef SUBNEWS_H
  20. #define SUBNEWS_H
  21.  
  22. #include "property.h"
  23. #include "outliner.h"
  24. #include "mailmisc.h"
  25. #include "statbar.h"
  26. #include "apimsg.h"
  27.  
  28. // Definitions for column headings in the outliner control
  29. #define ID_COLNEWS_NAME            1
  30. #define ID_COLNEWS_SUBSCRIBE    2
  31. #define ID_COLNEWS_POSTINGS        3
  32.  
  33. class CSubscribePropertySheet;
  34. class CNewsgroupsOutliner;
  35. class CSubscribeList;
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. //    Class: CServersCombo
  39.  
  40. class CServersCombo: public CComboBox
  41. {
  42. public:
  43.     CServersCombo();
  44.     ~CServersCombo();
  45.  
  46. protected:
  47.  
  48.     BOOL m_bStaticCtl;
  49.     HFONT m_hFont, m_hBoldFont;
  50.     LPIMAGEMAP m_pIImageMap;
  51.     LPUNKNOWN m_pIImageUnk;
  52.  
  53.     virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
  54.     
  55.     DECLARE_MESSAGE_MAP()
  56. };
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. //    Class: CSubscribeCX
  60. class CSubscribeCX: public CStubsCX
  61. {
  62. protected:
  63.     CSubscribePropertySheet* m_pSheet;
  64.  
  65.      int32 m_lPercent;
  66.     CString m_csProgress;
  67.     BOOL m_bAnimated;
  68.  
  69. public:
  70.     CSubscribeCX(CNetscapePropertySheet* pSheet);
  71.  
  72.     virtual CWnd *GetDialogOwner() const { return (CWnd*)m_pSheet;    }
  73.  
  74.     int32 QueryProgressPercent();
  75.     void SetProgressBarPercent(MWContext *pContext, int32 lPercent);
  76.  
  77.     void Progress(MWContext *pContext, const char *pMessage);
  78.     void AllConnectionsComplete(MWContext *pContext);
  79.  
  80.     void UpdateStopState( MWContext *pContext );
  81.  
  82.     CSubscribePropertySheet* GetPropertySheet() {return m_pSheet;}
  83. };
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. //    Class: CNewsgroupsOutlinerParent
  87. class CNewsgroupsOutlinerParent : public COutlinerParent 
  88. {
  89. public:
  90.     CNewsgroupsOutlinerParent();
  91.     virtual ~CNewsgroupsOutlinerParent();
  92.     virtual COutliner * GetOutliner ( );
  93.     virtual void CreateColumns ( );
  94.     virtual BOOL RenderData ( int idColumn, CRect & rect, CDC & dc, const char *);
  95.  
  96.     void SetPropertySheet(CSubscribePropertySheet* pSheet) { m_pSheet = pSheet; }
  97.  
  98. // Implementation
  99. protected:
  100.  
  101.     CSubscribePropertySheet* m_pSheet;
  102.  
  103.     DECLARE_MESSAGE_MAP()
  104. };
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107. // CSubscribePropertyPage dialog
  108. class CSubscribePropertyPage : public CNetscapePropertyPage
  109. {
  110. public:
  111.  
  112.     CSubscribePropertyPage(CWnd *pParent, MWContext * pContext,
  113.                             MSG_SubscribeMode nMode, UINT nID);
  114.    ~CSubscribePropertyPage();
  115.     
  116.     BOOL m_bFromTyping;
  117.     BOOL m_bProcessGetDeletion;
  118.     BOOL m_bListChangeStarting;
  119.  
  120.     CNewsgroupsOutliner * GetOutliner() { return m_pOutliner; }
  121.  
  122.     CServersCombo * GetServerCombo() { return &m_ServerCombo; }
  123.  
  124.     MSG_SubscribeMode GetMode() { return m_nMode; }
  125.  
  126.  
  127.     MWContext* GetContext();
  128.     CSubscribeCX* GetSubscribeContext();
  129.     MSG_Pane * GetPane(); 
  130.     CSubscribeList*  GetList();  
  131.     CSubscribeList**  GetListHandle();  
  132.     void SetSubscribeContext(CSubscribeCX* pCX);
  133.     void SetPane(MSG_Pane *pPane); 
  134.     void SetList(CSubscribeList* pList); 
  135.  
  136.      void DoSelChanged(MSG_GroupNameLine* pGroup);
  137.     void CheckSubscribeButton(MSG_GroupNameLine* pGroup);
  138.     Bool IsOutlinerHasFocus();
  139.     void EnableAllControls(BOOL bEnable);
  140.     void DoStopListChange();
  141.     void ClearNewsgroupSelection();
  142.  
  143.     virtual void ListChangeStarting(MSG_Pane* pane, XP_Bool asynchronous,
  144.                                     MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  145.                                      int32 num);
  146.     virtual void ListChangeFinished(MSG_Pane* pane, XP_Bool asynchronous,
  147.                                     MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  148.                                     int32 num);
  149.  
  150.     virtual BOOL OnInitDialog();
  151.     virtual BOOL OnSetActive();
  152.     virtual BOOL OnKillActive( );
  153.  
  154.     //{{AFX_VIRTUAL(CSubscribePropertyPage)
  155.     protected:
  156.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  157.     //}}AFX_VIRTUAL
  158.  
  159. protected: 
  160.     
  161.     CSubscribePropertySheet* m_pParent;
  162.     BOOL m_bActivated;
  163.     BOOL m_bSelChanged;
  164.     BOOL m_bNotifyAll;  //MAG_NotifyALl when outliner is not visible
  165.     BOOL m_bInitDialog;
  166.     BOOL m_bDoShowWindow;
  167.     UINT m_uTimer;  
  168.     XP_Bool m_bAsynchronous;
  169.  
  170.      MSG_Host** m_hNewsHost;
  171.     MSG_SubscribeMode m_nMode;
  172.  
  173.     CNewsgroupsOutlinerParent    m_OutlinerParent;
  174.     CNewsgroupsOutliner            *m_pOutliner;
  175.  
  176.     CServersCombo m_ServerCombo;
  177.  
  178.     BOOL InitSubscribePage();
  179.     BOOL CreateSubscribePage();
  180.     void SetNewsHosts(MSG_Master* pMaster);
  181.     void CleanupOnClose();
  182.  
  183.     afx_msg void OnAddServer();
  184.     afx_msg void OnSubscribeNewsgroup();
  185.     afx_msg void OnUnsubscribeNewsgroup();
  186.     afx_msg void OnChangeServer();
  187.     afx_msg void OnOK();
  188.     afx_msg void OnCancel();
  189.     afx_msg void OnTimer(UINT nIDEvent);
  190.     afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  191.    DECLARE_MESSAGE_MAP()
  192. };
  193.  
  194. /////////////////////////////////////////////////////////////////////////////
  195. //    Class: CNewsgroupsOutliner
  196.  
  197. class CNewsgroupsOutliner : public CMailNewsOutliner
  198. {
  199. friend class CNewsgroupsOutlinerParent;
  200.  
  201. protected:
  202.     int                    m_attribSortBy;
  203.     BOOL                m_bSortAscending;
  204.     char*                m_pszExtraText;
  205.     OutlinerAncestorInfo * m_pAncestor;
  206.     MSG_GroupNameLine    m_GroupLine;
  207.      BOOL                m_bSelChanged;
  208.  
  209.     CSubscribePropertyPage* m_pPage;
  210.  
  211. public:
  212.     CNewsgroupsOutliner ( );
  213.     virtual ~CNewsgroupsOutliner ( );
  214.  
  215.     void SetPage(CSubscribePropertyPage *pPage) { m_pPage = pPage; }
  216.     CSubscribePropertyPage * GetPage() { return m_pPage; }
  217.  
  218.     void DeselectItem();
  219.     BOOL SelectInitialItem();
  220.  
  221.     virtual void OnSelChanged();
  222.     virtual void OnSelDblClk();
  223.     virtual int ToggleExpansion ( int iLine );
  224.  
  225.     virtual int GetDepth( int iLine );
  226.     virtual int GetNumChildren( int iLine );
  227.     virtual BOOL IsCollapsed( int iLine );
  228.     virtual BOOL ColumnCommand(int iColumn, int iLine);
  229.  
  230.     virtual LPCTSTR GetColumnText ( UINT iColumn, void * pLineData );
  231.     virtual void * AcquireLineData ( int iLine );
  232.     virtual void ReleaseLineData ( void * pLineData );
  233.     virtual void GetTreeInfo ( int iLine, uint32 * pFlags, int * iDepth, 
  234.                                OutlinerAncestorInfo ** pAncestor );
  235.     virtual BOOL RenderData ( UINT idColumn, CRect & rect, CDC & dc, const char * text);
  236.     virtual int TranslateIcon ( void *);
  237.     virtual int TranslateIconFolder ( void *);
  238. };
  239.  
  240. /////////////////////////////////////////////////////////////////////////////
  241. //    Class: CSubscribeList
  242. class CSubscribeList: public IMsgList 
  243. {
  244.  
  245.     CSubscribePropertyPage *m_pSubscribePage;
  246.     unsigned long m_ulRefCount;
  247.  
  248. public:
  249. // IUnknown Interface
  250.     STDMETHODIMP            QueryInterface(REFIID,LPVOID *);
  251.     STDMETHODIMP_(ULONG)    AddRef(void);
  252.     STDMETHODIMP_(ULONG)    Release(void);
  253.  
  254. // IMsgList Interface
  255.     virtual void ListChangeStarting(MSG_Pane* pane, XP_Bool asynchronous,
  256.                                     MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  257.                                      int32 num);
  258.     virtual void ListChangeFinished(MSG_Pane* pane, XP_Bool asynchronous,
  259.                                     MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  260.                                     int32 num);
  261.     virtual void GetSelection(MSG_Pane* pane, MSG_ViewIndex **indices, int *count, 
  262.                                 int *focus);
  263.     virtual void SelectItem(MSG_Pane* pane, int item);
  264.     virtual void CopyMessagesInto( MSG_Pane *pane, MSG_ViewIndex *indices, int count,
  265.                                    MSG_FolderInfo *folderInfo) {}
  266.     virtual void MoveMessagesInto( MSG_Pane *pane, MSG_ViewIndex *indices, int count,
  267.                                    MSG_FolderInfo *folderInfo) {}
  268.  
  269.     void SetSubscribePage(CSubscribePropertyPage * pPage) 
  270.         { m_pSubscribePage = pPage; } 
  271.  
  272.     CSubscribeList(CSubscribePropertyPage *pPage) 
  273.     {
  274.         m_ulRefCount = 0;
  275.         m_pSubscribePage = pPage;
  276.     }
  277. };
  278.  
  279. /////////////////////////////////////////////////////////////////////////////
  280. // CAllNewsgroupsPage dialog
  281. class CAllNewsgroupsPage : public CSubscribePropertyPage
  282. {
  283. public:
  284.  
  285.     CAllNewsgroupsPage(CWnd *pParent, MWContext * pContext = NULL,
  286.                         MSG_SubscribeMode nMode = MSG_SubscribeAll);
  287.     
  288.     enum { IDD = IDD_NEWSGROUP_ALL };
  289.  
  290.     afx_msg void OnGetDeletions();
  291.  
  292.  
  293.  
  294.     //{{AFX_VIRTUAL(CAllNewsgroupsPage)
  295.     protected:
  296.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  297.     //}}AFX_VIRTUAL
  298.  
  299.     virtual BOOL OnInitDialog();
  300.     virtual BOOL OnKillActive( );
  301.  
  302. protected: 
  303.  
  304.     afx_msg void OnChangeNewsgroup();
  305.     afx_msg void OnExpandAll();
  306.     afx_msg void OnCollapseAll();
  307.     afx_msg void OnStop();
  308.    DECLARE_MESSAGE_MAP()
  309. };
  310.  
  311. /////////////////////////////////////////////////////////////////////////////
  312. // CSearchNewsgroupPage dialog
  313. class CSearchNewsgroupPage : public CSubscribePropertyPage
  314. {
  315. public:
  316.     CSearchNewsgroupPage(CWnd *pParent, MWContext * pContext = NULL,
  317.                           MSG_SubscribeMode nMode = MSG_SubscribeSearch);
  318.     
  319.     enum { IDD = IDD_NEWSGROUP_SEARCH };
  320.  
  321.     //{{AFX_VIRTUAL(CSearchNewsgroupPage)
  322.     protected:
  323.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  324.     //}}AFX_VIRTUAL
  325.  
  326.     virtual BOOL OnInitDialog();
  327.  
  328. protected:              
  329.  
  330.     afx_msg void OnSearchNow();
  331.     afx_msg void OnStop();
  332.     DECLARE_MESSAGE_MAP()
  333. };
  334.  
  335. /////////////////////////////////////////////////////////////////////////////
  336. // CNewNewsgroupsPage dialog
  337. class CNewNewsgroupsPage : public CSubscribePropertyPage
  338. {
  339. public:
  340.     CNewNewsgroupsPage(CWnd *pParent, MWContext * pContext = NULL,
  341.                         MSG_SubscribeMode nMode = MSG_SubscribeNew);
  342.     
  343.     enum { IDD = IDD_NEWSGROUP_NEW };
  344.  
  345.     BOOL    m_bGetNew;
  346.  
  347.     //{{AFX_VIRTUAL(CNewNewsgroupsPage)
  348.     protected:
  349.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  350.     //}}AFX_VIRTUAL
  351.  
  352.     virtual BOOL OnInitDialog();
  353.     virtual BOOL OnKillActive( );
  354.  
  355. protected:              
  356.  
  357.     afx_msg void OnGetNew();
  358.     afx_msg void OnClearNew();
  359.     afx_msg void OnStop();
  360.     DECLARE_MESSAGE_MAP()
  361.  
  362. };
  363.  
  364. /////////////////////////////////////////////////////////////////////////////
  365. // CSubscibePropertySheet
  366. class CSubscribePropertySheet : public CNetscapePropertySheet
  367. {
  368. public:
  369.  
  370.     CSubscribePropertySheet(CWnd *pParent, MWContext * pContext = NULL, const char* pName = NULL);
  371.     ~CSubscribePropertySheet();
  372.     
  373.     CSubscribeCX* GetSubscribeContext() { return m_pCX; }
  374.     void SetSubscribeContext(CSubscribeCX* pCX) { m_pCX = pCX; } 
  375.     MSG_Pane*  GetSubscribePane() { return m_pSubscribePane; }
  376.     void SetSubscribePane(MSG_Pane *pPane) { m_pSubscribePane = pPane; }
  377.     CSubscribeList*  GetSubscribeList() { return m_pSubscribeList; }
  378.     CSubscribeList**  GetSubscribeHandle() { return &m_pSubscribeList; }
  379.     void SetSubscribeList(CSubscribeList* pList) { m_pSubscribeList = pList; }
  380.     MSG_Host* GetHost() { return m_pCurrentHost; }
  381.     void SetHost(MSG_Host *pHost) { m_pCurrentHost = pHost; }
  382.  
  383.     void SetStatusText(const char* pMessage);
  384.     void Progress(const char *pMessage);
  385.     void SetProgressBarPercent(int32 lPercent);
  386.     void StartAnimation();
  387.     void StopAnimation();
  388.     void AllConnectionsComplete(MWContext *pContext);
  389.     void AddServer(MSG_Host* pHost);
  390.     void EnableNonImapPages(BOOL bEnable);
  391.  
  392.  
  393.     //In Win16, GetActivePage() is a protected
  394.     CSubscribePropertyPage*  GetCurrentPage() 
  395.         { return (CSubscribePropertyPage*)GetActivePage();    }
  396.  
  397.     CAllNewsgroupsPage* GetAllGroupPage() {return m_pAllGroupPage;}
  398.  
  399.     virtual void OnHelp();
  400.  
  401.     int nameWidth;
  402.     int subscribeWidth;
  403.     int postWidth;
  404.     int namePos;
  405.     int subscribePos;
  406.     int postPos;
  407.  
  408. protected:
  409.     
  410.     CNetscapeStatusBar    m_barStatus;
  411.      int                m_iProgress;
  412.  
  413.     MSG_Host*        m_pCurrentHost;
  414.  
  415.     CSubscribeCX*    m_pCX;
  416.     MSG_Pane*        m_pSubscribePane;
  417.     CSubscribeList*    m_pSubscribeList;
  418.     CSubscribePropertyPage *m_pNewPage;
  419.  
  420.     CAllNewsgroupsPage *m_pAllGroupPage;
  421.     CSearchNewsgroupPage *m_pSearchGroupPage;
  422.     CNewNewsgroupsPage *m_pNewGroupPage;
  423.  
  424.     BOOL            m_bCommitingStart;
  425.  
  426.  
  427.     void CreateProgressBar();
  428.  
  429.     virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  430. #ifdef _WIN32
  431.     virtual BOOL OnInitDialog();
  432. #else
  433.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  434. #endif
  435.     DECLARE_MESSAGE_MAP()
  436. };
  437.  
  438. class CServerTypeDialog : public CDialog 
  439. {
  440. // Attributes
  441. public:
  442.  
  443.     CServerTypeDialog(CWnd* pParent);
  444.  
  445.     enum { IDD = IDD_NEWSGROUP_SERVERTYPE };
  446.  
  447.     MSG_Host *GetNewHost() { return m_pHost; }
  448.  
  449.     //{{AFX_VIRTUAL(CNewNewsgroupsPage)
  450.     protected:
  451.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  452.     //}}AFX_VIRTUAL
  453.  
  454.     virtual BOOL OnInitDialog();
  455.  
  456.     // Implementation
  457. protected:
  458.  
  459.     MSG_Host *m_pHost;
  460.  
  461.     afx_msg void OnOK();
  462.     DECLARE_MESSAGE_MAP()
  463. };
  464.  
  465.  
  466. #endif SUBNEWS_H
  467.