home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / namcomp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.8 KB  |  336 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. #ifndef _namcomp_h_
  19. #define _namcomp_h_
  20.  
  21. // NAMCOMP.H
  22. //
  23. // DESCRIPTION:
  24. //        This file contains the declarations of the for the name completion 
  25. //        dialog
  26. //
  27.  
  28. #include "outliner.h"
  29. #include "apimsg.h"
  30. #include "addrbook.h"
  31. #include "mailfrm.h"
  32. #include "mailpriv.h"
  33. #include "mnrccln.h"
  34.  
  35. class CNameCompletion;
  36. class CNameCompletionOutliner;
  37. class CNameCompletionOutlinerParent;
  38. class CNameCompletionEntryList;
  39.  
  40. // Definitions for column headings in the outliner control
  41. #define DEF_VISIBLE_COLUMNS            5
  42. #define ID_COLADDR_TYPE                1
  43. #define ID_COLADDR_NAME                2
  44. #define ID_COLADDR_EMAIL            3
  45. #define ID_COLADDR_COMPANY            4
  46. #define ID_COLADDR_PHONE            5
  47. #define ID_COLADDR_LOCALITY            6
  48. #define ID_COLADDR_NICKNAME            7
  49.  
  50. // array of indexes for IDB_ADDRESSBOOK bitmap
  51. #define IDX_ADDRESSBOOKPERSON   0
  52. #define IDX_ADDRESSBOOKLIST        1
  53. #define IDX_ADDRESSBOOKPERCARD  2
  54.  
  55. // name completion context
  56. class CNameCompletionCX: public CStubsCX
  57. {
  58. protected:
  59.     CNameCompletion* m_pDialog;
  60.  
  61.     int32 m_lPercent;
  62.     BOOL m_bAnimated;
  63.  
  64. public:
  65.     CNameCompletionCX(CNameCompletion *pDialog);
  66.  
  67. public:
  68.     int32 QueryProgressPercent();
  69.     void SetProgressBarPercent(MWContext *pContext, int32 lPercent);
  70.  
  71.     void Progress(MWContext *pContext, const char *pMessage);
  72.     void AllConnectionsComplete(MWContext *pContext);
  73.  
  74.     void UpdateStopState( MWContext *pContext );
  75.     
  76.     CWnd *GetDialogOwner() const;
  77. };
  78.  
  79.  
  80.  
  81. /****************************************************************************
  82. *
  83. *    Class: CNameCompletionOutlinerParent
  84. *
  85. *    DESCRIPTION:
  86. *        This class is the window around the column/list object in the name 
  87. *        completion picker.  It is mainly purpose is to draw the column headings.
  88. *
  89. ****************************************************************************/
  90. class CNameCompletionOutlinerParent : public COutlinerParent 
  91. {
  92. public:
  93.     CNameCompletionOutlinerParent();
  94.     virtual ~CNameCompletionOutlinerParent();
  95.     virtual COutliner * GetOutliner ( );
  96.     virtual void CreateColumns ( );
  97.     virtual BOOL RenderData ( int idColumn, CRect & rect, CDC & dc, const char *);
  98.     virtual BOOL ColumnCommand ( int idColumn );
  99.  
  100. // Implementation
  101. protected:
  102.     // Generated message map functions
  103.     //{{AFX_MSG(CNameCompletionOutlinerParent)
  104.     afx_msg void OnLButtonUp ( UINT nFlags, CPoint point );
  105.     //}}AFX_MSG
  106.  
  107.     DECLARE_MESSAGE_MAP()
  108. };
  109.  
  110.  
  111. /****************************************************************************
  112. *
  113. *    Class: CNameCompletion
  114. *
  115. *    DESCRIPTION:
  116. *        This class is the name completion from the compose window
  117. *
  118. ****************************************************************************/
  119. class CNameCompletion : public CDialog, public IMailFrame {
  120.  
  121. // Attributes
  122. public:
  123.  
  124.     friend class CNameCompletionEntryList;
  125.     DIR_Server*        m_directory;
  126.     int            m_iWidth;
  127.  
  128.     enum { IDD = IDD_COMPLETION_PICKER };
  129.  
  130.     // ClassWizard generated virtual function overrides
  131.     //{{AFX_VIRTUAL(CNameCompletion)
  132. public:
  133. protected:
  134.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  135.     //}}AFX_VIRTUAL
  136.  
  137.     //{{AFX_DATA(CNameCompletion)
  138.     CString    m_searchString;
  139.     //}}AFX_DATA
  140.  
  141. protected:
  142.  
  143.     CNetscapeStatusBar                m_barStatus;
  144.     CNameCompletionCX                *m_pCX;
  145.     HFONT                            m_pFont;
  146.     CNameCompletionOutlinerParent    *m_pOutlinerParent;
  147.     CNameCompletionOutliner            *m_pOutliner;
  148.  
  149.     LPMSGLIST                        m_pIAddrList;
  150.     ABPane                            *m_addrBookPane;
  151.     BOOL                            m_bSearching;
  152.     CMailNewsResourceSwitcher        m_MailNewsResourceSwitcher;
  153.     LPCTSTR                            m_lpszSearchString;
  154.  
  155.     // IUnknown Interface
  156.     STDMETHODIMP            QueryInterface(REFIID,LPVOID *);
  157.     STDMETHODIMP_(ULONG)    AddRef(void);
  158.     STDMETHODIMP_(ULONG)    Release(void);
  159.  
  160. // Support for IMsgList Interface (Called by CNameCompletionList)
  161.     virtual void ListChangeStarting( MSG_Pane* pane, XP_Bool asynchronous,
  162.                                      MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  163.                                      int32 num);
  164.     virtual void ListChangeFinished( MSG_Pane* pane, XP_Bool asynchronous,
  165.                                      MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  166.                                      int32 num);
  167.  
  168.     void CleanupOnClose();
  169.  
  170. // Operations
  171. public:
  172.     CNameCompletion(LPCTSTR lpszSearchString, CWnd * parent = NULL);
  173.  
  174.     enum { ToolInvalid = -1, ToolText = 0, ToolPictures = 1, ToolBoth = 2 };
  175.  
  176.     // From CStubsCX
  177.     void Progress(const char *pMessage);
  178.     void SetProgressBarPercent(int32 lPercent);
  179.     void AllConnectionsComplete(MWContext *pContext);
  180.     void SetStatusText(const char* pMessage);
  181.  
  182.     // Support for IMailFrame
  183.     virtual CMailNewsFrame *GetMailNewsFrame();
  184.     virtual MSG_Pane *GetPane();
  185.     virtual void PaneChanged( MSG_Pane *pane, XP_Bool asynchronous, 
  186.                               MSG_PANE_CHANGED_NOTIFY_CODE, int32 value);
  187.     virtual void AttachmentCount(MSG_Pane *messagepane, void* closure,
  188.                                  int32 numattachments, XP_Bool finishedloading) {};
  189.     virtual void UserWantsToSeeAttachments(MSG_Pane *messagepane, void *closure) {};
  190.  
  191.     // Callback from LDAP search
  192.     void SetSearchResults(MSG_ViewIndex index, int32 num);
  193.     XP_Bool IsSearching () { return m_bSearching; }
  194.  
  195.     static void HandleErrorReturn(int errorID);
  196.  
  197.     void Create();
  198.     void DoUpdateAddressBook( CCmdUI* pCmdUI, AB_CommandType cmd, BOOL bUseCheck = TRUE );
  199.  
  200.     void UpdateButtons();
  201.     void PerformDirectorySearch();
  202.  
  203. // Overrides
  204.     // ClassWizard generated virtual function overrides
  205.     //{{AFX_VIRTUAL(CNameCompletion)
  206.     public:
  207.     virtual  BOOL OnInitDialog( );
  208.     protected:
  209.     //}}AFX_VIRTUAL
  210.  
  211. // Implementation
  212. protected:
  213.     // Generated message map functions
  214.     //{{AFX_MSG(CNameCompletion)
  215.     afx_msg int OnCreate( LPCREATESTRUCT );
  216.     afx_msg void OnSize( UINT, int, int);
  217.     afx_msg void OnOK();
  218.     afx_msg void OnCancel();
  219.     afx_msg void OnComposeMsg(void);
  220.     afx_msg void OnAddToAddressBook(void);
  221.     afx_msg void OnSelchange();
  222.     afx_msg void OnHelp();
  223.     //}}AFX_MSG
  224.     DECLARE_MESSAGE_MAP()
  225. };
  226.  
  227.  
  228. /****************************************************************************
  229. *
  230. *    Class: CNameCompletionOutliner
  231. *
  232. *    DESCRIPTION:
  233. *        This class is the column/list object in the name completion dialog
  234. *
  235. ****************************************************************************/
  236. class CNameCompletionOutliner : public COutliner
  237. {
  238. friend class CNameCompletionOutlinerParent;
  239.  
  240. protected:
  241.     int                    m_lineindex;
  242.     char*                m_pszExtraText;
  243.     ABPane*                m_pane;
  244.     int                    m_iMysticPlane;
  245.     MWContext*            m_pContext;
  246.     AB_EntryLine        m_EntryLine;
  247.     HFONT                m_hFont;
  248.  
  249. public:
  250.     CNameCompletionOutliner ( );
  251.     virtual ~CNameCompletionOutliner ( );
  252.  
  253.     void    UpdateCount();
  254.     void    OnChangeDirectory(int dirIndex);
  255.     virtual void OnSelChanged();
  256.     virtual void SetTotalLines( int iLines );
  257.     virtual void OnSelDblClk();
  258.  
  259.     virtual HFONT GetLineFont( void *pLineData );
  260.     virtual LPCTSTR GetColumnText ( UINT iColumn, void * pLineData );
  261.     virtual void * AcquireLineData ( int iLine );
  262.     virtual void ReleaseLineData ( void * pLineData );
  263.     virtual void GetTreeInfo ( int iLine, uint32 * pFlags, int * iDepth, 
  264.                                OutlinerAncestorInfo ** pAncestor );
  265.     virtual int TranslateIcon ( void *);
  266.     virtual int TranslateIconFolder ( void *);
  267.  
  268.     void SetPane( ABPane *pane );
  269.     ABPane* GetPane() { return m_pane; }
  270.     void SetColumnsForDirectory (DIR_Server* pServer);
  271.  
  272.     MWContext *GetContext() { return m_pContext; }
  273.     void SetContext( MWContext *pContext ) { m_pContext = pContext; }
  274.  
  275.     virtual void MysticStuffStarting( XP_Bool asynchronous,
  276.                                      MSG_NOTIFY_CODE notify, 
  277.                                      MSG_ViewIndex where,
  278.                                      int32 num);
  279.     virtual void MysticStuffFinishing( XP_Bool asynchronous,
  280.                                       MSG_NOTIFY_CODE notify, 
  281.                                       MSG_ViewIndex where,
  282.                                       int32 num);
  283.  
  284.     virtual BOOL RenderData ( UINT iColumn, CRect & rect, CDC & pdc, const char * );
  285.  
  286.     virtual BOOL ColumnCommand ( int iColumn, int iLine );
  287.  
  288. // Implementation
  289. protected:
  290.     // Generated message map functions
  291.     //{{AFX_MSG(CNameCompletionOutliner)
  292.     //}}AFX_MSG
  293.  
  294.     DECLARE_MESSAGE_MAP()
  295.  
  296.  
  297. };
  298.  
  299. /////////////////////////////////////////////////////////////////////////////
  300. // CNameCompletionEntryList
  301.  
  302. class CNameCompletionEntryList: public IMsgList {
  303.  
  304.     CNameCompletion *m_pNameCompletion;
  305.     unsigned long m_ulRefCount;
  306.  
  307. public:
  308. // IUnknown Interface
  309.     STDMETHODIMP            QueryInterface(REFIID,LPVOID *);
  310.     STDMETHODIMP_(ULONG)    AddRef(void);
  311.     STDMETHODIMP_(ULONG)    Release(void);
  312.  
  313. // IMsgList Interface
  314.     virtual void ListChangeStarting( MSG_Pane* pane, XP_Bool asynchronous,
  315.                                      MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  316.                                      int32 num);
  317.     virtual void ListChangeFinished( MSG_Pane* pane, XP_Bool asynchronous,
  318.                                      MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  319.                                      int32 num);
  320.     virtual void GetSelection( MSG_Pane* pane, MSG_ViewIndex **indices, int *count, 
  321.                                 int *focus);
  322.     virtual void SelectItem( MSG_Pane* pane, int item );
  323.  
  324.     virtual void CopyMessagesInto( MSG_Pane *pane, MSG_ViewIndex *indices, int count,
  325.                                    MSG_FolderInfo *folderInfo) {}
  326.     virtual void MoveMessagesInto( MSG_Pane *pane, MSG_ViewIndex *indices, int count,
  327.                                    MSG_FolderInfo *folderInfo) {}
  328.  
  329.     CNameCompletionEntryList( CNameCompletion *pNameCompletion ) {
  330.         m_ulRefCount = 0;
  331.         m_pNameCompletion = pNameCompletion;
  332.     }
  333. };
  334.  
  335. #endif
  336.