home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / csttlbr2.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  11.3 KB  |  348 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. #ifndef _CSTTLBR2_H
  19. #define _CSTTLBR2_H
  20.  
  21. #include "stdafx.h"
  22. #include "toolbar2.h"
  23. #include "animbar2.h"
  24.  
  25. #define CT_HIDETOOLBAR        (WM_USER + 15)
  26. #define CT_DRAGTOOLBAR        (WM_USER + 16)
  27. #define CT_DRAGTOOLBAR_OVER (WM_USER + 17)
  28. #define CT_CUSTOMIZE        (WM_USER + 18)
  29. #define IDC_COLLAPSE        (WM_USER + 19)
  30.  
  31.  
  32. typedef    enum  {eLARGE_HTAB, eSMALL_HTAB} HTAB_BITMAP;
  33.  
  34. class CCustToolbar;
  35.  
  36. #ifdef XP_WIN16
  37.  
  38. class CNetscapeControlBar : public CControlBar {
  39.  
  40. protected:
  41.  
  42. virtual LRESULT WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
  43.  
  44.  
  45.  
  46. };
  47.  
  48. #endif
  49.  
  50.  
  51. // Class:  CToolbarWindow
  52. //
  53. // The window that resides within the Tabbed toolbar.  It holds the toolbar
  54. // passed in by the user of the customizable toolbar
  55.  
  56. class CToolbarWindow  {
  57.  
  58. protected:
  59.     CWnd *m_pToolbar;            // the toolbar we're storing
  60.     int m_nNoviceHeight;        // the height when in novice mode
  61.     int m_nAdvancedHeight;        // the height when in advanced mode
  62.     int m_nToolbarStyle;        // is this pictures and text, pictures, or text
  63.     HTAB_BITMAP m_nHTab;        // Type of horizontal tab
  64.  
  65. public:
  66.     CToolbarWindow(CWnd *pToolbar, int nToolbarStyle, int nNoviceHeight, int nAdvancedHeight,
  67.                    HTAB_BITMAP nHTab);
  68.     ~CToolbarWindow();
  69.     CWnd *GetToolbar(void);
  70.  
  71.     virtual CWnd* GetNSToolbar() { return NULL; } 
  72.  
  73.     // if bWindowHeight is TRUE then use toolbar's height, if FALSE use passed in height
  74.     virtual int GetHeight(void);
  75.     int GetNoviceHeight(void) { return m_nNoviceHeight; }
  76.     int GetAdvancedHeight(void) { return m_nAdvancedHeight; }
  77.  
  78.     virtual void SetToolbarStyle(int nToolbarStyle) { m_nToolbarStyle = nToolbarStyle;}
  79.     int GetToolbarStyle(void) { return m_nToolbarStyle; }
  80.     
  81.     HTAB_BITMAP GetHTab(void) { return m_nHTab; }
  82.  
  83.     virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ){}
  84.  
  85. };
  86.  
  87. // Class:  CButtonToolbarWindow
  88. //
  89. // The window that resides within the Tabbed toolbar.  It holds the a CNSToolbar2
  90. class CButtonToolbarWindow: public CToolbarWindow {
  91.  
  92. public:
  93.     CButtonToolbarWindow(CWnd *pToolbar, int nToolbarStyle, int nNoviceHeight, int nAdvancedHeight,
  94.                          HTAB_BITMAP nHTab);
  95.  
  96.     virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  97.     virtual void SetToolbarStyle(int nToolbarStyle);
  98.     virtual int GetHeight(void);
  99.     virtual CWnd* GetNSToolbar() { return GetToolbar(); }
  100.  
  101.  
  102. };
  103.  
  104. // Class:  // Class:  CControlBarToolbarWindow
  105. //
  106. // The window that resides within the Tabbed toolbar.  It holds the a CNSToolbar2
  107. class CControlBarToolbarWindow: public CToolbarWindow {
  108.  
  109. public:
  110.     CControlBarToolbarWindow(CWnd *pToolbar, int nToolbarStyle, int nNoviceHeight, int nAdvancedHeight,
  111.                          HTAB_BITMAP nHTab);
  112.  
  113.     virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  114.     virtual int GetHeight(void);
  115.  
  116.     virtual CWnd* GetNSToolbar() { return GetToolbar(); }
  117. };
  118.  
  119.  
  120.  
  121. class CDragToolbar : public CWnd {
  122.  
  123. private:
  124.     CToolbarWindow *    m_pToolbar;
  125.     BOOL                m_bIsOpen;
  126.     BOOL                m_bIsShowing;
  127.     CPoint                m_mouseDownPoint;
  128.     BOOL                m_bDragging;
  129.     BOOL                m_bMouseDown;
  130.     UINT                m_nDragTimer;
  131.     BOOL                m_bMouseInTab;
  132.     UINT                m_nTabFocusTimer;
  133.     CAnimationBar2*        m_pAnimation;
  134.     HTAB_BITMAP            m_eHTabType;
  135.     BOOL                m_bEraseBackground;
  136.     CString                m_tabTip;
  137.     int                    m_nToolID;
  138.     CNSToolTip2        m_toolTip;
  139.     UINT                m_nToolbarID;
  140. public:
  141.     CDragToolbar();
  142.     ~CDragToolbar();
  143.     int Create(CWnd *pParent, CToolbarWindow *pToolbar);
  144.  
  145.     CWnd *GetToolbar(void);
  146.     int   GetToolbarHeight(void);
  147.     int GetMouseOffsetWithinToolbar(void) { return m_mouseDownPoint.y; }
  148.     void SetMouseOffsetWithinToolbar(int y) { m_mouseDownPoint.y = y; }
  149.     void SetShowing(BOOL bIsShowing) { m_bIsShowing = bIsShowing; }
  150.     BOOL GetShowing(void) { return m_bIsShowing; }
  151.     void SetOpen(BOOL bIsOpen) { m_bIsOpen = bIsOpen; }
  152.     BOOL GetOpen(void) { return m_bIsOpen;}
  153.     void SetTabTip(CString tabTip); 
  154.     CString &GetTabTip (void) { return m_tabTip; }
  155.     void SetToolID(int nToolID) { m_nToolID = nToolID; }
  156.     int  GetToolID(void) { return m_nToolID;    }
  157.     void SetToolbarID(int nToolbarID) {m_nToolbarID = nToolbarID;}
  158.     UINT GetToolbarID(void) { return m_nToolbarID;}
  159.     void SetToolbarStyle(int nToolbarStyle);
  160.     void SetAnimation(CAnimationBar2 *pAnimation);
  161.     HTAB_BITMAP GetHTabType(void) { return m_eHTabType;}
  162.     void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  163.     // Generated message map functions
  164.     //{{AFX_MSG(CDragToolbar)
  165.     afx_msg void OnSize( UINT nType, int cx, int cy );
  166.     afx_msg void OnPaint(void);
  167.     afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
  168.     afx_msg BOOL OnEraseBkgnd( CDC* pDC );
  169.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  170.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  171.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  172.     virtual afx_msg void OnTimer( UINT  nIDEvent );
  173.     afx_msg void OnPaletteChanged( CWnd* pFocusWnd );
  174.     afx_msg void OnSysColorChange();
  175.     //}}AFX_MSG
  176.  
  177.  
  178. private:
  179.     void ArrangeToolbar(int nWidth, int nHeight);
  180.     void StopDragging(void);
  181.     void CheckIfMouseInTab(CPoint point);
  182.  
  183.  
  184.     DECLARE_MESSAGE_MAP()
  185.  
  186. };
  187.  
  188. class CCustToolbarExternalTab {
  189.  
  190. private:
  191.     CWnd *                m_pOwner;
  192.     HTAB_BITMAP            m_eHTabType;
  193.     CString                m_tabTip;
  194.     int                    m_nToolID;
  195.     UINT                m_nTabID;
  196.  
  197. public:
  198.     CCustToolbarExternalTab(CWnd *pOwner, HTAB_BITMAP eHTabType, UINT nTipID, UINT nTabID);
  199.  
  200.     CWnd *GetOwner(void);
  201.     HTAB_BITMAP GetHTabType(void);
  202.     CString &GetTabTip (void);
  203.     void SetToolID(int nToolID) { m_nToolID = nToolID; }
  204.     int  GetToolID(void) { return m_nToolID;    }
  205.     UINT GetTabID(void);
  206.  
  207.  
  208. };
  209.  
  210. class CLinkToolbar;
  211.  
  212. class CCustToolbar : public CControlBar {
  213.  
  214.  
  215. private:
  216.     CFrameWnd *            m_pParent;
  217.     CDragToolbar**        m_pToolbarArray;
  218.     CDragToolbar**        m_pHiddenToolbarArray;
  219.     int                    m_nNumToolbars;
  220.     int                    m_nActiveToolbars;
  221.     CAnimationBar2*        m_pAnimation;            //The Netscape Icon Animation
  222.     int                    m_nAnimationPos;
  223.     int                    m_nNumOpen;
  224.     int                    m_nNumShowing;
  225.     CPoint                m_oldDragPoint;
  226.     HBITMAP                m_pHorizTabArray[4];
  227.     BOOL                m_bEraseBackground;
  228.     CNSToolTip2            m_toolTip;
  229.     BOOL                m_bSaveToolbarInfo;        // Do we save toolbar state
  230.     UINT                m_nTabHaveFocusTimer;
  231.     int                    m_nMouseOverTab;
  232.     CPtrArray            m_externalTabArray;
  233.     BOOL                m_bBottomBorder;
  234.  
  235.     enum HORIZTAB {LARGE_FIRST, LARGE_OTHER, SMALL_FIRST, SMALL_OTHER};
  236.  
  237. public:
  238.  
  239.     //Construction/destruction
  240.     CCustToolbar(int nNumToolbars);
  241.     ~CCustToolbar(); 
  242.  
  243.         //Creation
  244.     int Create(CFrameWnd* pParent, BOOL bHasAnimation);
  245.  
  246.     void AddNewWindow(UINT nToolbarID, CToolbarWindow* pWindow,  int nPosition, int nNoviceHeight, int nAdvancedHeight,
  247.                       UINT nTabBitmapIndex, CString tabTip, BOOL bIsNoviceMode, BOOL bIsOpen,
  248.                       BOOL bIsAnimation);
  249.     // Call this function when you are finished adding the toolbars that go in the
  250.     // customizable toolbar. 
  251.     void FinishedAddingNewWindows(void){}
  252.  
  253.     //Controlling the animated icon
  254.     void StopAnimation();
  255.     void StartAnimation();
  256.     void SetToolbarStyle(int nToolbarStyle);
  257.  
  258.     BOOL IsWindowShowing(CWnd *pToolbar);
  259.     BOOL IsWindowShowing(UINT nToolbarID);
  260.  
  261.     BOOL IsWindowIconized(CWnd *pToolbar);
  262.     int     GetWindowPosition(CWnd *pToolbar);
  263.  
  264.     void ShowToolbar(CWnd *pToolbar, BOOL bShow);
  265.     void ShowToolbar(UINT nToolbarID, BOOL bShow);
  266.  
  267.     void RenameToolbar(UINT nOldID, UINT nNewID, UINT nNewToolTipID);
  268.  
  269.     CWnd *GetToolbar(UINT nToolbarID);
  270.  
  271.         //Positioning/Resizing
  272.     CSize CalcDynamicLayout(int nLength, DWORD dwMode );
  273.  
  274.     virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  275.  
  276.     void Customize(CLinkToolbar *pLinkToolbar = NULL, int nSelectedButton = 0);
  277.     BOOL GetSaveToolbarInfo(void);
  278.     void SetSaveToolbarInfo(BOOL bSaveToolbarInfo);
  279.     void SetNewParentFrame(CFrameWnd *pParent);
  280.  
  281.     // Adding an external tab will cause the customizable toolbar to display
  282.     // a tab of eHTabType in iconized form.  If that tab is clicked, the tab
  283.     // will be removed and a message will be sent to pOwner that the hidden
  284.     // window should now be shown.
  285.     void AddExternalTab(CWnd *pOwner, HTAB_BITMAP eHTabType, UINT nTipID, UINT nTabID);
  286.     // Removing this tab will cause it to no longer be drawn and mouse clicks will no longer
  287.     // be sent to pOwner.
  288.     void RemoveExternalTab(UINT nTabID);
  289.  
  290.     void SetBottomBorder(BOOL bBottomBorder);
  291.     // Generated message map functions
  292.     //{{AFX_MSG(CCustToolbar)
  293.     afx_msg void OnSize( UINT nType, int cx, int cy );
  294.     afx_msg void OnPaint(void);
  295.     afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
  296.     afx_msg BOOL OnEraseBkgnd( CDC* pDC );
  297.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  298.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  299.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  300.     afx_msg LRESULT OnHideToolbar(WPARAM, LPARAM); 
  301.     afx_msg LRESULT OnDragToolbar(WPARAM, LPARAM);
  302.     afx_msg LRESULT OnDragToolbarOver(WPARAM wParam, LPARAM lParam);
  303.     afx_msg LRESULT CCustToolbar::OnCustomize(WPARAM wParam, LPARAM lParam);
  304. #ifndef WIN32
  305.     afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam);
  306. #endif
  307.     virtual afx_msg void OnTimer( UINT  nIDEvent );
  308.     afx_msg void OnPaletteChanged( CWnd* pFocusWnd );
  309.  
  310.     //}}AFX_MSG
  311.  
  312. protected:
  313. //    virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult );
  314.  
  315.  
  316. private:
  317.     int  CheckOpenButtons(CPoint point);
  318.     int     CheckClosedButtons(CPoint point);
  319.     BOOL PointInClosedTab(CPoint point, HTAB_BITMAP tabType, int nNumClosedButtons, int nStartX,
  320.                           int nBottom);
  321.     void DrawSeparator(HDC hDC, int nStartX, int nEndX, int nStartY, BOOL bToolbarSeparator = TRUE);
  322.     void SwitchChildren(CDragToolbar *pOriginal, CDragToolbar *pSwitch, int dir, int yPoint);
  323.     int  FindIndex(CDragToolbar *pToolbar);
  324.     CDragToolbar *FindToolbarFromPoint(CPoint point, CDragToolbar *pIgnore);
  325.     int     FindFirstShowingToolbar(int nIndex);
  326.     HBITMAP GetClosedButtonBitmap(HTAB_BITMAP tabType, int nNumClosedButtons);
  327.     int  GetNextClosedButtonX(HTAB_BITMAP tabType, int nNumClosedButtons, int nClosedStartX);
  328.     void GetClosedButtonRegion(HTAB_BITMAP tabType, int nNumClosedButtons, CRgn &rgn);
  329.     HBITMAP CreateHorizTab(UINT nID);
  330.     int FindDragToolbarFromWindow(CWnd *pWindow, CDragToolbar **pToolbarArray);
  331.     int FindDragToolbarFromID(UINT nToolbarID, CDragToolbar **pToolbarArray);
  332.     void ShowDragToolbar(int nIndex, BOOL bShow);
  333.     void OpenDragToolbar(int nIndex);
  334.     void OpenExternalTab(int nIndex);
  335.     void CheckAnimationChangedToolbar(CDragToolbar *pToolbar, int nIndex, BOOL bOpen);
  336.     void ChangeToolTips(int nHeight);
  337.     void FindToolRect(CRect & toolRect, HTAB_BITMAP eTabType, int nStartX, int nStartY, int nButtonNum);
  338.     int  FindFirstAvailablePosition(void);
  339.     void DrawClosedTab(HDC hCompatibleDC, HDC hDestDC, HTAB_BITMAP tabType, int nNumClosedButtons,
  340.                          BOOL bMouseOver, int nStartX, int nBottom);
  341.  
  342.     DECLARE_MESSAGE_MAP()
  343.  
  344. };
  345.  
  346.  
  347. #endif
  348.