home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / taskbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  22.0 KB  |  811 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. //
  20. // $Revision: 3.1 $
  21. //
  22. // TASKBAR.H
  23. //
  24. // DESCRIPTION:
  25. //        This file contains the declarations of the various task bar related
  26. //        classes.
  27. //
  28. // AUTHOR: Scott Jones
  29. //
  30. ///
  31.  
  32.  
  33. #if    !defined(__TASKBAR_H__)
  34. #define    __TASKBAR_H__
  35.  
  36. #ifndef    __AFXWIN_H__
  37.     #error include 'stdafx.h' before including this    file for PCH
  38. #endif
  39.  
  40. #include "tlbutton.h"
  41.  
  42. #define BROWSER_ICON_INDEX    0
  43. #define INBOX_ICON_INDEX    1
  44. #define UNKNOWN_MAIL_ICON_INDEX 2
  45. #define NEW_MAIL_ICON_INDEX 3
  46. #define NEWS_ICON_INDEX        4
  47. #define COMPOSE_ICON_INDEX    5
  48.  
  49. /****************************************************************************
  50. *
  51. *    Class: CTaskBarButtonDropTarget
  52. *
  53. *    DESCRIPTION:
  54. *        
  55. *        Some taskbar buttons may want to be drop targets.  So here's the class.
  56. *
  57. ****************************************************************************/
  58.  
  59. #define CTaskBarButtonDropTargetBase    CToolbarButtonDropTarget
  60.  
  61. class CTaskBarButtonDropTarget : public CTaskBarButtonDropTargetBase
  62. {
  63.     public:
  64.         CTaskBarButtonDropTarget(){m_pButton = NULL;}
  65.     protected:
  66.         virtual DROPEFFECT ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  67.             DWORD dwKeyState, CPoint point);
  68.         virtual DROPEFFECT ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  69.             DWORD dwKeyState, CPoint point);
  70.         virtual BOOL ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  71.             DROPEFFECT dropEffect, CPoint point) = 0;
  72.  
  73. }; 
  74.  
  75. #define CBrowserButtonDropTargetBase    CTaskBarButtonDropTarget
  76.  
  77. class CBrowserButtonDropTarget : public CBrowserButtonDropTargetBase
  78. {
  79.     public:
  80.         CBrowserButtonDropTarget(){m_pButton = NULL;}
  81.     protected:
  82.         virtual BOOL ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  83.             DROPEFFECT dropEffect, CPoint point);
  84.  
  85. }; 
  86.  
  87. #define CComposerButtonDropTargetBase    CTaskBarButtonDropTarget
  88.  
  89. class CComposerButtonDropTarget : public CComposerButtonDropTargetBase
  90. {
  91.     public:
  92.         CComposerButtonDropTarget(){m_pButton = NULL;}
  93.     protected:
  94.         virtual DROPEFFECT ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  95.             DWORD dwKeyState, CPoint point);
  96.         virtual DROPEFFECT ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  97.             DWORD dwKeyState, CPoint point);
  98.         virtual BOOL ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  99.             DROPEFFECT dropEffect, CPoint point);
  100.  
  101. }; 
  102.  
  103. #define CMessengerButtonDropTargetBase    CTaskBarButtonDropTarget
  104.  
  105. class CMessengerButtonDropTarget : public CMessengerButtonDropTargetBase
  106. {
  107.     public:
  108.         CMessengerButtonDropTarget(){m_pButton = NULL;}
  109.     protected:
  110.         virtual DROPEFFECT ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  111.             DWORD dwKeyState, CPoint point);
  112.         virtual DROPEFFECT ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  113.             DWORD dwKeyState, CPoint point);
  114.         virtual BOOL ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  115.             DROPEFFECT dropEffect, CPoint point);
  116.  
  117. }; 
  118.  
  119. #define CCollabraButtonDropTargetBase    CTaskBarButtonDropTarget
  120.  
  121. class CCollabraButtonDropTarget : public CCollabraButtonDropTargetBase
  122. {
  123.     public:
  124.         CCollabraButtonDropTarget(){m_pButton = NULL;}
  125.     protected:
  126.         virtual DROPEFFECT ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  127.             DWORD dwKeyState, CPoint point);
  128.         virtual DROPEFFECT ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  129.             DWORD dwKeyState, CPoint point);
  130.         virtual BOOL ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  131.             DROPEFFECT dropEffect, CPoint point);
  132.  
  133. }; 
  134.  
  135. /****************************************************************************
  136. *
  137. *    Class: CTaskIcon
  138. *
  139. *    DESCRIPTION:
  140. *        This class represents the abstraction of a task icon object. It
  141. *        encapsulates the data that is used to construct CTaskIconWnd objects.
  142. *
  143. ****************************************************************************/
  144.  
  145. #define CTaskIconBase    CObject
  146.  
  147. class CTaskIcon : public CTaskIconBase
  148. {
  149.     public:
  150.         CTaskIcon(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  151.             UINT idBmpLarge, int indexBmpLarge, UINT idBmpSmall,
  152.             int indexBmpSmall, UINT idHorizText, UINT idVertText,
  153.             UINT idDockedTip, UINT idFloatingTip);
  154.         virtual ~CTaskIcon();
  155.          
  156.         const UINT GetTaskID() const
  157.         {
  158.             return(m_idTask);
  159.         }
  160.         CWnd * GetNotifyWnd() const
  161.         {
  162.             return(m_pwndNotify);
  163.         }
  164.         const DWORD GetNotifyMessage() const
  165.         {
  166.             return(m_dwMessage);
  167.         }
  168.         const UINT GetLargeBmpID() const
  169.         {
  170.             return(m_idBmpLarge);
  171.         }
  172.         const UINT GetSmallBmpID() const
  173.         {
  174.             return(m_idBmpSmall);
  175.         }
  176.         void SetLargeBmpID(UINT idBmp)
  177.         {
  178.             m_idBmpLarge = idBmp;
  179.         }
  180.         void SetSmallBmpID(UINT idBmp)
  181.         {
  182.             m_idBmpSmall = idBmp;
  183.         }
  184.  
  185.         const int GetLargeBitmapIndex() const
  186.         {
  187.             return (m_indexBmpLarge);
  188.         }
  189.         const int GetSmallBitmapIndex() const
  190.         {
  191.             return(m_indexBmpSmall);
  192.         }
  193.         void SetLargeBitmapIndex(int indexBmp)
  194.         {
  195.             m_indexBmpLarge = indexBmp;
  196.         }
  197.         void SetSmallBitmapIndex(int indexBmp)
  198.         {
  199.             m_indexBmpSmall = indexBmp;
  200.         }
  201.  
  202.         const UINT GetHorizTextID()
  203.         {
  204.             return m_idHorizText;
  205.         }
  206.  
  207.         const UINT GetVertTextID()
  208.         {
  209.             return m_idVertText;
  210.         }
  211.  
  212.         const UINT GetDockedTipID()
  213.         {
  214.             return m_idDockedTip;
  215.         }
  216.  
  217.         const UINT GetFloatingTipID()
  218.         {
  219.             return m_idFloatingTip;
  220.         }
  221.  
  222.     protected:
  223.         CWnd * m_pwndNotify;    // Notifications go to this window
  224.         DWORD m_dwMessage;        // Callback message
  225.         UINT m_idTask;            // Task identifier for this icon
  226.         UINT m_idBmpLarge;        // Bitmap resource ID for large icon
  227.         UINT m_idBmpSmall;        // Bitmap resource ID for small icon
  228.         int m_indexBmpLarge;    // index for large bitmap
  229.         int m_indexBmpSmall;    // index for small bitmap
  230.         UINT m_idHorizText;        // String resource ID of horizontal text
  231.         UINT m_idVertText;        // String resource ID of vertical text
  232.         UINT m_idDockedTip;        // String resource ID of docked tool tip text
  233.         UINT m_idFloatingTip;    // String resource ID of floating tool tip text
  234.  
  235.     private:
  236.  
  237. }; // END OF CLASS CTaskIcon()
  238.  
  239.  
  240. /****************************************************************************
  241. *
  242. *    Class: CTaskIconArray
  243. *
  244. *    DESCRIPTION:
  245. *        This is a container class for holding CTaskIcon objects.
  246. *
  247. ****************************************************************************/
  248.  
  249. #define CTaskIconArrayBase    CObArray
  250.  
  251. class CTaskIconArray : public CTaskIconArrayBase
  252. {
  253.     public:
  254.         CTaskIconArray(){}
  255.         ~CTaskIconArray()
  256.         {
  257.             DeleteAll();
  258.         }
  259.         
  260.         int Add(CTaskIcon * pIcon)
  261.         {
  262.             return(CTaskIconArrayBase::Add(pIcon));
  263.         }
  264.         CTaskIcon * Get(int nIndex) const
  265.         {
  266.             return((CTaskIcon *)GetAt(nIndex));
  267.         }
  268.         int FindByID(UINT idTask);
  269.         void DeleteAll();
  270.         
  271.     protected:
  272.  
  273.     private:
  274.  
  275. }; // END OF CLASS CTaskIconArray()
  276.  
  277.  
  278. /****************************************************************************
  279. *
  280. *    Class: CTaskIconWnd
  281. *
  282. *    DESCRIPTION:
  283. *        This object represents a notification icon. It can be embeded within
  284. *        a task bar and provides mouse notifications to a given window. It is
  285. *        a window that paints its own bitmap, displays tool tip text, processes
  286. *        mouse events, etc.
  287. *
  288. ****************************************************************************/
  289.  
  290. #define CTaskIconWndBase    CStationaryToolbarButton
  291.  
  292. class CTaskIconWnd : public CTaskIconWndBase
  293. {
  294.     public:
  295.         CTaskIconWnd();
  296.         
  297.         BOOL CTaskIconWnd::Create(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  298.                                   UINT idBmp, int nBitmapIndex, UINT idHorizText, UINT idVertText, UINT idText, UINT idTip, BOOL bNoviceMode,
  299.                                   CSize noviceSize, CSize advancedSize, CSize bitmapSize, CWnd * pParent,
  300.                                   const CRect & rc = CRect(0,0,0,0));
  301.         
  302.         // Inline access functions
  303.         const UINT GetTaskID() const
  304.         {
  305.             return(m_idTask);
  306.         }
  307.         void SetBmpID(UINT idBmp)
  308.         {
  309.              m_idBmp = idBmp;
  310.         }
  311.         
  312.         const UINT GetHorizTextID(void) { return m_idHorizText; }
  313.         const UINT GetVertTextID(void) { return m_idVertText; }
  314.  
  315.     protected:
  316.         // Protected destructor so no one tries to instantiate us on the
  317.         // stack (we are an auto-deleting object)
  318.         virtual ~CTaskIconWnd();
  319.         virtual void PostNcDestroy();
  320.         virtual void AddDropTargetIfStandardButton(void);
  321.  
  322.     
  323.     //{{AFX_MSG(CTaskIconWnd)
  324.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  325.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  326.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  327.     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  328.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  329.     //}}AFX_MSG
  330.  
  331.     private:
  332.         CWnd * m_pwndNotify;    // Notifications go to this window
  333.         DWORD m_dwMessage;        // Callback message
  334.         UINT m_idTask;            // Task identifier for this icon
  335.         UINT m_idBmp;            // Bitmap identifier for this icon
  336.         UINT m_idHorizText;        // id when button is in horizontal mode
  337.         UINT m_idVertText;        // id when button is in vertical mode
  338.         
  339.     DECLARE_MESSAGE_MAP()
  340.     
  341. }; // END OF CLASS CTaskIconWnd()
  342.  
  343.  
  344. /****************************************************************************
  345. *
  346. *    Class: CTaskIconWndArray
  347. *
  348. *    DESCRIPTION:
  349. *        This is a container class for holding CTaskIconWnd objects.
  350. *
  351. ****************************************************************************/
  352.  
  353. #define CTaskIconWndArrayBase    CObArray
  354.  
  355. class CTaskIconWndArray : public CTaskIconWndArrayBase
  356. {
  357.     public:
  358.         CTaskIconWndArray(){}
  359.         ~CTaskIconWndArray(){}
  360.         
  361.         int Add(CTaskIconWnd * pIcon)
  362.         {
  363.             return(CTaskIconWndArrayBase::Add(pIcon));
  364.         }
  365.         CTaskIconWnd * Get(int nIndex) const
  366.         {
  367.             return((CTaskIconWnd *)GetAt(nIndex));
  368.         }
  369.         int FindByID(UINT idTask);
  370.         void DeleteAll();
  371.         
  372.     protected:
  373.  
  374.     private:
  375.  
  376. }; // END OF CLASS CTaskIconWndArray()
  377.  
  378.  
  379. /****************************************************************************
  380. *
  381. *    Class: CTaskBar
  382. *
  383. *    DESCRIPTION:
  384. *        This is the base class for task bar objects. All polymorphic functions
  385. *        common to the floating, docked, or other derived task bars are
  386. *        implemented here.
  387. *
  388. *        This is an abstract base class - you must instantiate one of the
  389. *        derived types. Also, objects of this class are auto-deleting, you
  390. *        must allocate them on the heap.
  391. *
  392. ****************************************************************************/
  393.  
  394. #define CTaskBarBase    CWnd
  395.  
  396. class CTaskBar : public CTaskBarBase
  397. {
  398.     public:
  399.         CTaskBar(int nToolbarStyle);
  400.         virtual BOOL Create(CWnd * pParent) = 0;
  401.         
  402.         virtual BOOL AddTaskIcon(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  403.                                  HBITMAP hBitmap, int nBitmapIndex, UINT idHorizText, UINT idVertText,
  404.                                    UINT idText, UINT idTip, int nToolbarStyle);
  405.  
  406.         BOOL ReplaceTaskIcon(UINT idTask, UINT idBmp, int nBitmapIndex);
  407.         BOOL RemoveTaskIcon(UINT idTask);
  408.         virtual CSize CalcDesiredDim();
  409.         virtual CSize GetButtonDimensions();
  410.         int GetTaskBarStyle(void) { return m_nToolbarStyle; }
  411.         void SetTaskBarStyle(int nToolbarStyle);
  412.         void ChangeButtonText(void);
  413.         void ReplaceButtonBitmap(int nIndex, HBITMAP hBitmap);
  414.         
  415.     // ClassWizard generated virtual function overrides
  416.     //{{AFX_VIRTUAL(CTaskBar)
  417.     //}}AFX_VIRTUAL
  418.  
  419.     protected:
  420.         // Protected destructor so no one tries to instantiate us on the
  421.         // stack (we are an auto-deleting object)
  422.         virtual ~CTaskBar();
  423.         virtual void PostNcDestroy();
  424.         virtual void DoPaint(CPaintDC & dc) = 0;
  425.         void LayoutIcons();
  426.         BOOL DragBarHitTest(const CPoint & pt);
  427.         
  428.         void ChangeButtonStyle(void);
  429.         CTaskIconWndArray m_TaskIconWndList;
  430.         CSize m_noviceButtonSize;
  431.         CSize m_advancedButtonSize;
  432.         CSize m_IconSize;
  433.  
  434.         int m_nMaxButtonWidth;
  435.         int m_nMaxButtonHeight;
  436.         
  437.  
  438.         int m_nDragBarWidth;        // when horizontal
  439.         int m_nDragBarHeight;        // when vertical
  440.         int m_nIconSpace;
  441.         int m_nToolbarStyle;
  442.  
  443.         BOOL m_bHorizontal;    // TRUE when oriented horizontally
  444.         BOOL m_bShowText;    // TRUE when icon text is to be shown
  445.  
  446.  
  447.     //{{AFX_MSG(CTaskBar)
  448.     afx_msg void OnPaint();
  449.     afx_msg void OnSize(UINT nType, int cx, int cy);
  450.     afx_msg void OnPaletteChanged( CWnd* pFocusWnd );
  451.     afx_msg void OnSysColorChange();
  452.  
  453.     //}}AFX_MSG
  454.     
  455.     private:
  456.  
  457.     DECLARE_MESSAGE_MAP()
  458.     
  459. }; // END OF CLASS CTaskBar()
  460.  
  461.  
  462. /****************************************************************************
  463. *
  464. *    Class: CDockButton
  465. *
  466. *    DESCRIPTION:
  467. *        This class represents the docking (minimize) button for the floating
  468. *        task bar.
  469. *
  470. ****************************************************************************/
  471.  
  472. #define CDockButtonBase    CButton
  473.  
  474. class CDockButton : public CDockButtonBase
  475. {
  476.     public:
  477.         CDockButton();
  478.         BOOL Create(const CRect & rect, CWnd* pwndParent, UINT uID);
  479.          
  480.     protected:
  481.         void DrawItem(LPDRAWITEMSTRUCT lpDrawItem);
  482.         void DrawImage(CDC * pDC, CRect & rect);
  483.         void DrawUpButton(CDC * pDC, CRect & rect);
  484.         void DrawDownButton(CDC * pDC, CRect & rect);
  485.         
  486.     //{{AFX_MSG(CDockButton)
  487.     //}}AFX_MSG
  488.  
  489.     private:
  490.  
  491.     DECLARE_MESSAGE_MAP()
  492.     
  493. }; // END OF CLASS CDockButton()
  494.  
  495.  
  496. /****************************************************************************
  497. *
  498. *    Class: CFloatingTaskBar
  499. *
  500. *    DESCRIPTION:
  501. *        This derived version of CTaskBar provides a "floating" task bar. It
  502. *        is in the form of a custom popup window.
  503. *
  504. ****************************************************************************/
  505.  
  506. #define CFloatingTaskBarBase    CTaskBar
  507.  
  508. class CFloatingTaskBar : public CFloatingTaskBarBase
  509. {
  510.     public:
  511.         CFloatingTaskBar(int nToolbarStyle, BOOL bOnTop = TRUE, BOOL bHorizontal = TRUE );
  512.         BOOL Create(CWnd * pParent);
  513.          
  514.     protected:
  515.         // Protected destructor so no one tries to instantiate us on the
  516.         // stack (we are an auto-deleting object)
  517.         virtual ~CFloatingTaskBar();
  518.         virtual void DoPaint(CPaintDC & dc);
  519.         void PaintDragBar(CDC * pdc);
  520.         void SetMenuState(CMenu * pMenu);
  521.  
  522.         CDockButton m_btnDock;        // Docking button
  523.         BOOL m_bActive;                // Maintains our active state
  524.         
  525.     //{{AFX_MSG(CFloatingTaskBar)
  526.     afx_msg void OnClose();
  527.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  528.     afx_msg void OnDock();
  529.     afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  530.     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  531.     afx_msg void OnMove(int x, int y);
  532.     afx_msg LRESULT OnAddMenu(WPARAM, LPARAM); 
  533.     afx_msg void OnAlwaysOnTop();
  534.     afx_msg void OnShowText();
  535.     afx_msg void OnPosition();
  536.     afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  537.     afx_msg void OnInitMenu(CMenu *pMenu);
  538.     afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
  539.   
  540.  
  541.     //}}AFX_MSG
  542.     
  543.     private:
  544.         BOOL m_bOnTop;        // TRUE when 'always on top' property is set
  545. //        BOOL m_bHorizontal;    // TRUE when oriented horizontally
  546.  
  547.     DECLARE_MESSAGE_MAP()
  548.     
  549. }; // END OF CLASS CFloatingTaskBar()
  550.  
  551.  
  552. /****************************************************************************
  553. *
  554. *    Class: CDockedTaskBar
  555. *
  556. *    DESCRIPTION:
  557. *        This derived version of CTaskBar provides a "docked" task bar. It is
  558. *        in the form of a mini child window embedded within its parent
  559. *        (normally a CNetscapeStatusBar).
  560. *
  561. ****************************************************************************/
  562.  
  563. #define CDockedTaskBarBase    CTaskBar
  564.  
  565. class CDockedTaskBar : public CDockedTaskBarBase
  566. {
  567.     public:
  568.         CDockedTaskBar(int nToolbarStyle);
  569.         BOOL Create(CWnd * pParent);
  570.          
  571.     protected:
  572.         // Protected destructor so no one tries to instantiate us on the
  573.         // stack (we are an auto-deleting object)
  574.         virtual ~CDockedTaskBar();
  575.         virtual void DoPaint(CPaintDC & dc);
  576.         void OnUnDock(CPoint & ptUL = CPoint(-1, -1));
  577.  
  578.     //{{AFX_MSG(CDockedTaskBar)
  579.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  580.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  581.     //}}AFX_MSG
  582.     
  583.     private:
  584.  
  585.     DECLARE_MESSAGE_MAP()
  586.     
  587. }; // END OF CLASS CDockedTaskBar()
  588.  
  589.  
  590. /****************************************************************************
  591. *
  592. *    Class: CTaskBarArray
  593. *
  594. *    DESCRIPTION:
  595. *        This is a container class for holding CTaskBar objects.
  596. *
  597. ****************************************************************************/
  598.  
  599. #define CTaskBarArrayBase    CObArray
  600.  
  601. class CTaskBarArray : public CTaskBarArrayBase
  602. {
  603.     public:
  604.         CTaskBarArray(){}
  605.         ~CTaskBarArray(){}
  606.         
  607.         int Add(CTaskBar * pTaskBar)
  608.         {
  609.             return(CTaskBarArrayBase::Add(pTaskBar));
  610.         }
  611.         CTaskBar * Get(int nIndex) const
  612.         {
  613.             return((CTaskBar *)GetAt(nIndex));
  614.         }
  615.         int Find(CTaskBar * pTaskBar);
  616.         void DeleteAll();
  617.         
  618.     protected:
  619.  
  620.     private:
  621.  
  622. }; // END OF CLASS CTaskBarArray()
  623.  
  624.  
  625. /****************************************************************************
  626. *
  627. *    Class: CTaskBarMgr
  628. *
  629. *    DESCRIPTION:
  630. *        This class provides an object for managing all task bars within
  631. *        the system. It maintains the abstract data for all active task icons
  632. *        and handles the generation and switching between floating, docked or
  633. *        other style task bars. All task bar operations should be piped though
  634. *        this object so it can handle propagation to the appropriate active
  635. *        task bar(s).
  636. *
  637. *        There are also some convenience functions available, for such actions
  638. *        as adding a common set of task icons.
  639. *
  640. ****************************************************************************/
  641.  
  642. // State flag definitions
  643. #define TBAR_FLOATING    0x1L
  644. #define TBAR_ONTOP        0x2L
  645. #define TBAR_SHOWTEXT    0x4L
  646. #define TBAR_HORIZONTAL    0x8L
  647.  
  648. // Forward declarations
  649. class CNetscapeStatusBar;
  650.  
  651. #define CTaskBarMgrBase    CObject
  652.  
  653. class CTaskBarMgr : public CTaskBarMgrBase
  654. {
  655.     public:
  656.         CTaskBarMgr();
  657.         virtual ~CTaskBarMgr();
  658.         
  659.         BOOL Init();
  660.         //if bAlwaysDock is TRUE then ignore the docked preference
  661.         void LoadPrefs(BOOL bAlwaysDock);
  662.         void SavePrefs(void);
  663.         void RegisterStatusBar(CNetscapeStatusBar * pStatBar);
  664.         void UnRegisterStatusBar(CNetscapeStatusBar * pStatBar);
  665.         void OnSizeStatusBar(CNetscapeStatusBar * pStatBar);
  666.         BOOL AddStandardIcons();
  667.         BOOL AddTaskIcon(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  668.                          UINT idBmpLarge, int nLargeIndex, UINT idBmpSmall, int nSmallIndex,
  669.                          UINT idHorizText, UINT idVertText, UINT idDockedTip, UINT idFloatingTip);
  670.         BOOL AddTaskIcon(UINT idTask, UINT idBmpLarge, int nLargeIndex, UINT idBmpSmall,
  671.                          int nSmallIndex, UINT idHorizText, UINT idVertText,
  672.                               UINT idDockedTip, UINT idFloatingTip);
  673.         BOOL ReplaceTaskIcon(UINT idTask, UINT idBmpLarge, UINT idBmpSmall, int nIndex = 0);
  674.         BOOL RemoveTaskIcon(UINT idTask);
  675.         void OnDockTaskBar();
  676.         void OnUnDockTaskBar(CPoint & ptUL = CPoint(-1, -1));
  677.         void SetTaskBarStyle(int nTaskBarStyle);
  678.         void SetSeparateTaskBarStyle(int nTaskBarStyle);
  679.         void ReloadIconBitmaps(CTaskBar *pTaskBar);
  680.         // if bAdd is TRUE then add a reference, otherwise, remove one.
  681.         void Reference(BOOL bAdd);
  682.         void ChangeTaskBarsPalette(HWND hFocus);
  683.  
  684.         CTaskIconArray &GetIconArray(void) { return m_IconList; }
  685.  
  686.         const BOOL IsInitialized() const
  687.         {
  688.             return(m_bInitialized);
  689.         }
  690.         const CPoint & GetLastFloatPos() const
  691.         {
  692.             return(m_ptLastFloatPos);
  693.         }
  694.         void SetLastFloatPos(const CPoint & pt)
  695.         {
  696.             m_ptLastFloatPos = pt;
  697.         }
  698.         const DWORD GetStateFlags() const
  699.         {
  700.             return(m_dwStateFlags);
  701.         }
  702.         void SetStateFlags(DWORD dwStateFlags)
  703.         {
  704.             m_dwStateFlags = dwStateFlags;
  705.         }
  706.          
  707.         
  708.         // Inline accessors for the state flags
  709.         const BOOL IsFloating() const
  710.         {
  711.             return !!(m_dwStateFlags & TBAR_FLOATING);
  712.         }
  713.         void SetFloating(BOOL bFloating)
  714.         {
  715.             if (bFloating)
  716.             {
  717.                 m_dwStateFlags |= TBAR_FLOATING;
  718.             }
  719.             else
  720.             {
  721.                 m_dwStateFlags &= ~TBAR_FLOATING;
  722.             }
  723.         }
  724.         
  725.         const BOOL IsOnTop() const
  726.         {
  727.             return !!(m_dwStateFlags & TBAR_ONTOP);
  728.         }
  729.         void SetOnTop(BOOL bOnTop)
  730.         {
  731.             if (bOnTop)
  732.             {
  733.                 m_dwStateFlags |= TBAR_ONTOP;
  734.             }
  735.             else
  736.             {
  737.                 m_dwStateFlags &= ~TBAR_ONTOP;
  738.             }
  739.         }
  740.         
  741.         const BOOL IsShowText() const
  742.         {
  743.             return !!(m_dwStateFlags & TBAR_SHOWTEXT);
  744.         }
  745.         void SetShowText(BOOL bShowText)
  746.         {
  747.             if (bShowText)
  748.             {
  749.                 m_dwStateFlags |= TBAR_SHOWTEXT;
  750.             }
  751.             else
  752.             {
  753.                 m_dwStateFlags &= ~TBAR_SHOWTEXT;
  754.             }
  755.             PositionFloatingTaskBar();
  756.  
  757.         }
  758.         
  759.         const BOOL IsHorizontal() const
  760.         {
  761.             return !!(m_dwStateFlags & TBAR_HORIZONTAL);
  762.         }
  763.         void SetHorizontal(BOOL bHorizontal)
  764.             {
  765.             if (bHorizontal)
  766.             {
  767.                 m_dwStateFlags |= TBAR_HORIZONTAL;
  768.             }
  769.             else
  770.             {
  771.                 m_dwStateFlags &= ~TBAR_HORIZONTAL;
  772.             }
  773.  
  774.             PositionFloatingTaskBar();
  775.         }
  776.         
  777.     protected:
  778.         BOOL CreateAllTaskBars();
  779.         void DestroyAllTaskBars();
  780.         BOOL CreateFloatingTaskBar();
  781.         BOOL CreateDockedTaskBar(CNetscapeStatusBar * pStatBar);
  782.         void PlaceOnStatusBar(CDockedTaskBar * pTaskBar,
  783.             CNetscapeStatusBar * pStatBar);
  784.         void AdjustStatusPane(CDockedTaskBar * pTaskBar,
  785.             CNetscapeStatusBar * pStatBar);
  786.         BOOL AddIconsToTaskBar(CTaskBar * pTaskBar);
  787.         void PositionDockedTaskBars();
  788.         void PositionFloatingTaskBar();
  789.         void ChangeTaskBarStyle(int nTaskBarStyle);
  790.  
  791.         
  792.         // State flags (these get saved in the registry by NETSCAPE.CPP)
  793.         DWORD m_dwStateFlags;            // These bits indicate various states
  794.                                         //   of the task bar
  795.         CPoint m_ptLastFloatPos;        // Upper left corner of floating TBar
  796.         
  797.         BOOL m_bInitialized;            // TRUE when we've been initialized
  798.         BOOL m_bSeparateTaskBarStyle;    // Are we getting style from out menu or externally?
  799.         CTaskIconArray m_IconList;        // Contains list of task icon objects
  800.         CTaskBarArray m_TaskBarList;    // Contains active task bar pointers
  801.         CObArray m_StatBarList;            // Contains status bar pointers
  802.         CMapPtrToPtr m_StatBarMap;        // Maps sbar pointers to tbar pointers
  803.         int m_nTaskBarStyle;            // The current style of the taskbar
  804.         int m_nReference;                // The number of references we have
  805.     private:
  806.  
  807. }; // END OF CLASS CTaskBarMgr()
  808.  
  809.  
  810. #endif // __TASKBAR_H__
  811.