home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WDRAW.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  10KB  |  341 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. #ifndef _WDRAW_HPP_INCLUDED
  12. #define _WDRAW_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WVECTOR_HPP_INCLUDED
  20. #  include "wvector.hpp"
  21. #endif
  22. #ifndef _WCANVAS_HPP_INCLUDED
  23. #  include "wcanvas.hpp"
  24. #endif
  25.  
  26. struct WPaintEventData;
  27. class WWindow;
  28.  
  29. // Note:  While this is in fact inherited from a WCanvas, it does so
  30. //        only so that the appropriate properties can be set.
  31.  
  32. class WCMCLASS WDrawPrimitive : public WCanvas {
  33.  
  34.     public:
  35.  
  36.         /**********************************************************
  37.          * Constructors and Destructors
  38.          *********************************************************/
  39.  
  40.         WDrawPrimitive();
  41.  
  42.         ~WDrawPrimitive();
  43.  
  44.         /**********************************************************
  45.          * Properties
  46.          *********************************************************/
  47.  
  48.         /**********************************************************
  49.          * Methods
  50.          *********************************************************/
  51.  
  52.         virtual WBool Draw( WCanvas * canvas );
  53.  
  54.         /**********************************************************
  55.          * Others
  56.          *********************************************************/
  57. };
  58.  
  59. extern template WVector<WDrawPrimitive>;
  60.  
  61. class WCMCLASS WDrawPrimitiveGroup : public WObject {
  62.  
  63.     public:
  64.  
  65.         /**********************************************************
  66.          * Constructors and Destructors
  67.          *********************************************************/
  68.  
  69.         WDrawPrimitiveGroup( WWindow *drawWindow=NULL );
  70.  
  71.         ~WDrawPrimitiveGroup();
  72.  
  73.         /**********************************************************
  74.          * Properties
  75.          *********************************************************/
  76.  
  77.         WWindow *GetDrawWindow() const;
  78.         WBool    SetDrawWindow( WWindow *drawWindow );
  79.  
  80.         /**********************************************************
  81.          * Methods
  82.          *********************************************************/
  83.  
  84.         // AddDrawPrimitive
  85.  
  86.         void AddDrawPrimitive( WDrawPrimitive * drawPrimitive );
  87.  
  88.         // RemoveDrawPrimitive
  89.  
  90.         void RemoveDrawPrimitive( WDrawPrimitive * drawPrimitive );
  91.  
  92.         /**********************************************************
  93.          * Others
  94.          *********************************************************/
  95.  
  96.         WBool PaintEventHandler( WWindow * window, WPaintEventData * event );
  97.  
  98.         /**********************************************************
  99.          * Data Members
  100.          *********************************************************/
  101.  
  102.     private:
  103.  
  104.         WWindow *                       _drawWindow;
  105.         WVector< WDrawPrimitive >       _drawPrimitives;
  106. };
  107.  
  108. class WCMCLASS WDrawRectangle : public WDrawPrimitive {
  109.  
  110.     public:
  111.  
  112.         /**********************************************************
  113.          * Constructors and Destructors
  114.          *********************************************************/
  115.  
  116.         WDrawRectangle();
  117.  
  118.         WDrawRectangle( const WRect & rect, WBool fill );
  119.  
  120.         ~WDrawRectangle();
  121.  
  122.         /**********************************************************
  123.          * Properties
  124.          *********************************************************/
  125.  
  126.         // Fill
  127.  
  128.         WBool GetFill() const;
  129.         WBool SetFill( WBool fill );
  130.  
  131.         // Rectangle
  132.  
  133.         WRect GetRectangle() const;
  134.         WBool SetRectangle( const WRect & rect );
  135.  
  136.         /**********************************************************
  137.          * Methods
  138.          *********************************************************/
  139.  
  140.         /**********************************************************
  141.          * Overrides
  142.          *********************************************************/
  143.  
  144.         virtual WBool Draw( WCanvas * canvas );
  145.  
  146.         /**********************************************************
  147.          * Data Members
  148.          *********************************************************/
  149.  
  150.     private:
  151.  
  152.         WRect                   _rect;
  153.         WBool                   _fill;
  154. };
  155.  
  156. class WCMCLASS WDrawEllipse : public WDrawPrimitive {
  157.  
  158.     public:
  159.  
  160.         /**********************************************************
  161.          * Constructors and Destructors
  162.          *********************************************************/
  163.  
  164.         WDrawEllipse();
  165.  
  166.         WDrawEllipse( const WRect & rect, WBool fill );
  167.  
  168.         ~WDrawEllipse();
  169.  
  170.         /**********************************************************
  171.          * Properties
  172.          *********************************************************/
  173.  
  174.         // Fill
  175.  
  176.         WBool GetFill() const;
  177.         WBool SetFill( WBool fill );
  178.  
  179.         // Rectangle
  180.  
  181.         WRect GetRectangle() const;
  182.         WBool SetRectangle( const WRect & rect );
  183.  
  184.         /**********************************************************
  185.          * Methods
  186.          *********************************************************/
  187.  
  188.         /**********************************************************
  189.          * Overrides
  190.          *********************************************************/
  191.  
  192.         virtual WBool Draw( WCanvas * canvas );
  193.  
  194.         /**********************************************************
  195.          * Data Members
  196.          *********************************************************/
  197.  
  198.     private:
  199.  
  200.         WRect                   _rect;
  201.         WBool                   _fill;
  202. };
  203.  
  204. class WCMCLASS WDrawLine : public WDrawPrimitive {
  205.  
  206.     public:
  207.  
  208.         /**********************************************************
  209.          * Constructors and Destructors
  210.          *********************************************************/
  211.  
  212.         WDrawLine();
  213.  
  214.         WDrawLine( const WPoint & endPoint );
  215.         WDrawLine( const WPoint & startPoint, const WPoint & endPoint );
  216.  
  217.         ~WDrawLine();
  218.  
  219.         /**********************************************************
  220.          * Properties
  221.          *********************************************************/
  222.  
  223.         // EndPoint
  224.  
  225.         WPoint GetEndPoint() const;
  226.         WBool  SetEndPoint( const WPoint & endPoint );
  227.  
  228.         // StartPoint
  229.  
  230.         WPoint GetStartPoint() const;
  231.         WBool  SetStartPoint( const WPoint & startPoint );
  232.  
  233.         // UseStartPoint
  234.  
  235.         WBool GetUseStartPoint() const;
  236.         WBool SetUseStartPoint( WBool useStartPoint );
  237.  
  238.         /**********************************************************
  239.          * Methods
  240.          *********************************************************/
  241.  
  242.         /**********************************************************
  243.          * Overrides
  244.          *********************************************************/
  245.  
  246.         virtual WBool Draw( WCanvas * canvas );
  247.  
  248.         /**********************************************************
  249.          * Data Members
  250.          *********************************************************/
  251.  
  252.     private:
  253.  
  254.         WPoint                  _startPoint;
  255.         WPoint                  _endPoint;
  256.         WBool                   _useStartPoint;
  257. };
  258.  
  259. class WCMCLASS WDrawText : public WDrawPrimitive {
  260.  
  261.     public:
  262.  
  263.         /**********************************************************
  264.          * Constructors and Destructors
  265.          *********************************************************/
  266.  
  267.         WDrawText();
  268.  
  269.         WDrawText( const WChar * string, WInt numChars=-1 );
  270.         WDrawText( const WPoint & pt, const WChar * string,
  271.                    WInt numChars=-1 );
  272.         WDrawText( const WRect & rect, const WChar * string,
  273.                    WInt numChars=-1, WULong flags=WDrawTextDefault );
  274.  
  275.         ~WDrawText();
  276.  
  277.         /**********************************************************
  278.          * Properties
  279.          *********************************************************/
  280.  
  281.         // DrawPosition
  282.         //
  283.         //     Note: DrawPosition is mutually exclusive with DrawRectangle
  284.  
  285.         WPoint GetDrawPosition() const;
  286.         WBool  SetDrawPosition( const WPoint & drawPosition );
  287.  
  288.         // DrawRectangle
  289.         //
  290.         //     Note: DrawRectangle is mutually exclusive with DrawPosition
  291.  
  292.         WRect GetDrawRectangle() const;
  293.         WBool SetDrawRectangle( const WRect & drawRectangle );
  294.  
  295.         // Flags
  296.  
  297.         WULong GetFlags() const;
  298.         WBool  SetFlags( WULong flags=WDrawTextDefault );
  299.  
  300.         // NumCharacters
  301.  
  302.         WInt  GetNumCharacters() const;
  303.         WBool SetNumCharacters( WInt numChars=-1 );
  304.  
  305.         // Text
  306.  
  307.         const WChar *GetText() const;
  308.         WBool        SetText( const WChar * text );
  309.  
  310.         /**********************************************************
  311.          * Methods
  312.          *********************************************************/
  313.  
  314.         /**********************************************************
  315.          * Overrides
  316.          *********************************************************/
  317.  
  318.         virtual WBool Draw( WCanvas * canvas );
  319.  
  320.         /**********************************************************
  321.          * Data Members
  322.          *********************************************************/
  323.  
  324.     private:
  325.  
  326.         const WChar *           _string;
  327.         WInt                    _numChars;
  328.         WULong                  _flags;
  329.         WPoint                  _drawPosition;
  330.         WRect                   _drawRect;
  331.         WBool                   _usePos;
  332.         WBool                   _useRect;
  333. };
  334.  
  335. #ifndef _WNO_PRAGMA_PUSH
  336. #pragma enum pop;
  337. #pragma pack(pop);
  338. #endif
  339.  
  340. #endif // _WDRAW_HPP_INCLUDED
  341.