2003-03-21 21:56:04 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: font.h
|
|
|
|
// Purpose: wxFont class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-03-21 21:56:04 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_FONT_H_
|
|
|
|
#define _WX_FONT_H_
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFont
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-10-18 03:54:43 -04:00
|
|
|
DECLARE_WXCOCOA_OBJC_CLASS(NSFont);
|
|
|
|
|
|
|
|
// Internal class that bridges us with code like wxSystemSettings
|
|
|
|
class wxCocoaFontFactory;
|
|
|
|
// We have c-tors/methods taking pointers of these
|
|
|
|
class wxFontRefData;
|
|
|
|
|
|
|
|
/*! @discussion
|
|
|
|
wxCocoa's implementation of wxFont is very incomplete. In particular,
|
|
|
|
a lot of work needs to be done on wxNativeFontInfo which is currently
|
|
|
|
using the totally generic implementation.
|
|
|
|
|
|
|
|
See the documentation in src/cocoa/font.mm for more implementatoin details.
|
|
|
|
*/
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
2003-03-21 21:56:04 -05:00
|
|
|
{
|
2007-10-18 03:54:43 -04:00
|
|
|
friend class wxCocoaFontFactory;
|
2003-03-21 21:56:04 -05:00
|
|
|
public:
|
2007-10-18 03:54:43 -04:00
|
|
|
/*! @abstract Default construction of invalid font for 2-step construct then Create process.
|
|
|
|
*/
|
2006-02-08 19:51:23 -05:00
|
|
|
wxFont() { }
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2007-10-18 03:54:43 -04:00
|
|
|
/*! @abstract Platform-independent construction with individual properties
|
|
|
|
*/
|
2008-11-03 12:02:25 -05:00
|
|
|
#if FUTURE_WXWIN_COMPATIBILITY_3_0
|
2003-03-21 21:56:04 -05:00
|
|
|
wxFont(int size,
|
|
|
|
int family,
|
|
|
|
int style,
|
|
|
|
int weight,
|
|
|
|
bool underlined = FALSE,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
2008-11-03 12:02:25 -05:00
|
|
|
{
|
|
|
|
(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)
|
2003-03-21 21:56:04 -05:00
|
|
|
{
|
|
|
|
(void)Create(size, family, style, weight, underlined, face, encoding);
|
|
|
|
}
|
2009-03-15 12:28:33 -04: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);
|
|
|
|
}
|
|
|
|
|
2007-10-18 03:54:43 -04:00
|
|
|
/*! @abstract Construction with opaque wxNativeFontInfo
|
|
|
|
*/
|
2003-03-21 21:56:04 -05:00
|
|
|
wxFont(const wxNativeFontInfo& info)
|
|
|
|
{
|
|
|
|
(void)Create(info);
|
|
|
|
}
|
|
|
|
|
2007-10-18 03:54:43 -04:00
|
|
|
/*! @abstract Construction with platform-dependent font descriptor string.
|
|
|
|
@param fontDesc Usually the result of wxNativeFontInfo::ToUserString()
|
|
|
|
*/
|
2003-03-21 21:56:04 -05:00
|
|
|
wxFont(const wxString& fontDesc);
|
|
|
|
|
2007-10-18 03:54:43 -04:00
|
|
|
// NOTE: Copy c-tor and assignment from wxObject is fine
|
|
|
|
|
2003-03-21 21:56:04 -05:00
|
|
|
bool Create(int size,
|
2008-11-03 12:02:25 -05:00
|
|
|
wxFontFamily family,
|
|
|
|
wxFontStyle style,
|
|
|
|
wxFontWeight weight,
|
2003-03-21 21:56:04 -05:00
|
|
|
bool underlined = FALSE,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
|
|
|
|
bool Create(const wxNativeFontInfo& info);
|
|
|
|
|
|
|
|
virtual ~wxFont();
|
|
|
|
|
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual int GetPointSize() const;
|
2008-11-03 12:02:25 -05:00
|
|
|
virtual wxFontFamily GetFamily() const;
|
|
|
|
virtual wxFontStyle GetStyle() const;
|
|
|
|
virtual wxFontWeight GetWeight() const;
|
2003-03-21 21:56:04 -05:00
|
|
|
virtual bool GetUnderlined() const;
|
|
|
|
virtual wxString GetFaceName() const;
|
|
|
|
virtual wxFontEncoding GetEncoding() const;
|
2003-09-23 21:23:37 -04:00
|
|
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
2003-03-21 21:56:04 -05:00
|
|
|
|
|
|
|
virtual void SetPointSize(int pointSize);
|
2008-11-03 12:02:25 -05:00
|
|
|
virtual void SetFamily(wxFontFamily family);
|
|
|
|
virtual void SetStyle(wxFontStyle style);
|
|
|
|
virtual void SetWeight(wxFontWeight weight);
|
2006-05-28 20:03:36 -04:00
|
|
|
virtual bool SetFaceName(const wxString& faceName);
|
2003-03-21 21:56:04 -05:00
|
|
|
virtual void SetUnderlined(bool underlined);
|
|
|
|
virtual void SetEncoding(wxFontEncoding encoding);
|
|
|
|
|
2008-11-03 12:02:25 -05:00
|
|
|
WXDECLARE_COMPAT_SETTERS
|
|
|
|
|
2003-03-21 21:56:04 -05:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2007-10-18 03:54:43 -04:00
|
|
|
/*! @abstract Defined on some ports (not including this one) in wxGDIObject
|
|
|
|
@discussion
|
|
|
|
The intention here I suppose is to allow one to create a wxFont without yet
|
|
|
|
creating the underlying native object. There's no point not to create the
|
|
|
|
NSFont immediately in wxCocoa so this is useless.
|
|
|
|
This method came from the stub code copied in the early days of wxCocoa.
|
|
|
|
FIXME(1): Remove this in trunk. FIXME(2): Is it really a good idea for this to
|
|
|
|
be part of the public API for wxGDIObject?
|
|
|
|
*/
|
2003-03-21 21:56:04 -05:00
|
|
|
virtual bool RealizeResource();
|
|
|
|
|
|
|
|
protected:
|
2007-10-18 03:54:43 -04:00
|
|
|
/*! @abstract Internal constructor with ref data
|
|
|
|
@discussion
|
|
|
|
Takes ownership of @a refData. That is, it is assumed that refData has either just been
|
|
|
|
created using new (which initializes its m_refCount to 1) or if you are sharing a ref that
|
|
|
|
you have called IncRef on it before passing it to this method.
|
|
|
|
*/
|
|
|
|
explicit wxFont(wxFontRefData *refData)
|
|
|
|
{ Create(refData); }
|
|
|
|
bool Create(wxFontRefData *refData);
|
2007-12-15 12:54:20 -05:00
|
|
|
|
|
|
|
virtual wxGDIRefData *CreateGDIRefData() const;
|
|
|
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
|
|
|
|
2003-03-21 21:56:04 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxFont)
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_FONT_H_
|