home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / taskbar.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  96.8 KB  |  3,749 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.CPP
  23. //
  24. // DESCRIPTION:
  25. //        This file contains the implementations of the various task bar related
  26. //        classes.
  27. //
  28. // AUTHOR: Scott Jones
  29. //
  30. ///
  31.  
  32.  
  33. /**    INCLUDE    **/
  34. #include "stdafx.h"
  35. #include "taskbar.h"
  36. #include "statbar.h"
  37. #include "hiddenfr.h"
  38. #include "feutil.h"
  39. #include "prefapi.h"
  40.  
  41. #ifdef _DEBUG
  42. #undef THIS_FILE
  43. static char    BASED_CODE THIS_FILE[] = __FILE__;
  44. #endif
  45.  
  46. #define SPACE_BETWEEN_ICONS 3
  47. #define TASKBAR_ADDMENU (WM_USER + 200)
  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. DROPEFFECT CTaskBarButtonDropTarget::ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  60.             DWORD dwKeyState, CPoint point)
  61. {
  62.  
  63.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  64.     
  65.     // Only interested in bookmarks
  66.     if (pDataObject->IsDataAvailable(
  67.         ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT)))
  68.     {
  69.         deReturn = DROPEFFECT_COPY;
  70.  
  71.     }
  72.  
  73.     return(deReturn);
  74.  
  75. }
  76.  
  77. DROPEFFECT CTaskBarButtonDropTarget::ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  78.             DWORD dwKeyState, CPoint point)
  79. {
  80.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  81.     
  82.     // Only interested in bookmarks
  83.     if (pDataObject->IsDataAvailable(
  84.         ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT)))
  85.     {
  86.         deReturn = DROPEFFECT_COPY;
  87.     }
  88.  
  89.     return(deReturn);
  90.  
  91. }
  92.  
  93. BOOL CBrowserButtonDropTarget::ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  94.             DROPEFFECT dropEffect, CPoint point)
  95. {
  96.     BOOL bRtn = FALSE;
  97.     
  98.     // Only interested in bookmarks
  99.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  100.     if (pDataObject->IsDataAvailable(cfBookmark))
  101.     {
  102.         // TODO: for now, just dump it at the top like the CTRL-D accelerator
  103.         // does. Later, we want to put it in a designated scrap folder or
  104.         // something.
  105.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  106.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  107.         ASSERT(pBookmark != NULL);
  108.  
  109.         CGenericFrame * pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
  110.         if (pFrame) {
  111.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  112.  
  113.             BOOL bNewWindow = (XP_STRCASECMP(urlType, "file:") == 0) ||
  114.                 (XP_STRCASECMP(urlType, "http:") == 0) || 
  115.                 (XP_STRCASECMP(urlType, "https:") == 0);
  116.  
  117.  
  118.             if(bNewWindow)
  119.                 // This checks for existing window with given URL
  120.                 FE_LoadUrl(pBookmark->szAnchor, LOAD_URL_NAVIGATOR);
  121.             else
  122.                 pFrame->GetMainContext()->NormalGetUrl(pBookmark->szAnchor);
  123.         }
  124.         //this needs to become what we are dropping onto
  125.         ::GlobalUnlock(hBookmark);
  126.  
  127.         bRtn = TRUE;
  128.     }
  129.     return bRtn;
  130. }
  131.  
  132. DROPEFFECT CComposerButtonDropTarget::ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  133.             DWORD dwKeyState, CPoint point)
  134. {
  135.  
  136.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  137.     
  138.     // Only interested in bookmarks
  139.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  140.  
  141.     if (pDataObject->IsDataAvailable(cfBookmark))
  142.     {
  143.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  144.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  145.         ASSERT(pBookmark != NULL);
  146.  
  147.         if(pBookmark)
  148.         {
  149.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  150.  
  151.             BOOL bAccept = (XP_STRCASECMP(urlType, "file:") == 0) ||
  152.                 (XP_STRCASECMP(urlType, "http:") == 0) || 
  153.                 (XP_STRCASECMP(urlType, "https:") == 0);
  154.  
  155.             if(bAccept)
  156.                 deReturn = DROPEFFECT_COPY;
  157.         }
  158.  
  159.     }
  160.  
  161.     return(deReturn);
  162.  
  163. }
  164.  
  165. DROPEFFECT CComposerButtonDropTarget::ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  166.             DWORD dwKeyState, CPoint point)
  167. {
  168.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  169.     
  170.     // Only interested in bookmarks
  171.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  172.  
  173.     if (pDataObject->IsDataAvailable(cfBookmark))
  174.     {
  175.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  176.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  177.         ASSERT(pBookmark != NULL);
  178.  
  179.         if(pBookmark)
  180.         {
  181.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  182.  
  183.             BOOL bAccept = (XP_STRCASECMP(urlType, "file:") == 0) ||
  184.                 (XP_STRCASECMP(urlType, "http:") == 0) || 
  185.                 (XP_STRCASECMP(urlType, "https:") == 0);
  186.  
  187.             if(bAccept)
  188.                 deReturn = DROPEFFECT_COPY;
  189.         }
  190.     }
  191.  
  192.     return(deReturn);
  193.  
  194. }
  195.  
  196. BOOL CComposerButtonDropTarget::ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  197.             DROPEFFECT dropEffect, CPoint point)
  198. {
  199.     BOOL bRtn = FALSE;
  200.     
  201.     // Only interested in bookmarks
  202.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  203.     if (pDataObject->IsDataAvailable(cfBookmark))
  204.     {
  205.         // TODO: for now, just dump it at the top like the CTRL-D accelerator
  206.         // does. Later, we want to put it in a designated scrap folder or
  207.         // something.
  208.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  209.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  210.         ASSERT(pBookmark != NULL);
  211.         CGenericFrame * pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
  212.  
  213.         if(pFrame)
  214.         {
  215.             FE_LoadUrl(pBookmark->szAnchor, LOAD_URL_COMPOSER);
  216.         }
  217.  
  218.         //this needs to become what we are dropping onto
  219.         ::GlobalUnlock(hBookmark);
  220.  
  221.         bRtn = TRUE;
  222.     }
  223.     return bRtn;
  224. }
  225.  
  226. DROPEFFECT CMessengerButtonDropTarget::ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  227.             DWORD dwKeyState, CPoint point)
  228. {
  229.  
  230.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  231.     
  232.     // Only interested in bookmarks
  233.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  234.  
  235.     if (pDataObject->IsDataAvailable(cfBookmark))
  236.     {
  237.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  238.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  239.         ASSERT(pBookmark != NULL);
  240.  
  241.         if(pBookmark)
  242.         {
  243.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  244.  
  245.             BOOL bAccept = (XP_STRCASECMP(urlType, "mailbox:") == 0);
  246.  
  247.             if(bAccept)
  248.                 deReturn = DROPEFFECT_COPY;
  249.         }
  250.     }
  251.     return(deReturn);
  252.  
  253. }
  254.  
  255. DROPEFFECT CMessengerButtonDropTarget::ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  256.             DWORD dwKeyState, CPoint point)
  257. {
  258.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  259.     
  260.     // Only interested in bookmarks
  261.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  262.  
  263.     if (pDataObject->IsDataAvailable(cfBookmark))
  264.     {
  265.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  266.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  267.         ASSERT(pBookmark != NULL);
  268.  
  269.         if(pBookmark)
  270.         {
  271.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  272.  
  273.             BOOL bAccept = (XP_STRCASECMP(urlType, "mailbox:") == 0);
  274.  
  275.             if(bAccept)
  276.                 deReturn = DROPEFFECT_COPY;
  277.         }
  278.     }
  279.     return(deReturn);
  280.  
  281. }
  282.  
  283. BOOL CMessengerButtonDropTarget::ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  284.             DROPEFFECT dropEffect, CPoint point)
  285. {
  286.     BOOL bRtn = FALSE;
  287.     
  288.     // Only interested in bookmarks
  289.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  290.     if (pDataObject->IsDataAvailable(cfBookmark))
  291.     {
  292.         // TODO: for now, just dump it at the top like the CTRL-D accelerator
  293.         // does. Later, we want to put it in a designated scrap folder or
  294.         // something.
  295.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  296.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  297.         ASSERT(pBookmark != NULL);
  298.  
  299.         CGenericFrame * pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
  300.         if (pFrame) {
  301.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  302.     
  303.             BOOL bAccept = (XP_STRCASECMP(urlType, "mailbox:") == 0);
  304.  
  305.             if(bAccept)
  306.                 pFrame->GetMainContext()->NormalGetUrl(pBookmark->szAnchor);
  307.     
  308.  
  309.         }
  310.         //this needs to become what we are dropping onto
  311.         ::GlobalUnlock(hBookmark);
  312.  
  313.         bRtn = TRUE;
  314.     }
  315.     return bRtn;
  316. }
  317.  
  318. DROPEFFECT CCollabraButtonDropTarget::ProcessDragEnter(CWnd *pWnd, COleDataObject *pDataObject, 
  319.             DWORD dwKeyState, CPoint point)
  320. {
  321.  
  322.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  323.     
  324.     // Only interested in bookmarks
  325.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  326.  
  327.     if (pDataObject->IsDataAvailable(cfBookmark))
  328.     {
  329.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  330.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  331.         ASSERT(pBookmark != NULL);
  332.  
  333.         if(pBookmark)
  334.         {
  335.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  336.  
  337.             BOOL bAccept = (XP_STRCASECMP(urlType, "news:") == 0) ||
  338.                                (XP_STRCASECMP(urlType, "snews:") == 0);
  339.  
  340.             if(bAccept)
  341.                 deReturn = DROPEFFECT_COPY;
  342.         }
  343.     }
  344.     return(deReturn);
  345.  
  346. }
  347.  
  348. DROPEFFECT CCollabraButtonDropTarget::ProcessDragOver(CWnd *pWnd, COleDataObject *pDataObject, 
  349.             DWORD dwKeyState, CPoint point)
  350. {
  351.     DROPEFFECT deReturn = DROPEFFECT_NONE;
  352.     
  353.     // Only interested in bookmarks
  354.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  355.  
  356.     if (pDataObject->IsDataAvailable(cfBookmark))
  357.     {
  358.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  359.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  360.         ASSERT(pBookmark != NULL);
  361.  
  362.         if(pBookmark)
  363.         {
  364.             char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  365.  
  366.             BOOL bAccept = (XP_STRCASECMP(urlType, "news:") == 0) ||
  367.                                (XP_STRCASECMP(urlType, "snews:") == 0);
  368.  
  369.             if(bAccept)
  370.                 deReturn = DROPEFFECT_COPY;
  371.         }
  372.     }
  373.     return(deReturn);
  374.  
  375. }
  376.  
  377. BOOL CCollabraButtonDropTarget::ProcessDrop(CWnd *pWnd, COleDataObject *pDataObject, 
  378.             DROPEFFECT dropEffect, CPoint point)
  379. {
  380.     BOOL bRtn = FALSE;
  381.     
  382.     // Only interested in bookmarks
  383.     CLIPFORMAT cfBookmark = ::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT);
  384.     if (pDataObject->IsDataAvailable(cfBookmark))
  385.     {
  386.         // TODO: for now, just dump it at the top like the CTRL-D accelerator
  387.         // does. Later, we want to put it in a designated scrap folder or
  388.         // something.
  389.         HGLOBAL hBookmark = pDataObject->GetGlobalData(cfBookmark);
  390.         LPBOOKMARKITEM pBookmark = (LPBOOKMARKITEM)::GlobalLock(hBookmark);
  391.         ASSERT(pBookmark != NULL);
  392.         
  393.         CGenericFrame * pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
  394.         if (pFrame) {
  395.     
  396.             if (pFrame) {
  397.                 char *urlType = NET_ParseURL(pBookmark->szAnchor, GET_PROTOCOL_PART);
  398.             
  399.                 BOOL bAccept = (XP_STRCASECMP(urlType, "news:") == 0) ||
  400.                                (XP_STRCASECMP(urlType, "snews:") == 0);
  401.  
  402.                 if(bAccept)
  403.                     pFrame->GetMainContext()->NormalGetUrl(pBookmark->szAnchor);
  404.             }
  405.         }
  406.         //this needs to become what we are dropping onto
  407.         ::GlobalUnlock(hBookmark);
  408.  
  409.         bRtn = TRUE;
  410.     }
  411.     return bRtn;
  412. }
  413.  
  414.  
  415. /****************************************************************************
  416. *
  417. *    Class: CTaskIcon
  418. *
  419. *    DESCRIPTION:
  420. *        This class represents the abstraction of a task icon object. It
  421. *        encapsulates the data that is used to construct CTaskIconWnd objects.
  422. *
  423. ****************************************************************************/
  424.  
  425. /****************************************************************************
  426. *
  427. *    CTaskIcon::CTaskIcon
  428. *
  429. *    PARAMETERS:
  430. *        idTask        - task identifier
  431. *        pwndNotify    - pointer to window desiring notification
  432. *        dwMessage    - user-defined callback message
  433. *        idBmpLarge    - bitmap resource ID for large icon
  434. *        idBmpSmall    - bitmap resource ID for small icon
  435. *        idTip        - string resource ID of tool tip text
  436. *
  437. *     RETURNS:
  438. *        N/A
  439. *
  440. *    DESCRIPTION:
  441. *       Constructor.
  442. *
  443. ****************************************************************************/
  444.  
  445. CTaskIcon::CTaskIcon(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  446.     UINT idBmpLarge, int indexBitmapLarge, UINT idBmpSmall, int indexBitmapSmall, UINT idHorizText,
  447.     UINT idVertText, UINT idDockedTip, UINT idFloatingTip)
  448. {
  449.     m_idTask = idTask;
  450.     m_pwndNotify = pwndNotify;
  451.     m_dwMessage = dwMessage;
  452.     m_idBmpLarge = idBmpLarge;
  453.     m_idBmpSmall = idBmpSmall;
  454.     m_indexBmpLarge = indexBitmapLarge;
  455.     m_indexBmpSmall = indexBitmapSmall;
  456.     m_idHorizText = idHorizText;
  457.     m_idVertText = idVertText;
  458.     m_idDockedTip = idDockedTip;
  459.     m_idFloatingTip = idFloatingTip;
  460.  
  461. } // END OF FUNCTION CTaskIcon::CTaskIcon()
  462.  
  463. /****************************************************************************
  464. *
  465. *  CTaskIcon::~CTaskIcon
  466. *
  467. *  PARAMETERS:
  468. *     N/A
  469. *
  470. *  RETURNS:
  471. *     N/A
  472. *
  473. *  DESCRIPTION:
  474. *     Destructor.
  475. *
  476. ****************************************************************************/
  477.  
  478. CTaskIcon::~CTaskIcon()
  479. {
  480. } // END OF FUNCTION CTaskIcon::~CTaskIcon()
  481.  
  482.  
  483. /****************************************************************************
  484. *
  485. *    Class: CTaskIconArray
  486. *
  487. *    DESCRIPTION:
  488. *        This is a container class for holding CTaskIcon objects.
  489. *
  490. ****************************************************************************/
  491.  
  492. /****************************************************************************
  493. *
  494. *    CTaskIconArray::FindByID
  495. *
  496. *    PARAMETERS:
  497. *        idTask    - id of icon object to be found
  498. *
  499. *    RETURNS:
  500. *        Index of the object if found, -1 if not.
  501. *
  502. *    DESCRIPTION:
  503. *        This function is called to search the list for an icon object with
  504. *        the given task identifier.
  505. *
  506. ****************************************************************************/
  507.  
  508. int CTaskIconArray::FindByID(UINT idTask)
  509. {
  510.     int nRtn = -1;
  511.     
  512.     BOOL bFound = FALSE;
  513.     for (int i = 0; (i < GetSize()) && !bFound; i++)
  514.     {
  515.         if (Get(i)->GetTaskID() == idTask)
  516.         {
  517.             bFound = TRUE;
  518.             nRtn = i;
  519.         }
  520.     }
  521.     
  522.     return(nRtn);
  523.  
  524. } // END OF    FUNCTION CTaskIconArray::FindByID()
  525.  
  526. /****************************************************************************
  527. *
  528. *    CTaskIconArray::DeleteAll
  529. *
  530. *    PARAMETERS:
  531. *        None
  532. *
  533. *    RETURNS:
  534. *        void
  535. *
  536. *    DESCRIPTION:
  537. *        This functions is called to delete all of the CTaskIcon objects
  538. *        in the container.
  539. *
  540. ****************************************************************************/
  541.  
  542. void CTaskIconArray::DeleteAll()
  543. {
  544.     int nSize = GetSize();
  545.  
  546.     for (int i = 0; i < nSize; i++)
  547.     {
  548.         CTaskIcon * pIcon = Get(i);
  549.         delete pIcon;
  550.     }
  551.     RemoveAll();
  552.  
  553. } // END OF    FUNCTION CTaskIconArray::DeleteAll()
  554.  
  555.  
  556. /****************************************************************************
  557. *
  558. *    Class: CTaskIconWnd
  559. *
  560. *    DESCRIPTION:
  561. *        This object represents a notification icon. It can be embeded within
  562. *        a task bar and provides mouse notifications to a given window. It is
  563. *        a window that paints its own bitmap, displays tool tip text, processes
  564. *        mouse events, etc.
  565. *
  566. ****************************************************************************/
  567.  
  568. BEGIN_MESSAGE_MAP(CTaskIconWnd, CTaskIconWndBase)
  569.     //{{AFX_MSG_MAP(CTaskIconWnd)
  570.     ON_WM_LBUTTONDOWN()
  571.     ON_WM_LBUTTONUP()
  572.     ON_WM_RBUTTONDOWN()
  573.     ON_WM_RBUTTONUP()
  574.     ON_WM_MOUSEMOVE()
  575.     //}}AFX_MSG_MAP
  576. END_MESSAGE_MAP()
  577.  
  578. /****************************************************************************
  579. *
  580. *    CTaskIconWnd::CTaskIconWnd
  581. *
  582. *    PARAMETERS:
  583. *        None
  584. *
  585. *     RETURNS:
  586. *        N/A
  587. *
  588. *    DESCRIPTION:
  589. *       Constructor. Instantiate the object, then call the Create() function.
  590. *
  591. ****************************************************************************/
  592.  
  593. CTaskIconWnd::CTaskIconWnd()
  594. {
  595.  
  596. } // END OF FUNCTION CTaskIconWnd::CTaskIconWnd()
  597.  
  598. /****************************************************************************
  599. *
  600. *  CTaskIconWnd::~CTaskIconWnd
  601. *
  602. *  PARAMETERS:
  603. *     N/A
  604. *
  605. *  RETURNS:
  606. *     N/A
  607. *
  608. *  DESCRIPTION:
  609. *     Destructor.
  610. *
  611. ****************************************************************************/
  612.  
  613. CTaskIconWnd::~CTaskIconWnd()
  614. {
  615.     
  616. } // END OF FUNCTION CTaskIconWnd::~CTaskIconWnd()
  617.  
  618. /****************************************************************************
  619. *
  620. *    CTaskIconWnd::Create
  621. *
  622. *    PARAMETERS:
  623. *        idTask        - task identifier
  624. *        pwndNotify    - pointer to window desiring notification
  625. *        dwMessage    - user-defined callback message
  626. *        idBmp        - bitmap resource ID
  627. *        idTip        - string resource ID of tool tip text
  628. *        pParent        - pointer to parent
  629. *        rc            - window rectangle, if desired
  630. *
  631. *    RETURNS:
  632. *        TRUE if creation is successful.
  633. *
  634. *    DESCRIPTION:
  635. *        This function should be called after construction to actually create
  636. *        the task icon window.
  637. *
  638. ****************************************************************************/
  639.  
  640. BOOL CTaskIconWnd::Create(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  641.     UINT idBmp, int nBitmapIndex, UINT idHorizText, UINT idVertText,
  642.     UINT idText, UINT idTip, int nToolbarStyle, CSize noviceSize, CSize advancedSize,
  643.     CSize bitmapSize, CWnd * pParent, const CRect & rc /*= (0,0,0,0)*/)
  644. {
  645.     m_idTask = idTask;
  646.     m_pwndNotify = pwndNotify;
  647.     m_dwMessage = dwMessage;
  648.     m_idHorizText = idHorizText;
  649.     m_idVertText = idVertText;
  650.  
  651.     CString text , tip;
  652.  
  653.     text.LoadString(idText);
  654.     tip.LoadString(idTip);
  655.  
  656.     BOOL bRtn = CTaskIconWndBase::Create(pParent, nToolbarStyle, noviceSize, advancedSize,
  657.                                          (const char*)text, (const char*)tip, "",
  658.                                          idBmp, nBitmapIndex, bitmapSize, FALSE, idTask, 
  659.                                          SHOW_ALL_CHARACTERS, 0);
  660.  
  661.     if(bRtn)
  662.     {
  663.         AddDropTargetIfStandardButton();
  664.     }
  665.  
  666.      return(bRtn);
  667.    
  668. } // END OF FUNCTION CTaskIconWnd::Create()
  669.  
  670. /****************************************************************************
  671. *
  672. *    CTaskIconWnd::PostNcDestroy
  673. *
  674. *    PARAMETERS:
  675. *        None
  676. *
  677. *    RETURNS:
  678. *        void
  679. *
  680. *    DESCRIPTION:
  681. *        We override this function to add auto-cleanup to the window.
  682. *
  683. ****************************************************************************/
  684.  
  685. void CTaskIconWnd::PostNcDestroy()
  686. {
  687.     delete this;
  688.  
  689. } // END OF    FUNCTION CTaskIconWnd::PostNcDestroy()
  690.  
  691. void CTaskIconWnd::AddDropTargetIfStandardButton(void)
  692. {
  693.     switch(m_idTask)
  694.     {
  695.         case ID_TOOLS_WEB:
  696.             SetDropTarget(new(CBrowserButtonDropTarget));
  697.             break;
  698.         case ID_TOOLS_EDITOR:
  699.             SetDropTarget(new(CComposerButtonDropTarget));
  700.             break;
  701.         case ID_TOOLS_INBOX:
  702.             SetDropTarget(new(CMessengerButtonDropTarget));
  703.             break;
  704.         case ID_TOOLS_NEWS:
  705.             SetDropTarget(new(CCollabraButtonDropTarget));
  706.             break;
  707.     }
  708.  
  709. }
  710.  
  711. /****************************************************************************
  712. *
  713. *    CTaskIconWnd::OnLButtonDown
  714. *
  715. *    PARAMETERS:
  716. *        nFlags    - not used
  717. *        point    - not used
  718. *
  719. *    RETURNS:
  720. *        void
  721. *
  722. *    DESCRIPTION:
  723. *        Handler for the WM_LBUTTONDOWN message. We send the notification to
  724. *        the window that's set to get them from this icon.
  725. *
  726. ****************************************************************************/
  727.  
  728. void CTaskIconWnd::OnLButtonDown(UINT nFlags, CPoint point) 
  729. {
  730.     CTaskIconWndBase::OnLButtonDown(nFlags, point);
  731.  
  732.     ASSERT(m_pwndNotify != NULL);
  733.     if (m_pwndNotify != NULL)
  734.     {
  735.         m_pwndNotify->SendMessage(CASTUINT(m_dwMessage), m_idTask, WM_LBUTTONDOWN);
  736.     }
  737.     
  738. } // END OF    FUNCTION CTaskIconWnd::OnLButtonDown()
  739.  
  740. /****************************************************************************
  741. *
  742. *    CTaskIconWnd::OnLButtonUp
  743. *
  744. *    PARAMETERS:
  745. *        nFlags    - not used
  746. *        point    - not used
  747. *
  748. *    RETURNS:
  749. *        void
  750. *
  751. *    DESCRIPTION:
  752. *        Handler for the WM_LBUTTONUP message. We send the notification to the
  753. *        window that's set to get them from this icon.
  754. *
  755. ****************************************************************************/
  756.  
  757. void CTaskIconWnd::OnLButtonUp(UINT nFlags, CPoint point) 
  758. {
  759.     CTaskIconWndBase::OnLButtonUp(nFlags, point);
  760.  
  761.     ASSERT(m_pwndNotify != NULL);
  762.     if (m_pwndNotify != NULL)
  763.     {
  764.         m_pwndNotify->SendMessage(CASTUINT(m_dwMessage), m_idTask, WM_LBUTTONUP);
  765.     }
  766.     
  767. } // END OF    FUNCTION CTaskIconWnd::OnLButtonUp()
  768.  
  769. /****************************************************************************
  770. *
  771. *    CTaskIconWnd::OnRButtonDown
  772. *
  773. *    PARAMETERS:
  774. *        nFlags    - not used
  775. *        point    - not used
  776. *
  777. *    RETURNS:
  778. *        void
  779. *
  780. *    DESCRIPTION:
  781. *        Handler for the WM_RBUTTONDOWN message. We just translate it to a
  782. *        notification for the window that's set to get them from this icon.
  783. *
  784. ****************************************************************************/
  785.  
  786. void CTaskIconWnd::OnRButtonDown(UINT nFlags, CPoint point) 
  787. {
  788.     CTaskIconWndBase::OnRButtonDown(nFlags, point);
  789.  
  790.     ASSERT(m_pwndNotify != NULL);
  791.     if (m_pwndNotify != NULL)
  792.     {
  793.         m_pwndNotify->SendMessage(CASTUINT(m_dwMessage), m_idTask, WM_RBUTTONDOWN);
  794.     }
  795.     
  796. } // END OF    FUNCTION CTaskIconWnd::OnRButtonDown()
  797.  
  798. /****************************************************************************
  799. *
  800. *    CTaskIconWnd::OnRButtonUp
  801. *
  802. *    PARAMETERS:
  803. *        nFlags    - not used
  804. *        point    - not used
  805. *
  806. *    RETURNS:
  807. *        void
  808. *
  809. *    DESCRIPTION:
  810. *        Handler for the WM_RBUTTONUP message. We just translate it to a
  811. *        notification for the window that's set to get them from this icon.
  812. *
  813. ****************************************************************************/
  814.  
  815. void CTaskIconWnd::OnRButtonUp(UINT nFlags, CPoint point) 
  816. {
  817.     CTaskIconWndBase::OnRButtonUp(nFlags, point);
  818.  
  819.     ASSERT(m_pwndNotify != NULL);
  820.     if (m_pwndNotify != NULL)
  821.     {
  822.         m_pwndNotify->SendMessage(CASTUINT(m_dwMessage), m_idTask, WM_RBUTTONUP);
  823.     }
  824.     
  825. } // END OF    FUNCTION CTaskIconWnd::OnRButtonUp()
  826.  
  827. /****************************************************************************
  828. *
  829. *    CTaskIconWnd::OnMouseMove
  830. *
  831. *    PARAMETERS:
  832. *        nFlags    - not used
  833. *        point    - not used
  834. *
  835. *    RETURNS:
  836. *        void
  837. *
  838. *    DESCRIPTION:
  839. *        Handler for the WM_MOUSEMOVE message. We send the notification to the
  840. *        window that's set to get them from this icon.
  841. *
  842. ****************************************************************************/
  843.  
  844. void CTaskIconWnd::OnMouseMove(UINT nFlags, CPoint point) 
  845. {
  846.     CTaskIconWndBase::OnMouseMove(nFlags, point);
  847.     
  848.     ASSERT(m_pwndNotify != NULL);
  849.     if (m_pwndNotify != NULL)
  850.     {
  851.         m_pwndNotify->SendMessage(CASTUINT(m_dwMessage), m_idTask, WM_MOUSEMOVE);
  852.     }
  853.     
  854. } // END OF    FUNCTION CTaskIconWnd::OnMouseMove()
  855.  
  856.  
  857. /****************************************************************************
  858. *
  859. *    Class: CTaskIconWndArray
  860. *
  861. *    DESCRIPTION:
  862. *        This is a container class for holding CTaskIconWnd objects.
  863. *
  864. ****************************************************************************/
  865.  
  866. /****************************************************************************
  867. *
  868. *    CTaskIconWndArray::FindByID
  869. *
  870. *    PARAMETERS:
  871. *        idTask    - id of icon object to be found
  872. *
  873. *    RETURNS:
  874. *        Index of the object if found, -1 if not.
  875. *
  876. *    DESCRIPTION:
  877. *        This function is called to search the list for an icon window with
  878. *        the given task identifier.
  879. *
  880. ****************************************************************************/
  881.  
  882. int CTaskIconWndArray::FindByID(UINT idTask)
  883. {
  884.     int nRtn = -1;
  885.     
  886.     BOOL bFound = FALSE;
  887.     for (int i = 0; (i < GetSize()) && !bFound; i++)
  888.     {
  889.         if (Get(i)->GetTaskID() == idTask)
  890.         {
  891.             bFound = TRUE;
  892.             nRtn = i;
  893.         }
  894.     }
  895.     
  896.     return(nRtn);
  897.  
  898. } // END OF    FUNCTION CTaskIconWndArray::FindByID()
  899.  
  900. /****************************************************************************
  901. *
  902. *    CTaskIconWndArray::DeleteAll
  903. *
  904. *    PARAMETERS:
  905. *        None
  906. *
  907. *    RETURNS:
  908. *        void
  909. *
  910. *    DESCRIPTION:
  911. *        This functions is called to delete all of the CTaskIconWnd objects
  912. *        in the container.
  913. *
  914. ****************************************************************************/
  915.  
  916. void CTaskIconWndArray::DeleteAll()
  917. {
  918.     for (int i = 0; i < GetSize(); i++)
  919.     {
  920.         CTaskIconWnd * pIcon = Get(i++);
  921.         if (pIcon != NULL)
  922.         {
  923.             pIcon->DestroyWindow();
  924.             // no need to call delete - pIcon has auto cleanup
  925.         }
  926.     }
  927.     RemoveAll();
  928.  
  929. } // END OF    FUNCTION CTaskIconWndArray::DeleteAll()
  930.  
  931.  
  932. /****************************************************************************
  933. *
  934. *    Class: CTaskBar
  935. *
  936. *    DESCRIPTION:
  937. *        This is the base class for task bar objects. All polymorphic functions
  938. *        common to the floating, docked, or other derived task bars are
  939. *        implemented here.
  940. *
  941. *        This is an abstract base class - you must instantiate one of the
  942. *        derived types. Also, objects of this class are auto-deleting, you
  943. *        must allocate them on the heap.
  944. *
  945. ****************************************************************************/
  946.  
  947. BEGIN_MESSAGE_MAP(CTaskBar, CTaskBarBase)
  948.     //{{AFX_MSG_MAP(CTaskBar)
  949.     ON_WM_PAINT()
  950.     ON_WM_SIZE()
  951.     ON_WM_PALETTECHANGED()
  952.     ON_WM_SYSCOLORCHANGE()
  953.     //}}AFX_MSG_MAP
  954. END_MESSAGE_MAP()
  955.  
  956. /****************************************************************************
  957. *
  958. *    CTaskBar::CTaskBar
  959. *
  960. *    PARAMETERS:
  961. *        None
  962. *
  963. *    RETURNS:
  964. *        N/A
  965. *
  966. *    DESCRIPTION:
  967. *        Constructor
  968. *
  969. ****************************************************************************/
  970.  
  971. CTaskBar::CTaskBar(int nToolbarStyle)
  972. {
  973.     // Derived classes must override these
  974.     m_noviceButtonSize.cx = 0;
  975.     m_noviceButtonSize.cy = 0;
  976.     m_advancedButtonSize.cx = 0;
  977.     m_advancedButtonSize.cy = 0;
  978.  
  979.     m_IconSize.cx = 0;
  980.     m_IconSize.cy = 0;
  981.  
  982.     m_nDragBarWidth = 0;
  983.     m_nIconSpace = 0;
  984.     m_nToolbarStyle = nToolbarStyle;
  985.  
  986.     m_nMaxButtonWidth = m_nMaxButtonHeight = 0;
  987.  
  988.     m_bHorizontal = TRUE;
  989.  
  990. } // END OF    FUNCTION CTaskBar::CTaskBar()
  991.  
  992. /****************************************************************************
  993. *
  994. *    CTaskBar::~CTaskBar
  995. *
  996. *    PARAMETERS:
  997. *        N/A
  998. *
  999. *    RETURNS:
  1000. *        N/A
  1001. *
  1002. *    DESCRIPTION:
  1003. *        Destructor.
  1004. *
  1005. ****************************************************************************/
  1006.  
  1007. CTaskBar::~CTaskBar()
  1008. {
  1009.  
  1010. } // END OF    FUNCTION CTaskBar::~CTaskBar()
  1011.  
  1012.  
  1013. /****************************************************************************
  1014. *
  1015. *    CTaskBar::PostNcDestroy
  1016. *
  1017. *    PARAMETERS:
  1018. *        None
  1019. *
  1020. *    RETURNS:
  1021. *        void
  1022. *
  1023. *    DESCRIPTION:
  1024. *        We override this function to add auto-cleanup to the window.
  1025. *
  1026. ****************************************************************************/
  1027.  
  1028. void CTaskBar::PostNcDestroy()
  1029. {
  1030.     delete this;
  1031.  
  1032. } // END OF    FUNCTION CTaskBar::PostNcDestroy()
  1033.  
  1034. /****************************************************************************
  1035. *
  1036. *    CTaskBar::OnSize
  1037. *
  1038. *    PARAMETERS:
  1039. *        nType, cs, cy    - not used
  1040. *
  1041. *    RETURNS:
  1042. *        void
  1043. *
  1044. *    DESCRIPTION:
  1045. *        We process the WM_SIZE message so we can reposition our icons.
  1046. *
  1047. ****************************************************************************/
  1048.  
  1049. void CTaskBar::OnSize(UINT nType, int cx, int cy) 
  1050. {
  1051.     CTaskBarBase::OnSize(nType, cx, cy);
  1052.     LayoutIcons();
  1053.  
  1054. } // END OF    FUNCTION CTaskBar::OnSize()
  1055.  
  1056. /****************************************************************************
  1057. *
  1058. *    CTaskBar::OnPaint
  1059. *
  1060. *    PARAMETERS:
  1061. *        None
  1062. *
  1063. *    RETURNS:
  1064. *        void
  1065. *
  1066. *    DESCRIPTION:
  1067. *        Overridden to do special painting for the task bar. This includes
  1068. *        faking a title bar and a minimize control.
  1069. *
  1070. ****************************************************************************/
  1071.  
  1072. void CTaskBar::OnPaint() 
  1073. {
  1074.     // Do not call CTaskBarBase::OnPaint() for painting messages
  1075.     CPaintDC dc(this); // device context for painting
  1076.  
  1077.     HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame());
  1078.     HPALETTE hOldPalette = ::SelectPalette(dc.m_hDC, hPalette, FALSE);
  1079.     DoPaint(dc);
  1080.     // Should get unselect when destroy.
  1081.     ::SelectPalette(dc.m_hDC, hOldPalette, TRUE);
  1082.     
  1083. } // END OF    FUNCTION CTaskBar::OnPaint()
  1084.  
  1085. void CTaskBar::OnPaletteChanged( CWnd* pFocusWnd )
  1086. {
  1087.     if (pFocusWnd != this) {
  1088.         HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame());
  1089.         if (WFE_IsGlobalPalette(hPalette)) {
  1090.             HDC hDC = ::GetDC(m_hWnd);
  1091.             HPALETTE hOldPalette = ::SelectPalette(hDC, hPalette, FALSE);
  1092.             ::SelectPalette(hDC, hOldPalette, TRUE);
  1093.             ::ReleaseDC(m_hWnd, hDC);
  1094.         }
  1095.         Invalidate(FALSE);
  1096.     }
  1097. }
  1098.  
  1099.  
  1100. void CTaskBar::OnSysColorChange(void)
  1101. {
  1102.  
  1103.     theApp.GetTaskBarMgr().ReloadIconBitmaps(this);
  1104.  
  1105. }
  1106.  
  1107. /****************************************************************************
  1108. *
  1109. *    CTaskBar::AddTaskIcon
  1110. *
  1111. *    PARAMETERS:
  1112. *        idTask        - task identifier
  1113. *        pwndNotify    - pointer to window desiring notification
  1114. *        dwMessage    - user-defined callback message
  1115. *        idBmp        - bitmap resource ID
  1116. *        idTip        - string resource ID of tool tip text
  1117. *
  1118. *    RETURNS:
  1119. *        TRUE if successful, FALSE if not.
  1120. *
  1121. *    DESCRIPTION:
  1122. *        This function is called to add an icon to the task bar.    Notifications
  1123. *        (mouse events) are then sent to the window identified by pwndNotify.
  1124. *
  1125. ****************************************************************************/
  1126.  
  1127. BOOL CTaskBar::AddTaskIcon(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  1128.     HBITMAP hBitmap, int nBitmapIndex, UINT idHorizText, UINT idVertText,
  1129.     UINT idText, UINT idTip, int nToolbarStyle)
  1130. {
  1131.     BOOL bRtn = FALSE;
  1132.     
  1133.     // Create new task icon object and add it to the list
  1134.     CTaskIconWnd * pIcon = new CTaskIconWnd;
  1135.     ASSERT(pIcon != NULL);
  1136.     if (pIcon != NULL)
  1137.     {
  1138.         bRtn = pIcon->Create(idTask, pwndNotify, dwMessage, 0, nBitmapIndex, idHorizText, idVertText,
  1139.                              idText, idTip, nToolbarStyle, m_noviceButtonSize, m_advancedButtonSize,
  1140.                              m_IconSize, this);
  1141.  
  1142.         pIcon->SetBitmap(hBitmap, TRUE);
  1143.  
  1144.         CSize size = pIcon->GetRequiredButtonSize();
  1145.         
  1146.         if(m_nToolbarStyle != TB_PICTURESANDTEXT)
  1147.         {
  1148.             //for the moment we need to make the docked bar smaller than it should be
  1149.             //in order to make things fit
  1150.             size.cy -= 2;
  1151.         }
  1152.  
  1153.         if(size.cx > m_nMaxButtonWidth)
  1154.             m_nMaxButtonWidth = size.cx;
  1155.  
  1156.         if(size.cy > m_nMaxButtonHeight)
  1157.             m_nMaxButtonHeight = size.cy;
  1158.  
  1159.         m_TaskIconWndList.Add(pIcon);
  1160.         
  1161.         // Note: our icons will be sized/positioned in our OnSize()
  1162.     }
  1163.     
  1164.     return(bRtn);
  1165.  
  1166. } // END OF    FUNCTION CTaskBar::AddTaskIcon()
  1167.  
  1168. /****************************************************************************
  1169. *
  1170. *    CTaskBar::ReplaceTaskIcon
  1171. *
  1172. *    PARAMETERS:
  1173. *        idTask    - task identifier
  1174. *        idBmp    - new bitmap resource ID
  1175. *
  1176. *    RETURNS:
  1177. *        TRUE if the icon was successfully replaced, FALSE if not (such as
  1178. *        when no existing icon with the given ID is found).
  1179. *
  1180. *    DESCRIPTION:
  1181. *        This function is called to replace an existing icon in the task bar
  1182. *        whenever it is desirable to show a different image, but retain the
  1183. *        notification handler and other information for the icon.
  1184. *
  1185. ****************************************************************************/
  1186.  
  1187. BOOL CTaskBar::ReplaceTaskIcon(UINT idTask, UINT idBmp, int nBitmapIndex)
  1188. {
  1189.     BOOL bRtn = FALSE;
  1190.     
  1191.     int i = m_TaskIconWndList.FindByID(idTask);
  1192.     if (i > -1)
  1193.     {
  1194.         bRtn = TRUE;
  1195.         
  1196.         CTaskIconWnd * pIcon = m_TaskIconWndList.Get(i);
  1197.         pIcon->SetBmpID(idBmp);
  1198.         pIcon->ReplaceBitmap(idBmp, nBitmapIndex);
  1199.     }
  1200.     
  1201.     return(bRtn);
  1202.  
  1203. } // END OF    FUNCTION CTaskBar::ReplaceTaskIcon()
  1204.  
  1205. /****************************************************************************
  1206. *
  1207. *    CTaskBar::RemoveTaskIcon
  1208. *
  1209. *    PARAMETERS:
  1210. *        idTask    - task identifier
  1211. *
  1212. *    RETURNS:
  1213. *        TRUE if the icon was successfully removed from the task bar, FALSE
  1214. *        if not (such as when no existing icon with the given ID is found).
  1215. *
  1216. *    DESCRIPTION:
  1217. *        This function is called to remove an icon from the task bar when it
  1218. *        is no longer desirable to have it displayed. This is the only case
  1219. *        where this function is useful, since cleanup is performed
  1220. *        automatically when the task bar is destroyed.
  1221. *
  1222. ****************************************************************************/
  1223.  
  1224. BOOL CTaskBar::RemoveTaskIcon(UINT idTask)
  1225. {
  1226.     BOOL bRtn = FALSE;
  1227.     
  1228.     int i = m_TaskIconWndList.FindByID(idTask);
  1229.     if (i > -1)
  1230.     {
  1231.         bRtn = TRUE;
  1232.         
  1233.         CTaskIconWnd * pIcon = m_TaskIconWndList.Get(i);
  1234.         pIcon->DestroyWindow();    // no need to delete - it's auto cleanup
  1235.         m_TaskIconWndList.RemoveAt(i);
  1236.         
  1237.         // Note: our icons will be re-sized/positioned in our OnSize()
  1238.     }
  1239.     
  1240.     return(bRtn);
  1241.  
  1242. } // END OF    FUNCTION CTaskBar::RemoveTaskIcon()
  1243.  
  1244. /****************************************************************************
  1245. *
  1246. *    CTaskBar::CalcDesiredDim
  1247. *
  1248. *    PARAMETERS:
  1249. *        None
  1250. *
  1251. *    RETURNS:
  1252. *        The width and height that the task bar requires to draw itself
  1253. *
  1254. *    DESCRIPTION:
  1255. *        This function is called to determine the dimensions that the Task
  1256. *        Bar window will require.
  1257. *
  1258. ****************************************************************************/
  1259.  
  1260. CSize CTaskBar::CalcDesiredDim()
  1261. {
  1262.     CSize sizeRtn;
  1263.     CSize sizeButton;
  1264.  
  1265.     // Make it wide enough for all icons, plus the margin
  1266.     int nNumIcons = m_TaskIconWndList.GetSize();
  1267.  
  1268.     CSize buttonSize(m_nMaxButtonWidth, m_nMaxButtonHeight);
  1269.  
  1270.     if(m_bHorizontal)
  1271.     {
  1272.         sizeRtn.cy = 0;
  1273.         sizeRtn.cx = 0;
  1274.         for(int i = 0; i < nNumIcons; i++)
  1275.         {
  1276.             CTaskIconWnd *pIcon = (CTaskIconWnd*)m_TaskIconWndList[i];
  1277.  
  1278.             sizeButton = pIcon->GetRequiredButtonSize();
  1279.             sizeRtn.cx += sizeButton.cx; 
  1280.  
  1281.         }
  1282.  
  1283.         sizeRtn.cx += ((nNumIcons + 1) * m_nIconSpace);
  1284.  
  1285.         // Must allow for drag bar
  1286.         sizeRtn.cx += m_nDragBarWidth;
  1287.         
  1288.         // Make height proportional to the icon height
  1289.         sizeRtn.cy = buttonSize.cy + 6;
  1290.     }
  1291.     else // if vertical
  1292.     {
  1293.         sizeRtn.cy = sizeRtn.cx = 0;
  1294.  
  1295.         for(int i = 0; i < nNumIcons; i++)
  1296.         {
  1297.             CTaskIconWnd *pIcon = (CTaskIconWnd*)m_TaskIconWndList[i];
  1298.  
  1299.             sizeButton = pIcon->GetRequiredButtonSize();
  1300.             sizeRtn.cy += sizeButton.cy; 
  1301.  
  1302.         }
  1303.  
  1304.         sizeRtn.cy += ((nNumIcons + 1) * m_nIconSpace);
  1305.  
  1306.         // Must all for drag bar
  1307.         sizeRtn.cy += m_nDragBarWidth;
  1308.  
  1309.         //currently magic numbers to make it look the same size as when in horizontal position
  1310.         sizeRtn.cx = buttonSize.cx + 6;
  1311.     }
  1312.     
  1313.     #ifdef WIN32
  1314.         int nBorderWidth = ::GetSystemMetrics(SM_CXSIZEFRAME);
  1315.     #else
  1316.         int nBorderWidth = ::GetSystemMetrics(SM_CXFRAME);
  1317.     #endif
  1318.  
  1319.     sizeRtn.cx += nBorderWidth;
  1320.     //add the title bar
  1321.     sizeRtn.cy += GetSystemMetrics(SM_CYCAPTION);
  1322.     return(sizeRtn);
  1323.     
  1324. } // END OF    FUNCTION CTaskBar::CalcDesiredDim()
  1325.  
  1326. /****************************************************************************
  1327. *
  1328. *    CTaskBar::GetButtonDimensions
  1329. *
  1330. *    PARAMETERS:
  1331. *        None
  1332. *
  1333. *    RETURNS:
  1334. *        The size of a button depending upon the mode we are in
  1335. *
  1336. *    DESCRIPTION:
  1337. *        This function is called to determine the dimensions of a button on
  1338. *        the taskbar
  1339. *
  1340. ****************************************************************************/
  1341. CSize CTaskBar::GetButtonDimensions(void)
  1342. {
  1343.         return( m_nToolbarStyle == TB_PICTURESANDTEXT ? m_noviceButtonSize : m_advancedButtonSize);
  1344. } // END OF FUNCTION CTaskBar::GetButtonDimensions()
  1345.  
  1346. /****************************************************************************
  1347. *
  1348. *    CTaskBar::SetTaskBarStyle
  1349. *
  1350. *    PARAMETERS:
  1351. *        nToolbarStyle The style we are changing to
  1352. *
  1353. *    RETURNS:
  1354. *        nothing
  1355. *
  1356. *    DESCRIPTION:
  1357. *        This function is called to change the taskbar style to nToolbarStyle
  1358. *
  1359. ****************************************************************************/
  1360.  
  1361. void CTaskBar::SetTaskBarStyle(int nToolbarStyle)
  1362. {
  1363.     m_nToolbarStyle = nToolbarStyle;
  1364.     m_bShowText = m_nToolbarStyle != TB_PICTURES;
  1365.     ChangeButtonStyle();
  1366. }
  1367.  
  1368.   /****************************************************************************
  1369. *
  1370. *    CTaskBar::LayoutIcons
  1371. *
  1372. *    PARAMETERS:
  1373. *        None
  1374. *
  1375. *    RETURNS:
  1376. *        void
  1377. *
  1378. *    DESCRIPTION:
  1379. *        This protected helper function is called to arrange the task icons
  1380. *        appropriately within the task bar.
  1381. *
  1382. ****************************************************************************/
  1383.  
  1384. void CTaskBar::LayoutIcons()
  1385. {
  1386.     int nX, nY;
  1387.     int nHSpace, nVSpace;
  1388.  
  1389.     // The idea is to space the icons evenly, allowing for the grab bar.
  1390.     CRect rc;
  1391.     GetClientRect(&rc);
  1392.     
  1393.     int nNumIcons = m_TaskIconWndList.GetSize();
  1394.     // If taskbar is horizontal, buttons have same height but different widths.  If
  1395.     // vertical, buttons have same width, but different heights.
  1396.     CSize sameSize = CSize(m_nMaxButtonWidth, m_nMaxButtonHeight);
  1397.     CSize individualButtonSize;
  1398.  
  1399.     if(m_bHorizontal)
  1400.     {
  1401.         rc.left += m_nDragBarWidth;
  1402.  
  1403.         nX = rc.left + m_nIconSpace;
  1404.         nVSpace = ((rc.Height() - (sameSize.cy)) + 1) / 2;
  1405.         nVSpace = (nVSpace > 0) ? nVSpace : 0;
  1406.         nY = rc.top + nVSpace;
  1407.     }
  1408.     else // if vertical
  1409.     {
  1410.         rc.top += m_nDragBarHeight;
  1411.  
  1412.         nY = rc.top + m_nIconSpace;
  1413.         nHSpace = ((rc.Width() - sameSize.cx) + 1) / 2;
  1414.         nHSpace = (nHSpace > 0) ? nHSpace : 0;
  1415.         nX = rc.left + nHSpace;
  1416.     }
  1417.  
  1418.     // Now re-size & re-position the icons
  1419.     for (int i = 0; i < m_TaskIconWndList.GetSize(); i++)
  1420.     {
  1421.         CTaskIconWnd * pIcon = m_TaskIconWndList.Get(i);
  1422.         individualButtonSize = pIcon->GetRequiredButtonSize();
  1423.  
  1424.  
  1425.         if(m_bHorizontal)
  1426.         {
  1427.             pIcon->MoveWindow(nX, nY, individualButtonSize.cx, sameSize.cy);
  1428.             nX += (individualButtonSize.cx + m_nIconSpace);
  1429.         }
  1430.         else
  1431.         {
  1432.             pIcon->MoveWindow(nX, nY, sameSize.cx, individualButtonSize.cy);
  1433.             nY += (individualButtonSize.cy + m_nIconSpace);
  1434.         }
  1435.     }
  1436.  
  1437. } // END OF    FUNCTION CTaskBar::LayoutIcons()
  1438.  
  1439. /****************************************************************************
  1440. *
  1441. *    CTaskBar::DragBarHitTest
  1442. *
  1443. *    PARAMETERS:
  1444. *        pt    - point to test
  1445. *
  1446. *    RETURNS:
  1447. *        TRUE if the given point lies within our drag bar, FALSE if not
  1448. *
  1449. *    DESCRIPTION:
  1450. *        This protected helper function is called to determine whether a
  1451. *        given point lies within our drag bar area.
  1452. *
  1453. ****************************************************************************/
  1454.  
  1455. BOOL CTaskBar::DragBarHitTest(const CPoint & pt)
  1456. {
  1457.     CRect rc;
  1458.     GetClientRect(&rc);
  1459.  
  1460.     if(m_bHorizontal)
  1461.     {
  1462.         rc.right = m_nDragBarWidth;
  1463.     }
  1464.     else
  1465.     {
  1466.         rc.bottom = m_nDragBarHeight;
  1467.     }
  1468.     
  1469.     return(rc.PtInRect(pt));
  1470.  
  1471. } // END OF    FUNCTION CTaskBar::DragBarHitTest()
  1472.  
  1473.  
  1474. void CTaskBar::ChangeButtonStyle(void)
  1475. {
  1476.     int nCount = m_TaskIconWndList.GetSize();
  1477.  
  1478.     m_nMaxButtonWidth = m_nMaxButtonHeight = 0;
  1479.  
  1480.     for(int i = 0; i < nCount; i++)
  1481.     {
  1482.         CTaskIconWnd *pIcon = (CTaskIconWnd*)m_TaskIconWndList[i];
  1483.  
  1484.         pIcon->SetButtonMode(m_nToolbarStyle);
  1485.  
  1486.         CSize size = pIcon->GetRequiredButtonSize();
  1487.         
  1488.         if(m_nToolbarStyle != TB_PICTURESANDTEXT)
  1489.         {
  1490.             //for the moment we need to make the docked bar smaller than it should be
  1491.             //in order to make things fit
  1492.             size.cy -= 2;
  1493.         }
  1494.  
  1495.         if(size.cx > m_nMaxButtonWidth)
  1496.             m_nMaxButtonWidth = size.cx;
  1497.  
  1498.         if(size.cy > m_nMaxButtonHeight)
  1499.             m_nMaxButtonHeight = size.cy;
  1500.  
  1501.     }
  1502.  
  1503. }
  1504.  
  1505. void CTaskBar::ChangeButtonText(void)
  1506. {
  1507.  
  1508.     int nCount = m_TaskIconWndList.GetSize();
  1509.  
  1510.     m_nMaxButtonWidth = m_nMaxButtonHeight = 0;
  1511.  
  1512.     for(int i = 0; i < nCount; i++)
  1513.     {
  1514.         CTaskIconWnd *pIcon = (CTaskIconWnd*)m_TaskIconWndList[i];
  1515.  
  1516.         int idText = m_bHorizontal ? pIcon->GetHorizTextID() : pIcon->GetVertTextID();
  1517.         CString csText;
  1518.         csText.LoadString(idText);
  1519.  
  1520.         pIcon->SetText(csText);
  1521.         
  1522.         // Need to recalculate the maximum sizes
  1523.         CSize size = pIcon->GetRequiredButtonSize();
  1524.         
  1525.         if(size.cx > m_nMaxButtonWidth)
  1526.             m_nMaxButtonWidth = size.cx;
  1527.  
  1528.         if(size.cy > m_nMaxButtonHeight)
  1529.             m_nMaxButtonHeight = size.cy;
  1530.     }
  1531. }
  1532.  
  1533. void CTaskBar::ReplaceButtonBitmap(int nIndex, HBITMAP hBitmap)
  1534. {
  1535.  
  1536.     CTaskIconWnd *pIcon = (CTaskIconWnd*)m_TaskIconWndList[nIndex];
  1537.  
  1538.     pIcon->SetBitmap(hBitmap, TRUE);
  1539.  
  1540.     pIcon->Invalidate();
  1541.  
  1542. }
  1543.  
  1544. /****************************************************************************
  1545. *
  1546. *    Class: CFloatingTaskBar
  1547. *
  1548. *    DESCRIPTION:
  1549. *        This derived version of CTaskBar provides a "floating" task bar. It
  1550. *        is in the form of a custom popup window.
  1551. *
  1552. ****************************************************************************/
  1553.  
  1554. /****************************************************************************
  1555. *
  1556. *    CONSTANTS
  1557. *
  1558. ****************************************************************************/
  1559. static const UINT uID_DOCK = 0xff;    // Docking button ID
  1560. static const int nDOCK_BTN_W = 13;
  1561. static const int nDOCK_BTN_H = 13;
  1562.  
  1563. BEGIN_MESSAGE_MAP(CFloatingTaskBar, CFloatingTaskBarBase)
  1564.     //{{AFX_MSG_MAP(CFloatingTaskBar)
  1565.     ON_WM_CLOSE()
  1566.     ON_WM_MOUSEMOVE()
  1567.     ON_BN_CLICKED(uID_DOCK, OnDock)
  1568.     ON_WM_LBUTTONDBLCLK()
  1569.     ON_WM_RBUTTONUP()
  1570.     ON_WM_MOVE()
  1571.     ON_COMMAND(ID_TBAR_ALWAYSONTOP, OnAlwaysOnTop)
  1572.     ON_COMMAND(ID_TBAR_SHOWTEXT, OnShowText)
  1573.     ON_COMMAND(ID_TBAR_POSITION, OnPosition)
  1574.     ON_MESSAGE(TASKBAR_ADDMENU, OnAddMenu)
  1575.     ON_WM_SYSCOMMAND()
  1576.     ON_WM_INITMENU()
  1577.     ON_WM_CREATE()
  1578.     //}}AFX_MSG_MAP
  1579. END_MESSAGE_MAP()
  1580.  
  1581. /****************************************************************************
  1582. *
  1583. *    CFloatingTaskBar::CFloatingTaskBar
  1584. *
  1585. *    PARAMETERS:
  1586. *        bOnTop        - TRUE if the 'always on top' style should be used
  1587. *        bShowText    - TRUE if button text should be shown
  1588. *        bHorizontal    - TRUE if task bar is oriented horizontally
  1589. *
  1590. *    RETURNS:
  1591. *        N/A
  1592. *
  1593. *    DESCRIPTION:
  1594. *        Constructor.
  1595. *
  1596. ****************************************************************************/
  1597.  
  1598. CFloatingTaskBar::CFloatingTaskBar(int nToolbarStyle, BOOL bOnTop /*=TRUE*/, BOOL bHorizontal /*=TRUE*/)
  1599.     : CTaskBar(nToolbarStyle)
  1600. {
  1601.     m_noviceButtonSize.cx = 65;
  1602.     m_noviceButtonSize.cy = 43;
  1603.     m_advancedButtonSize.cx = 34;
  1604.     m_advancedButtonSize.cy = 24;
  1605.  
  1606.     m_IconSize.cx = 32;
  1607.     m_IconSize.cy = 22;
  1608.  
  1609.     m_nDragBarWidth = m_nDragBarHeight = 0;
  1610.  
  1611.     m_nIconSpace = 4;
  1612.     m_bActive = FALSE;
  1613.     
  1614.     m_bOnTop = bOnTop;
  1615.     m_bHorizontal = bHorizontal;
  1616.     m_bShowText = nToolbarStyle != TB_PICTURES;
  1617.     
  1618. } // END OF    FUNCTION CFloatingTaskBar::CFloatingTaskBar()
  1619.  
  1620. /****************************************************************************
  1621. *
  1622. *    CFloatingTaskBar::~CFloatingTaskBar
  1623. *
  1624. *    PARAMETERS:
  1625. *        N/A
  1626. *
  1627. *    RETURNS:
  1628. *        N/A
  1629. *
  1630. *    DESCRIPTION:
  1631. *        Destructor.
  1632. *
  1633. ****************************************************************************/
  1634.  
  1635. CFloatingTaskBar::~CFloatingTaskBar()
  1636. {
  1637.     int test = 0;
  1638. } // END OF    FUNCTION CFloatingTaskBar::~CFloatingTaskBar()
  1639.  
  1640. /****************************************************************************
  1641. *
  1642. *    CFloatingTaskBar::Create
  1643. *
  1644. *    PARAMETERS:
  1645. *        pParent    - pointer to parent window
  1646. *
  1647. *    RETURNS:
  1648. *        TRUE if creation is successful, FALSE if not.
  1649. *
  1650. *    DESCRIPTION:
  1651. *        This function must be called after construction to create the task
  1652. *        bar.
  1653. *
  1654. ****************************************************************************/
  1655.  
  1656. BOOL CFloatingTaskBar::Create(CWnd * pParent)
  1657. {
  1658.     BOOL bRtn = FALSE;
  1659.     
  1660.     CBrush brush;
  1661.  
  1662.     CString strClass = theApp.NSToolBarClass;
  1663.     
  1664.     CString strName("");
  1665.     DWORD dwExStyle = m_bOnTop ? WS_EX_TOPMOST : 0;
  1666.  
  1667. #ifdef WIN32
  1668.     bRtn = CFloatingTaskBarBase::CreateEx(dwExStyle | WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE, (const char *)strClass,
  1669.     (const char *)strName, WS_DLGFRAME | WS_BORDER | WS_POPUP | WS_SYSMENU ,
  1670.         0, 0, 0, 0, pParent->GetSafeHwnd(), NULL);
  1671. #else 
  1672.     bRtn = CFloatingTaskBarBase::CreateEx(dwExStyle, (const char *)strClass,
  1673.     (const char *)strName, WS_CAPTION | WS_POPUP | WS_SYSMENU ,
  1674.         0, 0, 0, 0, pParent->GetSafeHwnd(), NULL);
  1675. #endif
  1676.  
  1677.  
  1678.     return(bRtn);
  1679.     
  1680. } // END OF    FUNCTION CFloatingTaskBar::Create()
  1681.  
  1682. int CFloatingTaskBar::OnCreate( LPCREATESTRUCT lpCreateStruct )
  1683. {
  1684.     CFloatingTaskBarBase::OnCreate(lpCreateStruct);
  1685.  
  1686.     PostMessage(TASKBAR_ADDMENU, 0, 0L);
  1687.     return 0;
  1688. }
  1689.  
  1690.  
  1691. LRESULT CFloatingTaskBar::OnAddMenu(WPARAM wParam, LPARAM lParam)
  1692. {
  1693.     CMenu *pSysMenu = GetSystemMenu(FALSE);
  1694.  
  1695.     pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);
  1696.     pSysMenu->RemoveMenu(SC_MINIMIZE, MF_BYCOMMAND);
  1697.     pSysMenu->RemoveMenu(SC_RESTORE, MF_BYCOMMAND);
  1698.     pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
  1699.  
  1700.     pSysMenu->InsertMenu(0, CASTUINT(MF_BYPOSITION | MF_STRING), ID_TBAR_ALWAYSONTOP, szLoadString(IDS_TASKBAR_ONTOP));
  1701.     pSysMenu->InsertMenu(1, CASTUINT(MF_BYPOSITION | MF_STRING), CASTUINT(ID_TBAR_POSITION), szLoadString(CASTUINT(m_bHorizontal ? IDS_VERTICAL : IDS_HORIZONTAL)));
  1702.     pSysMenu->InsertMenu(2, CASTUINT(MF_BYPOSITION | MF_STRING), CASTUINT(ID_TBAR_SHOWTEXT), szLoadString(CASTUINT(m_bShowText ? IDS_TASKBAR_HIDETEXT : IDS_TASKBAR_SHOWTEXT))); 
  1703.     pSysMenu->InsertMenu(3, CASTUINT(MF_BYPOSITION | MF_SEPARATOR));
  1704.  
  1705.     return 1;
  1706. }
  1707. /****************************************************************************
  1708. *
  1709. *    CFloatingTaskBar::OnClose
  1710. *
  1711. *    PARAMETERS:
  1712. *        None
  1713. *
  1714. *    RETURNS:
  1715. *        void
  1716. *
  1717. *    DESCRIPTION:
  1718. *        We process WM_CLOSE so we can actually dock instead.
  1719. *
  1720. ****************************************************************************/
  1721.  
  1722. void CFloatingTaskBar::OnClose()
  1723. {
  1724.     // Tell the task bar Manager to dock
  1725.     OnDock();
  1726.     
  1727. } // END OF    FUNCTION CFloatingTaskBar::OnClose()
  1728.  
  1729. /****************************************************************************
  1730. *
  1731. *    CFloatingTaskBar::OnDock
  1732. *
  1733. *    PARAMETERS:
  1734. *        None
  1735. *
  1736. *    RETURNS:
  1737. *        void
  1738. *
  1739. *    DESCRIPTION:
  1740. *        This is the handler for the dock button. It can be called to dock
  1741. *        the task bar (change to docked state).
  1742. *
  1743. ****************************************************************************/
  1744.  
  1745. void CFloatingTaskBar::OnDock()
  1746. {
  1747.     ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().OnDockTaskBar();
  1748.  
  1749. } // END OF    FUNCTION CFloatingTaskBar::OnDock()
  1750.  
  1751. /****************************************************************************
  1752. *
  1753. *    CFloatingTaskBar::DoPaint
  1754. *
  1755. *    PARAMETERS:
  1756. *        dc    - reference to dc for painting
  1757. *
  1758. *    RETURNS:
  1759. *        void
  1760. *
  1761. *    DESCRIPTION:
  1762. *        Virtual handler for the paint message. Here's where we do all our
  1763. *        specialized drawing for our task bar.
  1764. *
  1765. ****************************************************************************/
  1766.  
  1767. void CFloatingTaskBar::DoPaint(CPaintDC & dc)
  1768. {
  1769.     
  1770. } // END OF    FUNCTION CFloatingTaskBar::DoPaint()
  1771.  
  1772. /****************************************************************************
  1773. *
  1774. *    CFloatingTaskBar::PaintDragBar
  1775. *
  1776. *    PARAMETERS:
  1777. *        pdc    - pointer to dc to draw on
  1778. *
  1779. *    RETURNS:
  1780. *        void
  1781. *
  1782. *    DESCRIPTION:
  1783. *        Protected helper for painting our custom window caption.
  1784. *
  1785. ****************************************************************************/
  1786.  
  1787. void CFloatingTaskBar::PaintDragBar(CDC * pdc)
  1788. {
  1789.     CRect rcClient;
  1790.     GetClientRect(&rcClient);
  1791.     
  1792.     if(m_bHorizontal)
  1793.     {
  1794.         // Draw a 3-d border to the right of the drag bar
  1795.         CRect rcTmp(m_nDragBarWidth, 0, m_nDragBarWidth + 1, rcClient.bottom);
  1796.         CBrush brShadow(::GetSysColor(COLOR_BTNSHADOW));
  1797.         pdc->FillRect(rcTmp, &brShadow);
  1798.         rcTmp.OffsetRect(1, 0);
  1799.         CBrush brHilight(::GetSysColor(COLOR_BTNHIGHLIGHT));
  1800.         pdc->FillRect(rcTmp, &brHilight);
  1801.  
  1802.         // Draw a 3-d "grip"
  1803.         for (int i = nDOCK_BTN_H + 2; i < (rcClient.bottom - 2); i += 3)
  1804.         {
  1805.             rcTmp.SetRect(1, i, m_nDragBarWidth - 1, i + 1);
  1806.             pdc->FillRect(rcTmp, &brShadow);
  1807.             rcTmp.SetRect(1, i + 1, m_nDragBarWidth - 1, i + 2);
  1808.             pdc->FillRect(rcTmp, &brHilight);
  1809.         }
  1810.     }
  1811.     else // if vertical
  1812.     {
  1813.         CRect rcTmp(0, m_nDragBarHeight, rcClient.right, m_nDragBarWidth + 1);
  1814.         CBrush brShadow(::GetSysColor(COLOR_BTNSHADOW));
  1815.         pdc->FillRect(rcTmp, &brShadow);
  1816.         rcTmp.OffsetRect(0, 1);
  1817.         CBrush brHilight(::GetSysColor(COLOR_BTNHIGHLIGHT));
  1818.         pdc->FillRect(rcTmp, &brHilight);
  1819.  
  1820.         // Draw a 3-d "grip"
  1821.         for (int i = nDOCK_BTN_W + 2; i < (rcClient.right - 2); i += 3)
  1822.         {
  1823.             rcTmp.SetRect(i, 1, i + 1, m_nDragBarHeight - 1);
  1824.             pdc->FillRect(rcTmp, &brShadow);
  1825.             rcTmp.SetRect(i + 1, 1,  i + 2, m_nDragBarHeight - 1);
  1826.             pdc->FillRect(rcTmp, &brHilight);
  1827.         }
  1828.  
  1829.  
  1830.  
  1831.     }
  1832.     
  1833. } // END OF    FUNCTION CFloatingTaskBar::PaintDragBar()
  1834.  
  1835. /****************************************************************************
  1836. *
  1837. *    CFloatingTaskBar::OnMouseMove
  1838. *
  1839. *    PARAMETERS:
  1840. *        nFlags    - control key flags
  1841. *        point    - cursor coordinate
  1842. *
  1843. *    RETURNS:
  1844. *        void
  1845. *
  1846. *    DESCRIPTION:
  1847. *        We process this message to allow the user to move the floating task
  1848. *        bar around, since we're not a normal window and have no title bar.
  1849. *
  1850. ****************************************************************************/
  1851.  
  1852. void CFloatingTaskBar::OnMouseMove(UINT nFlags, CPoint point) 
  1853. {
  1854.     CFloatingTaskBarBase::OnMouseMove(nFlags, point);
  1855.  
  1856.     // Are we being dragged?
  1857.     if (nFlags & MK_LBUTTON)
  1858.     {
  1859.         // By the drag bar?
  1860.         if (DragBarHitTest(point))
  1861.         {
  1862.             // Start the drag process
  1863.             CRect rc;
  1864.             GetWindowRect(&rc);
  1865.             CRectTracker Tracker(&rc, CRectTracker::solidLine);
  1866.             Tracker.m_sizeMin.cx = rc.Width();
  1867.             Tracker.m_sizeMin.cy = rc.Height();
  1868.             ClientToScreen(&point);
  1869.             if (Tracker.Track(this, point, FALSE, GetDesktopWindow()))
  1870.             {
  1871.                 // User released and position changed
  1872.                 rc = Tracker.m_rect;
  1873.                 ClientToScreen(&rc);
  1874.                 MoveWindow(&rc);
  1875.                 
  1876.                 // Inform task bar manager of our new position
  1877.                 ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().SetLastFloatPos(
  1878.                     rc.TopLeft());
  1879.             }
  1880.         }
  1881.     }
  1882.         
  1883. } // END OF    FUNCTION CFloatingTaskBar::OnMouseMove()
  1884.  
  1885. /****************************************************************************
  1886. *
  1887. *    CFloatingTaskBar::OnLButtonDblClk
  1888. *
  1889. *    PARAMETERS:
  1890. *        nFlags    - control key flags
  1891. *        point    - cursor coordinate
  1892. *
  1893. *    RETURNS:
  1894. *        void
  1895. *
  1896. *    DESCRIPTION:
  1897. *        We process this message so user can dock us by double-clicking on
  1898. *        the drag bar.
  1899. *
  1900. ****************************************************************************/
  1901.  
  1902. void CFloatingTaskBar::OnLButtonDblClk(UINT nFlags, CPoint point) 
  1903. {
  1904.     CFloatingTaskBarBase::OnLButtonDblClk(nFlags, point);
  1905.     
  1906.     if (DragBarHitTest(point))
  1907.     {
  1908.         OnDock();
  1909.     }
  1910.     
  1911. } // END OF    FUNCTION CFloatingTaskBar::OnLButtonDblClk()
  1912.  
  1913. /****************************************************************************
  1914. *
  1915. *    CFloatingTaskBar::OnRButtonUp
  1916. *
  1917. *    PARAMETERS:
  1918. *        nFlags    - control key flags
  1919. *        point    - cursor coordinate
  1920. *
  1921. *    RETURNS:
  1922. *        void
  1923. *
  1924. *    DESCRIPTION:
  1925. *        We process this handler so we can display the right mouse pop-up
  1926. *        menu.
  1927. *
  1928. ****************************************************************************/
  1929.  
  1930. void CFloatingTaskBar::OnRButtonUp(UINT nFlags, CPoint point) 
  1931. {
  1932.     CMenu Menu;
  1933.     if (Menu.LoadMenu(IDR_TASKBAR_POPUP))
  1934.     {
  1935.         CMenu * pSubMenu = Menu.GetSubMenu(0);
  1936.         SetMenuState(pSubMenu);
  1937.         ClientToScreen(&point);
  1938.         pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
  1939.             point.x, point.y, this);
  1940.     }
  1941.     
  1942.     CFloatingTaskBarBase::OnRButtonUp(nFlags, point);
  1943.     
  1944. } // END OF    FUNCTION CFloatingTaskBar::OnRButtonUp()
  1945.  
  1946. void CFloatingTaskBar::OnMove( int x, int y )
  1947. {
  1948.     CPoint point(x - GetSystemMetrics(SM_CXDLGFRAME),y - GetSystemMetrics(SM_CYCAPTION) -  GetSystemMetrics(SM_CYDLGFRAME));
  1949.  
  1950.     // Inform task bar manager of our new position
  1951.     ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().SetLastFloatPos(point);
  1952.  
  1953.     CFloatingTaskBarBase::OnMove(x,y);
  1954.  
  1955. }
  1956.  
  1957. /****************************************************************************
  1958. *
  1959. *    CFloatingTaskBar::SetMenuState
  1960. *
  1961. *    PARAMETERS:
  1962. *        pMenu    - pointer to popup menu
  1963. *
  1964. *    RETURNS:
  1965. *        void
  1966. *
  1967. *    DESCRIPTION:
  1968. *        Helper function for setting the right mouse popup menu's state.
  1969. *
  1970. ****************************************************************************/
  1971.  
  1972. void CFloatingTaskBar::SetMenuState(CMenu * pMenu)
  1973. {
  1974.     pMenu->CheckMenuItem(ID_TBAR_ALWAYSONTOP,
  1975.         m_bOnTop ? MF_CHECKED : MF_UNCHECKED);
  1976.     pMenu->ModifyMenu(ID_TBAR_POSITION, MF_BYCOMMAND | MF_STRING, CASTINT(ID_TBAR_POSITION),
  1977.                       szLoadString(CASTINT(m_bHorizontal ? IDS_VERTICAL : IDS_HORIZONTAL)) );
  1978.     pMenu->ModifyMenu(ID_TBAR_SHOWTEXT, MF_BYCOMMAND | MF_STRING, CASTINT(ID_TBAR_SHOWTEXT),
  1979.                       szLoadString(CASTINT(m_bShowText ? IDS_TASKBAR_HIDETEXT : IDS_TASKBAR_SHOWTEXT))); 
  1980.  
  1981.  
  1982.  
  1983. } // END OF    FUNCTION CFloatingTaskBar::SetMenuState()
  1984.  
  1985. /****************************************************************************
  1986. *
  1987. *    CFloatingTaskBar::OnAlwaysOnTop
  1988. *
  1989. *    PARAMETERS:
  1990. *        None
  1991. *
  1992. *    RETURNS:
  1993. *        void
  1994. *
  1995. *    DESCRIPTION:
  1996. *        Command handler for the "Always On Top" menu item.
  1997. *
  1998. ****************************************************************************/
  1999.  
  2000. void CFloatingTaskBar::OnAlwaysOnTop() 
  2001. {
  2002.     if (m_bOnTop)
  2003.     {
  2004.         m_bOnTop = FALSE;
  2005.         SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  2006.     }
  2007.     else
  2008.     {
  2009.         m_bOnTop = TRUE;
  2010.         SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  2011.     }
  2012.     
  2013.     // Inform task bar manager of our new state
  2014.     ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().SetOnTop(m_bOnTop);
  2015.                     
  2016. } // END OF    FUNCTION CFloatingTaskBar::OnAlwaysOnTop()
  2017.  
  2018. /****************************************************************************
  2019. *
  2020. *    CFloatingTaskBar::OnShowText
  2021. *
  2022. *    PARAMETERS:
  2023. *        None
  2024. *
  2025. *    RETURNS:
  2026. *        void
  2027. *
  2028. *    DESCRIPTION:
  2029. *        Command handler for "Show Text" menu item.
  2030. *
  2031. ****************************************************************************/
  2032.  
  2033. void CFloatingTaskBar::OnShowText() 
  2034. {
  2035.     m_bShowText = !m_bShowText;
  2036.     
  2037.     // Inform task bar manager of our new state
  2038.     ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().SetSeparateTaskBarStyle(m_bShowText ?  TB_PICTURESANDTEXT : TB_PICTURES);
  2039.  
  2040. } // END OF    FUNCTION CFloatingTaskBar::OnShowText()
  2041.  
  2042. /****************************************************************************
  2043. *
  2044. *    CFloatingTaskBar::OnPosition
  2045. *
  2046. *    PARAMETERS:
  2047. *        None
  2048. *
  2049. *    RETURNS:
  2050. *        void
  2051. *
  2052. *    DESCRIPTION:
  2053. *        Command handler for changing the Horizonta/Vertical menu item.
  2054. *
  2055. ****************************************************************************/
  2056.  
  2057. void CFloatingTaskBar::OnPosition() 
  2058. {
  2059.     m_bHorizontal = !m_bHorizontal;
  2060.         
  2061.     // We need to set the new button text.
  2062.     ChangeButtonText();
  2063.  
  2064.     // Inform task bar manager of our new state
  2065.     ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().SetHorizontal(m_bHorizontal);
  2066.     
  2067. } // END OF    FUNCTION CFloatingTaskBar::OnHorizontal()
  2068.  
  2069.  
  2070. void CFloatingTaskBar::OnSysCommand( UINT nID, LPARAM lParam )
  2071. {
  2072.     if(nID == ID_TBAR_ALWAYSONTOP)
  2073.         OnAlwaysOnTop();
  2074.     else if(nID == ID_TBAR_POSITION)
  2075.         OnPosition();
  2076.     else if(nID == ID_TBAR_SHOWTEXT)
  2077.         OnShowText();
  2078.     else
  2079.         CFloatingTaskBarBase::OnSysCommand(nID, lParam);
  2080.  
  2081.  
  2082. }
  2083.  
  2084. void CFloatingTaskBar::OnInitMenu( CMenu* pMenu )
  2085. {
  2086.  
  2087.     pMenu->CheckMenuItem(ID_TBAR_ALWAYSONTOP, m_bOnTop ? MF_CHECKED : MF_UNCHECKED);
  2088.     pMenu->ModifyMenu(ID_TBAR_POSITION, MF_BYCOMMAND | MF_STRING, CASTUINT(ID_TBAR_POSITION),
  2089.                      szLoadString(CASTUINT(m_bHorizontal ? IDS_VERTICAL : IDS_HORIZONTAL)) );
  2090.     pMenu->ModifyMenu(ID_TBAR_SHOWTEXT, MF_BYCOMMAND | MF_STRING, CASTUINT(ID_TBAR_SHOWTEXT),
  2091.                      szLoadString(CASTUINT(m_bShowText ? IDS_TASKBAR_HIDETEXT : IDS_TASKBAR_SHOWTEXT))); 
  2092.  
  2093. }
  2094.  
  2095. /****************************************************************************
  2096. *
  2097. *    Class: CDockedTaskBar
  2098. *
  2099. *    DESCRIPTION:
  2100. *        This derived version of CTaskBar provides a "docked" task bar. It is
  2101. *        in the form of a mini child window embedded within its parent
  2102. *        (normally a CNetscapeStatusBar).
  2103. *
  2104. ****************************************************************************/
  2105.  
  2106. BEGIN_MESSAGE_MAP(CDockedTaskBar, CDockedTaskBarBase)
  2107.     //{{AFX_MSG_MAP(CDockedTaskBar)
  2108.     ON_WM_MOUSEMOVE()
  2109.     ON_WM_LBUTTONUP()
  2110.     //}}AFX_MSG_MAP
  2111. END_MESSAGE_MAP()
  2112.  
  2113. /****************************************************************************
  2114. *
  2115. *    CDockedTaskBar::CDockedTaskBar
  2116. *
  2117. *    PARAMETERS:
  2118. *        None
  2119. *
  2120. *    RETURNS:
  2121. *        N/A
  2122. *
  2123. *    DESCRIPTION:
  2124. *        Constructor
  2125. *
  2126. ****************************************************************************/
  2127.  
  2128. CDockedTaskBar::CDockedTaskBar(int nToolbarStyle)
  2129. : CTaskBar(nToolbarStyle)
  2130. {
  2131.     m_noviceButtonSize.cx = 27;
  2132.     m_noviceButtonSize.cy = 25;
  2133.     m_advancedButtonSize.cx = 27;
  2134.     m_advancedButtonSize.cy = 14;
  2135.  
  2136.     m_IconSize.cx = 25;
  2137.     m_IconSize.cy = 12;
  2138.  
  2139.     m_nDragBarWidth = 11;
  2140.     m_nIconSpace = 1;
  2141.     m_bShowText = FALSE;
  2142.  
  2143. } // END OF    FUNCTION CDockedTaskBar::CDockedTaskBar()
  2144.  
  2145. /****************************************************************************
  2146. *
  2147. *    CDockedTaskBar::~CDockedTaskBar
  2148. *
  2149. *    PARAMETERS:
  2150. *        N/A
  2151. *
  2152. *    RETURNS:
  2153. *        N/A
  2154. *
  2155. *    DESCRIPTION:
  2156. *        Destructor.
  2157. *
  2158. ****************************************************************************/
  2159.  
  2160. CDockedTaskBar::~CDockedTaskBar()
  2161. {
  2162.  
  2163. } // END OF    FUNCTION CDockedTaskBar::~CDockedTaskBar()
  2164.  
  2165. /****************************************************************************
  2166. *
  2167. *    CDockedTaskBar::Create
  2168. *
  2169. *    PARAMETERS:
  2170. *        pParent    - pointer to the window in which the task bar is docked
  2171. *
  2172. *    RETURNS:
  2173. *        TRUE if creation is successful, FALSE if not.
  2174. *
  2175. *    DESCRIPTION:
  2176. *        This function must be called after construction to create the task
  2177. *        bar.
  2178. *
  2179. ****************************************************************************/
  2180.  
  2181. BOOL CDockedTaskBar::Create(CWnd * pParent)
  2182. {
  2183.     BOOL bRtn = FALSE;
  2184.     
  2185.     CBrush brush;
  2186.  
  2187.     CString strClass = theApp.NSToolBarClass;
  2188.     
  2189.     CString strName;
  2190.     strName.LoadString(IDS_TBAR_NAME);
  2191.     bRtn = CDockedTaskBarBase::CreateEx(0, (const char *)strClass,
  2192.         (const char *)strName, WS_CHILD | WS_VISIBLE ,
  2193.         0, 0, 0, 0, pParent->GetSafeHwnd(), NULL);
  2194.         
  2195.     return(bRtn);
  2196.     
  2197. } // END OF    FUNCTION CDockedTaskBar::Create()
  2198.  
  2199. /****************************************************************************
  2200. *
  2201. *    CDockedTaskBar::DoPaint
  2202. *
  2203. *    PARAMETERS:
  2204. *        dc    - reference to dc for painting
  2205. *
  2206. *    RETURNS:
  2207. *        void
  2208. *
  2209. *    DESCRIPTION:
  2210. *        Virtual handler for the paint message. Here's where we do all our
  2211. *        specialized drawing for our task bar.
  2212. *
  2213. ****************************************************************************/
  2214.  
  2215. void CDockedTaskBar::DoPaint(CPaintDC & dc)
  2216. {
  2217.     CRect rcClient;
  2218.     GetClientRect(&rcClient);
  2219.     
  2220.     // Draw a 3-d "grip" for the drag bar
  2221.     CRect rcTmp(rcClient);
  2222.     CBrush brHilight(::GetSysColor(COLOR_BTNHIGHLIGHT));
  2223.     CBrush brShadow(::GetSysColor(COLOR_BTNSHADOW));
  2224.     for (int i = 3; i < (rcClient.bottom - 2); i += 3)
  2225.     {
  2226.         rcTmp.SetRect(2, i, m_nDragBarWidth - 1, i + 1);
  2227.         dc.FillRect(rcTmp, &brShadow);
  2228.         rcTmp.SetRect(2, i + 1, m_nDragBarWidth - 1, i + 2);
  2229.         dc.FillRect(rcTmp, &brHilight);
  2230.     }
  2231.  
  2232.     // Draw a 3-d border to the right of the drag bar
  2233.     rcTmp.SetRect(m_nDragBarWidth, 0, m_nDragBarWidth + 1, rcClient.bottom);
  2234.     dc.FillRect(rcTmp, &brShadow);
  2235.     rcTmp.OffsetRect(1, 0);
  2236.     dc.FillRect(rcTmp, &brHilight);
  2237.     
  2238.     
  2239.     // Now draw our 3-d edge borders
  2240.     
  2241.     // Left and top edges
  2242.     rcTmp.SetRect(rcClient.left, rcClient.top, 1, rcClient.bottom);
  2243.     dc.FillRect(rcTmp, &brHilight);
  2244.     rcTmp.SetRect(rcClient.left, rcClient.top, rcClient.right, 1);
  2245.     dc.FillRect(rcTmp, &brHilight);
  2246.     
  2247.     // Right and bottom
  2248.     rcTmp.SetRect(rcClient.left, rcClient.bottom - 1, rcClient.right,
  2249.         rcClient.bottom);
  2250.     dc.FillRect(rcTmp, &brShadow);
  2251.     rcTmp.SetRect(rcClient.right - 1, rcClient.top, rcClient.right,
  2252.         rcClient.bottom);
  2253.     dc.FillRect(rcTmp, &brShadow);
  2254.     
  2255. } // END OF    FUNCTION CDockedTaskBar::DoPaint()
  2256.  
  2257. /****************************************************************************
  2258. *
  2259. *    CDockedTaskBar::OnMouseMove
  2260. *
  2261. *    PARAMETERS:
  2262. *        nFlags    - control key flags
  2263. *        point    - cursor coordinate
  2264. *
  2265. *    RETURNS:
  2266. *        void
  2267. *
  2268. *    DESCRIPTION:
  2269. *        We process this message to allow the user to drag the docked task
  2270. *        bar off and "undock" it.
  2271. *
  2272. ****************************************************************************/
  2273.  
  2274. void CDockedTaskBar::OnMouseMove(UINT nFlags, CPoint point) 
  2275. {
  2276.     CDockedTaskBarBase::OnMouseMove(nFlags, point);
  2277.  
  2278.     // Are we being dragged?
  2279.     if (nFlags & MK_LBUTTON)
  2280.     {
  2281.         // By the drag bar?
  2282.         if (DragBarHitTest(point))
  2283.         {
  2284.             // Start the drag process
  2285.             CRect rc;
  2286.             GetWindowRect(&rc);
  2287.             CRectTracker Tracker(&rc, CRectTracker::solidLine);
  2288.             Tracker.m_sizeMin.cx = rc.Width();
  2289.             Tracker.m_sizeMin.cy = rc.Height();
  2290.             ClientToScreen(&point);
  2291.             if (Tracker.Track(this, point, FALSE, GetDesktopWindow()))
  2292.             {
  2293.                 // User released, so undock.
  2294.                 rc = Tracker.m_rect;
  2295.                 ClientToScreen(&rc);
  2296.                 OnUnDock(rc.TopLeft());
  2297.             }
  2298.         }
  2299.     }
  2300.         
  2301. } // END OF    FUNCTION CDockedTaskBar::OnMouseMove()
  2302.  
  2303. /****************************************************************************
  2304. *
  2305. *    CDockedTaskBar::OnLButtonUp
  2306. *
  2307. *    PARAMETERS:
  2308. *        nFlags    - control key flags
  2309. *        point    - cursor coordinate
  2310. *
  2311. *    RETURNS:
  2312. *        void
  2313. *
  2314. *    DESCRIPTION:
  2315. *        We process this message so user can un-dock us by clicking on
  2316. *        the drag bar.
  2317. *
  2318. ****************************************************************************/
  2319.  
  2320. void CDockedTaskBar::OnLButtonUp(UINT nFlags, CPoint point) 
  2321. {
  2322.     CDockedTaskBarBase::OnLButtonUp(nFlags, point);
  2323.     
  2324.     if (DragBarHitTest(point))
  2325.     {
  2326.         OnUnDock();
  2327.     }
  2328.     
  2329. } // END OF    FUNCTION CDockedTaskBar::OnLButtonUp()
  2330.  
  2331. /****************************************************************************
  2332. *
  2333. *    CDockedTaskBar::OnUnDock
  2334. *
  2335. *    PARAMETERS:
  2336. *        ptUL    - upper left corner for new floating task bar, or -1,-1 
  2337. *                  for default location.
  2338. *
  2339. *    RETURNS:
  2340. *        void
  2341. *
  2342. *    DESCRIPTION:
  2343. *        This function is called to un-dock the task bar (changed to floating
  2344. *        state).
  2345. *
  2346. ****************************************************************************/
  2347.  
  2348. void CDockedTaskBar::OnUnDock(CPoint & ptUL /*= (-1,-1)*/)
  2349. {
  2350.     ((CNetscapeApp *)AfxGetApp())->GetTaskBarMgr().OnUnDockTaskBar(ptUL);
  2351.  
  2352. } // END OF    FUNCTION CDockedTaskBar::OnUnDock()
  2353.  
  2354.  
  2355. /****************************************************************************
  2356. *
  2357. *    Class: CTaskBarArray
  2358. *
  2359. *    DESCRIPTION:
  2360. *        This is a container class for holding CTaskBar objects.
  2361. *
  2362. ****************************************************************************/
  2363.  
  2364. /****************************************************************************
  2365. *
  2366. *    CTaskBarArray::DeleteAll
  2367. *
  2368. *    PARAMETERS:
  2369. *        None
  2370. *
  2371. *    RETURNS:
  2372. *        void
  2373. *
  2374. *    DESCRIPTION:
  2375. *        This functions is called to delete all of the CTaskBar objects
  2376. *        in the container.
  2377. *
  2378. ****************************************************************************/
  2379.  
  2380. void CTaskBarArray::DeleteAll()
  2381. {
  2382.     for (int i = 0; i < GetSize(); i++)
  2383.     {
  2384.         CTaskBar * pTaskBar = Get(i);
  2385.         if (pTaskBar != NULL)
  2386.         {
  2387.             pTaskBar->DestroyWindow();
  2388.             // no need to call delete - pTaskBar has auto cleanup
  2389.         }
  2390.     }
  2391.     RemoveAll();
  2392.  
  2393. } // END OF    FUNCTION CTaskBarArray::DeleteAll()
  2394.  
  2395. /****************************************************************************
  2396. *
  2397. *    CTaskBarArray::Find
  2398. *
  2399. *    PARAMETERS:
  2400. *        pTaskBar    - pointer to object to located
  2401. *
  2402. *    RETURNS:
  2403. *        Index of the object if found, -1 if not.
  2404. *
  2405. *    DESCRIPTION:
  2406. *        This function is called to search the list for a given object.
  2407. *
  2408. ****************************************************************************/
  2409.  
  2410. int CTaskBarArray::Find(CTaskBar * pTaskBar)
  2411. {
  2412.     int nRtn = -1;
  2413.     
  2414.     BOOL bFound = FALSE;
  2415.     for (int i = 0; (i < GetSize()) && !bFound; i++)
  2416.     {
  2417.         if (Get(i) == pTaskBar)
  2418.         {
  2419.             nRtn = i;
  2420.             bFound = TRUE;
  2421.         }
  2422.     }
  2423.     
  2424.     return(nRtn);
  2425.  
  2426. } // END OF    FUNCTION CTaskBarArray::Find()
  2427.  
  2428.  
  2429. /****************************************************************************
  2430. *
  2431. *    Class: CTaskBarMgr
  2432. *
  2433. *    DESCRIPTION:
  2434. *        This class provides an object for managing all task bars within
  2435. *        the system. It maintains the abstract data for all active task icons
  2436. *        and handles the generation and switching between floating, docked or
  2437. *        other style task bars. All task bar operations should be piped though
  2438. *        this object so it can handle propagation to the appropriate active
  2439. *        task bar(s).
  2440. *
  2441. *        There are also some convenience functions available, for such actions
  2442. *        as adding a common set of task icons.
  2443. *
  2444. ****************************************************************************/
  2445.  
  2446. /****************************************************************************
  2447. *
  2448. *    CTaskBarMgr::CTaskBarMgr
  2449. *
  2450. *    PARAMETERS:
  2451. *        None
  2452. *
  2453. *    RETURNS:
  2454. *        N/A
  2455. *
  2456. *    DESCRIPTION:
  2457. *        Constructor.
  2458. *
  2459. ****************************************************************************/
  2460.  
  2461. CTaskBarMgr::CTaskBarMgr()
  2462. {
  2463.     m_bInitialized = FALSE;
  2464.     m_ptLastFloatPos = CPoint(-1, -1);
  2465.     m_dwStateFlags = 0;
  2466.     m_bSeparateTaskBarStyle = FALSE;
  2467.     m_nReference = 0;
  2468.  
  2469. } // END OF    FUNCTION CTaskBarMgr::CTaskBarMgr()
  2470.  
  2471. /****************************************************************************
  2472. *
  2473. *    CTaskBarMgr::~CTaskBarMgr
  2474. *
  2475. *    PARAMETERS:
  2476. *        N/A
  2477. *
  2478. *    RETURNS:
  2479. *        N/A
  2480. *
  2481. *    DESCRIPTION:
  2482. *        Destructor.
  2483. *
  2484. ****************************************************************************/
  2485.  
  2486. CTaskBarMgr::~CTaskBarMgr()
  2487. {
  2488.  
  2489. } // END OF    FUNCTION CTaskBarMgr::~CTaskBarMgr()
  2490.  
  2491. /****************************************************************************
  2492. *
  2493. *    CTaskBarMgr::Init
  2494. *
  2495. *    PARAMETERS:
  2496. *        None
  2497. *
  2498. *    RETURNS:
  2499. *        TRUE if initialization is successful
  2500. *
  2501. *    DESCRIPTION:
  2502. *        This function must be called after construction to initialize the
  2503. *        task bar manager.
  2504. *
  2505. ****************************************************************************/
  2506.  
  2507. BOOL CTaskBarMgr::Init()
  2508. {
  2509.     // Don't allow multiple initialization
  2510.     BOOL bRtn = !m_bInitialized;
  2511.     ASSERT(bRtn);
  2512.     if (bRtn)
  2513.     {
  2514.         m_bInitialized = TRUE;
  2515.         bRtn = CreateAllTaskBars();
  2516.     }
  2517.     
  2518.     return(bRtn);
  2519.     
  2520. } // END OF    FUNCTION CTaskBarMgr::Init()
  2521.  
  2522. void CTaskBarMgr::LoadPrefs(BOOL bAlwaysDock)
  2523. {
  2524.     CPoint ptTB;
  2525.     int32 x, y, nButtonStyle;
  2526.     PREF_GetIntPref("taskbar.x", &x);
  2527.     PREF_GetIntPref("taskbar.y", &y);
  2528. #ifdef XP_WIN32
  2529.     ptTB.x =x;
  2530.     ptTB.y =y;
  2531. #else
  2532.     ptTB.x =CASTINT(x);
  2533.     ptTB.y =CASTINT(y);
  2534. #endif
  2535.     SetLastFloatPos(ptTB);
  2536.     BOOL bFloating, bHorizontal, bOnTop;
  2537.  
  2538.     if(bAlwaysDock)
  2539.         bFloating = FALSE;
  2540.     else
  2541.         PREF_GetBoolPref("taskbar.floating", &bFloating);
  2542.  
  2543.     PREF_GetBoolPref("taskbar.horizontal", &bHorizontal);
  2544.     PREF_GetBoolPref("taskbar.ontop", &bOnTop);
  2545.     DWORD dwStates = 0;
  2546.     dwStates = dwStates | (bFloating ? TBAR_FLOATING : 0) | (bHorizontal ? TBAR_HORIZONTAL : 0) |
  2547.         (bOnTop ? TBAR_ONTOP : 0);
  2548.     SetStateFlags(dwStates);
  2549.  
  2550.     PREF_GetIntPref("taskbar.button_style", &nButtonStyle);
  2551.     if(nButtonStyle == -1)
  2552.         m_nTaskBarStyle = theApp.m_pToolbarStyle;
  2553.     else
  2554.     {
  2555.         m_nTaskBarStyle = CASTINT(nButtonStyle);
  2556.         m_bSeparateTaskBarStyle = TRUE;
  2557.     }
  2558.  
  2559.     Init();
  2560.     AddStandardIcons();
  2561. }
  2562.  
  2563. void CTaskBarMgr::SavePrefs(void)
  2564. {
  2565.     DWORD dwState = GetStateFlags();
  2566.     PREF_SetBoolPref("taskbar.floating", IsFloating());
  2567.     PREF_SetBoolPref("taskbar.horizontal", IsHorizontal());
  2568.     PREF_SetBoolPref("taskbar.ontop", IsOnTop());
  2569.     CPoint ptTB =GetLastFloatPos();
  2570.     PREF_SetIntPref("taskbar.x", ptTB.x);
  2571.     PREF_SetIntPref("taskbar.y", ptTB.y);
  2572.  
  2573.     if(m_bSeparateTaskBarStyle)
  2574.         PREF_SetIntPref("taskbar.button_style", m_nTaskBarStyle);
  2575. }
  2576.  
  2577. /**********************************************************************************************
  2578. *
  2579. *    CTaskBarMgr::AllTaskBars
  2580. *
  2581. *    PARAMETERS:
  2582. *        None
  2583. *
  2584. *    RETURNS:
  2585. *        TRUE if successful, FALSE if not.
  2586. *
  2587. *    DESCRIPTION:
  2588. *        Protected helper function for generating all task bars (either one
  2589. *        floating or any number of docked) from our abstract icon data list.
  2590. *
  2591. ****************************************************************************/
  2592.  
  2593. BOOL CTaskBarMgr::CreateAllTaskBars()
  2594. {
  2595.     BOOL bRtn = FALSE;
  2596.     ASSERT(m_bInitialized);
  2597.     
  2598.     // Should be starting clean, or call DestroyAllTaskBars() first
  2599.     ASSERT(m_TaskBarList.GetSize() == 0);
  2600.     
  2601.     if (IsFloating())
  2602.     {
  2603.         // Create a single floating task bar
  2604.         bRtn = CreateFloatingTaskBar();
  2605.     }
  2606.     else
  2607.     {
  2608.         // Create docked task bars for each status bar
  2609.         for (int i = 0; i < m_StatBarList.GetSize(); i++)
  2610.         {
  2611.             CreateDockedTaskBar((CNetscapeStatusBar *)(m_StatBarList.GetAt(i)));
  2612.         }
  2613.     }
  2614.     
  2615.     return(bRtn);
  2616.  
  2617. } // END OF    FUNCTION CTaskBarMgr::CreateAllTaskBars()
  2618.  
  2619. /****************************************************************************
  2620. *
  2621. *    CTaskBarMgr::DestroyAllTaskBars
  2622. *
  2623. *    PARAMETERS:
  2624. *        None
  2625. *
  2626. *    RETURNS:
  2627. *        void
  2628. *
  2629. *    DESCRIPTION:
  2630. *        Protected helper function for destroying all active task bars,
  2631. *        floating or docked.
  2632. *
  2633. ****************************************************************************/
  2634.  
  2635. void CTaskBarMgr::DestroyAllTaskBars()
  2636. {
  2637.     m_TaskBarList.DeleteAll();
  2638.  
  2639.     // Must return the status bar pane to 0 size
  2640.     for (int i = 0; i < m_StatBarList.GetSize(); i++)
  2641.     {
  2642.         CNetscapeStatusBar * pSB =
  2643.             (CNetscapeStatusBar *)m_StatBarList.GetAt(i);
  2644.         if( !pSB )
  2645.         { 
  2646.             continue;
  2647.         }
  2648.         pSB->SetTaskBarPaneWidth( 0 );
  2649.     }
  2650.                 
  2651.     m_StatBarMap.RemoveAll();
  2652.     
  2653. } // END OF    FUNCTION CTaskBarMgr::DestroyAllTaskBars()
  2654.  
  2655. /****************************************************************************
  2656. *
  2657. *    CTaskBarMgr::RegisterStatusBar
  2658. *
  2659. *    PARAMETERS:
  2660. *        pStatBar    - pointer to the status bar being registered
  2661. *
  2662. *    RETURNS:
  2663. *        void
  2664. *
  2665. *    DESCRIPTION:
  2666. *        This function should be called whenever a new status bar is    created
  2667. *        and it is desirable to have task bars docked within it. The new
  2668. *        status bar is added to the list maintained by the task bar manager -
  2669. *        UnRegisterStatusBar() should be called when the status bar is
  2670. *        destroyed or no longer wants to have task bars docked within it.
  2671. *
  2672. ****************************************************************************/
  2673.  
  2674. void CTaskBarMgr::RegisterStatusBar(CNetscapeStatusBar * pStatBar)
  2675. {
  2676.  
  2677.     
  2678.     
  2679.     m_StatBarList.Add(pStatBar);
  2680.     
  2681.     // It's perfectly OK for frame windows to register their status bars
  2682.     // with us before we're initialized, but we don't create a task bar for
  2683.     // it unless we are (and if we're also in the docked state).
  2684.     if (m_bInitialized && !IsFloating())
  2685.     {
  2686.         CreateDockedTaskBar(pStatBar);
  2687.     }
  2688.  
  2689. } // END OF    FUNCTION CTaskBarMgr::RegisterStatusBar()
  2690.  
  2691. /****************************************************************************
  2692. *
  2693. *    CTaskBarMgr::UnRegisterStatusBar
  2694. *
  2695. *    PARAMETERS:
  2696. *        pStatBar    - pointer to the status bar being unregistered
  2697. *
  2698. *    RETURNS:
  2699. *        void
  2700. *
  2701. *    DESCRIPTION:
  2702. *        This function should be called whenever a status bar is destroyed or
  2703. *        no longer wants to have task bars docked within it. It removes it
  2704. *        from the list maintained by the task bar manager.
  2705. *
  2706. ****************************************************************************/
  2707.  
  2708. void CTaskBarMgr::UnRegisterStatusBar(CNetscapeStatusBar * pStatBar)
  2709. {
  2710.     // Find the given status bar in our list
  2711.     BOOL bDone = FALSE;
  2712.     for (int i = 0; (i < m_StatBarList.GetSize()) && !bDone; i++)
  2713.     {
  2714.         CNetscapeStatusBar * pSB =
  2715.             (CNetscapeStatusBar *)m_StatBarList.GetAt(i);
  2716.         if (pSB == pStatBar)
  2717.         {
  2718.             // Found it, so take it out of our list
  2719.             bDone = TRUE;
  2720.             m_StatBarList.RemoveAt(i);
  2721.             
  2722.             // If there's a task bar embedded in this status bar, it will
  2723.             // be destroyed automatically, so don't worry about deleting
  2724.             // the object. However, we do need to eliminate it from our
  2725.             // list of active task bars, and break the association in the map.
  2726.             CTaskBar * pTB = NULL;
  2727.             if (m_StatBarMap.Lookup(pStatBar, (void * &)pTB))
  2728.             {
  2729.                 // Remove map entry
  2730.                 m_StatBarMap.RemoveKey(pStatBar);
  2731.                 
  2732.                 // Now remove the task bar from the list
  2733.                 int i = m_TaskBarList.Find(pTB);
  2734.                 if (i > -1)
  2735.                 {
  2736.                     m_TaskBarList.RemoveAt(i);
  2737.                 }
  2738.             }
  2739.         }
  2740.     }
  2741.  
  2742. } // END OF    FUNCTION CTaskBarMgr::UnRegisterStatusBar()
  2743.  
  2744. /****************************************************************************
  2745. *
  2746. *    CTaskBarMgr::OnSizeStatusBar
  2747. *
  2748. *    PARAMETERS:
  2749. *        pStatBar    - pointer to the status bar whose size has changed
  2750. *
  2751. *    RETURNS:
  2752. *        void
  2753. *
  2754. *    DESCRIPTION:
  2755. *        This function is called by a registered status bar when it has been
  2756. *        resized. Since we have to be in control of all task bars, we're
  2757. *        responsible of repositioning any that are docked on the given status
  2758. *        bar.
  2759. *
  2760. ****************************************************************************/
  2761.  
  2762. void CTaskBarMgr::OnSizeStatusBar(CNetscapeStatusBar * pStatBar)
  2763. {
  2764.     if (!IsFloating())
  2765.     {
  2766.         CDockedTaskBar * pTB = NULL;
  2767.         if (m_StatBarMap.Lookup(pStatBar, (void * &)pTB))
  2768.         {
  2769.             AdjustStatusPane(pTB, pStatBar);
  2770.             PlaceOnStatusBar(pTB, pStatBar);
  2771.         }
  2772.     }
  2773.  
  2774. } // END OF    FUNCTION CTaskBarMgr::OnSizeStatusBar()
  2775.  
  2776. /****************************************************************************
  2777. *
  2778. *    CTaskBarMgr::CreateDockedTaskBar
  2779. *
  2780. *    PARAMETERS:
  2781. *        pStatBar    - pointer to status bar that houses the task bar
  2782. *
  2783. *    RETURNS:
  2784. *        TRUE if successful, FALSE if not.
  2785. *
  2786. *    DESCRIPTION:
  2787. *        Protected helper function for specifically creating a docked task bar.
  2788. *
  2789. ****************************************************************************/
  2790.  
  2791. BOOL CTaskBarMgr::CreateDockedTaskBar(CNetscapeStatusBar * pStatBar)
  2792. {
  2793.     BOOL bRtn = ((pStatBar != NULL) && ::IsWindow(pStatBar->GetSafeHwnd()));
  2794.  
  2795.     if (bRtn)
  2796.     {
  2797.         CDockedTaskBar * pTB = new CDockedTaskBar(TB_PICTURES);
  2798.         ASSERT(pTB != NULL);
  2799.         if (pTB != NULL)
  2800.         {
  2801.             // Create, add to active list and the map
  2802.             bRtn = pTB->Create(pStatBar);
  2803.             m_TaskBarList.Add(pTB);
  2804.             m_StatBarMap.SetAt(pStatBar, pTB);
  2805.             
  2806.             // Add the icons
  2807.             AddIconsToTaskBar(pTB);
  2808.             
  2809.             // Embed the thing in the status bar. This consists of changing
  2810.             // the pane info to the correct width and moving the task bar
  2811.             // to that location.
  2812.             AdjustStatusPane(pTB, pStatBar);
  2813.             PlaceOnStatusBar(pTB, pStatBar);
  2814.         }
  2815.     }    
  2816.     
  2817.     return(bRtn);
  2818.     
  2819. } // END OF    FUNCTION CTaskBarMgr::CreateDockedTaskBar()
  2820.  
  2821. /****************************************************************************
  2822. *
  2823. *    CTaskBarMgr::AdjustStatusPane
  2824. *
  2825. *    PARAMETERS:
  2826. *        pTaskBar    - pointer to task bar
  2827. *        pStatBar    - status bar that houses it
  2828. *
  2829. *    RETURNS:
  2830. *        void
  2831. *
  2832. *    DESCRIPTION:
  2833. *        Protected helper function for adjusting the status pane so that
  2834. *        the docked task bar will fit within it.
  2835. *
  2836. ****************************************************************************/
  2837.  
  2838. void CTaskBarMgr::AdjustStatusPane(CDockedTaskBar * pTaskBar,
  2839.     CNetscapeStatusBar * pStatBar)
  2840. {
  2841.     CSize sizeTB = pTaskBar->CalcDesiredDim();
  2842.     pStatBar->SetTaskBarPaneWidth( sizeTB.cx );
  2843. } // END OF    FUNCTION CTaskBarMgr::AdjustStatusPane()
  2844.  
  2845. /****************************************************************************
  2846. *
  2847. *    CTaskBarMgr::PlaceOnStatusBar
  2848. *
  2849. *    PARAMETERS:
  2850. *        pTaskBar    - pointer to task bar to be positioned
  2851. *        pStatBar    - status bar that houses it
  2852. *
  2853. *    RETURNS:
  2854. *        void
  2855. *
  2856. *    DESCRIPTION:
  2857. *        This protected helper function is called to place a docked task bar
  2858. *        in the correct pane of a status bar. AdjustStatusPane() should have
  2859. *        been called at some prior time to set the pane to the proper width.
  2860. *
  2861. ****************************************************************************/
  2862.  
  2863. void CTaskBarMgr::PlaceOnStatusBar(CDockedTaskBar * pTaskBar,
  2864.     CNetscapeStatusBar * pStatBar)
  2865. {
  2866.     pStatBar->SetTaskBarSize( pTaskBar );
  2867. } // END OF    FUNCTION CTaskBarMgr::PlaceOnStatusBar()
  2868.  
  2869. /****************************************************************************
  2870. *
  2871. *    CTaskBarMgr::PositionDockedTaskBars
  2872. *
  2873. *    PARAMETERS:
  2874. *        None
  2875. *
  2876. *    RETURNS:
  2877. *        void
  2878. *
  2879. *    DESCRIPTION:
  2880. *        Protected helper function called to position all task bars that are
  2881. *        docked within status bars. This is needed after icons are added or
  2882. *        removed dynamically. First, the status bar pane is set to the desired
  2883. *        width, then the task bar is positioned within it.
  2884. *
  2885. ****************************************************************************/
  2886.  
  2887. void CTaskBarMgr::PositionDockedTaskBars()
  2888. {
  2889.     if (!IsFloating())
  2890.     {
  2891.         for (int i = 0; i < m_StatBarList.GetSize(); i++)
  2892.         {
  2893.             CNetscapeStatusBar * pSB =
  2894.                 (CNetscapeStatusBar *)m_StatBarList.GetAt(i);
  2895.             CDockedTaskBar * pTB = NULL;
  2896.             if (m_StatBarMap.Lookup(pSB, (void * &)pTB))
  2897.             {
  2898.                 AdjustStatusPane(pTB, pSB);
  2899.                 PlaceOnStatusBar(pTB, pSB);
  2900.             }
  2901.         }
  2902.     }
  2903.  
  2904. } // END OF    FUNCTION CTaskBarMgr::PositionDockedTaskBars()
  2905.  
  2906. /****************************************************************************
  2907. *
  2908. *    CTaskBarMgr::PositionFloatingTaskBar
  2909. *
  2910. *    PARAMETERS:
  2911. *        None
  2912. *
  2913. *    RETURNS:
  2914. *        void
  2915. *
  2916. *    DESCRIPTION:
  2917. *        Protected helper function called to position the floating task bar.
  2918. *
  2919. ****************************************************************************/
  2920.  
  2921. void CTaskBarMgr::PositionFloatingTaskBar()
  2922. {
  2923.     if (IsFloating())
  2924.     {
  2925.         // First, see how big it wants to be
  2926.         CTaskBar * pTB = m_TaskBarList.Get(0);
  2927.         ASSERT(pTB != NULL);
  2928.         CSize sizeTB = pTB->CalcDesiredDim();
  2929.         
  2930.         // For the upper left corner, we first try using the last known
  2931.         // coordinates, and if that fails, use the top right of the screen.
  2932.         int nX = 0, nY = 0;
  2933.         if (m_ptLastFloatPos != CPoint(-1, -1))
  2934.         {
  2935.             nX = m_ptLastFloatPos.x;
  2936.             nY = m_ptLastFloatPos.y;
  2937.         }
  2938.         else
  2939.         {
  2940.             CGenericFrame * pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
  2941.             ASSERT(pFrame != NULL);
  2942.             if (pFrame != NULL)
  2943.             {
  2944.                 RECT rect;
  2945.                 pFrame->GetWindowRect(&rect);
  2946.                         
  2947.                 int nCaptionHeight = ::GetSystemMetrics(SM_CYCAPTION);
  2948.     #ifdef WIN32
  2949.                 int nBorderHeight = ::GetSystemMetrics(SM_CYSIZEFRAME);
  2950.     #else
  2951.                 int nBorderHeight = ::GetSystemMetrics(SM_CYFRAME);
  2952.     #endif
  2953.  
  2954.                 int nCaptionButtonWidth = ::GetSystemMetrics(SM_CXSIZE);
  2955.                 CSize taskbarButtonSize = pTB->GetButtonDimensions();
  2956.  
  2957.                 if(IsHorizontal())
  2958.                 {
  2959.  
  2960.                     nX = (int) (rect.right - sizeTB.cx - (( 4.5 * nCaptionButtonWidth )));
  2961.                     nY = rect.top + nCaptionHeight + nBorderHeight + 2 - sizeTB.cy;
  2962.                 }
  2963.                 else
  2964.                 {
  2965.                     nX = (int) (rect.right + 2);
  2966.                     nY = rect.top + nCaptionHeight + nBorderHeight;
  2967.                 }
  2968.             }
  2969.                 
  2970.             // DON'T set m_ptLastFloatPos here - leave it set to -1,-1 so
  2971.             // we default each time, until the user has moved the task bar
  2972.             // and it is set properly.
  2973.         }
  2974.         
  2975.         // make it repaint itself since it might have to repaint the drag bars.
  2976.         pTB->Invalidate();
  2977.         // Reposition the window
  2978.         // make sure it doesn't go off the screen
  2979.         int nScreenHeight = ::GetSystemMetrics(SM_CYFULLSCREEN);
  2980.         int nScreenWidth = ::GetSystemMetrics(SM_CXFULLSCREEN);
  2981.  
  2982.         if(nY > nScreenHeight + sizeTB.cy)
  2983.             nY = 0;
  2984.         else if(nY + sizeTB.cy > nScreenHeight)
  2985.             nY = nScreenHeight - sizeTB.cy;
  2986.         else if(nY < 0)
  2987.             nY = 0;
  2988.  
  2989.         if(nX > nScreenWidth + sizeTB.cx)
  2990.             nX = 0;
  2991.         else if(nX + sizeTB.cx > nScreenWidth)
  2992.             nX = nScreenWidth - sizeTB.cx;
  2993.         else if(nX < 0)
  2994.             nX = 0;
  2995.  
  2996.  
  2997.         pTB->MoveWindow(nX, nY, sizeTB.cx, sizeTB.cy);
  2998.     }
  2999.  
  3000. } // END OF    FUNCTION CTaskBarMgr::PositionFloatingTaskBar()
  3001.  
  3002. /****************************************************************************
  3003. *
  3004. *    CTaskBarMgr::CreateFloatingTaskBar
  3005. *
  3006. *    PARAMETERS:
  3007. *        None
  3008. *
  3009. *    RETURNS:
  3010. *        TRUE if successful, FALSE if not.
  3011. *
  3012. *    DESCRIPTION:
  3013. *        Protected helper function for specifically creating a floating task
  3014. *        bar.
  3015. *
  3016. ****************************************************************************/
  3017.  
  3018. BOOL CTaskBarMgr::CreateFloatingTaskBar()
  3019. {
  3020.     BOOL bRtn = FALSE;
  3021.  
  3022.     CPoint oldPoint = m_ptLastFloatPos;
  3023.  
  3024.     CFloatingTaskBar * pTB = new CFloatingTaskBar(m_nTaskBarStyle, IsOnTop(), IsHorizontal());
  3025.     ASSERT(pTB != NULL);
  3026.     if (pTB != NULL)
  3027.     {
  3028.         bRtn = pTB->Create(AfxGetMainWnd());
  3029.         
  3030.         if (bRtn)
  3031.         {
  3032.             
  3033.             if(m_nReference > 0)
  3034.                 pTB->ShowWindow(SW_SHOWNA);
  3035.             // Put it in our active list and fill it with existing icons
  3036.             m_TaskBarList.Add(pTB);
  3037.             AddIconsToTaskBar(pTB);
  3038.             m_ptLastFloatPos = oldPoint;
  3039.             PositionFloatingTaskBar();
  3040.         }
  3041.     }
  3042.     
  3043.     return(bRtn);
  3044.     
  3045. } // END OF    FUNCTION CTaskBarMgr::CreateFloatingTaskBar()
  3046.  
  3047. void CTaskBarMgr::ReloadIconBitmaps(CTaskBar *pTaskBar)
  3048. {
  3049.  
  3050.     HBITMAP hBitmap = NULL;
  3051.     int nSize = m_IconList.GetSize();
  3052.  
  3053.     int i;
  3054.  
  3055.     // First remove all of the bitmaps from the map.
  3056.     for(i = 0; i < nSize; i++)
  3057.     {
  3058.         CTaskIcon * pIcon = m_IconList.Get(i);
  3059.         int idBmp = pIcon->GetLargeBmpID();
  3060.  
  3061.         WFE_RemoveBitmapFromMap(idBmp);
  3062.             
  3063.         idBmp = pIcon->GetSmallBmpID();
  3064.  
  3065.         WFE_RemoveBitmapFromMap(idBmp);
  3066.     }
  3067.  
  3068.     // Now replace the bitmaps
  3069.     for(i = 0; i < nSize; i++)
  3070.     {
  3071.         CTaskIcon * pIcon = m_IconList.Get(i);
  3072.         int idBmp = IsFloating() ? pIcon->GetLargeBmpID() :
  3073.             pIcon->GetSmallBmpID();
  3074.  
  3075.         HDC hDC = GetDC(pTaskBar->m_hWnd);
  3076.         hBitmap = WFE_LookupLoadAndEnterBitmap(hDC, idBmp, TRUE, 
  3077.                                             WFE_GetUIPalette(pTaskBar->GetParentFrame()), 
  3078.                                                GetSysColor(COLOR_BTNFACE), RGB(255, 0, 255));
  3079.         ReleaseDC(pTaskBar->m_hWnd, hDC);
  3080.  
  3081.         pTaskBar->ReplaceButtonBitmap(i, hBitmap);
  3082.     }
  3083.  
  3084. }
  3085.  
  3086. void CTaskBarMgr::Reference(BOOL bAdd)
  3087. {
  3088.     CFloatingTaskBar *pTB = NULL;
  3089.  
  3090.     if(IsFloating())
  3091.         pTB = (CFloatingTaskBar*)m_TaskBarList.Get(0);
  3092.  
  3093.     if(bAdd)
  3094.     {
  3095.         if(pTB && m_nReference == 0)
  3096.             pTB->ShowWindow(SW_SHOW);
  3097.         m_nReference++;
  3098.     }
  3099.     else
  3100.     {
  3101.         if(pTB && m_nReference == 1)
  3102.             pTB->ShowWindow(SW_HIDE);
  3103.         m_nReference--;
  3104.     }
  3105.  
  3106. }
  3107.  
  3108. void CTaskBarMgr::ChangeTaskBarsPalette(HWND hFocus)
  3109. {
  3110.     if(m_bInitialized)
  3111.     {
  3112.         int nSize = m_TaskBarList.GetSize();
  3113.  
  3114.         for (int i = 0; i < nSize; i++)
  3115.         {
  3116.             CTaskBar * pTB = m_TaskBarList.Get(i);
  3117.  
  3118.             pTB->SendMessage(WM_PALETTECHANGED, (WPARAM)hFocus, 0);
  3119.  
  3120.         }
  3121.     }
  3122. }
  3123.  
  3124. /****************************************************************************
  3125. *
  3126. *    CTaskBarMgr::AddIconsToTaskBar
  3127. *
  3128. *    PARAMETERS:
  3129. *        pTaskBar    - pointer to the task bar to be filled
  3130. *
  3131. *    RETURNS:
  3132. *        TRUE if successful, FALSE if a failure occurs.
  3133. *
  3134. *    DESCRIPTION:
  3135. *        Protected helper function for adding all of the icons in our list
  3136. *        to a given (presumably newly created) task bar.
  3137. *
  3138. ****************************************************************************/
  3139.  
  3140. BOOL CTaskBarMgr::AddIconsToTaskBar(CTaskBar * pTaskBar)
  3141. {
  3142.  
  3143.     BOOL bRtn = TRUE;
  3144.     HBITMAP hBitmap = NULL;
  3145.  
  3146.     for (int i = 0; (i < m_IconList.GetSize()) && bRtn; i++)
  3147.     {
  3148.         CTaskIcon * pIcon = m_IconList.Get(i);
  3149.         int idBmp = IsFloating() ? pIcon->GetLargeBmpID() :
  3150.             pIcon->GetSmallBmpID();
  3151.  
  3152.         int idTip = IsFloating() ? pIcon->GetFloatingTipID() :
  3153.             pIcon->GetDockedTipID();
  3154.  
  3155.         HDC hDC = GetDC(pTaskBar->m_hWnd);
  3156.         hBitmap = WFE_LookupLoadAndEnterBitmap(hDC, idBmp, TRUE, WFE_GetUIPalette(pTaskBar->GetParentFrame()), 
  3157.                                                sysInfo.m_clrBtnFace, RGB(255, 0, 255));
  3158.         ReleaseDC(pTaskBar->m_hWnd, hDC);
  3159.  
  3160.         int nBitmapIndex = IsFloating() ? pIcon->GetLargeBitmapIndex() :
  3161.             pIcon->GetSmallBitmapIndex();
  3162.         
  3163.         int idText = IsHorizontal() ? pIcon->GetHorizTextID() : pIcon->GetVertTextID();
  3164.             
  3165.         bRtn = pTaskBar->AddTaskIcon(pIcon->GetTaskID(), pIcon->GetNotifyWnd(),
  3166.             pIcon->GetNotifyMessage(), hBitmap, nBitmapIndex, pIcon->GetHorizTextID(), 
  3167.             pIcon->GetVertTextID(), idText, idTip, 
  3168.             pTaskBar->GetTaskBarStyle());
  3169.     }
  3170.     
  3171.     return(bRtn);
  3172.  
  3173. } // END OF    FUNCTION CTaskBarMgr::AddIconsToTaskBar()
  3174.  
  3175. /****************************************************************************
  3176. *
  3177. *    CTaskBarMgr::AddStandardIcons
  3178. *
  3179. *    PARAMETERS:
  3180. *        None
  3181. *
  3182. *    RETURNS:
  3183. *        TRUE if successful, FALSE if not.
  3184. *
  3185. *    DESCRIPTION:
  3186. *        This function call be called to add the three default icons (Mail,
  3187. *        Web & News) to our icon list, and therefore to all active task bars.
  3188. *
  3189. ****************************************************************************/
  3190.  
  3191. BOOL CTaskBarMgr::AddStandardIcons()
  3192. {
  3193.     BOOL bRtn = TRUE;
  3194.     
  3195.     bRtn =     AddTaskIcon(ID_TOOLS_WEB, IDB_TASKBARL, BROWSER_ICON_INDEX, IDB_TASKBARS,
  3196.                         BROWSER_ICON_INDEX,    IDS_NOTIFY_WEB_TIP, IDS_NOTIFY_WEB_TIP, 
  3197.                         IDS_NOTIFY_WEB_TIP, IDS_TASKBAR_FLOAT_NAVTIP) &&
  3198.             AddTaskIcon(ID_TOOLS_INBOX, IDB_TASKBARL, UNKNOWN_MAIL_ICON_INDEX, IDB_TASKBARS,
  3199.                         UNKNOWN_MAIL_ICON_INDEX, IDS_NOTIFY_MAIL1_TIP, IDS_NOTIFY_MAIL1_TIP,
  3200.                         IDS_NOTIFY_MAIL1_TIP, IDS_TASKBAR_FLOAT_MAILTIP) &&
  3201.             AddTaskIcon(ID_TOOLS_NEWS, IDB_TASKBARL, NEWS_ICON_INDEX, IDB_TASKBARS,
  3202.                         NEWS_ICON_INDEX, IDS_TASKBAR_NEWS_HTEXT, IDS_TASKBAR_NEWS_HTEXT, 
  3203.                         IDS_NOTIFY_NEWS_TIP, IDS_TASKBAR_FLOAT_NEWSTIP) &&
  3204.             AddTaskIcon(ID_TOOLS_EDITOR, IDB_TASKBARL, COMPOSE_ICON_INDEX, IDB_TASKBARS,
  3205.                         COMPOSE_ICON_INDEX, IDS_NOTIFY_COMPOSE_TIP, IDS_NOTIFY_COMPOSE_TIP, 
  3206.                         IDS_NOTIFY_COMPOSE_TIP, IDS_TASKBAR_FLOAT_COMPOSETIP);
  3207.     
  3208.     return(bRtn);
  3209.  
  3210. } // END OF    FUNCTION CTaskBarMgr::AddStandardIcons
  3211.  
  3212. /****************************************************************************
  3213. *
  3214. *    CTaskBarMgr::AddTaskIcon
  3215. *
  3216. *    PARAMETERS:
  3217. *        idTask        - task identifier
  3218. *        idBmpLarge    - bitmap resource ID for large icon (floating)
  3219. *        idBmpSmall    - bitmap resource ID for small icon (docked)
  3220. *        idTip        - string resource ID of tool tip text
  3221. *
  3222. *    RETURNS:
  3223. *        TRUE if successful, FALSE if not.
  3224. *
  3225. *    DESCRIPTION:
  3226. *        This function is called to add a task icon to the list maintained
  3227. *        by the task bar manager. The appropriate icon window will then be
  3228. *        created and added to any active task bars, floating or docked.
  3229. *
  3230. *        Notifications (mouse events) for the new icon are sent to the default
  3231. *        window (main frame window) using the default message (MSG_TASK_NOTIFY).
  3232. *        To specify a different handler, call the overloaded version of this
  3233. *        function that takes    those parameters.
  3234. *
  3235. ****************************************************************************/
  3236.  
  3237. BOOL CTaskBarMgr::AddTaskIcon(UINT idTask, UINT idBmpLarge, int nLargeIndex, UINT idBmpSmall,
  3238.                               int nSmallIndex,    UINT idHorizText, UINT idVertText,
  3239.                               UINT idDockedTip, UINT idFloatingTip)
  3240. {
  3241.     return(AddTaskIcon(idTask, AfxGetMainWnd(), MSG_TASK_NOTIFY, idBmpLarge, nLargeIndex,
  3242.         idBmpSmall, nSmallIndex, idHorizText, idVertText, idDockedTip, idFloatingTip));
  3243.  
  3244. } // END OF    FUNCTION CTaskBarMgr::AddTaskIcon()
  3245.  
  3246. /****************************************************************************
  3247. *
  3248. *    CTaskBarMgr::AddTaskIcon
  3249. *
  3250. *    PARAMETERS:
  3251. *        idTask        - task identifier
  3252. *        pwndNotify    - pointer to window desiring notification
  3253. *        dwMessage    - user-defined callback message
  3254. *        idBmpLarge    - bitmap resource ID for large icon (floating)
  3255. *        idBmpSmall    - bitmap resource ID for small icon (docked)
  3256. *        idHorizText - string resource ID for horizontal text
  3257. *        idVertText  - string resource ID for vertical text
  3258. *        idTip        - string resource ID of tool tip text
  3259. *
  3260. *    RETURNS:
  3261. *        TRUE if successful, FALSE if not.
  3262. *
  3263. *    DESCRIPTION:
  3264. *        This function is called to add a task icon to the list maintained
  3265. *        by the task bar manager. The appropriate icon window will then be
  3266. *        created and added to any active task bars, floating or docked.
  3267. *
  3268. *        Notifications (mouse events) for the new icon are sent to the window
  3269. *        identified by pwndNotify, using the message dwMessage. For the default
  3270. *        message and handlers, call the overloaded version of this function
  3271. *        that omits those parameters.
  3272. *
  3273. ****************************************************************************/
  3274.  
  3275. BOOL CTaskBarMgr::AddTaskIcon(UINT idTask, CWnd * pwndNotify, DWORD dwMessage,
  3276.     UINT idBmpLarge, int nLargeIndex, UINT idBmpSmall, int nSmallIndex, 
  3277.     UINT idHorizText, UINT idVertText, UINT idDockedTip, UINT idFloatingTip)
  3278. {
  3279.     BOOL bRtn = TRUE;
  3280.     HBITMAP hBitmap;
  3281.  
  3282.     // First, create a new icon object and add to our list.
  3283.     CTaskIcon * pIcon = new CTaskIcon(idTask, pwndNotify, dwMessage,
  3284.         idBmpLarge, nLargeIndex,  idBmpSmall, nSmallIndex, idHorizText,
  3285.         idVertText, idDockedTip, idFloatingTip);
  3286.     ASSERT(pIcon != NULL);        
  3287.     m_IconList.Add(pIcon);
  3288.     
  3289.     // Now add the icon to any existing task bars
  3290.     int idBmp = IsFloating() ? idBmpLarge : idBmpSmall;
  3291.     int idTip = IsFloating() ? idFloatingTip : idDockedTip;
  3292.     int idText = IsHorizontal() ? idHorizText : idVertText;
  3293.  
  3294.     int nBitmapIndex = IsFloating() ? nLargeIndex : nSmallIndex;
  3295.  
  3296.  
  3297.     for (int i = 0; (i < m_TaskBarList.GetSize()) && bRtn; i++)
  3298.     {
  3299.         CTaskBar * pTB = m_TaskBarList.Get(i);
  3300.  
  3301.         HDC hDC = GetDC(pTB->m_hWnd);
  3302.         hBitmap = WFE_LookupLoadAndEnterBitmap(hDC, idBmp, TRUE, WFE_GetUIPalette(pTB->GetParentFrame()), sysInfo.m_clrBtnFace,
  3303.                                                RGB(255, 0, 255));
  3304.  
  3305.         ReleaseDC(pTB->m_hWnd, hDC);
  3306.         
  3307.         bRtn = pTB->AddTaskIcon(idTask, pwndNotify, dwMessage, hBitmap, nBitmapIndex,
  3308.             idHorizText, idVertText, idText, idTip, IsFloating()? pTB->GetTaskBarStyle(): TB_PICTURES);
  3309.     }
  3310.  
  3311.     // Finally, since the size of the task bar has changed, we must
  3312.     // re-position all.
  3313.     if (IsFloating())
  3314.     {
  3315.         PositionFloatingTaskBar();
  3316.     }
  3317.     else
  3318.     {
  3319.         PositionDockedTaskBars();
  3320.     }
  3321.     
  3322.     return(bRtn);
  3323.  
  3324. } // END OF    FUNCTION CTaskBarMgr::AddTaskIcon()
  3325.  
  3326. /****************************************************************************
  3327. *
  3328. *    CTaskBarMgr::ReplaceTaskIcon
  3329. *
  3330. *    PARAMETERS:
  3331. *        idTask        - task identifier
  3332. *        idBmpLarge    - new bitmap resource ID for large icon (floating)
  3333. *        idBmpSmall    - new bitmap resource ID for small icon (docked)
  3334. *
  3335. *    RETURNS:
  3336. *        TRUE if the icon was successfully replaced, FALSE if not (such as
  3337. *        when no existing icon with the given ID is found).
  3338. *
  3339. *    DESCRIPTION:
  3340. *        This function is called to replace an existing icon in the task bar
  3341. *        whenever it is desirable to show a different image, but retain the
  3342. *        notification handler and other information for the icon. An example
  3343. *        of this would be changing the mail icon to show a different state.
  3344. *
  3345. ****************************************************************************/
  3346.  
  3347. BOOL CTaskBarMgr::ReplaceTaskIcon(UINT idTask, UINT idBmpLarge, UINT idBmpSmall, int nIndex)
  3348. {
  3349.     BOOL bRtn = FALSE;
  3350.  
  3351.     if(!m_bInitialized)
  3352.         return FALSE;
  3353.  
  3354.     // Replace the bmps for the abstract icon object in our list
  3355.     int i = m_IconList.FindByID(idTask);
  3356.     ASSERT(i > -1);
  3357.     if (i > -1)
  3358.     {
  3359.         bRtn = TRUE;
  3360.         
  3361.         CTaskIcon * pIcon = m_IconList.Get(i);
  3362.         pIcon->SetLargeBmpID(idBmpLarge);
  3363.         pIcon->SetSmallBmpID(idBmpSmall);
  3364.         //take this out eventually and replace with passed in parameters
  3365.         pIcon->SetLargeBitmapIndex(nIndex);
  3366.         pIcon->SetSmallBitmapIndex(nIndex);
  3367.     
  3368.     
  3369.         // Now tell all active task bars to replace it
  3370.         for (i = 0; i < m_TaskBarList.GetSize(); i++)
  3371.         {
  3372.             CTaskBar * pTB = m_TaskBarList.Get(i);
  3373.             int idBmp = IsFloating() ? idBmpLarge : idBmpSmall;
  3374.             BOOL bOk = pTB->ReplaceTaskIcon(idTask, idBmp, nIndex);
  3375.             ASSERT(bOk);
  3376.         }
  3377.     }    
  3378.     return(bRtn);
  3379.  
  3380. } // END OF    FUNCTION CTaskBarMgr::ReplaceTaskIcon()
  3381.  
  3382. /****************************************************************************
  3383. *
  3384. *    CTaskBarMgr::RemoveTaskIcon
  3385. *
  3386. *    PARAMETERS:
  3387. *        idTask    - task identifier
  3388. *
  3389. *    RETURNS:
  3390. *        TRUE if the icon was successfully removed from the task bar, FALSE
  3391. *        if not (such as when no existing icon with the given ID is found).
  3392. *
  3393. *    DESCRIPTION:
  3394. *        This function is called to remove an icon from the task bar when it
  3395. *        is no longer desirable to have it displayed. This is the only case
  3396. *        where this function is useful, since cleanup is performed
  3397. *        automatically when the task bar is destroyed.
  3398. *
  3399. ****************************************************************************/
  3400.  
  3401. BOOL CTaskBarMgr::RemoveTaskIcon(UINT idTask)
  3402. {
  3403.     BOOL bRtn = FALSE;
  3404.  
  3405.     // Remove the abstract icon object from our list
  3406.     int i = m_IconList.FindByID(idTask);
  3407.     ASSERT(i > -1);
  3408.     if (i > -1)
  3409.     {
  3410.         bRtn = TRUE;
  3411.         
  3412.         CTaskIcon * pIcon = m_IconList.Get(i);
  3413.         delete pIcon;
  3414.         m_IconList.RemoveAt(i);
  3415.     }
  3416.     
  3417.     // Just tell all active task bars to remove it
  3418.     for (i = 0; i < m_TaskBarList.GetSize(); i++)
  3419.     {
  3420.         CTaskBar * pTB = m_TaskBarList.Get(i);
  3421.         BOOL bOk = pTB->RemoveTaskIcon(idTask);
  3422.         ASSERT(bOk);
  3423.     }
  3424.         
  3425.     // Re-size/re-position the task bar(s)
  3426.     if (IsFloating())
  3427.     {
  3428.         PositionFloatingTaskBar();
  3429.     }
  3430.     else
  3431.     {
  3432.         PositionDockedTaskBars();
  3433.     }
  3434.     
  3435.     return(bRtn);
  3436.  
  3437. } // END OF    FUNCTION CTaskBarMgr::RemoveTaskIcon()
  3438.  
  3439. /****************************************************************************
  3440. *
  3441. *    CTaskBarMgr::OnDockTaskBar
  3442. *
  3443. *    PARAMETERS:
  3444. *        None
  3445. *
  3446. *    RETURNS:
  3447. *        void
  3448. *
  3449. *    DESCRIPTION:
  3450. *        This function is called to dock the task bar.
  3451. *
  3452. ****************************************************************************/
  3453.  
  3454. void CTaskBarMgr::OnDockTaskBar()
  3455. {
  3456.     ASSERT(IsFloating());
  3457.     DestroyAllTaskBars();
  3458.     SetFloating(FALSE);
  3459.     CreateAllTaskBars();
  3460.  
  3461. } // END OF    FUNCTION CTaskBarMgr::OnDockTaskBar()
  3462.  
  3463. /****************************************************************************
  3464. *
  3465. *    CTaskBarMgr::OnUnDockTaskBar
  3466. *
  3467. *    PARAMETERS:
  3468. *        ptUL    - upper left corner for new floating task bar, or -1,-1 
  3469. *                  for default location.
  3470. *
  3471. *    RETURNS:
  3472. *        void
  3473. *
  3474. *    DESCRIPTION:
  3475. *        This function is called to un-dock the task bar (move to floating
  3476. *        state).
  3477. *
  3478. ****************************************************************************/
  3479.  
  3480. void CTaskBarMgr::OnUnDockTaskBar(CPoint & ptUL /*= (-1,-1)*/)
  3481. {
  3482.     ASSERT(!IsFloating());
  3483.     DestroyAllTaskBars();
  3484.     SetFloating(TRUE);
  3485.     if (ptUL != CPoint(-1, -1))
  3486.     {
  3487.         m_ptLastFloatPos = ptUL;
  3488.     }
  3489.     CreateAllTaskBars();
  3490.  
  3491. } // END OF    FUNCTION CTaskBarMgr::OnUnDockTaskBar()
  3492.  
  3493.  
  3494. void CTaskBarMgr::SetSeparateTaskBarStyle(int nTaskBarStyle)
  3495. {
  3496.     m_bSeparateTaskBarStyle = TRUE;
  3497.  
  3498.     ChangeTaskBarStyle(nTaskBarStyle);
  3499.  
  3500. }
  3501.  
  3502. void CTaskBarMgr::SetTaskBarStyle(int nTaskBarStyle)
  3503. {
  3504.     if(!m_bSeparateTaskBarStyle)
  3505.     {
  3506.         ChangeTaskBarStyle(nTaskBarStyle);
  3507.     }
  3508. }
  3509.  
  3510. void CTaskBarMgr::ChangeTaskBarStyle(int nTaskBarStyle)
  3511. {
  3512.     m_nTaskBarStyle = nTaskBarStyle;
  3513.     if(IsFloating())
  3514.     {
  3515.         CTaskBar * pTB = m_TaskBarList.Get(0);
  3516.         pTB->SetTaskBarStyle(nTaskBarStyle);
  3517.         PositionFloatingTaskBar();
  3518.     }
  3519. }
  3520.  
  3521. /****************************************************************************
  3522. *
  3523. *    Class: CDockButton
  3524. *
  3525. *    DESCRIPTION:
  3526. *        This class represents the docking (minimize) button for the floating
  3527. *        task bar.
  3528. *
  3529. ****************************************************************************/
  3530.  
  3531. /****************************************************************************
  3532. *
  3533. *    CONSTANTS
  3534. *
  3535. ****************************************************************************/
  3536. static const int nIMG_WIDTH = 9;
  3537. static const int nIMG_HEIGHT = 9;
  3538.  
  3539. BEGIN_MESSAGE_MAP(CDockButton, CDockButtonBase)
  3540.     //{{AFX_MSG_MAP(CDockButton)
  3541.     //}}AFX_MSG_MAP
  3542. END_MESSAGE_MAP()
  3543.  
  3544. /****************************************************************************
  3545. *
  3546. *    CDockButton::CDockButton
  3547. *
  3548. *    PARAMETERS:
  3549. *        None
  3550. *
  3551. *    RETURNS:
  3552. *        N/A
  3553. *
  3554. *    DESCRIPTION:
  3555. *        Constructor.
  3556. *
  3557. ****************************************************************************/
  3558.  
  3559. CDockButton::CDockButton()
  3560. {
  3561.  
  3562. } // END OF    FUNCTION CDockButton::CDockButton()
  3563.  
  3564. /****************************************************************************
  3565. *
  3566. *    CDockButton::Create
  3567. *
  3568. *    PARAMETERS:
  3569. *        rect        - rectangle for initial size/position
  3570. *        pwndParent    - pointer to parent window
  3571. *        uID            - control identifier
  3572. *
  3573. *    RETURNS:
  3574. *        TRUE if creation is successful, FALSE if an error occurs.
  3575. *
  3576. *    DESCRIPTION:
  3577. *        This function is called to create the button, after construction.
  3578. *
  3579. ****************************************************************************/
  3580.  
  3581. BOOL CDockButton::Create(const CRect & rect, CWnd* pwndParent, UINT uID)
  3582. {
  3583.     BOOL bRtn = CDockButtonBase::Create("", WS_CHILD | WS_VISIBLE |
  3584.         BS_OWNERDRAW, rect, pwndParent, uID);
  3585.         
  3586.     return(bRtn);
  3587.  
  3588. } // END OF    FUNCTION CDockButton::Create()
  3589.  
  3590. /****************************************************************************
  3591. *
  3592. *    CDockButton::DrawItem
  3593. *
  3594. *    PARAMETERS:
  3595. *        None
  3596. *
  3597. *    RETURNS:
  3598. *        void
  3599. *
  3600. *    DESCRIPTION:
  3601. *        Overridden to draw the bitmap image on our button.
  3602. *
  3603. ****************************************************************************/
  3604.  
  3605. void CDockButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItem)
  3606. {
  3607.     ASSERT(lpDrawItem != NULL);
  3608.  
  3609.     CDC * pDC = CDC::FromHandle(lpDrawItem->hDC);
  3610.     CRect rcBtn(&(lpDrawItem->rcItem));
  3611.     
  3612.     // Since we're owner-draw, we must do everything. First paint the button
  3613.     // face.
  3614.     CBrush brFace(RGB(192, 192, 192));
  3615.     pDC->FillRect(rcBtn, &brFace);
  3616.     
  3617.     // Now the 3d border
  3618.     if (lpDrawItem->itemState & ODS_SELECTED)
  3619.     {
  3620.         // Draw depressed look
  3621.         DrawDownButton(pDC, rcBtn);
  3622.     }
  3623.     else
  3624.     {
  3625.         // Draw normal look
  3626.         DrawUpButton(pDC, rcBtn);
  3627.     }
  3628.  
  3629.     // Finally, paint our image. Shift down one pixel if in depressed state.
  3630.     if (lpDrawItem->itemState & ODS_SELECTED)
  3631.     {
  3632.         rcBtn.left += 1;
  3633.         rcBtn.top += 1;
  3634.     }
  3635.     DrawImage(pDC, rcBtn);
  3636.     
  3637. } // END OF FUNCTION CDockButton::DrawItem()
  3638.  
  3639. /****************************************************************************
  3640. *
  3641. *    CDockButton::DrawUpButton
  3642. *
  3643. *    PARAMETERS:
  3644. *        pDC        - pointer to DC to draw on
  3645. *        rect    - client rect to draw in
  3646. *
  3647. *    RETURNS:
  3648. *        void
  3649. *
  3650. *    DESCRIPTION:
  3651. *        Protected helper function for drawing the 3d "up button" look.
  3652. *
  3653. ****************************************************************************/
  3654.  
  3655. void CDockButton::DrawUpButton(CDC * pDC, CRect & rect)
  3656. {
  3657.     // Hilight
  3658.     CRect rc(0, 0, rect.right, 1);
  3659.     CBrush br(::GetSysColor(COLOR_BTNHIGHLIGHT));
  3660.     pDC->FillRect(rc, &br);
  3661.     rc.SetRect(0, 0, 1, rect.bottom);
  3662.     pDC->FillRect(rc, &br);
  3663.     
  3664.     // Shadow
  3665.     br.DeleteObject();
  3666.     br.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
  3667.     rc.SetRect(0, rect.bottom - 1, rect.right, rect.bottom);
  3668.     pDC->FillRect(rc, &br);
  3669.     rc.SetRect(rect.right - 1, 0, rect.right, rect.bottom);
  3670.     pDC->FillRect(rc, &br);
  3671.  
  3672. } // END OF    FUNCTION CDockButton::DrawUpButton()
  3673.  
  3674. /****************************************************************************
  3675. *
  3676. *    CDockButton::DrawDownButton
  3677. *
  3678. *    PARAMETERS:
  3679. *        pDC        - pointer to DC to draw on
  3680. *        rect    - client rect to draw in
  3681. *
  3682. *    RETURNS:
  3683. *        void
  3684. *
  3685. *    DESCRIPTION:
  3686. *        Protected helper function for drawing the 3d "down button" look.
  3687. *
  3688. ****************************************************************************/
  3689.  
  3690. void CDockButton::DrawDownButton(CDC * pDC, CRect & rect)
  3691. {
  3692.     // Hilight
  3693.     CRect rc(0, rect.bottom - 1, rect.right, rect.bottom);
  3694.     CBrush br(::GetSysColor(COLOR_BTNHIGHLIGHT));
  3695.     pDC->FillRect(rc, &br);
  3696.     rc.SetRect(rect.right - 1, 0, rect.right, rect.bottom);
  3697.     pDC->FillRect(rc, &br);
  3698.     
  3699.     // Shadow
  3700.     br.DeleteObject();
  3701.     br.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
  3702.     rc.SetRect(0, 0, rect.right, 1);
  3703.     pDC->FillRect(rc, &br);
  3704.     rc.SetRect(0, 0, 1, rect.bottom);
  3705.     pDC->FillRect(rc, &br);
  3706.  
  3707. } // END OF    FUNCTION CDockButton::DrawDownButton()
  3708.  
  3709. /****************************************************************************
  3710. *
  3711. *    CDockButton::DrawImage
  3712. *
  3713. *    PARAMETERS:
  3714. *        pDC        - pointer to DC to draw on
  3715. *        rect    - client rect to draw in
  3716. *
  3717. *    RETURNS:
  3718. *        void
  3719. *
  3720. *    DESCRIPTION:
  3721. *        Protected helper function for drawing our bitmap image on the button.
  3722. *
  3723. ****************************************************************************/
  3724.  
  3725. void CDockButton::DrawImage(CDC * pDC, CRect & rect)
  3726. {
  3727.     // Create a scratch DC and select our bitmap into it.
  3728.     CDC * pBmpDC = new CDC;
  3729.     pBmpDC->CreateCompatibleDC(pDC);
  3730.     CBitmap bmp;
  3731.     bmp.LoadBitmap(IDB_DOCK_BTN);
  3732.     CBitmap * pOldBmp = pBmpDC->SelectObject(&bmp);
  3733.         
  3734.     // Center the image within the button    
  3735.     CPoint ptDst(rect.left + (((rect.Width() - nIMG_WIDTH) + 1) / 2),
  3736.         rect.top + (((rect.Height() - nIMG_HEIGHT) + 1) / 2));
  3737.         
  3738.     // Call the handy transparent blit function to paint the bitmap over
  3739.     // whatever colors exist.    
  3740.     ::FEU_TransBlt(pBmpDC, pDC, CPoint(0, 0), ptDst, nIMG_WIDTH, nIMG_HEIGHT,WFE_GetUIPalette(GetParentFrame()));
  3741.     
  3742.     // Cleanup
  3743.     pBmpDC->SelectObject(pOldBmp);
  3744.     pBmpDC->DeleteDC();
  3745.     delete pBmpDC;
  3746.     bmp.DeleteObject();
  3747.     
  3748. } // END OF    FUNCTION CDockButton::DrawImage()
  3749.