home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / usertlbr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.8 KB  |  237 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 _USERTLBR_H
  20. #define _USERTLBR_H
  21.  
  22. #include <afxwin.h>
  23. #include <afxext.h>
  24. #include <afxpriv.h>
  25. #include <afxole.h>
  26. #include <afxdisp.h>
  27. #include <afxodlgs.h>
  28. #ifdef _WIN32
  29. #include <afxcmn.h>
  30. #endif
  31.  
  32. #include "tlbutton.h"
  33. #include "toolbar2.h"
  34. #include "rdfacc.h"
  35. #include "cxicon.h"
  36.  
  37. #define CLinkToolbarButtonDropTargetBase    CToolbarButtonDropTarget
  38.  
  39. class CLinkToolbarButtonDropTarget : public CLinkToolbarButtonDropTargetBase
  40. {
  41.     public:
  42.         CLinkToolbarButtonDropTarget(){m_pButton = NULL;}
  43.     protected:
  44.         virtual DROPEFFECT ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  45.             DWORD dwKeyState, CPoint point);
  46.         virtual DROPEFFECT ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  47.             DWORD dwKeyState, CPoint point);
  48.         virtual BOOL ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  49.             DROPEFFECT dropEffect, CPoint point);
  50.  
  51. }; 
  52.  
  53. #define CLinkToolbarButtonBase CDragableToolbarButton
  54.  
  55. class CLinkToolbarButton: public CLinkToolbarButtonBase, public CCustomImageObject {
  56.  
  57. protected:
  58.     HT_Resource m_Node;                // The resource corresponding to the RDF node
  59.     BOOKMARKITEM m_bookmark;
  60.     UINT m_uCurBMID;
  61.     CMapWordToPtr m_BMMenuMap;        // Maps the bookmark menu IDs
  62.     int currentRow;                 // The row of the personal toolbar this button resides on.
  63.     CDropMenu* m_pCachedDropMenu;    // A pointer to a drop menu that is tracked across 
  64.                                     // node opening (HT) callbacks
  65.     BOOL m_bShouldShowRMMenu;        // Set to TRUE by default.  Quickfile/Breadcrumbs set it to FALSE.
  66.  
  67.     CRDFCommandMap m_MenuCommandMap;    // Command map for back-end generated right mouse menu commands.
  68.  
  69. public:
  70.     CLinkToolbarButton();
  71.     ~CLinkToolbarButton();
  72.  
  73.     int Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize,
  74.                LPCTSTR pButtonText, LPCTSTR pToolTipText, 
  75.                LPCTSTR pStatusText,
  76.                CSize bitmapSize, int nMaxTextChars, int nMinTextChars, BOOKMARKITEM bookmark, 
  77.                HT_Resource pNode, DWORD dwButtonStyle = 0);
  78.  
  79.     int GetRow() { return currentRow; }
  80.     void SetRow(int i) { currentRow = i; }
  81.  
  82.     virtual void OnAction(void);
  83.     virtual CSize GetButtonSizeFromChars(CString s, int c);
  84.     virtual CSize GetMinimalButtonSize();
  85.     virtual CSize GetMaximalButtonSize();
  86.  
  87.     virtual BOOL UseLargeIcons() { return FALSE; }
  88.     virtual void UpdateIconInfo() { DetermineIconType(m_Node, UseLargeIcons()); }
  89.  
  90.     virtual void FillInOleDataSource(COleDataSource *pDataSource);
  91.  
  92.     BOOKMARKITEM GetBookmarkItem();
  93.     HT_Resource GetNode(void) { return m_Node;}
  94.     void SetNode(HT_Resource pBookmark, BOOL bAddRef = TRUE);
  95.     void SetBookmarkItem(BOOKMARKITEM bookmark);
  96.     virtual void EditTextChanged(char *pText);
  97.     void SetTextWithoutResize(CString text);
  98.  
  99.     virtual UINT GetBitmapID(void);
  100.     virtual UINT GetBitmapIndex(void);
  101.  
  102.     void FillInMenu(HT_Resource pNode);
  103.     void LoadComplete(HT_Resource r);
  104.     virtual void DrawCustomIcon(HDC hDC, int x, int y);
  105.     virtual void DrawLocalIcon(HDC hDC, int x, int y);
  106.     
  107.     virtual HT_View GetHTView() { return HT_GetView(m_Node); }
  108.  
  109. protected:
  110.     virtual void DrawPicturesMode(HDC hDC, CRect rect);
  111.     virtual void DrawPicturesAndTextMode(HDC hDC, CRect rect);
  112.     virtual BOOL CreateRightMouseMenu(void);
  113.     virtual CWnd* GetMenuParent(void);
  114.     virtual void GetPicturesAndTextModeTextRect(CRect &rect);
  115.     virtual void GetPicturesModeTextRect(CRect &rect);
  116.     virtual void DrawButtonText(HDC hDC, CRect rcTxt, CSize sizeTxt, CString strTxt);
  117.     
  118. protected:
  119.         // Generated message map functions
  120.     //{{AFX_MSG(CLinkToolbarButton)
  121.     afx_msg LRESULT OnDragMenuOpen(WPARAM, LPARAM);
  122.     afx_msg BOOL OnCommand(UINT wParam,LONG lParam);
  123.     afx_msg LRESULT OnDropMenuDropOccurred(WPARAM, LPARAM);
  124.     afx_msg LRESULT OnDropMenuDraggingOccurred(WPARAM, LPARAM);
  125.     afx_msg LRESULT OnDropMenuClosed(WPARAM, LPARAM);
  126.     afx_msg LRESULT OnFillInMenu(WPARAM wParam, LPARAM lParam);
  127.     afx_msg void OnSysColorChange( );
  128.  
  129.     //}}AFX_MSG
  130.  
  131.     DECLARE_MESSAGE_MAP()
  132.  
  133.  
  134. };
  135.  
  136. void ptNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened);
  137.  
  138. /****************************************************************************
  139. *
  140. *    Class: CLinkToolbarDropTarget
  141. *
  142. *    DESCRIPTION:
  143. *        This class provides a drag-drop target for the bookmark quick file
  144. *        button.
  145. *
  146. ****************************************************************************/
  147. class CLinkToolbar;
  148.  
  149. class CLinkToolbarDropTarget : public COleDropTarget
  150. {
  151. private:
  152.     CLinkToolbar *m_pToolbar;
  153.  
  154. public:
  155.     CLinkToolbarDropTarget() {m_pToolbar = NULL;}
  156.     void Toolbar(CLinkToolbar *pToolbar);
  157.      
  158. protected:
  159.  
  160.     virtual DROPEFFECT OnDragEnter(CWnd * pWnd,
  161.         COleDataObject * pDataObject, DWORD dwKeyState, CPoint point);
  162.     virtual DROPEFFECT OnDragOver(CWnd * pWnd,
  163.         COleDataObject * pDataObject, DWORD dwKeyState, CPoint point );
  164.     virtual BOOL OnDrop(CWnd * pWnd, COleDataObject * pDataObject,
  165.         DROPEFFECT dropEffect, CPoint point);
  166.  
  167.     private:
  168.  
  169. };
  170.  
  171. class CLinkToolbar : public CNSToolbar2 {
  172.  
  173. private:
  174.     CLinkToolbarDropTarget m_DropTarget;
  175.     HT_Pane m_PersonalToolbarPane;
  176.     CRDFCommandMap m_MenuCommandMap;    // Command map for back-end generated right mouse menu commands.
  177.     
  178.     int m_nNumberOfRows;
  179.  
  180.     CLinkToolbarButton* m_pDragButton;
  181.     int m_iDragFraction;
  182.  
  183.     static int m_nMinToolbarButtonChars;
  184.     static int m_nMaxToolbarButtonChars;
  185.  
  186. public:
  187.     CLinkToolbar(int nMaxButtons, int nToolbarStyle, int nPicturesAndTextHeight, int nPicturesHeight,
  188.                  int nTextHeight);
  189.     ~CLinkToolbar();
  190.  
  191.     // Used to create toolbars
  192.     static CLinkToolbar* CreateUserToolbar(CWnd* pParent);
  193.  
  194.     int Create(CWnd *pParent);
  195.     virtual int GetHeight(void);
  196.     
  197.     // Override layout scheme to dynamically resize buttons.
  198.     void LayoutButtons(int nIndex); // Index will be ignored by this version of the function
  199.                                     // since adding/deleting buttons may cause all buttons to resize
  200.     
  201.     
  202.     void AddHTButton(HT_Resource n);  // Called to add a new button to the toolbar
  203.  
  204.     void SetMinimumRows(int rowWidth); // Called to determine and set the # of rows required by the toolbar.
  205.  
  206.     int GetRows() { return m_nNumberOfRows; }
  207.     void SetRows(int i) { m_nNumberOfRows = i; }
  208.  
  209.     void WidthChanged(int width);  // Inherited from toolbar.  Called when width changes, e.g. window resize or animation placed on toolbar.
  210.  
  211.     void FillInToolbar(); // Called to create and place the buttons on the toolbar
  212.  
  213.     HT_Pane GetPane() { return m_PersonalToolbarPane; }  // Returns the HT-Pane
  214.  
  215.     void SetDragFraction(int i) { m_iDragFraction = i; }
  216.     int GetDragFraction() { return m_iDragFraction; }
  217.  
  218.     void SetDragButton(CLinkToolbarButton* pButton) { m_pDragButton = pButton; }
  219.     CLinkToolbarButton* GetDragButton() { return m_pDragButton; }
  220.  
  221. protected:
  222.     // Helper function used in conjunction with LayoutButtons
  223.     void ComputeLayoutInfo(CLinkToolbarButton* pButton, int numChars, int rowWidth, int& usedSpace);
  224.  
  225.     // Generated message map functions
  226.     //{{AFX_MSG(CLinkToolbar)
  227.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  228.     afx_msg BOOL OnCommand( WPARAM wParam, LPARAM lParam );
  229.     //}}AFX_MSG
  230.     DECLARE_MESSAGE_MAP()
  231.  
  232.  
  233. };
  234.  
  235.  
  236. #endif
  237.