home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / edcombtb.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.9 KB  |  206 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. // edcombtb.h : header file
  20. //
  21. //  Custom Toolbar class to facilitate using ComboBoxes in CToolBar type of toolbar
  22. //  
  23. //  Features:
  24. //    - Manages placement of CComboBox (or derived class) withing toolbar;
  25. //        (Owner creates the ComboBox(es) and manages messages)
  26. //    - Accessor functions are command ID - driven, rather than index into controll array
  27. //    - Easy to use Enable, SetCheck functions that redraw only when state changes
  28. //    - Allows user configuring: hiding controls with space compaction
  29. //      (relative position is cannot be changed, it just turn each on/off)
  30. //
  31. //  Owner must fill comboboxes and manage command messages
  32. //
  33. //  Created: 8/38/95 by Charles Manske
  34. //
  35. #ifdef EDITOR
  36. #ifndef _EDCOMBTB_H
  37. #define _EDCOMBTB_H
  38.  
  39. #include    "edres2.h"  // For IDD_CONFIG_COMBOBAR
  40.  
  41. #include "toolbar2.h"
  42.  
  43. #define     SEPARATOR_WIDTH     8   // 6-pixel gap + 2 for overlap
  44.  
  45. // Use this ID to place-hold for ComboBox in ID Array
  46. #define     ID_COMBOBOX         (UINT)-1
  47.  
  48. typedef struct _TB_CONTROLINFO {
  49.     UINT        nID;                // Button or combobox Command ID, or ID_SEPARATOR
  50.     BOOL        bIsButton;          // Test this for Check/Uncheck functions
  51.     BOOL        bDoOnButtonDown;    // Trigger action on button down (normal is button up)
  52.     int         nImageIndex;        // Relative to images in Bitmap (ignored for sep.,Combo)
  53.     int         nWidth;             // Width of separator or ComboBox
  54.     BOOL        bShow;              // If FALSE, control doesn't appear on toolbar
  55.     BOOL        bComboBox;          // TRUE if combobox
  56.     CComboBox * pComboBox;          // Must be supplied by owner of ComboBox
  57. } TB_CONTROLINFO, *LPTB_CONTROLINFO;
  58.  
  59. class CConfigComboBar;
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CComboToolBar window
  63.  
  64. class CComboToolBar : public CToolBar
  65. {
  66. // Construction
  67. public:
  68.     CComboToolBar();
  69.  
  70. // Attributes
  71. public:
  72.  
  73.     // Should be same as public CToolTar::m_nCount (includes separators)
  74.     // int               m_nItemCount;      
  75.     int               m_nButtonCount;
  76.     int               m_nComboBoxCount;
  77.     int               m_nControlCount;   // Count of buttons + comboboxes
  78.     CSize             m_sizeButton;
  79.  
  80.     LPTB_CONTROLINFO  m_pInfo;
  81.     SIZE              m_sizeImage;  // Size of 1 button image
  82.     UINT              m_nIDBitmap;
  83.  
  84. private:
  85.     UINT              m_nComboTop;
  86.     BOOL *            m_pEnableConfig;
  87.     CNSToolbar2*      m_pToolbar;
  88.  
  89. #ifdef XP_WIN16
  90.     CNSToolTip      * m_pToolTip;
  91. #endif
  92.  
  93. // Operations
  94. public:
  95.  
  96.     // Combination of CToolBar::Create(), LoadBitmap(), and SetButtons() 
  97.     //  Assumes docking at all sides if no comboxes, or just Top or Bottom if combobox(es) used.
  98.     //  If no nBitmapID, then only ComboBoxes in toolbar
  99.     //
  100.     //  lpIDArray is same as for CToolBar, and MUST be supplied,
  101.     //   But use ID_COMBOBOX to place-hold where comboboxes are desired
  102.     //
  103.     //  nIDCount must be >=1
  104.     //  All size values will assume Windows small-button guidelines defaults if 0
  105.     //
  106.     BOOL Create( BOOL bIsPageComposer, CWnd* pParent, UINT nIDBar, UINT nIDCaption,
  107.                  UINT * pIDArray, int nIDCount,      // Command ID array and count
  108.                  UINT nIDBitmap, SIZE sizeButton, SIZE sizeImage );
  109.  
  110.     // After creating toobar, call this to enable/disable action on button down
  111.     // Used primarily when action is creation of a CDropdownToolbar
  112.     void SetDoOnButtonDown( UINT nID, BOOL bSet );
  113.  
  114.     // After creating toobar, call this to set combobox command ID and its full size
  115.     //   (including dropdown height) of each combobox used
  116.     // If nHeight = 0, Height is calculated from number of items.
  117.     // Call in the same order as appearance in toolbar
  118.     void SetComboBox( UINT nID, CComboBox * pComboBox, UINT nWidth, UINT nListWidth, UINT nListHeight );
  119.     
  120.     // Get the rect of a button in screen coordinates
  121.     // Used primarily with CDropdownToolbar
  122.     BOOL GetButtonRect( UINT nID, RECT * pRect );
  123.     
  124.     // CToolBar has public GetCount() to return m_nCount
  125.     // inline UINT GetCount() { return m_nItemCount; }
  126.     inline UINT GetButtonCount() { return m_nButtonCount; }
  127.     inline UINT GetComboBoxCount() { return m_nComboBoxCount; }
  128.  
  129.     // These are better than CCmdUI versions because they
  130.     //   change state only if current state is different
  131.  
  132.     void EnableAll( BOOL bEnable );           // Enable/Disable all controls
  133.     void Enable( UINT nID, BOOL bEnable );    // or just one
  134.     void _Enable( int iIndex, BOOL bEnable ); // Index into array of all controls
  135.     
  136.     // Removes/Restores item from configure dialog
  137.     void EnableConfigure( UINT nID, BOOL bEnable );
  138.  
  139.     // iCheck: 0 = no, 1 = checked, 2 = indeterminate 
  140.     void SetCheck( UINT nID, int iCheck );  
  141.  
  142.     // Set all states with array of new values
  143.     void SetCheckAll( int *  pCheckArray );
  144.     
  145.     // SetCheck for just one item
  146.     void _SetCheck( int iIndex, int iCheck );
  147.  
  148.     // Supply an array of new Show states for ALL items
  149.     // must point to array of length m_nCount;
  150.     void ShowAll( BOOL * pShowArray );
  151.     void Show( UINT nID, BOOL bShow );              // or change just one control
  152.     void ShowByIndex( int iIndex, BOOL bShow );     // or one control using index
  153.     
  154.     // Allow user to select which controls to show/hide on the toolbar!
  155. //   void ConfigureToolBar(CWnd *pParent = NULL);
  156.  
  157.     // Get pointer to toolbar item info
  158.     inline LPTB_CONTROLINFO GetInfoPtr() { return m_pInfo; }
  159.  
  160.     // Use with GetWindowRect when real window
  161.     //  size is needed for docked toolbars
  162.     //  (GetWindowRect reports full client width if docked top/bottom,
  163.     //   or client height if docked on side).  If bCNSToolbar is true then include
  164.     // the CNSToolbar in the width.
  165.     int GetToolbarWidth(BOOL bCNSToolbar = TRUE);
  166.     //void GetToolbarWindowRect(RECT * pRect);
  167.  
  168.    // Used after changing Show state of 1 or more items 
  169.     //  to move comboboxes and adjust spacing
  170.     // Use nStart to recalc starting at the control just changed
  171.     // Win16: This MUST be called at least once after all comboboxes
  172.     //   are set and layout is final -- to assign Win16 tooltips
  173.     void RecalcLayout( int nStart = 0);
  174.  
  175.     // Set a child toolbar to appear on the right side of this toolbar
  176.     void SetCNSToolbar(CNSToolbar2 *pToolbar);
  177.  
  178.     // so we can pass this event on to the buttons
  179.     virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  180.  
  181.     // How big do we need to be
  182.     CSize CalcDynamicLayout(int nLength, DWORD dwMode );
  183.  
  184.  
  185. // Implementation
  186. public:
  187.     virtual ~CComboToolBar();
  188.  
  189.     // Generated message map functions
  190. protected:
  191. #ifdef XP_WIN16
  192.     BOOL PreTranslateMessage(MSG* pMsg);    // For tooltip message routing
  193. #endif
  194.     //{{AFX_MSG(CComboToolBar)
  195.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  196.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  197.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  198.     afx_msg void OnSize( UINT nType, int cx, int cy );
  199.     //}}AFX_MSG
  200.  
  201.     DECLARE_MESSAGE_MAP()
  202. };
  203.  
  204. #endif // _EDCOMBTB_H
  205. #endif // EDITOR
  206.