home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WOLEFONT.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  8KB  |  265 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 _WOLEFONT_HPP_INCLUDED
  12. #define _WOLEFONT_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WOLEAUTO_HPP_INCLUDED
  20. #   include "woleauto.hpp"
  21. #endif
  22. #ifndef _WDSPHLPR_HPP_INCLUDED
  23. #   include "wdsphlpr.hpp"
  24. #endif
  25. #ifndef _WFONT_HPP_INCLUDED
  26. #   include "wfont.hpp"
  27. #endif
  28.  
  29. #ifndef _WIN16
  30. #undef CreateFont
  31. #undef CreateFontIndirect
  32. #ifdef _UNICODE
  33. #define CreateFont         CreateFontW
  34. #define CreateFontIndirect CreateFontIndirectW
  35. #else
  36. #define CreateFont         CreateFontA
  37. #define CreateFontIndirect CreateFontIndirectA
  38. #endif
  39. #endif
  40.  
  41. /* tmPitchAndFamily flags */
  42. #define WTMPF_FIXED_PITCH       0x01
  43. #define WTMPF_VECTOR            0x02
  44. #define WTMPF_DEVICE            0x08
  45. #define WTMPF_TRUETYPE          0x04
  46.  
  47. typedef struct WTextMetricOLE {
  48.     WLong       tmHeight;
  49.     WLong       tmAscent;
  50.     WLong       tmDescent;
  51.     WLong       tmInternalLeading;
  52.     WLong       tmExternalLeading;
  53.     WLong       tmAveCharWidth;
  54.     WLong       tmMaxCharWidth;
  55.     WLong       tmWeight;
  56.     WLong       tmOverhang;
  57.     WLong       tmDigitizedAspectX;
  58.     WLong       tmDigitizedAspectY;
  59.     long char   tmFirstChar;
  60.     long char   tmLastChar;
  61.     long char   tmDefaultChar;
  62.     long char   tmBreakChar;
  63.     WByte       tmItalic;
  64.     WByte       tmUnderlined;
  65.     WByte       tmStruckOut;
  66.     WByte       tmPitchAndFamily;
  67.     WByte       tmCharSet;
  68. } WTextMetricOLE;
  69.  
  70. typedef struct WOleFontDesc {
  71.     WString     name;
  72.     WCurrency   size;
  73.     WShort      weight;
  74.     WShort      charset;
  75.     WBool       italic;
  76.     WBool       underline;
  77.     WBool       strikethrough;
  78. } WOleFontDesc;
  79.  
  80. /*************************************************************************
  81.  *
  82.  * WFontDisp -- Standard OLE Font type dispatch helper
  83.  *
  84.  *
  85.  *   Events:
  86.  *
  87.  *
  88.  *************************************************************************/
  89.  
  90. class WCMCLASS WFontDisp : public WOleDispatchHelper {
  91.  
  92.     public:
  93.  
  94.         /**********************************************************
  95.          * Constructors and Destructors
  96.          *********************************************************/
  97.  
  98.         WFontDisp( WPIDispatch pIDispatch=NULL, WBool release=TRUE,
  99.                    WBool initMembers=TRUE );
  100.         WFontDisp( const WFontDisp & fontDisp );
  101.         ~WFontDisp();
  102.  
  103.     public:
  104.  
  105.         /**********************************************************
  106.          * Properties
  107.          *********************************************************/
  108.  
  109.         // Name
  110.         WString GetName( void );
  111.         WBool SetName( const WString & name );
  112.  
  113.         // Size
  114.         WCurrency GetSize( void );
  115.         WBool SetSize( const WCurrency & size );
  116.  
  117.         // Bold
  118.         WVARIANT_BOOL GetBold( void );
  119.         WBool SetBold( WVARIANT_BOOL bold );
  120.  
  121.         // Italic
  122.         WVARIANT_BOOL GetItalic( void );
  123.         WBool SetItalic( WVARIANT_BOOL italic );
  124.  
  125.         // Underline
  126.         WVARIANT_BOOL GetUnderline( void );
  127.         WBool SetUnderline( WVARIANT_BOOL underline );
  128.  
  129.         // Strikethrough
  130.         WVARIANT_BOOL GetStrikethrough( void );
  131.         WBool SetStrikethrough( WVARIANT_BOOL strikethrough );
  132.  
  133.         // Weight
  134.         WShort GetWeight( void );
  135.         WBool SetWeight( WShort weight );
  136.  
  137.         WShort GetCharset( void );
  138.         WBool SetCharset( WShort charset );
  139.  
  140.         /**************************************************************
  141.          * Operators
  142.          **************************************************************/
  143.  
  144.         WFontDisp & operator=( const WFontDisp & fontDisp );
  145.  
  146.         /**********************************************************
  147.          * Data
  148.          *********************************************************/
  149. };
  150.  
  151. /*************************************************************************
  152.  *
  153.  * WIFont -- Standard OLE Font type
  154.  *
  155.  *
  156.  *   Events:
  157.  *
  158.  *
  159.  *************************************************************************/
  160.  
  161. class WCMCLASS WIFont : public WObject {
  162.     WDeclareSubclass( WIFont, WObject );
  163.  
  164.     public:
  165.  
  166.         /**********************************************************
  167.          * Constructors and Destructors
  168.          *********************************************************/
  169.  
  170.         WIFont();
  171.         WIFont( WPIFont ifont );
  172.         WIFont( const WIFont & ifont );
  173.         WIFont( const WOleFontDesc & fd );
  174.         WIFont( const WFont & font );
  175.         virtual ~WIFont();
  176.  
  177.     public:
  178.  
  179.         /**************************************************************
  180.          * Properties
  181.          **************************************************************/
  182.  
  183.         // Name
  184.         WString GetName( void ) const;
  185.         WBool SetName( const WString & name);
  186.  
  187.         // Size
  188.         WCurrency GetSize( void ) const;
  189.         WBool SetSize( const WCurrency & size );
  190.  
  191.         // Bold
  192.         WBool GetBold( void ) const;
  193.         WBool SetBold( WBool bold );
  194.  
  195.         // Italic
  196.         WBool GetItalic( void ) const;
  197.         WBool SetItalic( WBool italic );
  198.  
  199.         // Underline
  200.         WBool GetUnderline( void ) const;
  201.         WBool SetUnderline( WBool underline );
  202.  
  203.         // Strikethrough
  204.         WBool GetStrikethrough( void ) const;
  205.         WBool SetStrikethrough( WBool strikethrough );
  206.  
  207.         // Weight
  208.         WShort GetWeight( void ) const;
  209.         WBool SetWeight( WShort weight );
  210.  
  211.         // Charset
  212.         WShort GetCharset( void ) const;
  213.         WBool SetCharset( WShort charset );
  214.  
  215.         // Hdc
  216.         WBool SetHdc( WDeviceHandle hdc);
  217.  
  218.         WPIFont GetIFont( void ) const;
  219.         WPIDispatch GetIDispatch( void ) const;
  220.         WFontDisp GetFontDisp( void ) const;
  221.  
  222.         /**********************************************************
  223.          * Methods
  224.          *********************************************************/
  225.  
  226.         static WIFont *CreateFont( void );
  227.         static WIFont *CreateFontIndirect( const WOleFontDesc & fd );
  228.  
  229.         // IFont Methods
  230.         WBool Clone( WIFont & newFont );
  231.         WBool IsEqual( const WIFont & otherFont );
  232.         WBool QueryTextMetrics( WTextMetricOLE & ptm );
  233.         WBool AddRefHfont( WFontHandle hfont );
  234.         WBool ReleaseHfont( WFontHandle hfont );
  235.  
  236.         /**********************************************************
  237.          * Item Properties
  238.          *********************************************************/
  239.  
  240.         WBool GethFont( WFontHandle & phfont );
  241.         WBool SetRatio( WLong cyLogical, WLong cyHimetric );
  242.  
  243.         /**************************************************************
  244.          * Operators
  245.          **************************************************************/
  246.  
  247.         WIFont & operator=( const WIFont & font );
  248.  
  249.  
  250.     /**********************************************************
  251.      * Data Members
  252.      *********************************************************/
  253.     
  254.     private:
  255.         WPIFont _ifont;
  256. };
  257.  
  258. #ifndef _WNO_PRAGMA_PUSH
  259. #pragma enum pop;
  260. #pragma pack(pop);
  261. #endif
  262.  
  263. #endif // _WOLEFONT_HPP_INCLUDED
  264.  
  265.