home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WDATANAV.HPP < prev    next >
C/C++ Source or Header  |  1997-01-23  |  8KB  |  283 lines

  1. /*************************************************************************
  2.  *
  3.  * WDataNavigator 
  4.  *
  5.  *   Events:
  6.  *
  7.  *       DataAvailable --
  8.  *
  9.  *       DataClose --
  10.  *
  11.  *       DataOpen --
  12.  *
  13.  *       DataRequest --
  14.  *
  15.  *************************************************************************/
  16.  
  17. #ifndef _WDATANAV_HPP_INCLUDED
  18. #define _WDATANAV_HPP_INCLUDED
  19.  
  20. #ifndef _WNO_PRAGMA_PUSH
  21. #pragma pack(push,8);
  22. #pragma enum int;
  23. #endif
  24.  
  25. #ifndef _WWINDOW_HPP_INCLUDED
  26. #  include "wwindow.hpp"
  27. #endif
  28. #ifndef _WCONTROL_HPP_INCLUDED
  29. #  include "wcontrol.hpp"
  30. #endif
  31. #ifndef _WDATATRG_HPP_INCLUDED
  32. #  include "wdatatrg.hpp"
  33. #endif
  34. #ifndef _WDATASRC_HPP_INCLUDED
  35. #  include "wdatasrc.hpp"
  36. #endif
  37.  
  38. enum WDNAction {
  39.     WDNActionNone,
  40.     WDNActionMoveFirst,
  41.     WDNActionMoveLast
  42. };
  43.  
  44. //
  45. // DataNavigator styles
  46. //
  47.  
  48. #define WDNSDefault             ((WStyle)0x50000000L) // WS_VISIBLE|WS_CHILD
  49.  
  50. class WCMCLASS WDataNavigator : public WControl {
  51.     WDeclareSubclass( WDataNavigator, WControl );
  52.  
  53.     public:
  54.     
  55.         /***************************************************************
  56.          * Constructors and Destructors
  57.          ***************************************************************/
  58.  
  59.         WDataNavigator();
  60.     
  61.         ~WDataNavigator();
  62.  
  63.         /***************************************************************
  64.          * Properties
  65.          ***************************************************************/
  66.  
  67.         // BOFAction
  68.         //
  69.         //    Determines what to do when the cursor is moved to the
  70.         //    beginning of the query.
  71.  
  72.         WDNAction GetBOFAction() const;
  73.         WBool     SetBOFAction( WDNAction action );
  74.  
  75.         // DataSource
  76.         //
  77.         //    The data source to track.
  78.  
  79.         WDataSource *GetDataSource() const;
  80.         WBool        SetDataSource( WDataSource *source );
  81.  
  82.         // EOFAction
  83.         //
  84.         //    Determines what to do when the cursor is moved to the
  85.         //    end of the query.
  86.  
  87.         WDNAction GetEOFAction() const;
  88.         WBool     SetEOFAction( WDNAction action );
  89.  
  90.         // KeepFocus
  91.         //
  92.         //    If TRUE, the focus stays on a button when the user
  93.         //    clicks on it, otherwise it returns to where it came
  94.         //    from.
  95.  
  96.         WBool GetKeepFocus() const;
  97.         WBool SetKeepFocus( WBool keep );
  98.  
  99.         // ShowAdd
  100.         //
  101.         //    Show the Add button.
  102.  
  103.         WBool GetShowAdd() const;
  104.         WBool SetShowAdd( WBool show );
  105.  
  106.         // ShowCancel
  107.         //
  108.         //    Show the cancel button.
  109.  
  110.         WBool GetShowCancel() const;
  111.         WBool SetShowCancel( WBool show );
  112.  
  113.         // ShowDelete
  114.         //
  115.         //    Show the delete button.
  116.  
  117.         WBool GetShowDelete() const;
  118.         WBool SetShowDelete( WBool show );
  119.  
  120.         // ShowEdit
  121.         //
  122.         //    Show the edit button.
  123.  
  124.         WBool GetShowEdit() const;
  125.         WBool SetShowEdit( WBool show );
  126.  
  127.         // ShowMoveFirst
  128.         //
  129.         //    Show the movefirst button.
  130.  
  131.         WBool GetShowMoveFirst() const;
  132.         WBool SetShowMoveFirst( WBool show );
  133.  
  134.         // ShowMoveLast
  135.         //
  136.         //    Show the movelast button.
  137.  
  138.         WBool GetShowMoveLast() const;
  139.         WBool SetShowMoveLast( WBool show );
  140.  
  141.         // ShowMoveNext
  142.         //
  143.         //    Show the movenext button.
  144.  
  145.         WBool GetShowMoveNext() const;
  146.         WBool SetShowMoveNext( WBool show );
  147.  
  148.         // ShowMovePrevious
  149.         //
  150.         //   Show the moveprevious button.
  151.  
  152.         WBool GetShowMovePrevious() const;
  153.         WBool SetShowMovePrevious( WBool show );
  154.  
  155.         // ShowRefresh
  156.         //
  157.         //   Show the refresh button.
  158.  
  159.         WBool GetShowRefresh() const;
  160.         WBool SetShowRefresh( WBool show );
  161.  
  162.         // ShowSearch
  163.         //
  164.         //   Show the search button.
  165.  
  166.         WBool GetShowSearch() const;
  167.         WBool SetShowSearch( WBool show );
  168.  
  169.         // ShowTooltips
  170.         //
  171.         //   Show the tooltips.
  172.  
  173.         WBool GetShowTooltips() const;
  174.         WBool SetShowTooltips( WBool show );
  175.  
  176.         // ShowUpdate
  177.         //
  178.         //   Show the update button.
  179.  
  180.         WBool GetShowUpdate() const;
  181.         WBool SetShowUpdate( WBool show );
  182.  
  183.         /***************************************************************
  184.          * Methods
  185.          ***************************************************************/
  186.  
  187.         /***************************************************************
  188.          * Overrides
  189.          ***************************************************************/
  190.  
  191.         virtual WStyle GetDefaultStyle() const;
  192.         virtual WStyle GetDefaultExtendedStyle() const;
  193.         virtual const WChar * InitializeClass();
  194.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  195.                                    void *data );
  196.  
  197.         WBool GetShowState( int ) const;
  198.         WBool SetShowState( int, WBool );
  199.  
  200.         /***************************************************************
  201.          * Event Handlers
  202.          ***************************************************************/
  203.  
  204.     protected:
  205.         WLong WhichButton( const WPoint & pt, WRect *r=NULL );
  206.  
  207.         WBool SizeChangingHandler( WDataNavigator *, WResizeEventData * );
  208.         WBool ResizeHandler( WDataNavigator *, WResizeEventData * );
  209.         WBool EraseBackgroundHandler( WDataNavigator *, WEventData * );
  210.         WBool PaintHandler( WDataNavigator *, WPaintEventData * );
  211.         WBool LeftButtonDownHandler( WDataNavigator * window,
  212.                                      WMouseEventData * event );
  213.         WBool LeftButtonUpHandler( WDataNavigator * window,
  214.                                      WMouseEventData * event );
  215.         WBool MouseMoveHandler( WDataNavigator *, WMouseEventData *event );
  216.  
  217.         WBool DataOpenHandler( WDataNavigator *, WDataOpenEventData *ev );
  218.         WBool DataCloseHandler( WDataNavigator *, WDataCloseEventData *ev );
  219.         WBool DataAvailableHandler( WDataNavigator *, WDataAvailableEventData *ev );
  220.  
  221.         WBool AdjustCursorHandler( WDataNavigator *, WAdjustCursorEventData * );
  222.         WBool DestroyEventHandler( WDataNavigator *, WEventData * );
  223.  
  224.         /***************************************************************
  225.          * Internal
  226.          ***************************************************************/
  227.  
  228.     public:
  229.  
  230.         enum WDNButton {
  231.             WDNButtonMoveFirst,
  232.             WDNButtonMovePrevious,
  233.             WDNButtonMoveNext,
  234.             WDNButtonMoveLast,
  235.             WDNButtonAdd,
  236.             WDNButtonDelete,
  237.             WDNButtonEdit,
  238.             WDNButtonUpdate,
  239.             WDNButtonCancel,
  240.             WDNButtonRefresh,
  241.             WDNButtonSearch,
  242.         
  243.             WDNButtonLastPlusOne
  244.         };
  245.         
  246.     protected:
  247.  
  248.         struct ButtonInfo {
  249.             WBool    visible;
  250.             WBool    enabled;
  251.             WBool    selected;
  252.             WShort   horizID;
  253.             WShort   vertID;
  254.             WString *tooltip;
  255.         };
  256.  
  257.         void DrawButton( ButtonInfo & b, WRect rcItem, WDisplayCanvas *canvas );
  258.         void RedrawButton( WLong which );
  259.         void UpdateButtons( WULong ev );
  260.         void DeleteToolTip();
  261.  
  262.         ButtonInfo   _buttons[ WDNButtonLastPlusOne ];
  263.         WUShort      _numVisible;
  264.         WBitmap      _bitmap;
  265.         WDataTarget *_dataTarget;
  266.         WBool        _keepFocus;
  267.         WBool        _vertical;
  268.         WDNAction    _bofAction;
  269.         WDNAction    _eofAction;
  270.         WBool        _redo;
  271.         WLong        _which;
  272.         WShort       _lastX;
  273.         WShort       _lastY;
  274.         WBool        _showTooltips;
  275. };
  276.  
  277. #ifndef _WNO_PRAGMA_PUSH
  278. #pragma enum pop;
  279. #pragma pack(pop);
  280. #endif
  281.  
  282. #endif // _WDATANAV_HPP_INCLUDED
  283.