home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1994, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- /*************************************************************************
- *
- * WToolbar -- Wrapper for the Windows 95 Toolbar control.
- *
- * Events:
- *
- * Click --
- *
- * ToolbarDragBegin --
- *
- * ToolbarDragEnd --
- *
- *************************************************************************/
-
- #ifndef _WTOOLBAR_HPP_INCLUDED
- #define _WTOOLBAR_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WBITMAP_HPP_INCLUDED
- # include "wbitmap.hpp"
- #endif
- #ifndef _WCONTROL_HPP_INCLUDED
- # include "wcontrol.hpp"
- #endif
- #ifndef _WPOINT_HPP_INCLUDED
- # include "wpoint.hpp"
- #endif
- #ifndef _WWINDOW_HPP_INCLUDED
- # include "wwindow.hpp"
- #endif
- #ifndef _WVECTOR_HPP_INCLUDED
- # include "wvector.hpp"
- #endif
- #ifndef _WSIZE_HPP_INCLUDED
- # include "wsize.hpp"
- #endif
- #ifndef _WARRAY_HPP_INCLUDED
- # include "warray.hpp"
- #endif
-
- class WToolbar;
-
- typedef void WCMDEF (WObject::*WToolTipCallback)( WToolbar * w, WLong id, WString & str );
-
- enum WToolbarStandardBitmap {
- WTBStdBmpCut = 0,
- WTBStdBmpCopy = 1,
- WTBStdBmpPaste = 2,
- WTBStdBmpUndo = 3,
- WTBStdBmpRedo = 4,
- WTBStdBmpDelete = 5,
- WTBStdBmpFileNew = 6,
- WTBStdBmpFileOpen = 7,
- WTBStdBmpFileSave = 8,
- WTBStdBmpPrintPreview = 9,
- WTBStdBmpProperties = 10,
- WTBStdBmpHelp = 11,
- WTBStdBmpFind = 12,
- WTBStdBmpReplace = 13,
- WTBStdBmpPrint = 14,
- };
-
- enum WToolbarViewBitmap {
- WTBViewBmpLargeIcons = 0,
- WTBViewBmpSmallIcons = 1,
- WTBViewBmpList = 2,
- WTBViewBmpDetails = 3,
- WTBViewBmpSortName = 4,
- WTBViewBmpSortSize = 5,
- WTBViewBmpSortDate = 6,
- WTBViewBmpSortType = 7,
- WTBViewBmpParentFolder = 8,
- WTBViewBmpNetConnect = 9,
- WTBViewBmpNetDisconnect = 10,
- WTBViewBmpNewFolder = 11,
- };
-
- enum WToolbarItemStyle {
- WTBBPushButton = 0x00,
- WTBBSeparator = 0x01,
- WTBBCheckButton = 0x02,
- WTBBGroupButton = 0x04,
- WTBBCheckGroupButton = 0x06,
- };
-
- enum WToolbarItemHandle { NULLHTBITEM = 0, LASTHTBITEM = LAST_16TO32BIT };
-
- struct WToolbarEventData : public WEventData {
- WToolbarItemHandle item;
- };
-
- struct WToolbarDragBeginEventData : public WEventData {
- WToolbarItemHandle item;
- WWindow * over;
- };
-
- struct WToolbarDragEndEventData : public WEventData {
- WToolbarItemHandle item;
- WWindow * over;
- };
-
- class WCMCLASS WToolbarItemInfo {
-
- public:
-
- /**********************************************************
- * Constructors and Destructors
- *********************************************************/
-
- WToolbarItemInfo();
- WToolbarItemInfo( const WToolbarItemInfo & info );
-
- ~WToolbarItemInfo();
-
- /**********************************************************
- * Methods
- *********************************************************/
-
- void Init();
-
- /**********************************************************
- * Operators
- *********************************************************/
-
- WToolbarItemInfo& operator=( const WToolbarItemInfo & info );
-
- public:
-
- /**********************************************************
- * Data Members
- *********************************************************/
-
- WToolbarItemStyle style;
- WInt bitmapIndex;
- WInt stringIndex;
- WBool enabled;
- WBool checked;
- WBool pressed;
- WBool indeterminate;
- WBool hidden;
- WBool lineBreak;
- void * userData;
- WInt commandID;
- WBool inToolbar;
- WString text;
- WString toolTipText;
- };
-
- extern template WArrayReference<WToolbarItemInfo>;
- extern template WArray<WToolbarItemInfo>;
- typedef WArray<WToolbarItemInfo> WToolbarItemInfoArray;
-
- //
- // Toolbar styles
- //
-
- #define WTOOLBSDefault ((WStyle)0x50000271L) // WS_VISIBLE|WS_CHILD|CCS_NOHILITE|CCS_NODIVIDER|CCS_TOP|CCS_ADJUSTABLE
- #define WTOOLBSAltDrag ((WStyle)0x00000400L) // TBSTYLE_ALTDRAG
- #define WTOOLBSWrapable ((WStyle)0x00000200L) // TBSTYLE_WRAPABLE
- #define WTOOLBSToolTips ((WStyle)0x00000100L) // TBSTYLE_TOOLTIPS
- #define WTOOLBSMultiline ((WStyle)0x00000200L) // TBSTYLE_WRAPABLE
- #define WTOOLBSFlat ((WStyle)0x00000800L) // LBS_EXTENDEDSEL
- #define WTOOLBSExDefault ((WStyle)0x00000000L) // WS_OVERLAPPED
-
- class WCMCLASS WToolbar : public WControl {
- WDeclareSubclass( WToolbar, WControl );
-
- public:
-
- /**********************************************************
- * Constructors and Destructors
- *********************************************************/
-
- WToolbar();
-
- ~WToolbar();
-
- /**********************************************************
- * Properties
- *********************************************************/
-
- // AutoSize
-
- virtual WBool SetAutoSize( WBool on );
- virtual WBool GetAutoSize() const;
-
- // BitmapSize
- //
- // Note: Default size is 16x15
-
- WBool SetBitmapSize( const WSize & bitmapSize );
- WSize GetBitmapSize();
-
- // ButtonSize
- //
- // Note: Default size is 24x22
-
- WBool SetButtonSize( const WSize & buttonSize );
- WSize GetButtonSize( WBool calculate=TRUE );
-
- // Count
-
- WInt GetCount() const;
-
- // ToolTip
-
- virtual WToolTip * GetToolTip() const;
- virtual WBool SetToolTip( WToolTip * toolTip );
-
- /**********************************************************
- * Methods
- *********************************************************/
-
- // Add
-
- WToolbarItemHandle Add( WToolbarItemInfo & info, WInt index );
- WBool Add( WToolbarItemInfoArray & infoArray );
-
- // AddBitmap
-
- WBool AddBitmap( const WResourceID & bitmapID, WInt numBitmaps,
- WInt * index=NULL );
- WBool AddBitmap( const WBitmap & bitmap, WInt numBitmaps,
- WInt * index=NULL );
- WBool AddBitmap( WBool standard=TRUE, WBool large=TRUE,
- WInt * index=NULL );
-
- // AddBitmaps
-
- WBool AddBitmaps( const WResourceIDArray & bitmapIDArray,
- WIntArray * index=NULL );
- WBool AddBitmaps( const WBitmapArray & bitmapArray,
- WIntArray * index=NULL );
-
- // Change Bitmap
-
- WBool ChangeBitmap( WToolbarItemHandle item,
- WInt bitmapIndex );
-
- // AddString
-
- WBool AddString( const WString & text, WInt * index=NULL );
-
- // AutoSize
-
- virtual void AutoSize();
-
- // CalculateSize
-
- virtual WRect CalculateSize( const WRect & size, WBool adjust );
-
- // Customize
-
- void Customize();
-
- // Delete
-
- WBool Delete( WToolbarItemHandle item );
- WBool Delete( WInt index );
-
- // Hide
-
- WBool Hide( WToolbarItemHandle item );
-
- // Retrieve
-
- WToolbarItemHandle Retrieve( WInt index );
-
- // Show
-
- WBool Show( WToolbarItemHandle item );
-
- /**********************************************************
- * Item Properties
- *********************************************************/
-
- // ButtonStyle
-
- WToolbarItemStyle GetButtonStyle( WToolbarItemHandle item );
-
- // Checked
-
- WBool SetChecked( WToolbarItemHandle item, WBool checked=TRUE );
- WBool GetChecked( WToolbarItemHandle item );
-
- // Enabled
-
- WBool SetEnabled( WToolbarItemHandle item, WBool enable=TRUE );
- WBool GetEnabled( WToolbarItemHandle item );
-
- // Indeterminate
-
- WBool SetIndeterminate( WToolbarItemHandle item, WBool indeterminate=TRUE );
- WBool GetIndeterminate( WToolbarItemHandle item );
-
- // ItemInfo
-
- WToolbarItemInfo GetItemInfo( WToolbarItemHandle item ) const;
-
- // LineBreak
-
- WBool SetLineBreak( WToolbarItemHandle item, WBool lineBreak=FALSE );
- WBool GetLineBreak( WToolbarItemHandle item );
-
- // Pressed
-
- WBool SetPressed( WToolbarItemHandle item, WBool pressed=TRUE );
- WBool GetPressed( WToolbarItemHandle item );
-
- // Rectangle
-
- WRect GetRectangle( WToolbarItemHandle item );
-
- // UserData
- //
- // Get per-item data.
-
- void * GetUserData( WToolbarItemHandle item ) const;
-
- /**********************************************************
- * Overrides
- *********************************************************/
-
- virtual WBool SetEnabled( WBool enabled );
-
- virtual WBool GetEnabled() const;
-
- virtual WBool SetVisible( WBool visible );
-
- virtual WBool GetVisible() const;
-
- virtual WRect GetRectangle( WBool absolute=FALSE ) const;
-
- virtual WBool Move( const WRect & rectangle, WBool update=TRUE );
-
- virtual WBool Move( const WRect & rectangle, WDeferMoveHandle & dwp );
-
- virtual WBool Move( const WPoint & point, WBool update=TRUE );
-
- virtual WBool Move( const WPoint & point, WDeferMoveHandle & dwp );
-
- virtual WBool Update( WBool force=FALSE );
-
- virtual WBool SetParent( const WWindow * parent );
-
- virtual WWindow * GetParent() const;
-
- virtual void * GetUserData() const;
-
- virtual WStyle GetDefaultStyle() const;
-
- virtual WStyle GetDefaultExtendedStyle() const;
-
- virtual const WChar * InitializeClass();
-
- virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
- void * data=NULL );
-
- virtual WBool WantsDragMessage( WULong whichButton ) const;
- virtual WBool FillDragEventData( WDragEventData & event ) const;
-
- protected:
-
- virtual WBool ProcessCommand( WUInt id, WNotify code,
- WNotifyInfo info, WLong & returns );
-
- virtual WBool ProcessNotify( WUInt id, WNotify code, WNotifyInfo info,
- WLong & returns );
-
- virtual WBool MakeWindow( WWindow * parent, WUInt id,
- const WChar * className,
- const WChar * title, const WRect & r,
- WStyle wstyle, WStyle exStyle,
- void * data=NULL );
-
- /**********************************************************
- * Other
- *********************************************************/
-
- WBool GetLineBreakByIndex( WInt index );
-
- protected:
-
- WBool PositionChangingEventHandler( WWindow * window,
- WMoveEventData * event );
-
- WBool NeedToolTipTextEventHandler( WWindow * source,
- WToolTipTextEventData * event );
-
- WBool BackingNeedToolTipTextEventHandler( WWindow * source,
- WToolTipTextEventData * event );
-
- void MapFromToolbarItem( WToolbarItemInfo const * button,
- void * info ) const;
-
- void MapToToolbarItem( WToolbarItemInfo * button,
- void const * info ) const;
-
- void PrepareForCustomization();
-
- /**********************************************************
- * Data members
- *********************************************************/
-
- private:
-
- WToolbarItemHandle _lastCommandID;
- WBool _autoSize;
- WSize _bitmapSize;
- WSize _buttonSize;
- WULong _buttonCount;
- void * _internalData;
- WForm * _backing;
- WRect _lastCalcRequest;
- WRect _lastCalcResult;
- WBool _lastCalcAdjust;
- };
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WTOOLBAR_HPP_INCLUDED
-