home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WSPLITB.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  8KB  |  251 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.  * WSplitBar -- Wrapper for the Windows 95 SplitBar control.
  14.  *
  15.  *   Events:
  16.  *
  17.  *************************************************************************/
  18.  
  19. #ifndef _WSPLITB_HPP_INCLUDED
  20. #define _WSPLITB_HPP_INCLUDED
  21.  
  22. #ifndef _WNO_PRAGMA_PUSH
  23. #pragma pack(push,8);
  24. #pragma enum int;
  25. #endif
  26.  
  27. #ifndef _WPOINT_HPP_INCLUDED
  28. #  include "wpoint.hpp"
  29. #endif
  30. #ifndef _WCONTROL_HPP_INCLUDED
  31. #  include "wcontrol.hpp"
  32. #endif
  33.  
  34. enum WSplitDir {
  35.     WSplitHorizontal,
  36.     WSplitVertical,
  37. };
  38.  
  39. enum WSplitTrackingMode {
  40.     WSplitTrackingStretch,
  41.     WSplitTrackingSlide,
  42.     WSplitTrackingManual,
  43.     WSplitTrackingStatic
  44. };
  45.  
  46. struct WSplitRect {
  47.     WLong               left;
  48.     WLong               top;
  49.     WLong               right;
  50.     WLong               bottom;
  51. };
  52.  
  53. //
  54. // SplitBar styles
  55. //
  56.  
  57. #define WSplitDefault ((WStyle)0x50000001L) // WS_VISIBLE | WSPLIT_DRAWENDS | WS_CHILD | WSPLIT_DRAWBORDER
  58. #define WSPLIT_DRAWENDS 0x00000001L
  59. #define WSPLIT_BORDER   0x00000002L
  60.  
  61. #define WSplitDrawEnds ((WStyle)0x00000001L)    // WSPLIT_DRAWENDS
  62. #define WSplitBorder   ((WStyle)0x00000002L)    // WSPLIT_BORDER
  63.  
  64. class WCMCLASS WSplitBar: public WControl {
  65.     WDeclareSubclass( WSplitBar, WControl );
  66.  
  67.     public:
  68.     
  69.         /**************************************************************
  70.          * Contructors and destructors
  71.          **************************************************************/
  72.  
  73.         ~WSplitBar();
  74.  
  75.     protected:
  76.     
  77.         WSplitBar( WSplitDir dir,
  78.                    WSplitTrackingMode split=WSplitTrackingStretch );
  79.     
  80.     public:
  81.  
  82.         /**************************************************************
  83.          * Properties
  84.          **************************************************************/
  85.  
  86.         // Border
  87.  
  88.         WBool GetBorder() const;
  89.         WBool SetBorder( WBool on );
  90.  
  91.         // BottomOffset
  92.  
  93.         WUInt GetBottomOffset() const;
  94.         WBool SetBottomOffset( WUInt bottomOffset );
  95.  
  96.         // LeftOffset
  97.  
  98.         WUInt GetLeftOffset() const;
  99.         WBool SetLeftOffset( WUInt leftOffset );
  100.  
  101.         // RightOffset
  102.  
  103.         WUInt GetRightOffset() const;
  104.         WBool SetRightOffset( WUInt rightOffset );
  105.  
  106.         // TopOffset
  107.  
  108.         WUInt GetTopOffset() const;
  109.         WBool SetTopOffset( WUInt topOffset );
  110.  
  111.         // Direction
  112.  
  113.         virtual WSplitDir GetDirection() const;
  114.  
  115.         // DrawEnds
  116.  
  117.         WBool GetDrawEnds() const;
  118.         WBool SetDrawEnds( WBool drawEnds );
  119.  
  120.         // TrackingMode
  121.  
  122.         WSplitTrackingMode GetTrackingMode() const;
  123.         WBool              SetTrackingMode( WSplitTrackingMode mode );
  124.  
  125.         /**************************************************************
  126.          * Methods
  127.          **************************************************************/
  128.  
  129.         /**************************************************************
  130.          * Overrides
  131.          **************************************************************/
  132.  
  133.         virtual WBool ProcessMessage( const WMessage & msg,
  134.                                       WLong & returns );
  135.  
  136.         virtual const WChar * InitializeClass();
  137.  
  138.         virtual WBool LoadWindow( WWindow * parent,
  139.                                   const WResourceID & id,
  140.                                   WModuleHandle module=_ApplicationModule );
  141.  
  142.         /**************************************************************
  143.          * Event Handlers
  144.          **************************************************************/
  145.  
  146.     private:
  147.  
  148.         WBool OnDragFeedback( WWindow *, WDragEventData * event );
  149.  
  150.         WBool OnDragEnd( WWindow *, WDragEventData * event );
  151.  
  152.         WBool PaintHandler( WWindow * window, WPaintEventData * event );
  153.  
  154.         WBool MoveEventHandler( WWindow * window, WMoveEventData * event );
  155.  
  156.         /**************************************************************
  157.          * Others
  158.          **************************************************************/
  159.  
  160.     private:
  161.  
  162.         void MovePanes( const WPoint & diff, WBool stretch );
  163.  
  164.         WBool IsLeftPane( const WSplitRect & split, const WSplitRect & pane ) const;
  165.  
  166.         WBool IsRightPane( const WSplitRect & split, const WSplitRect & pane ) const;
  167.  
  168.         WBool IsTopPane( const WSplitRect & split, const WSplitRect & pane ) const;
  169.  
  170.         WBool IsBottomPane( const WSplitRect & split, const WSplitRect & pane ) const;
  171.  
  172.         /**************************************************************
  173.          * Data members
  174.          **************************************************************/
  175.  
  176.     private:
  177.     
  178.         WSplitTrackingMode  _trackingMode;
  179.         WSplitDir           _direction;
  180.         WPoint              _dragfrom;
  181.         WRect               _dragrect;
  182.         WRect               _savedpos;
  183.         WUInt               _topOffset;
  184.         WUInt               _bottomOffset;
  185.         WUInt               _leftOffset;
  186.         WUInt               _rightOffset;
  187. };
  188.     
  189. class WCMCLASS WVSplitBar : public WSplitBar {
  190.     WDeclareSubclass( WVSplitBar, WSplitBar );
  191.     
  192.     public:
  193.  
  194.         /**************************************************************
  195.          * Contructors and destructors
  196.          **************************************************************/
  197.  
  198.         WVSplitBar();
  199.  
  200.         ~WVSplitBar();
  201.     
  202.         /**************************************************************
  203.          * Properties
  204.          **************************************************************/
  205.  
  206.         /**************************************************************
  207.          * Methods
  208.          **************************************************************/
  209.  
  210.         /**************************************************************
  211.          * Overrides
  212.          **************************************************************/
  213.  
  214.         virtual WStyle GetDefaultStyle() const;
  215. };
  216.     
  217. class WCMCLASS WHSplitBar : public WSplitBar {
  218.     WDeclareSubclass( WHSplitBar, WSplitBar );
  219.     
  220.     public:
  221.     
  222.         /**************************************************************
  223.          * Contructors and destructors
  224.          **************************************************************/
  225.  
  226.         WHSplitBar();
  227.  
  228.         ~WHSplitBar();
  229.     
  230.         /**************************************************************
  231.          * Properties
  232.          **************************************************************/
  233.  
  234.         /**************************************************************
  235.          * Methods
  236.          **************************************************************/
  237.  
  238.         /**************************************************************
  239.          * Overrides
  240.          **************************************************************/
  241.  
  242.         virtual WStyle GetDefaultStyle() const;
  243. };
  244.     
  245. #ifndef _WNO_PRAGMA_PUSH
  246. #pragma enum pop;
  247. #pragma pack(pop);
  248. #endif
  249.  
  250. #endif // _WSPLITB_HPP_INCLUDED
  251.