2011-03-20 18:05:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2016-06-26 05:25:29 +00:00
|
|
|
// Name: wx/x11/font.h
|
2011-03-20 18:05:19 +00:00
|
|
|
// Purpose: wxFont class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
2016-06-26 05:25:29 +00:00
|
|
|
// Created: 17/09/98
|
2011-03-20 18:05:19 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_FONT_H_
|
|
|
|
#define _WX_FONT_H_
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
class wxXFont;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
// Font
|
2011-03-20 18:05:19 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
|
|
|
{
|
|
|
|
public:
|
2016-06-26 05:25:29 +00:00
|
|
|
// ctors and such
|
2011-03-20 18:05:19 +00:00
|
|
|
wxFont() { }
|
|
|
|
|
2013-09-22 22:44:55 +00:00
|
|
|
wxFont(const wxFontInfo& info)
|
|
|
|
{
|
|
|
|
Create(info.GetPointSize(),
|
|
|
|
info.GetFamily(),
|
|
|
|
info.GetStyle(),
|
|
|
|
info.GetWeight(),
|
|
|
|
info.IsUnderlined(),
|
|
|
|
info.GetFaceName(),
|
|
|
|
info.GetEncoding());
|
|
|
|
|
|
|
|
if ( info.IsUsingSizeInPixels() )
|
|
|
|
SetPixelSize(info.GetPixelSize());
|
|
|
|
}
|
|
|
|
|
2011-03-20 18:05:19 +00:00
|
|
|
wxFont(int size,
|
|
|
|
wxFontFamily family,
|
|
|
|
wxFontStyle style,
|
|
|
|
wxFontWeight weight,
|
2016-06-26 05:25:29 +00:00
|
|
|
bool underlined = false,
|
2011-03-20 18:05:19 +00:00
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
|
|
|
{
|
2016-06-26 05:25:29 +00:00
|
|
|
Create(size, family, style, weight, underlined, face, encoding);
|
2011-03-20 18:05:19 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(int size,
|
|
|
|
wxFontFamily family,
|
|
|
|
wxFontStyle style,
|
|
|
|
wxFontWeight weight,
|
2016-06-26 05:25:29 +00:00
|
|
|
bool underlined = false,
|
2011-03-20 18:05:19 +00:00
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
wxFont(const wxNativeFontInfo& info);
|
|
|
|
|
|
|
|
wxFont(const wxString &nativeInfoString)
|
|
|
|
{
|
|
|
|
Create(nativeInfoString);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(const wxString& fontname,
|
|
|
|
wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
|
|
|
|
|
|
|
|
// DELETEME: no longer seems to be implemented.
|
|
|
|
// bool Create(const wxNativeFontInfo& fontinfo);
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
virtual ~wxFont();
|
|
|
|
|
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual int GetPointSize() const;
|
|
|
|
virtual wxFontStyle GetStyle() const;
|
|
|
|
virtual wxFontWeight GetWeight() const;
|
|
|
|
virtual bool GetUnderlined() const;
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool GetStrikethrough() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
virtual wxString GetFaceName() const;
|
|
|
|
virtual wxFontEncoding GetEncoding() const;
|
|
|
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool IsFixedWidth() const;
|
|
|
|
|
2011-03-20 18:05:19 +00:00
|
|
|
virtual void SetPointSize(int pointSize);
|
|
|
|
virtual void SetFamily(wxFontFamily family);
|
|
|
|
virtual void SetStyle(wxFontStyle style);
|
|
|
|
virtual void SetWeight(wxFontWeight weight);
|
|
|
|
virtual bool SetFaceName(const wxString& faceName);
|
|
|
|
virtual void SetUnderlined(bool underlined);
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetStrikethrough(bool strikethrough) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
virtual void SetEncoding(wxFontEncoding encoding);
|
|
|
|
|
|
|
|
wxDECLARE_COMMON_FONT_METHODS();
|
|
|
|
|
2016-06-26 05:25:29 +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,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
|
|
|
{
|
|
|
|
(void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
|
|
|
|
}
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
// Implementation
|
|
|
|
|
|
|
|
#if wxUSE_PANGO
|
|
|
|
// Set Pango attributes in the specified layout. Currently only
|
|
|
|
// underlined and strike-through attributes are handled by this function.
|
|
|
|
//
|
|
|
|
// If neither of them is specified, returns false, otherwise sets up the
|
|
|
|
// attributes and returns true.
|
|
|
|
bool SetPangoAttrs(PangoLayout* layout) const;
|
|
|
|
#else
|
|
|
|
// Find an existing, or create a new, XFontStruct
|
|
|
|
// based on this wxFont and the given scale. Append the
|
|
|
|
// font to list in the private data for future reference.
|
|
|
|
|
|
|
|
// TODO This is a fairly basic implementation, that doesn't
|
|
|
|
// allow for different facenames, and also doesn't do a mapping
|
|
|
|
// between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
|
|
|
|
// and the fonts that are available on a particular system.
|
|
|
|
// Maybe we need to scan the user's machine to build up a profile
|
|
|
|
// of the fonts and a mapping file.
|
|
|
|
|
|
|
|
// Return font struct, and optionally the Motif font list
|
|
|
|
wxXFont *GetInternalFont(double scale = 1.0,
|
|
|
|
WXDisplay* display = NULL) const;
|
|
|
|
|
|
|
|
// Helper function for convenient access of the above.
|
|
|
|
WXFontStructPtr GetFontStruct(double scale = 1.0,
|
|
|
|
WXDisplay* display = NULL) const;
|
|
|
|
#endif
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual wxGDIRefData *CreateGDIRefData() const;
|
|
|
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
|
2011-03-20 18:05:19 +00:00
|
|
|
virtual wxFontFamily DoGetFamily() const;
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
void Unshare();
|
|
|
|
|
2011-03-20 18:05:19 +00:00
|
|
|
private:
|
2016-06-26 05:25:29 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxFont);
|
2011-03-20 18:05:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_FONT_H_
|