X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..75ded4d17344618afd302a0671f1277791ee17ed:/include/wx/os2/font.h?ds=sidebyside diff --git a/include/wx/os2/font.h b/include/wx/os2/font.h index aff8fb3a75..7060847d66 100644 --- a/include/wx/os2/font.h +++ b/include/wx/os2/font.h @@ -1,89 +1,143 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: font.h +// Name: wx/os2/font.h // Purpose: wxFont class -// Author: AUTHOR +// Author: David Webster // Modified by: -// Created: ??/??/98 +// Created: 10/06/99 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Copyright: (c) David Webster +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_FONT_H_ #define _WX_FONT_H_ -#ifdef __GNUG__ -#pragma interface "font.h" -#endif - #include "wx/gdiobj.h" +#include "wx/os2/private.h" -class WXDLLEXPORT wxFont; +WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxEmptyString; -class WXDLLEXPORT wxFontRefData: public wxGDIRefData -{ - friend class WXDLLEXPORT wxFont; -public: - wxFontRefData(); - wxFontRefData(const wxFontRefData& data); - ~wxFontRefData(); -protected: - int m_pointSize; - int m_family; - int m_style; - int m_weight; - bool m_underlined; - wxString m_faceName; -/* TODO: implementation - WXHFONT m_hFont; -*/ -}; - -#define M_FONTDATA ((wxFontRefData *)m_refData) - -WXDLLEXPORT_DATA(extern const char*) wxEmptyString; - -// Font -class WXDLLEXPORT wxFont: public wxGDIObject +// ---------------------------------------------------------------------------- +// wxFont +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxFont : public wxFontBase { - DECLARE_DYNAMIC_CLASS(wxFont) public: - wxFont(); - wxFont(int pointSize, int family, int style, int weight, bool underlined = FALSE, const wxString& faceName = wxEmptyString); - inline wxFont(const wxFont& font) { Ref(font); } - - ~wxFont(); - - bool Create(int pointSize, int family, int style, int weight, bool underlined = FALSE, const wxString& faceName = wxEmptyString); - - virtual bool Ok() const { return (m_refData != NULL) ; } - - inline int GetPointSize() const { return M_FONTDATA->m_pointSize; } - inline int GetFamily() const { return M_FONTDATA->m_family; } - inline int GetStyle() const { return M_FONTDATA->m_style; } - inline int GetWeight() const { return M_FONTDATA->m_weight; } - wxString GetFamilyString() const ; - wxString GetFaceName() const ; - wxString GetStyleString() const ; - wxString GetWeightString() const ; - inline bool GetUnderlined() const { return M_FONTDATA->m_underlined; } - - void SetPointSize(int pointSize); - void SetFamily(int family); - void SetStyle(int style); - void SetWeight(int weight); - void SetFaceName(const wxString& faceName); - void SetUnderlined(bool underlined); - - inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; } - inline bool operator == (const wxFont& font) { return m_refData == font.m_refData; } - inline bool operator != (const wxFont& font) { return m_refData != font.m_refData; } - - // Implementation + // ctors and such + wxFont() { } + +#if FUTURE_WXWIN_COMPATIBILITY_3_0 + wxFont(int size, + int family, + int style, + int weight, + bool underlined = false, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding); + } +#endif + + wxFont(int size, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, + bool underlined = false, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + Create(size, family, style, weight, underlined, face, encoding); + } + + wxFont(const wxSize& pixelSize, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, + bool underlined = false, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + Create(10, family, style, weight, underlined, face, encoding); + SetPixelSize(pixelSize); + } + + bool Create(int size, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, + bool underlined = false, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + + wxFont( const wxNativeFontInfo& rInfo + ,WXHFONT hFont = 0 + ) + + { + (void)Create( rInfo + ,hFont + ); + } + + wxFont(const wxString& rsFontDesc); + + bool Create( const wxNativeFontInfo& rInfo + ,WXHFONT hFont = 0 + ); + + virtual ~wxFont(); + + // + // Implement base class pure virtuals + // + virtual int GetPointSize(void) const; + virtual wxFontStyle GetStyle() const; + virtual wxFontWeight GetWeight() const; + virtual bool GetUnderlined(void) const; + virtual wxString GetFaceName(void) const; + virtual wxFontEncoding GetEncoding(void) const; + virtual const wxNativeFontInfo* GetNativeFontInfo() const; + + virtual void SetPointSize(int nPointSize); + virtual void SetFamily(wxFontFamily family); + virtual void SetStyle(wxFontStyle style); + virtual void SetWeight(wxFontWeight weight); + virtual bool SetFaceName(const wxString& rsFaceName); + virtual void SetUnderlined(bool bUnderlined); + virtual void SetEncoding(wxFontEncoding vEncoding); + + wxDECLARE_COMMON_FONT_METHODS(); + + // + // For internal use only! + // + void SetPS(HPS hPS); + void SetFM( PFONTMETRICS pFM + ,int nNumFonts + ); + // + // Implementation only from now on + // ------------------------------- + // + virtual bool IsFree(void) const; + virtual bool RealizeResource(void); + virtual WXHANDLE GetResourceHandle(void) const; + virtual bool FreeResource(bool bForce = false); + + WXHFONT GetHFONT(void) const; + protected: - bool RealizeResource(); - void Unshare(); -}; + virtual void DoSetNativeFontInfo(const wxNativeFontInfo& rInfo); + virtual wxFontFamily DoGetFamily() const; -#endif - // _WX_FONT_H_ + // implement wxObject virtuals which are used by AllocExclusive() + virtual wxGDIRefData *CreateGDIRefData() const; + virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; + +private: + DECLARE_DYNAMIC_CLASS(wxFont) +}; // end of wxFont + +#endif // _WX_FONT_H_