home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / BOCOLE.PAK / BOLEFONT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  5.4 KB  |  164 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectComponents
  3. // Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
  4. //
  5. // $Revision:   2.10  $
  6. //
  7. // Implements the Bolero versoin of the OLE2 font object.
  8. //----------------------------------------------------------------------------
  9. #ifndef _BOLEFONT_H
  10. #define _BOLEFONT_H 
  11.  
  12. #ifndef _BOLECOMP_H
  13. #include "BOleComp.h"
  14. #endif
  15.  
  16. #ifdef WIN32
  17. #define SETFONTSIZE(size, n)                { size.s.Lo = n##0000; size.s.Hi = 0; }
  18. #define XFERFONTSIZE(sizeout, sizein)       { sizeout.s.Lo = sizein.s.Lo; sizeout.s.Hi = sizein.s.Hi; }
  19. #define ISEQUALFONTSIZE(sizeout, sizein)    ((sizeout.s.Hi == sizein.s.Hi) && (sizein.s.Hi == sizein.s.Lo))
  20. #else
  21. #define SETFONTSIZE(size, n)                { size.Lo = n##0000; (size).Hi = 0; }
  22. #define XFERFONTSIZE(sizeout, sizein)       { sizeout.Lo = sizein.Lo; sizeout.Hi = sizein.Hi; }
  23. #define ISEQUALFONTSIZE(sizeout, sizein)    ((sizeout.Hi == sizein.Hi) && (sizein.Hi == sizein.Lo))
  24. #endif
  25.  
  26.  
  27. class _ICLASS BOleFontObj;
  28. class _ICLASS BEventList;
  29.  
  30. enum TFontStyle { fsBold=0x01, fsItalic=0x02, fsUnderline=0x04, 
  31.                   fsStrikeThrough=0x08 };
  32.  
  33. class _ICLASS BOleFont : public BOleComponent,   public IFont, 
  34.                          public IFontDisp,
  35.                          public IConnectionPointContainer
  36. {
  37. protected:
  38.   // next 5 members equivalent to FONTDESC struct
  39.   BSTR       bstrName;   
  40.   CY         height;
  41.   short      weight;
  42.   short      charSet;
  43.   int        style;  
  44.  
  45.   long       cyLogical;
  46.   long       cyHimetric;   
  47.   BOleFontObj *pF;
  48.   BOOL       modified;
  49.   ITypeLib   *pTL;
  50.   ITypeInfo  *pTI;
  51.   BEventList *pEventList; // ConnectionPoints list
  52.  
  53. public:
  54.    BOleFont (BOleClassManager *pF, IBUnknownMain * pO);
  55.    ~BOleFont ();
  56.  
  57.   // IUnknown Methods
  58.   //
  59.   DEFINE_IUNKNOWN(pObjOuter);
  60.   virtual HRESULT _IFUNC QueryInterfaceMain(REFIID iid, LPVOID FAR* pif);
  61.  
  62.   // IFont methods
  63.   //
  64.   // property support
  65.   HRESULT _IFUNC get_Name (BSTR FAR* pname);
  66.   HRESULT _IFUNC put_Name (BSTR name);
  67.   HRESULT _IFUNC get_Size (CY FAR* psize);
  68.   HRESULT _IFUNC put_Size (CY size);
  69.   HRESULT _IFUNC get_Bold (BOOL FAR* pbold);
  70.   HRESULT _IFUNC put_Bold (BOOL bold);
  71.   HRESULT _IFUNC get_Italic (BOOL FAR* pitalic);
  72.   HRESULT _IFUNC put_Italic (BOOL italic);
  73.   HRESULT _IFUNC get_Underline (BOOL FAR* punderline);
  74.   HRESULT _IFUNC put_Underline (BOOL underline);
  75.   HRESULT _IFUNC get_Strikethrough (BOOL FAR* pstrikethrough);
  76.   HRESULT _IFUNC put_Strikethrough (BOOL strikethrough);
  77.   HRESULT _IFUNC get_Weight (short FAR* pweight);
  78.   HRESULT _IFUNC put_Weight (short weight);
  79.   HRESULT _IFUNC get_Charset (short FAR* pcharset);
  80.   HRESULT _IFUNC put_Charset (short charset);
  81.  
  82.   // main functionality
  83.   // 
  84.   HRESULT _IFUNC get_hFont (HFONT FAR* phfont);                
  85.   HRESULT _IFUNC Clone (IFont FAR* FAR* lplpfont);             
  86.   HRESULT _IFUNC IsEqual (IFont FAR * lpFontOther);            
  87.   HRESULT _IFUNC SetRatio (long cyLogical, long cyHimetric);   
  88.   HRESULT _IFUNC QueryTextMetrics (LPTEXTMETRICOLE lptm);      
  89.   HRESULT _IFUNC AddRefHfont (HFONT hfont);                    
  90.   HRESULT _IFUNC ReleaseHfont (HFONT hfont);                   
  91.   HRESULT _IFUNC SetHdc (HDC hdc) { return ResultFromScode (E_NOTIMPL); }
  92.  
  93.  
  94.   // IDispatch methods
  95.   //
  96.   HRESULT _IFUNC GetTypeInfoCount (UINT FAR* pctinfo);
  97.   HRESULT _IFUNC GetTypeInfo (UINT itinfo, LCID lcid,          
  98.      ITypeInfo FAR* FAR* pptinfo);                     
  99.   HRESULT _IFUNC GetIDsOfNames (REFIID riid, LPOLESTR FAR* rgszNames,
  100.      UINT cNames, LCID lcid, DISPID FAR* rgdispid);
  101.   HRESULT _IFUNC Invoke (DISPID dispidMember, REFIID riid, LCID lcid,
  102.      WORD wFlags, DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
  103.      EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr);
  104.  
  105.   // IConnectionPointContainer methods 
  106.   // 
  107.   HRESULT _IFUNC EnumConnectionPoints (LPENUMCONNECTIONPOINTS FAR*);
  108.   HRESULT _IFUNC FindConnectionPoint (REFIID, LPCONNECTIONPOINT FAR*);
  109.  
  110.   // Other accessors
  111.   //
  112.   long getCyHimetric ()           { return cyHimetric; };
  113.   long getCyLogical ()            { return cyLogical; };
  114.   int  getStyle ()                { return style; };
  115.   BSTR getName ()                 { return bstrName; };
  116.  
  117. protected:
  118.   BOleFontObj *FindFontObj ();
  119.   BOleFontObj *FindFontObj (HFONT hFont);
  120.   BOOL         IsEqual (BOleFontObj FAR * pObj);
  121.   HRESULT      PropChanged (DISPID dispid);
  122.   HRESULT      PropRequestEdit (DISPID dispid);
  123. };
  124.  
  125.  
  126. class _ICLASS BOleFontObj : public BOleComponent
  127. {
  128. protected:
  129.   HFONT     hFont;
  130.   CY        height;
  131.   short     weight;
  132.   short     charSet;
  133.   int       style;  
  134.   BSTR      bstrName;   
  135.   long      cyLogical;
  136.   long      cyHimetric;   
  137.   BOleFontObj *pNext;
  138.   BOleFontObj *pPrev;
  139.   int       nRefs;  
  140.  
  141. public:
  142.    BOleFontObj (BOleClassManager *pF, IBUnknownMain * pO);
  143.    ~BOleFontObj ();
  144.  
  145.   BOOL SingleRef ()     { return (nRefs <= 1); };
  146.  
  147.   // IUnknown Methods
  148.   //
  149.   DEFINE_IUNKNOWN(pObjOuter);
  150.   ULONG _IFUNC AddRefMain();
  151.   ULONG _IFUNC ReleaseMain();
  152.  
  153.   HRESULT CreateHFont (BOleFont *pBF);
  154.  
  155.   void   SetPrev (BOleFontObj *pF)    { pPrev = pF; };
  156.   void   SetNext (BOleFontObj *pF)    { pNext = pF; };
  157.   BOleFontObj *GetPrev ()             { return pPrev; };
  158.   BOleFontObj *GetNext ()             { return pNext; };
  159.   friend BOleFont;  // access to object members
  160. };
  161.  
  162.  
  163. #endif 
  164.