home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WTABCTRL.HPP < prev    next >
C/C++ Source or Header  |  1996-10-28  |  9KB  |  278 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WTabControl -- Wrapper for the Windows 95 TabControl.
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Select --
  19.  *
  20.  *       SelectChanging --
  21.  *
  22.  *************************************************************************/
  23.  
  24. #ifndef _WTABCTRL_HPP_INCLUDED
  25. #define _WTABCTRL_HPP_INCLUDED
  26.  
  27. #ifndef _WNO_PRAGMA_PUSH
  28. #pragma pack(push,8);
  29. #pragma enum int;
  30. #endif
  31.  
  32. #ifndef _WCONTROL_HPP_INCLUDED
  33. #  include "wcontrol.hpp"
  34. #endif
  35. #ifndef _WVECTOR_HPP_INCLUDED
  36. #  include "wvector.hpp"
  37. #endif
  38. #ifndef _WSIZE_HPP_INCLUDED
  39. #  include "wsize.hpp"
  40. #endif
  41. #ifndef _WIMGLIST_HPP_INCLUDED
  42. #  include "wimglist.hpp"
  43. #endif  
  44.  
  45. //
  46. // TabControl styles
  47. //
  48.  
  49. #define WTCSDefault            ((WStyle)0x54001200L) // WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|TCS_MULTILINE|TCS_FOCUSONBUTTONDOWN|TCS_TABS
  50. #define WTCSSingleline         ((WStyle)0x00000000L) // TCS_SINGLELINE
  51. #define WTCSTabs               ((WStyle)0x00000000L) // TCS_TABS
  52. #define WTCSRightJustify       ((WStyle)0x00000000L) // TCS_RIGHTJUSTIFY
  53. #define WTCSForceIconLeft      ((WStyle)0x00000010L) // TCS_FORCEICONLEFT
  54. #define WTCSForceLabelLeft     ((WStyle)0x00000020L) // TCS_FORCELABELLEFT
  55. #define WTCSShareImageLists    ((WStyle)0x00000040L) // TCS_SHAREIMAGELISTS
  56. #define WTCSButtons            ((WStyle)0x00000100L) // TCS_BUTTONS
  57. #define WTCSMultiline          ((WStyle)0x00000200L) // TCS_MULTILINE
  58. #define WTCSFixedWidth         ((WStyle)0x00000400L) // TCS_FIXEDWIDTH
  59. #define WTCSRaggedRight        ((WStyle)0x00000800L) // TCS_RAGGEDRIGHT
  60. #define WTCSFocusOnButtonDown  ((WStyle)0x00001000L) // TCS_FOCUSONBUTTONDOWN
  61. #define WTCSOwnerDrawFixed     ((WStyle)0x00002000L) // TCS_OWNERDRAWFIXED
  62. #define WTCSToolTips           ((WStyle)0x00004000L) // TCS_TOOLTIPS
  63. #define WTCSFocusNever         ((WStyle)0x00008000L) // TCS_FOCUSNEVER
  64.  
  65. #define WTCHTNowhere            0x0001
  66. #define WTCHTOnItemIcon         0x0002
  67. #define WTCHTOnItemLabel        0x0004
  68. #define WTCHTOnItem             0x0006
  69.  
  70. struct WTabControlEventData : public WEventData {
  71.     WLong         newID;
  72.     WLong         oldID;
  73. };
  74.  
  75. class WTabControl;
  76. class WToolTip;
  77.  
  78. class WCMCLASS WTabControl : public WControl {
  79.     WDeclareSubclass( WTabControl, WControl );
  80.  
  81.     public:
  82.  
  83.         /**********************************************************
  84.          * Constructors and destructors
  85.          *********************************************************/
  86.  
  87.         WTabControl();
  88.     
  89.         ~WTabControl();
  90.     
  91.         /**********************************************************
  92.          * Properties
  93.          *********************************************************/
  94.  
  95.         // Count
  96.         //
  97.         //     Retrieves the number of items.
  98.  
  99.         WShort GetCount() const;
  100.  
  101.         // Selected
  102.         //
  103.         //     Sets/gets the item which is currently selected.
  104.  
  105.         WLong GetSelected();
  106.         WBool SetSelected( WLong id );
  107.  
  108.         // TabHeight
  109.  
  110.         WLong  GetTabHeight();
  111.         WBool SetTabHeight( WLong tabHeight );
  112.  
  113.         // TabSize
  114.  
  115.         WSize GetTabSize();
  116.         WBool SetTabSize( const WSize & tabSize );
  117.  
  118.         // TabWidth
  119.  
  120.         WLong  GetTabWidth();
  121.         WBool SetTabWidth( WLong tabWidth );
  122.  
  123.         /**********************************************************
  124.          * Methods
  125.          *********************************************************/
  126.  
  127.         // Add
  128.         //
  129.         //     Add a new item. Autosize is currently unused.
  130.  
  131.         WLong Add( WLong id, const WChar * text, WInt imageIndex,
  132.                    WBool autoSize=TRUE, void *itemData=NULL );
  133.         WLong Add( WLong id, const WChar * text, WBool autoSize=TRUE,
  134.                    void *itemData=NULL );
  135.         WLong Add( WLong id, WInt imageIndex, WBool autoSize=TRUE,
  136.                    void *itemData=NULL );
  137.  
  138.         // Retrieve
  139.         //
  140.         //     Hit test
  141.         
  142.         WLong Retrieve( const WPoint & pt, WLong * flags=NULL );
  143.  
  144.         // Delete
  145.         //
  146.         //     Delete an item.  Important to note is that windows attached
  147.         //     to the item via SetWindow() are NOT destroyed by this call
  148.         //     unless the selfDelete parameter is set to TRUE
  149.  
  150.         WBool Delete( WLong id );
  151.  
  152.         // DeleteAll
  153.         //
  154.         //     Delete all items in the control.
  155.         //     c.f. Delete
  156.  
  157.         WBool DeleteAll();
  158.  
  159.         // AdjustRect
  160.         //
  161.         //     Adjust the given rectangle.  If wantSmaller is set to TRUE,
  162.         //     this maps the supplied WRect from the tab control to a page
  163.         //     or tab on the tab control.  The mapping is reversed if
  164.         //     wantSmaller is set to FALSE.
  165.  
  166.         void AdjustRect( WBool wantSmaller, WRect & rect );
  167.  
  168.         /**********************************************************
  169.          * Item Properties
  170.          *********************************************************/
  171.  
  172.         // ImageList
  173.  
  174.         WBool SetImageList(WImageList * il);
  175.         WImageList *  GetImageList () const;
  176.         
  177.         // ImageIndex
  178.  
  179.         WBool SetImageIndex( WLong itemNumber, WInt imageIndex );
  180.         WInt GetImageIndex( WLong itemNumber );
  181.  
  182.         // RealUserData
  183.  
  184.         void * GetRealUserData( WLong itemNumber );
  185.  
  186.         // Rectangle
  187.  
  188.         WRect GetRectangle( WLong itemNumber );
  189.  
  190.         // Text 
  191.  
  192.         WBool SetText( WLong itemNumber, const WString & str );
  193.         WString GetText( WLong itemNumber );
  194.     
  195.         // UserData
  196.  
  197.         WBool  SetUserData( WLong itemNumber, void * itemUserData );
  198.         void * GetUserData( WLong itemNumber );
  199.  
  200.         // Window
  201.  
  202.         WBool SetWindow( WLong itemNumber, WWindow * win,
  203.                          WBool relativePos=TRUE, WBool adjustSize=TRUE,
  204.                          WBool selfDelete=FALSE );
  205.         WWindow * GetWindow( WLong itemNumber );
  206.  
  207.         /**********************************************************
  208.          * Overrides
  209.          *********************************************************/
  210.  
  211.         virtual WBool SetText( const WString & text );
  212.  
  213.         virtual WString GetText() const;
  214.  
  215.         virtual WToolTip * GetToolTip() const;
  216.  
  217.         virtual WBool SetToolTip( WToolTip * toolTip );
  218.  
  219.         virtual WBool SetUserData( void * userData );
  220.  
  221.         virtual void * GetUserData() const;
  222.  
  223.         virtual const WChar * InitializeClass();
  224.  
  225.         virtual WStyle GetDefaultStyle() const;
  226.  
  227.         virtual WStyle GetDefaultExtendedStyle() const;
  228.  
  229.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  230.                                    void * data=NULL );
  231.  
  232.         virtual WRect GetRectangle( WBool absolute=FALSE ) const;
  233.  
  234.     protected:
  235.  
  236.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  237.                                   const WChar * className,
  238.                                   const WChar * title, const WRect & r,
  239.                                   WStyle wstyle, WStyle exStyle,
  240.                                   void * data=NULL );
  241.  
  242.         virtual WBool ProcessNotify( WUInt id, WNotify code,
  243.                                      WNotifyInfo info, WLong & returns );
  244.     
  245.         /**********************************************************
  246.          * Event handlers
  247.          *********************************************************/
  248.  
  249.     protected:
  250.  
  251.         WBool MoveEventHandler( WWindow * window,
  252.                                 WMoveEventData * event );
  253.  
  254.         WBool ResizeEventHandler( WWindow * window,
  255.                                   WResizeEventData * event );
  256.  
  257.         WBool DestroyEventHandler( WWindow * window, WEventData * event );
  258.  
  259.         WBool NeedToolTipTextEventHandler( WWindow * source,
  260.                                            WToolTipTextEventData * event );
  261.  
  262.         /**********************************************************
  263.          * Data members
  264.          *********************************************************/
  265.  
  266.     private:
  267.  
  268.         WInt                    _lastId;
  269.         WImageList *            _imageList;
  270. };
  271.  
  272. #ifndef _WNO_PRAGMA_PUSH
  273. #pragma enum pop;
  274. #pragma pack(pop);
  275. #endif
  276.  
  277. #endif // _WTABCTRL_HPP_INCLUDED
  278.