home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / rdfacc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.8 KB  |  184 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 RDFACC_H
  20. #define RDFACC_H
  21.  
  22. #include "cxstubs.h"
  23.  
  24. class CCustomImageObject;
  25. class NSNavCenterImage;
  26.  
  27. enum IconType { BUILTIN_BITMAP, LOCAL_FILE, ARBITRARY_URL }; // TODO: Use this icon type for the tree AND the toolbars
  28.  
  29. class CHTFEData
  30. {
  31. private:
  32.     CHTFEData(); // Disallow the instantiation of objects of this class.
  33.  
  34. public:
  35.     
  36.     static void FlushIconInfo() 
  37.     { 
  38.         // Just remove the HICONs from the local file cache.
  39.         m_LocalFileCache.RemoveAll();  
  40.         
  41.         // Need to iterate over all the elements in the custom URL cache and destroy the images.
  42.         POSITION pos = m_CustomURLCache.GetStartPosition();
  43.         void* pData;
  44.         CString key;
  45.         while (pos != NULL)
  46.         {
  47.             m_CustomURLCache.GetNextAssoc(pos, key, pData);
  48.             NSNavCenterImage* pImage = (NSNavCenterImage*)pData;
  49.             delete pImage;
  50.         }
  51.     }
  52.  
  53.     static CMapStringToPtr m_LocalFileCache; 
  54.       // Hashed on file extension e.g., .html would hold the icon for HTML files.
  55.       // Special keys: "open folder" and "closed folder" are used to hold the folder icons.
  56.       //               file URLs are used to represent drives, e.g., file:///a|/
  57.       //               "no extension" is used to represent files with no extension
  58.  
  59.     static CMapStringToPtr m_CustomURLCache;
  60.       // Hashed on the URL of the image.  Holds pointers to NSNavCenterImages.
  61. };
  62.  
  63. class CRDFColumn : public CObject
  64. {
  65. private:
  66.     char* name; // The column's name.
  67.     int width; // The column's width
  68.     void* token; // The column token
  69.     uint32 tokenType; // The column token type
  70.     char buffer[200]; // A temp. storage buffer for column data
  71.  
  72. public:
  73.     CRDFColumn(char* n, int w, void* t, uint32 tt)
  74.         :name(n), width(w), token(t), tokenType(tt) {}
  75.  
  76.     uint32 GetDataType() const { return tokenType; }
  77.     char* GetName() { return name; }
  78.     void* GetToken() { return token; }
  79.     char* GetStorageBuffer() { return buffer; }
  80. };
  81.  
  82. class CRDFMenuCommand : public CObject
  83. {
  84. private:
  85.     HT_MenuCmd htCommandID;
  86.     char* name;
  87.  
  88. public:
  89.     CRDFMenuCommand(char* n, HT_MenuCmd ht)
  90.         :name(n), htCommandID(ht) {}
  91.  
  92.     HT_MenuCmd GetHTCommand() { return htCommandID; }
  93. };
  94.  
  95. class CRDFCommandMap
  96. {
  97. private:
  98.     CObArray commandMap; // Contains a mapping of idents to objects.  This is used
  99.                          // for columns and for menus.
  100. public:
  101.     CRDFCommandMap()
  102.     {
  103.     }
  104.  
  105. private:
  106.     CRDFCommandMap(const CRDFCommandMap& la)
  107.     {} // Object cannot be copied
  108.  
  109. public:
  110.     ~CRDFCommandMap() 
  111.     {
  112.         Clear();
  113.     }
  114.     
  115.     int AddCommand(CObject* theObject)
  116.     {
  117.         return commandMap.Add(theObject);
  118.     }
  119.  
  120.     CObject* GetCommand(int i) { return commandMap[i]; }
  121.  
  122.     void Clear()
  123.     {
  124.         int count = commandMap.GetSize();
  125.         for (int i = count-1; i >= 0; i--)
  126.         {
  127.             CObject* obj = commandMap[i];
  128.             commandMap.RemoveAt(i);
  129.             delete obj;
  130.         }
  131.     }
  132. };
  133.  
  134. class CRDFOutliner;
  135.  
  136. class CRDFEditWnd : public CEdit
  137. {
  138. protected:
  139.     CRDFOutliner* m_pOwner;    
  140. public:
  141.     CRDFEditWnd(CRDFOutliner* owner) { m_pOwner = owner; }
  142.     ~CRDFEditWnd() {};
  143.  
  144.     virtual BOOL PreTranslateMessage ( MSG * msg );
  145.  
  146. protected:
  147.         // Generated message map functions
  148.     //{{AFX_MSG(CRDFEditWnd)
  149.     afx_msg void OnDestroy();
  150.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  151.     afx_msg void OnKillFocus( CWnd* pNewWnd );
  152.     //}}AFX_MSG
  153.     DECLARE_MESSAGE_MAP()
  154.  
  155. };
  156.  
  157. // The RDF Context
  158. class CRDFCX : public CStubsCX
  159. {
  160. private:
  161.     CWnd* m_pCurrentRDFWindow;
  162.  
  163. public:
  164.     CRDFCX(ContextType ctMyType, MWContextType XPType) 
  165.         :CStubsCX(ctMyType, XPType) { m_pCurrentRDFWindow = NULL; };
  166.  
  167.     virtual CWnd *GetDialogOwner() const;
  168.  
  169.     void TrackRDFWindow(CWnd* pWnd) { m_pCurrentRDFWindow = pWnd; };
  170.  
  171. };
  172.  
  173. BOOL IsLocalFile(const char* pURL);
  174. BOOL IsExecutableURL(const char* pURL);
  175. HICON DrawLocalFileIcon(HT_Resource r, int left, int top, HDC hdc);
  176. NSNavCenterImage* DrawArbitraryURL(HT_Resource r, int left, int top, int imageWidth, 
  177.                                    int imageHeight, HDC hDC, COLORREF bkColor,
  178.                                    CCustomImageObject* pObject, BOOL largeIcon);
  179.  
  180. HICON FetchLocalFileIcon(HT_Resource r);
  181. NSNavCenterImage* FetchCustomIcon(HT_Resource r, CCustomImageObject* pObject, BOOL largeIcon);
  182. IconType DetermineIconType(HT_Resource pNode, BOOL largeIcon);
  183.  
  184. #endif // RDFACC_H