home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WHEADER.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  7KB  |  217 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.  * WColumnHeading -- Wrapper for the Windows 95 Header control.
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Change -- Occurs whenever an item changes state (i.e., is
  19.  *                 selected/deselected).
  20.  *
  21.  *       Click -- When an item is clicked.
  22.  *
  23.  *       DoubleClick -- When an item is double-clicked.
  24.  *
  25.  *************************************************************************/
  26.  
  27. #ifndef _WHEADER_HPP_INCLUDED
  28. #define _WHEADER_HPP_INCLUDED
  29.  
  30. #ifndef _WNO_PRAGMA_PUSH
  31. #pragma pack(push,8);
  32. #pragma enum int;
  33. #endif
  34.  
  35. #ifndef _WCONTROL_HPP_INCLUDED
  36. #  include "wcontrol.hpp"
  37. #endif
  38. #ifndef _WWINDOW_HPP_INCLUDED
  39. #  include "wwindow.hpp"
  40. #endif
  41. #ifndef _WLLIST_HPP_INCLUDED
  42. #  include "wllist.hpp"
  43. #endif
  44.  
  45. class WColumnHeading;
  46.  
  47. enum WColumnHeadingItemType {
  48.     WColumnHeadingString,
  49.     WColumnHeadingBitmap
  50. };
  51.  
  52. enum WColumnHeadingAlignment {
  53.     WColumnHeadingLeft,
  54.     WColumnHeadingCenter,
  55.     WColumnHeadingRight
  56. };
  57.  
  58. enum WMouseButtonNumber {
  59.     WLeftMouseButton    = 0,
  60.     WRightMouseButton   = 1,
  61.     WMiddleMouseButton  = 2,
  62. };
  63.  
  64. enum WColumnHeadingHitTest {
  65.     WColumnHeadingHitTestNoWhere        = 0x0001,
  66.     WColumnHeadingHitTestOnHead         = 0x0002,
  67.     WColumnHeadingHitTestOnDivider      = 0x0004,
  68.     WColumnHeadingHitTestOnHiddenItem   = 0x0008,
  69.     WColumnHeadingHitTestAbove          = 0x0100,
  70.     WColumnHeadingHitTestBelow          = 0x0200,
  71.     WColumnHeadingHitTestToRight        = 0x0400,
  72.     WColumnHeadingHitTestToLeft         = 0x0800
  73. };
  74.  
  75. struct WColumnHeadingEventData : public WEventData {
  76.     WInt                itemNumber;
  77.     WMouseButtonNumber  buttonNumber;
  78. };
  79.  
  80. //
  81. // ColumnHeading styles
  82. //
  83.  
  84. #define WHSDefault              ((WStyle)0x50000002L) // WS_VISIBLE|WS_CHILD|HDS_HORZ|HDS_BUTTONS
  85. #define WHSHorizontal           ((WStyle)0x00000000L) // HDS_HORZ
  86. #define WHSButtons              ((WStyle)0x00000002L) // HDS_BUTTONS
  87. #define WHSHidden               ((WStyle)0x00000008L) // HDS_HIDDEN
  88.  
  89. class WCMCLASS WColumnHeading : public WControl {
  90.     WDeclareSubclass( WColumnHeading, WControl );
  91.  
  92.     public:
  93.     
  94.         /**********************************************************
  95.          * Constructors and Destructors
  96.          *********************************************************/
  97.  
  98.         WColumnHeading();
  99.     
  100.         ~WColumnHeading();
  101.  
  102.         /**********************************************************
  103.          * Properties
  104.          *********************************************************/
  105.  
  106.         // Count -- Gets the number of items in the header.
  107.  
  108.         WInt GetCount() const;
  109.  
  110.         /**********************************************************
  111.          * Methods
  112.          *********************************************************/
  113.  
  114.         // Add
  115.         //
  116.         //     Add a new item.  Items start at 0.  If you set itemNumber to
  117.         //     0, the new item is added at the beginning.  If you set
  118.         //     itemNumber to be greater than or equal to the number of items in
  119.         //     the control, the new item is added at the end.
  120.  
  121.         WInt Add( WInt itemNumber, WColumnHeadingItemType type,
  122.                   const WBitmapHandle & bmpHandle, const WChar * text,
  123.                   WLong width,
  124.                   WColumnHeadingAlignment align=WColumnHeadingLeft,
  125.                   void * data=NULL );
  126.  
  127.         WInt Add( WInt itemNumber, const WChar * text, WLong width,
  128.                          WColumnHeadingAlignment align=WColumnHeadingLeft,
  129.                          void * data=NULL );
  130.  
  131.         WInt Add( WInt itemNumber, const WBitmapHandle & bmpHandle,
  132.                   WLong width,
  133.                   WColumnHeadingAlignment align=WColumnHeadingLeft,
  134.                   void * data=NULL );
  135.  
  136.         // Delete
  137.         //
  138.         //     Delete an item.
  139.  
  140.         WBool Delete( WInt itemNumber );
  141.  
  142.         /**********************************************************
  143.          * Item Properties
  144.          *********************************************************/
  145.         // Retrive --  Get item number on base of point and 
  146.         //             if flags != 0 the additional info about
  147.         //             the hit test
  148.         //
  149.         WInt  Retrieve( const WPoint & point, WInt * flags = NULL ) const;
  150.         
  151.         // Alignment -- Gets/sets the alignment of the given column.
  152.         //              Choices are left, center or right.
  153.  
  154.         WBool SetAlignment( WInt itemNumber,
  155.                             WColumnHeadingAlignment alignment );
  156.         WColumnHeadingAlignment GetAlignment( WInt itemNumber ) const;
  157.  
  158.         // BitmapHandle -- Gets/sets the bitmap handle of the given column.
  159.         //              Choose NULLHBMP for no bitmap.
  160.  
  161.         WBool SetBitmapHandle( WInt itemNumber, WBitmapHandle bmpHandle );
  162.         WBitmapHandle GetBitmapHandle( WInt itemNumber ) const;
  163.  
  164.         // ColumnWidth -- Sets/gets the width of the given column.
  165.  
  166.         WBool SetColumnWidth( WInt itemNumber, WLong width );
  167.         WLong GetColumnWidth( WInt itemNumber ) const;
  168.  
  169.         // Text -- Gets/sets the caption of an item/subitem.  If no parm
  170.         //         is given, defaults to column 0 which is the item label.
  171.  
  172.         WBool SetText( WInt itemNumber, const WString & str );
  173.         WString GetText( WInt itemNumber ) const;
  174.  
  175.         // Type -- Gets/sets the type of the item, whether as a bitmap or
  176.         //         string.
  177.  
  178.         WBool SetType( WInt itemNumber, WColumnHeadingItemType type );
  179.         WColumnHeadingItemType GetType( WInt itemNumber ) const;
  180.  
  181.         // UserData -- Gets/sets the per-item data.
  182.  
  183.         WBool SetUserData( WInt itemNumber, void *itemUserData );
  184.         void * GetUserData( WInt itemNumber ) const;
  185.  
  186.         /**********************************************************
  187.          * Overrides
  188.          *********************************************************/
  189.  
  190.         virtual WBool SetText( const WString & str );
  191.  
  192.         virtual WString GetText() const;
  193.  
  194.         virtual WBool SetUserData( void * userData );
  195.  
  196.         virtual void * GetUserData() const;
  197.  
  198.         virtual const WChar * InitializeClass();
  199.  
  200.         virtual WStyle GetDefaultStyle() const;
  201.  
  202.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  203.                                    void * data=NULL );
  204.  
  205.     protected:
  206.         virtual WBool ProcessNotify( WUInt id, WNotify code, WNotifyInfo info,
  207.                                      WLong & returns );
  208.     
  209. };
  210.  
  211. #ifndef _WNO_PRAGMA_PUSH
  212. #pragma enum pop;
  213. #pragma pack(pop);
  214. #endif
  215.  
  216. #endif // _WHEADER_HPP_INCLUDED
  217.