home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WWELL.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  7KB  |  222 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.  * WWell -- Wrapper for the Windows 95 Well control.
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Click --
  19.  *
  20.  *       DrawItem --
  21.  *
  22.  *       Select --
  23.  *
  24.  *************************************************************************/
  25.  
  26. #ifndef _WWELL_HPP_INCLUDED
  27. #define _WWELL_HPP_INCLUDED
  28.  
  29. #ifndef _WNO_PRAGMA_PUSH
  30. #pragma pack(push,8);
  31. #pragma enum int;
  32. #endif
  33.  
  34. #ifndef _WPOINT_HPP_INCLUDED
  35. #  include "wpoint.hpp"
  36. #endif
  37. #ifndef _WRECT_HPP_INCLUDED
  38. #  include "wrect.hpp"
  39. #endif
  40. #ifndef _WDRAWITM_HPP_INCLUDED
  41. #  include "wdrawitm.hpp"
  42. #endif
  43. #ifndef _WCONTROL_HPP_INCLUDED
  44. #  include "wcontrol.hpp"
  45. #endif
  46.  
  47. //
  48. // WWell styles
  49. //
  50.  
  51. #define WWellDefault    ((WStyle)0x50000000L) // WS_VISIBLE | WS_CHILD
  52.  
  53. class WCMCLASS WWell: public WControl {
  54.     WDeclareSubclass( WWell, WControl );
  55.  
  56.         /**************************************************************
  57.          * Contructors and destructors
  58.          **************************************************************/
  59.  
  60.     public:
  61.     
  62.         WWell();  // 4x4 well
  63.         WWell( WUInt numColumns, WUInt numRows );
  64.  
  65.         ~WWell();
  66.  
  67.         /**************************************************************
  68.          * Properties
  69.          **************************************************************/
  70.  
  71.         // ColumnCount
  72.  
  73.         WUInt         GetColumnCount() const;
  74.         virtual WBool SetColumnCount( WUInt numColumns );
  75.  
  76.         // RowCount
  77.  
  78.         WUInt         GetRowCount() const;
  79.         virtual WBool SetRowCount( WUInt numRows );
  80.  
  81.         // Selected
  82.         //
  83.         //     Note:  item.x represents the column,
  84.         //            item.y represents the row
  85.  
  86.         WBool  SetSelected( const WPoint & item, WBool redraw=TRUE );
  87.         WPoint GetSelected() const;
  88.  
  89.         // TrackMouse
  90.  
  91.         WBool GetTrackMouse() const;
  92.         WBool SetTrackMouse( WBool trackMouse );
  93.  
  94.         /**************************************************************
  95.          * Methods
  96.          **************************************************************/
  97.  
  98.         // CalculateIdealHeight
  99.  
  100.         WUInt CalculateIdealHeight( WUInt itemHeight );
  101.  
  102.         // CalculateIdealWidth
  103.  
  104.         WUInt CalculateIdealWidth( WUInt itemWidth );
  105.  
  106.         /**************************************************************
  107.          * Others
  108.          **************************************************************/
  109.  
  110.     public:
  111.  
  112.         WBool PaintHandler( WWindow * window, WPaintEventData * event );
  113.  
  114.         WBool PositionChangedEventHandler( WWell * window,
  115.                                            WMoveEventData * event );
  116.  
  117.         WBool MouseMoveEventHandler( WWell * window,
  118.                                      WMouseEventData * event );
  119.  
  120.         WBool LeftButtonDownEventHandler( WWell * window,
  121.                                           WMouseEventData * event );
  122.  
  123.         WBool KeyDownEventHandler( WWell * window,
  124.                                    WKeyPressEventData * event );
  125.  
  126.         WBool CharacterPressEventHandler( WWell * window,
  127.                                           WCharacterPressEventData * event );
  128.  
  129.     private:
  130.  
  131.         virtual WStyle GetDefaultStyle() const;
  132.  
  133.         virtual WULong GetDialogCode( WUInt wParam = 0, WLong lParam = 0 );
  134.  
  135.         void SetEvents();
  136.  
  137.         /**************************************************************
  138.          * Data members
  139.          **************************************************************/
  140.  
  141.     protected:
  142.  
  143.         WUInt                   _numColumns;
  144.         WUInt                   _numRows;
  145.         WUInt                   _selectedItem;
  146.         WBool                   _trackMouse;
  147. };
  148.  
  149. class WCMCLASS WColorWell : public WWell {
  150.     WDeclareSubclass( WColorWell, WWell );
  151.  
  152.         /**************************************************************
  153.          * Contructors and destructors
  154.          **************************************************************/
  155.  
  156.     public:
  157.     
  158.         WColorWell(); // 4x4 well
  159.         WColorWell( WUInt numColumns, WUInt numRows );
  160.  
  161.         ~WColorWell();
  162.  
  163.         /**************************************************************
  164.          * Properties
  165.          **************************************************************/
  166.  
  167.         // ResetColorsOnSizeChange
  168.  
  169.         WBool GetResetColorsOnSizeChange() const;
  170.         WBool SetResetColorsOnSizeChange( WBool resetOnChange );
  171.  
  172.         /**************************************************************
  173.          * Methods
  174.          **************************************************************/
  175.  
  176.         // ResetMonochromeColors
  177.  
  178.         WBool ResetMonochromeColors( WBool repaint=TRUE );
  179.  
  180.         // ResetColors
  181.  
  182.         WBool ResetColors( WBool repaint=TRUE );
  183.  
  184.         /**************************************************************
  185.          * Item Properties
  186.          **************************************************************/
  187.  
  188.         // Color
  189.  
  190.         WColor GetColor( WInt itemNumber );
  191.         WBool  SetColor( WInt itemNumber, const WColor & color,
  192.                          WBool repaint=FALSE );
  193.  
  194.         /**************************************************************
  195.          * Others
  196.          **************************************************************/
  197.  
  198.         virtual WBool SetRowCount( WUInt numRows );
  199.         virtual WBool SetColumnCount( WUInt numColumns );
  200.  
  201.     private:
  202.  
  203.         WBool DrawItemEventHandler( WWell * window,
  204.                                     WDrawItemEventData * event );
  205.  
  206.         /**************************************************************
  207.          * Data members
  208.          **************************************************************/
  209.  
  210.     private:
  211.  
  212.         WColor *                _colorArray;
  213.         WBool                   _resetOnChange;
  214. };
  215.     
  216. #ifndef _WNO_PRAGMA_PUSH
  217. #pragma enum pop;
  218. #pragma pack(pop);
  219. #endif
  220.  
  221. #endif // _WWELL_HPP_INCLUDED
  222.