home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ifont.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  8.6 KB  |  276 lines

  1. #ifndef _IFONT_
  2.   #define _IFONT_
  3. /*******************************************************************************
  4. * FILE NAME: IFONT.HPP                                                         *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IFont                                                                    *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #include <ivbase.hpp>
  19. #include <ihandle.hpp>
  20.  
  21. extern "C" {
  22.   extern void* __stdcall _IFontDlgProc( void*, unsigned long, void*, void* );
  23. }
  24.  
  25. class IString;
  26. class IWindow;
  27. class IFontDialog;
  28. class IPoint;
  29. class ISize;
  30. class IFontPrivateData;
  31. class IBidiSettings;
  32.  
  33. struct _FATTRS;
  34. struct _FONTMETRICS;
  35. struct tagLOGFONTA;
  36.  
  37. #pragma pack(4)
  38.  
  39. class IFont : public IVBase {
  40. typedef IVBase
  41.   Inherited;
  42. public:
  43. /*------------------------------- Constructors -------------------------------*/
  44.   IFont         (const IWindow* window = 0);
  45.  
  46.   IFont         (const char*    faceName,
  47.                  unsigned long  pointSize = 0,
  48.                  Boolean        useFixedFont = false,
  49.                  Boolean        useVectorFont = false,
  50.                  const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  51.  
  52.   IFont         (const IPresSpaceHandle& presSpaceHandle);
  53.  
  54.   IFont         (const IFont&            fntCopy);
  55.  
  56.   IFont&        operator=(const IFont&   font);
  57.  
  58. virtual
  59.  ~IFont         ( );
  60.  
  61. /*--------------------- Setting General Font Attributes ----------------------*/
  62. virtual IFont
  63.  &setName       (const char* name,
  64.                  const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  65.  &setPointSize  (unsigned long size,
  66.                  const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  67.  
  68. /*------------------- Setting Font Style -------------------------------------*/
  69. virtual IFont
  70.  &setUnderscore     (Boolean underscore = true),
  71.  &setStrikeout      (Boolean strikeout  = true),
  72.  &setOutline        (Boolean outline    = true),
  73.  &setBold           (Boolean bold       = true),
  74.  &setItalic         (Boolean italics    = true),
  75.  &setAllEmphasis    (Boolean turnOn     = true);
  76.  
  77. /*------------------- Getting Font Style -------------------------------------*/
  78. Boolean
  79.   isUnderscore      ( ) const,
  80.   isStrikeout       ( ) const,
  81.   isOutline         ( ) const,
  82.   isBold            ( ) const,
  83.   isItalic          ( ) const;
  84.  
  85. /*------------------------- Getting Font Attributes --------------------------*/
  86. Boolean
  87.   isBitmap          ( ) const,
  88.   isFixed           ( ) const;
  89.  
  90. IString
  91.   name              ( ) const;
  92.  
  93. unsigned long
  94.   pointSize         ( ) const;
  95.  
  96. /*------------------------ Setting Font Direction ----------------------------*/
  97. enum Direction {
  98.   defaultDir,
  99.   leftToRight,
  100.   topToBottom,
  101.   rightToLeft,
  102.   bottomToTop
  103. };
  104.  
  105. virtual IFont
  106.  &setDirection      (Direction direction);
  107.  
  108.  
  109. ISize
  110.   maxSize           ( ) const,
  111.   maxUppercaseSize  ( ) const;
  112.  
  113. unsigned long
  114.   charWidth         (char c) const,
  115.   textWidth         (const char* text) const,
  116.   textWidth         (const char* text, IBidiSettings& settings) const,
  117.   minTextWidth      (const char* line) const,
  118.   textLines         (const char* text,
  119.                      unsigned long lineWidth) const,
  120.   maxAscender       ( ) const,
  121.   maxDescender      ( ) const,
  122.   internalLeading   ( ) const,
  123.   externalLeading   ( ) const,
  124.   maxCharHeight     ( ) const,
  125.   avgCharWidth      ( ) const;
  126.  
  127.  
  128. /*---------------------- Setting Window Font ---------------------------------*/
  129. virtual Boolean
  130.   setWindowFont    (IWindow* window) const;
  131.  
  132. /*--------------------- Setting Vector Font Attributes -----------------------*/
  133. virtual IFont
  134.  &setCharWidth   (unsigned long width,
  135.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  136.  &setCharHeight  (unsigned long height,
  137.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  138.  &setCharSize    (const ISize& size,
  139.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  140.  &setFontAngle   (const IPoint& point,
  141.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  142.  &setFontShear   (const IPoint& point,
  143.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  144.  
  145. /*--------------------- Drawing Functions ------------------------------------*/
  146. virtual IFont
  147.  &beginUsingFont     (const IPresSpaceHandle& presSpaceHandle),
  148.  &endUsingFont       (const IPresSpaceHandle& presSpaceHandle);
  149.  
  150. /*-------------------------------- Font Types --------------------------------*/
  151. virtual IFont
  152.  &useNonPropOnly  (Boolean nonProportionalOnly = true,
  153.                    const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  154.  &useBitmapOnly   (Boolean bitmapOnly = true,
  155.                    const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  156.  &useVectorOnly   (Boolean vectorOnly = true,
  157.                    const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  158.  
  159. Boolean
  160.   isNonPropOnly    () const,
  161.   isBitmapOnly     () const,
  162.   isVectorOnly     () const;
  163.  
  164. /*---------- Accessing Presentation Manager Structures Related to Font -------*/
  165.  
  166. const struct tagLOGFONTA
  167.  *logfont     () const;
  168.  
  169.  
  170. class FaceNameCursor : public IVBase {
  171. public:
  172. /*-------------------------------- Font Type ---------------------------------*/
  173. enum FontType
  174. {
  175.   bitmap,
  176.   vector,
  177.   both
  178. };
  179.  
  180. /*------------------------------- Constructors -------------------------------*/
  181.   FaceNameCursor (FontType fontType = both,
  182.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  183. virtual
  184.  ~FaceNameCursor ( );
  185.  
  186. /*-------------------------------- Overrides ---------------------------------*/
  187. virtual Boolean
  188.   setToFirst    ( ),
  189.   setToNext     ( ),
  190.   setToPrevious ( ),
  191.   setToLast     ( ),
  192.   isValid       ( ) const;
  193.  
  194. virtual void
  195.   invalidate    ( );
  196.  
  197. private:
  198. /*--------------------------------- Private ----------------------------------*/
  199. unsigned
  200.   index,
  201.   count;
  202. IString
  203.  *facenames;
  204. friend class IFont;
  205. };  //FaceNameCursor
  206.  
  207.  
  208. class PointSizeCursor : public IVBase {
  209. public:
  210. /*------------------------------- Constructors -------------------------------*/
  211.   PointSizeCursor(const char* facename,
  212.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  213. virtual
  214.  ~PointSizeCursor ( );
  215.  
  216. /*-------------------------------- Overrides ---------------------------------*/
  217. virtual Boolean
  218.   setToFirst    ( ),
  219.   setToNext     ( ),
  220.   setToPrevious ( ),
  221.   setToLast     ( ),
  222.   isValid       ( ) const;
  223.  
  224. virtual void
  225.   invalidate    ( );
  226.  
  227. private:
  228. /*--------------------------------- Private ----------------------------------*/
  229. friend class IFont;
  230.  
  231. unsigned
  232.   index,
  233.   count;
  234. long
  235.  *pointsizes;
  236. };  //PointSizeCursor
  237.  
  238. /*---------------------- Cursor Related Functions ----------------------------*/
  239. static IString
  240.   faceNameAt( const FaceNameCursor& faceNameCursor );
  241.  
  242. static long
  243.   pointSizeAt( const PointSizeCursor& pointSizeCursor );
  244.  
  245.  
  246. private:
  247. /*--------------------------------- Private ----------------------------------*/
  248. IFontPrivateData
  249.  *ppd;
  250.  
  251. IFont
  252.  &initialize     (const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle()),
  253.  ©Private( );
  254.  
  255. IFont
  256.  &makeFontMetrics(const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle(),
  257.                   Boolean fUpdateCharSet = true ),
  258.  &fontChanged    (),
  259.  &mustUseVector  (Boolean fDoIt = true),
  260.  &setFontFromDialog (IFontDialog& fontDlg,
  261.                   const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle());
  262.  
  263.  
  264. friend void* __stdcall
  265.   _IFontDlgProc( void*         hwnd,
  266.                  unsigned long msg,
  267.                  void*         mp1,
  268.                  void*         mp2 );
  269.  
  270.  
  271. }; //IFont
  272.  
  273. #pragma pack()
  274.  
  275. #endif /* _IFONT_ */
  276.