home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / quickfil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.0 KB  |  269 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. //        This file contains the declarations of the various Bookmark Quick
  20. //        File classes.
  21.  
  22.  
  23. #if    !defined(__QUICKFIL_H__)
  24. #define    __QUICKFIL_H__
  25.  
  26. #ifndef    __AFXWIN_H__
  27.     #error include 'stdafx.h' before including this    file for PCH
  28. #endif
  29.  
  30. /****************************************************************************
  31. *
  32. *    Class: CTreeItemList
  33. *
  34. *    DESCRIPTION:
  35. *        This is a collection class for holding CTreeItem objects.
  36. *
  37. ****************************************************************************/
  38.  
  39. class CTreeItem;
  40. #define CTreeItemListBase    CPtrArray
  41.  
  42. class CTreeItemList : public CTreeItemListBase
  43. {
  44.     public:
  45.         CTreeItemList();
  46.         virtual ~CTreeItemList();
  47.         
  48.         int Add(CTreeItem * pItem)
  49.         {
  50.             return(CTreeItemListBase::Add(pItem));
  51.         }
  52.         CTreeItem * Get(int nIndex) const
  53.         {
  54.             return((CTreeItem *)GetAt(nIndex));
  55.         }
  56.         
  57.     protected:
  58.  
  59.     private:
  60.  
  61. }; // END OF CLASS CTreeItemList()
  62.  
  63.  
  64. /****************************************************************************
  65. *
  66. *    Class: CTreeItem
  67. *
  68. *    DESCRIPTION:
  69. *        This class provides an abstract object for representing an item
  70. *        within a hierarchical tree.
  71. *
  72. ****************************************************************************/
  73.  
  74. class CTreeItem
  75. {
  76.     public:
  77.         CTreeItem(CBitmap * pUnselectedImg, CBitmap *pSelectedImg, const UINT uID, const CString & strLabel,
  78.                   CMenu *pSubMenu = NULL);
  79.         virtual ~CTreeItem();
  80.         
  81.         CTreeItemList * GetSubItems()
  82.         {
  83.             return(&m_SubItems);
  84.         }
  85.  
  86.         CMenu * GetSubMenu(void)
  87.         {
  88.             return(m_pSubMenu);
  89.         }
  90.  
  91.         CBitmap * GetUnselectedImage() const
  92.         {
  93.             return (m_pUnselectedImg);
  94.         }
  95.  
  96.         CBitmap * GetSelectedImage() const
  97.         {
  98.             return(m_pSelectedImg);
  99.         }
  100.         const UINT GetID() const
  101.         {
  102.             return(m_uID);
  103.         }
  104.  
  105.         const CString & GetLabel() const
  106.         {
  107.             return(m_strLabel);
  108.         }
  109.         
  110.         void SetUnselectedBitmapSize(CSize size)
  111.         {
  112.             m_unselectedBitmapSize = size;
  113.         }
  114.  
  115.         CSize GetUnselectedBitmapSize(void)
  116.         {
  117.             return m_unselectedBitmapSize;
  118.         }
  119.  
  120.         void SetSelectedBitmapSize(CSize size)
  121.         {
  122.             m_selectedBitmapSize = size;
  123.         }
  124.  
  125.         CSize GetSelectedBitmapSize(void)
  126.         {
  127.             return m_selectedBitmapSize;
  128.         }
  129.  
  130.         void SetTextSize(CSize size)
  131.         {
  132.             m_textSize = size;
  133.         }
  134.  
  135.         CSize GetTextSize(void)
  136.         {
  137.             return m_textSize;
  138.         }
  139.  
  140.         void SetAcceleratorSize(CSize size)
  141.         {
  142.             m_accelSize = size;
  143.         }
  144.  
  145.         CSize GetAcceleratorSize(void)
  146.         {
  147.             return m_accelSize;
  148.         }
  149.  
  150.     // Aurora improvements to handle custom icons and arbitrary URLs.
  151.         void       SetIcon(void* pIcon, IconType iconType) { m_pCustomIcon = pIcon; m_nIconType = iconType; }
  152.         HICON       GetLocalFileIcon() { return (HICON)m_pCustomIcon; }
  153.         NSNavCenterImage* GetCustomIcon() { return (NSNavCenterImage*)m_pCustomIcon; }
  154.         IconType GetIconType() { return m_nIconType; }
  155.  
  156.     protected:
  157.         CBitmap * m_pUnselectedImg;    // Image to be displayed for this item when unselected
  158.         CBitmap * m_pSelectedImg;   // Image to be displayed for this item when selected
  159.         UINT m_uID;            // Unique item identifier
  160.         CString m_strLabel;    // Text label for this item
  161.         
  162.         CSize m_unselectedBitmapSize; // The size of the unselected bitmap
  163.         CSize m_selectedBitmapSize;   // The size of the selected bitmap
  164.         CSize m_textSize;    // The size of the text in the font when this is calculated
  165.         CSize m_accelSize;    // The size of the accelerator in the font when this is calculated
  166.         CTreeItemList m_SubItems;    // List of items subordinate to this one
  167.         CMenu *m_pSubMenu;
  168.  
  169.         void* m_pCustomIcon;
  170.         IconType m_nIconType;
  171.  
  172.     private:
  173.  
  174. }; // END OF CLASS CTreeItem()
  175.  
  176.  
  177. /****************************************************************************
  178. *
  179. *    Class: CTreeMenu
  180. *
  181. *    DESCRIPTION:
  182. *        This class provides a custom, owner draw menu object for displaying
  183. *        graphics as well as text in a menu item. A group of these objects
  184. *        can be used to construct a hierarchical list.
  185. *
  186. ****************************************************************************/
  187.  
  188. #define CTreeMenuBase    CMenu
  189.  
  190. class CTreeMenu : public CTreeMenuBase, public CCustomImageObject
  191. {
  192.     public:
  193.         CTreeMenu();
  194.         ~CTreeMenu();
  195.  
  196.         BOOL AddItem(CTreeItem * pItem, int nPosition = 0, CTreeMenu *pSubMenu = NULL, void* pCustomIcon = NULL, IconType m_nIconType = BUILTIN_BITMAP);
  197.         BOOL Create()
  198.         {
  199.             return(CreatePopupMenu());
  200.         }
  201.         void ClearItems(int start, int fromEnd);
  202.         void CalculateItemDimensions(void);
  203.         CMenu * FindMenu(CString& menuName);
  204.         // if nCommand is 0, then the mnemonic is for a submenu
  205.         void AddMnemonic(TCHAR cMnemonic, UINT nCommand, int nPosition);
  206.         // if nCommand is 0 then mnemonic is for a submenu
  207.         // it returns FALSE if there is no mnemonic
  208.         BOOL GetMnemonic(TCHAR cMnemonic, UINT &nCommand, int &nPosition);
  209.         void SetParent(CWnd *pParent) { m_pParent = pParent;}
  210.  
  211.         virtual void LoadComplete(HT_Resource r) {}
  212.  
  213.     protected:
  214.         virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMI);
  215.         virtual void DrawItem(LPDRAWITEMSTRUCT lpDI);
  216.         virtual CSize DrawImage(CDC * pDC, const CRect & rect, CTreeItem * pItem, BOOL bIsSelected);
  217.         virtual void DeleteMnemonics(void);
  218.  
  219.     private:
  220.         int m_WidestImage;
  221.         int m_WidestText;
  222.         int m_WidestAccelerator;
  223.         CTreeItemList m_itemList;
  224.         CMapWordToPtr m_mnemonicMap;
  225.         CWnd *m_pParent;
  226.     private:
  227.         CSize MeasureBitmap(CBitmap *pBitmap);
  228.         CSize MeasureText(CString text);
  229.  
  230.  
  231. }; // END OF CLASS CTreeMenu()
  232.  
  233.  
  234. /****************************************************************************
  235. *
  236. *    Class: CPopupTree
  237. *
  238. *    DESCRIPTION:
  239. *        This class represents a hierarchical popup menu object that can be
  240. *        used for selecting from a list of sub-categorized items.
  241. *
  242. ****************************************************************************/
  243.  
  244. class CPopupTree
  245. {
  246.     public:
  247.         CPopupTree(CTreeItemList * pItems);
  248.         virtual ~CPopupTree();
  249.         
  250.         BOOL Activate(int nX, int nY, CWnd * pParent);
  251.          
  252.     protected:
  253.         void BuildMenu(CTreeMenu * pMenu, CTreeItemList * pItems);
  254.         
  255.         CTreeItemList * m_pTree;    // Contains entire tree of abstract item
  256.                                     // objects. The menu is constructed from
  257.                                     // this.
  258.         
  259.     private:
  260.         CObArray m_GarbageList;        // Used for garbage collection, since we
  261.                                     // dynamically allocate stuff within a
  262.                                     // recursive function.
  263.  
  264.                                     
  265. }; // END OF CLASS CPopupTree()
  266.  
  267.  
  268. #endif // __QUICKFIL_H__
  269.