2009-01-17 10:43:43 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/osx/font.h
|
2009-01-17 10:43:43 +00:00
|
|
|
// Purpose: wxFont class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_FONT_H_
|
|
|
|
#define _WX_FONT_H_
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFont
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2009-03-20 13:56:57 +00:00
|
|
|
// font styles
|
|
|
|
enum wxOSXSystemFont
|
|
|
|
{
|
|
|
|
wxOSX_SYSTEM_FONT_NONE = 0,
|
|
|
|
wxOSX_SYSTEM_FONT_NORMAL,
|
|
|
|
wxOSX_SYSTEM_FONT_BOLD,
|
|
|
|
wxOSX_SYSTEM_FONT_SMALL,
|
|
|
|
wxOSX_SYSTEM_FONT_SMALL_BOLD,
|
|
|
|
wxOSX_SYSTEM_FONT_MINI,
|
|
|
|
wxOSX_SYSTEM_FONT_MINI_BOLD,
|
|
|
|
wxOSX_SYSTEM_FONT_LABELS,
|
2010-11-05 21:43:07 +00:00
|
|
|
wxOSX_SYSTEM_FONT_VIEWS
|
2009-03-20 13:56:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-01-17 10:43:43 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctors and such
|
|
|
|
wxFont() { }
|
2010-09-30 11:44:45 +00:00
|
|
|
|
Add wxFontInfo class to allow using named parameters for wxFont creation.
This helper class allows to create wxFonts using shorter and more readable
code, e.g.
wxFont font(12, wxFONTFLAG_DEFAULT,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, true,
"DejaVu Sans");
can now be written simply as
wxFont font(wxFontInfo(12).FaceName("DejaVu Sans").Underlined());
Remove the ctor from font flags added in r70445 as it's not needed any longer
now that we have this one and adding it resulted in compilation errors in the
existing code which compiled with 2.8 because of ambiguities between that ctor
and wxFont(int size, int family, int style, int weight. bool underlined, ...)
one, e.g.
wxFont(12, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL)
didn't compile any more but it does compile again now.
See #9907.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-04-30 10:27:38 +00:00
|
|
|
wxFont(const wxFontInfo& info)
|
|
|
|
{
|
2018-09-12 15:50:06 +00:00
|
|
|
Create(info.GetFractionalPointSize(),
|
Add wxFontInfo class to allow using named parameters for wxFont creation.
This helper class allows to create wxFonts using shorter and more readable
code, e.g.
wxFont font(12, wxFONTFLAG_DEFAULT,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, true,
"DejaVu Sans");
can now be written simply as
wxFont font(wxFontInfo(12).FaceName("DejaVu Sans").Underlined());
Remove the ctor from font flags added in r70445 as it's not needed any longer
now that we have this one and adding it resulted in compilation errors in the
existing code which compiled with 2.8 because of ambiguities between that ctor
and wxFont(int size, int family, int style, int weight. bool underlined, ...)
one, e.g.
wxFont(12, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL)
didn't compile any more but it does compile again now.
See #9907.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-04-30 10:27:38 +00:00
|
|
|
info.GetFamily(),
|
|
|
|
info.GetStyle(),
|
|
|
|
info.GetWeight(),
|
|
|
|
info.IsUnderlined(),
|
|
|
|
info.GetFaceName(),
|
|
|
|
info.GetEncoding());
|
|
|
|
|
|
|
|
if ( info.IsUsingSizeInPixels() )
|
|
|
|
SetPixelSize(info.GetPixelSize());
|
|
|
|
}
|
|
|
|
|
2010-04-08 18:47:41 +00:00
|
|
|
wxFont( wxOSXSystemFont systemFont );
|
2018-09-01 17:42:18 +00:00
|
|
|
wxFont(CTFontRef font);
|
2009-01-17 10:43:43 +00:00
|
|
|
|
2009-10-31 23:00:04 +00:00
|
|
|
#if wxOSX_USE_COCOA
|
|
|
|
wxFont(WX_NSFont nsfont);
|
|
|
|
#endif
|
|
|
|
|
2009-01-17 10:43:43 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2018-09-01 17:42:18 +00:00
|
|
|
wxFont(float 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);
|
|
|
|
}
|
|
|
|
|
2009-03-15 16:28:33 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-01-17 10:43:43 +00:00
|
|
|
bool Create(int size,
|
|
|
|
wxFontFamily family,
|
|
|
|
wxFontStyle style,
|
|
|
|
wxFontWeight weight,
|
|
|
|
bool underlined = false,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
|
2018-09-01 17:42:18 +00:00
|
|
|
bool Create(float size,
|
|
|
|
wxFontFamily family,
|
|
|
|
wxFontStyle style,
|
|
|
|
wxFontWeight weight,
|
|
|
|
bool underlined = false,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
|
2009-01-17 10:43:43 +00:00
|
|
|
wxFont(const wxNativeFontInfo& info)
|
|
|
|
{
|
|
|
|
(void)Create(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxFont(const wxString& fontDesc);
|
|
|
|
|
|
|
|
bool Create(const wxNativeFontInfo& info);
|
|
|
|
|
|
|
|
virtual ~wxFont();
|
|
|
|
|
|
|
|
// implement base class pure virtuals
|
2018-09-01 17:42:18 +00:00
|
|
|
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
|
|
|
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
|
|
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
|
|
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
|
|
|
virtual bool GetUnderlined() const wxOVERRIDE;
|
|
|
|
virtual bool GetStrikethrough() const wxOVERRIDE;
|
|
|
|
virtual wxString GetFaceName() const wxOVERRIDE;
|
|
|
|
virtual wxFontEncoding GetEncoding() const wxOVERRIDE;
|
|
|
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
|
|
|
|
|
|
|
virtual bool IsFixedWidth() const wxOVERRIDE;
|
|
|
|
|
2018-09-05 23:40:47 +00:00
|
|
|
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
|
2018-09-01 17:42:18 +00:00
|
|
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
|
|
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
|
|
|
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
|
|
|
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
|
|
|
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
|
|
|
virtual void SetStrikethrough(bool strikethrough) wxOVERRIDE;
|
|
|
|
virtual void SetEncoding(wxFontEncoding encoding) wxOVERRIDE;
|
2009-01-17 10:43:43 +00:00
|
|
|
|
2009-06-12 20:11:21 +00:00
|
|
|
wxDECLARE_COMMON_FONT_METHODS();
|
2009-01-17 10:43:43 +00:00
|
|
|
|
2014-01-06 12:42:37 +00:00
|
|
|
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
|
|
|
|
wxFont(int size,
|
|
|
|
int family,
|
|
|
|
int style,
|
|
|
|
int weight,
|
|
|
|
bool underlined = false,
|
|
|
|
const wxString& face = wxEmptyString,
|
2014-01-21 19:32:04 +00:00
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
2014-01-06 12:42:37 +00:00
|
|
|
|
|
|
|
|
2009-01-17 10:43:43 +00:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
|
|
|
virtual bool RealizeResource();
|
|
|
|
|
|
|
|
// Mac-specific, risks to change, don't use in portable code
|
|
|
|
|
2009-03-20 13:56:57 +00:00
|
|
|
#if wxOSX_USE_COCOA_OR_CARBON
|
2009-03-24 07:56:17 +00:00
|
|
|
CGFontRef OSXGetCGFont() const;
|
2009-01-17 10:43:43 +00:00
|
|
|
#endif
|
2009-03-20 13:56:57 +00:00
|
|
|
|
2009-03-24 07:56:17 +00:00
|
|
|
CTFontRef OSXGetCTFont() const;
|
2017-06-20 15:55:26 +00:00
|
|
|
CFDictionaryRef OSXGetCTFontAttributes() const;
|
2009-03-20 13:56:57 +00:00
|
|
|
|
|
|
|
#if wxOSX_USE_COCOA
|
2009-03-24 07:56:17 +00:00
|
|
|
WX_NSFont OSXGetNSFont() const;
|
2009-03-20 13:56:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if wxOSX_USE_IPHONE
|
2009-03-24 07:56:17 +00:00
|
|
|
WX_UIFont OSXGetUIFont() const;
|
2009-03-20 13:56:57 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-17 10:43:43 +00:00
|
|
|
protected:
|
2018-09-01 17:42:18 +00:00
|
|
|
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info) wxOVERRIDE;
|
|
|
|
virtual wxFontFamily DoGetFamily() const wxOVERRIDE;
|
2009-04-14 19:58:51 +00:00
|
|
|
|
2018-09-01 17:42:18 +00:00
|
|
|
virtual wxGDIRefData *CreateGDIRefData() const wxOVERRIDE;
|
|
|
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const wxOVERRIDE;
|
2009-01-17 10:43:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxFont);
|
2009-01-17 10:43:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_FONT_H_
|