1///////////////////////////////////////////////////////////////////////////// 2// Name: font.h 3// Purpose: wxFont class 4// Author: Julian Smart 5// Modified by: 6// Created: 01/02/97 7// RCS-ID: $Id: font.h 49216 2007-10-18 08:23:05Z DE $ 8// Copyright: (c) Julian Smart 9// Licence: wxWindows licence 10///////////////////////////////////////////////////////////////////////////// 11 12#ifndef _WX_FONT_H_ 13#define _WX_FONT_H_ 14 15// ---------------------------------------------------------------------------- 16// wxFont 17// ---------------------------------------------------------------------------- 18 19DECLARE_WXCOCOA_OBJC_CLASS(NSFont); 20 21// Internal class that bridges us with code like wxSystemSettings 22class wxCocoaFontFactory; 23// We have c-tors/methods taking pointers of these 24class wxFontRefData; 25 26/*! @discussion 27 wxCocoa's implementation of wxFont is very incomplete. In particular, 28 a lot of work needs to be done on wxNativeFontInfo which is currently 29 using the totally generic implementation. 30 31 See the documentation in src/cocoa/font.mm for more implementatoin details. 32 */ 33class WXDLLEXPORT wxFont : public wxFontBase 34{ 35 friend class wxCocoaFontFactory; 36public: 37 /*! @abstract Default construction of invalid font for 2-step construct then Create process. 38 */ 39 wxFont() { } 40 41 /*! @abstract Platform-independent construction with individual properties 42 */ 43 wxFont(int size, 44 int family, 45 int style, 46 int weight, 47 bool underlined = FALSE, 48 const wxString& face = wxEmptyString, 49 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) 50 { 51 (void)Create(size, family, style, weight, underlined, face, encoding); 52 } 53 54 /*! @abstract Construction with opaque wxNativeFontInfo 55 */ 56 wxFont(const wxNativeFontInfo& info) 57 { 58 (void)Create(info); 59 } 60 61 /*! @abstract Construction with platform-dependent font descriptor string. 62 @param fontDesc Usually the result of wxNativeFontInfo::ToUserString() 63 */ 64 wxFont(const wxString& fontDesc); 65 66 // NOTE: Copy c-tor and assignment from wxObject is fine 67 68 bool Create(int size, 69 int family, 70 int style, 71 int weight, 72 bool underlined = FALSE, 73 const wxString& face = wxEmptyString, 74 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); 75 76 bool Create(const wxNativeFontInfo& info); 77 78 virtual ~wxFont(); 79 80 // implement base class pure virtuals 81 virtual int GetPointSize() const; 82 virtual int GetFamily() const; 83 virtual int GetStyle() const; 84 virtual int GetWeight() const; 85 virtual bool GetUnderlined() const; 86 virtual wxString GetFaceName() const; 87 virtual wxFontEncoding GetEncoding() const; 88 virtual const wxNativeFontInfo *GetNativeFontInfo() const; 89 90 virtual void SetPointSize(int pointSize); 91 virtual void SetFamily(int family); 92 virtual void SetStyle(int style); 93 virtual void SetWeight(int weight); 94 virtual bool SetFaceName(const wxString& faceName); 95 virtual void SetUnderlined(bool underlined); 96 virtual void SetEncoding(wxFontEncoding encoding); 97 98 // implementation only from now on 99 // ------------------------------- 100 101 /*! @abstract Defined on some ports (not including this one) in wxGDIObject 102 @discussion 103 The intention here I suppose is to allow one to create a wxFont without yet 104 creating the underlying native object. There's no point not to create the 105 NSFont immediately in wxCocoa so this is useless. 106 This method came from the stub code copied in the early days of wxCocoa. 107 FIXME(1): Remove this in trunk. FIXME(2): Is it really a good idea for this to 108 be part of the public API for wxGDIObject? 109 */ 110 virtual bool RealizeResource(); 111 112protected: 113 /*! @abstract Helper method for COW. 114 @discussion 115 wxFont can be considered a mutable holder of an immutable opaque implementation object. 116 All methods that mutate the font should first call Unshare() to ensure that mutating 117 the implementation object does not cause another wxFont that happened to share the 118 same ref data to mutate. 119 */ 120 void Unshare(); 121 122 /*! @abstract Internal constructor with ref data 123 @discussion 124 Takes ownership of @a refData. That is, it is assumed that refData has either just been 125 created using new (which initializes its m_refCount to 1) or if you are sharing a ref that 126 you have called IncRef on it before passing it to this method. 127 */ 128 explicit wxFont(wxFontRefData *refData) 129 { Create(refData); } 130 bool Create(wxFontRefData *refData); 131private: 132 DECLARE_DYNAMIC_CLASS(wxFont) 133}; 134 135#endif 136 // _WX_FONT_H_ 137