// Name: font.cpp
// Author: Vaclav Slavik
// Id: $Id$
-// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "font.h"
#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
#include "wx/font.h"
#include "wx/fontutil.h"
#include "wx/cmndata.h"
#include "wx/gdicmn.h"
#include "wx/tokenzr.h"
#include "wx/settings.h"
-
-#include <strings.h>
+#include "wx/mgl/private.h"
// ----------------------------------------------------------------------------
// wxFontRefData
wxMGLFontLibrary *m_library;
bool m_valid;
+ wxNativeFontInfo m_info;
+
friend class wxFont;
};
m_valid = data.m_valid;
if ( m_library )
m_library->IncRef();
+ wxLogTrace("mgl_font", "created fntrefdata %p, library is %p", this, m_library);
}
wxFontRefData::wxFontRefData(int size, int family, int style,
wxFontEncoding encoding)
{
Init(size, family, style, weight, underlined, faceName, encoding);
+ wxLogTrace("mgl_font", "created fntrefdata %p, library is %p", this, m_library);
}
wxFontRefData::~wxFontRefData()
{
+ wxLogTrace("mgl_font", "destructing fntrefdata %p, library is %p", this, m_library);
if ( m_library )
m_library->DecRef();
}
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
-void wxFont::Init()
-{
- if (wxTheFontList)
- wxTheFontList->Append(this);
-}
-
bool wxFont::Create(const wxNativeFontInfo& info)
{
return Create(info.pointSize, info.family, info.style, info.weight,
return instance->GetMGLfont_t();
}
-void wxFont::Unshare()
+wxObjectRefData *wxFont::CreateRefData() const
{
- if ( !m_refData )
- {
- m_refData = new wxFontRefData();
- }
- else
- {
- wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
+ return new wxFontRefData;
}
-wxFont::~wxFont()
+wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
{
- if (wxTheFontList)
- wxTheFontList->DeleteObject(this);
+ return new wxFontRefData(*(wxFontRefData *)data);
}
+
// ----------------------------------------------------------------------------
// accessors
// ----------------------------------------------------------------------------
return M_FONTDATA->m_encoding;
}
+bool wxFont::IsFixedWidth() const
+{
+ wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
+
+ return (bool)(M_FONTDATA->m_library->GetFamily()->GetInfo()->isFixed);
+}
+
+const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
+{
+ wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
+
+ M_FONTDATA->m_info.InitFromFont(*this);
+
+ return &(M_FONTDATA->m_info);
+}
// ----------------------------------------------------------------------------
// change font attributes
void wxFont::SetPointSize(int pointSize)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_pointSize = pointSize;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetFamily(int family)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_family = family;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetStyle(int style)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_style = style;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetWeight(int weight)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_weight = weight;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetFaceName(const wxString& faceName)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_faceName = faceName;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetUnderlined(bool underlined)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_underlined = underlined;
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_encoding = encoding;
M_FONTDATA->m_valid = FALSE;