Font updates for OS/2

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8906 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster 2000-12-11 04:36:46 +00:00
parent 2f2dc32851
commit e99762c031
8 changed files with 994 additions and 721 deletions

View File

@ -13,6 +13,7 @@
#define _WX_FONT_H_
#include "wx/gdiobj.h"
#include "wx/os2/private.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
@ -25,73 +26,83 @@ class WXDLLEXPORT wxFont : public wxFontBase
public:
// ctors and such
wxFont() { Init(); }
wxFont(const wxFont& font) { Init(); Ref(font); }
wxFont(const wxFont& rFont) { Init(); Ref(rFont); }
wxFont(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
wxFont( int nSize
,int nFamily
,int nStyle
,int nWeight
,bool bUnderlined = FALSE
,const wxString& rsFace = wxEmptyString
,wxFontEncoding vEncoding = wxFONTENCODING_DEFAULT
)
{
Init();
(void)Create(size, family, style, weight, underlined, face, encoding);
(void)Create(nSize, nFamily, nStyle, nWeight, bUnderlined, rsFace, vEncoding);
}
bool Create(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
bool Create( int nSize
,int nFamily
,int nStyle
,int nWeight
,bool bUnderlined = FALSE
,const wxString& rsFace = wxEmptyString
,wxFontEncoding vEncoding = wxFONTENCODING_DEFAULT
);
virtual ~wxFont();
// assignment
wxFont& operator=(const wxFont& font);
//
// Assignment
//
wxFont& operator=(const wxFont& rFont);
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual int GetFamily() const;
virtual int GetStyle() const;
virtual int GetWeight() const;
virtual bool GetUnderlined() const;
virtual wxString GetFaceName() const;
virtual wxFontEncoding GetEncoding() const;
//
// Implement base class pure virtuals
//
virtual int GetPointSize(void) const;
virtual int GetFamily(void) const;
virtual int GetStyle(void) const;
virtual int GetWeight(void) const;
virtual bool GetUnderlined(void) const;
virtual wxString GetFaceName(void) const;
virtual wxFontEncoding GetEncoding(void) const;
virtual HPS GetPS(void) const;
virtual void SetPointSize(int pointSize);
virtual void SetFamily(int family);
virtual void SetStyle(int style);
virtual void SetWeight(int weight);
virtual void SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);
virtual void SetPointSize(int nPointSize);
virtual void SetFamily(int nFamily);
virtual void SetStyle(int nStyle);
virtual void SetWeight(int nWeight);
virtual void SetFaceName(const wxString& rsFaceName);
virtual void SetUnderlined(bool bUnderlined);
virtual void SetEncoding(wxFontEncoding vEncoding);
virtual void SetPS(HPS hPS);
virtual void SetFM( PFONTMETRICS pFM
,int nNumFonts
);
// implementation only from now on
//
// Implementation only from now on
// -------------------------------
int GetFontId() const;
virtual bool IsFree() const;
virtual bool RealizeResource();
virtual WXHANDLE GetResourceHandle();
virtual bool FreeResource(bool force = FALSE);
/*
virtual bool UseResource();
virtual bool ReleaseResource();
*/
//
int GetFontId(void) const;
virtual bool IsFree(void) const;
virtual bool RealizeResource(void);
virtual WXHANDLE GetResourceHandle(void);
virtual bool FreeResource(bool bForce = FALSE);
protected:
// common part of all ctors
void Init();
void Unshare();
//
// Common part of all ctors
//
void Init(void);
void Unshare(void);
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
void OS2SelectMatchingFontByName(void);
#endif
// _WX_FONT_H_
DECLARE_DYNAMIC_CLASS(wxFont)
}; // end of wxFont
#endif // _WX_FONT_H_

View File

@ -174,9 +174,16 @@ WXDLLEXPORT void wxSetInstance(HINSTANCE hInst);
WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, wxFont *font);
WXDLLEXPORT wxFont wxCreateFontFromLogFont(LOGFONT *logFont);
WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
WXDLLEXPORT void wxFillLogFont( LOGFONT* pLogFont
,PFACENAMEDESC pFaceName
,const wxFont* pFont
);
WXDLLEXPORT wxFont wxCreateFontFromLogFont( LOGFONT* pLogFont
,PFONTMETRICS pFM
,PFACENAMEDESC pFace
);
WXDLLEXPORT int wxGpiStrcmp(char* s0, char* s1);
WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);

View File

@ -301,7 +301,7 @@ bool wxApp::RegisterWindowClasses(
if (!::WinRegisterClass( vHab
,wxCanvasClassName
,wxWndProc
,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT | CS_CLIPCHILDREN
,sizeof(ULONG)
))
{

View File

@ -146,13 +146,12 @@ wxDC::wxDC(void)
m_nDCCount = 0;
m_hOldPS = NULL;
m_hPS = NULL;
m_bIsPaintTime = FALSE;// True at Paint Time
};
m_bIsPaintTime = FALSE; // True at Paint Time
}
wxDC::~wxDC(void)
{
// TODO:
};
}
// This will select current objects out of the DC,
// which is what you have to do before deleting the
@ -425,19 +424,13 @@ void wxDC::DoDrawArc(
dAnglmid = (dAngl1 + dAngl2)/2. + M_PI;
vXm = vXc + dRadius * cos(dAnglmid);
vYm = vYc + dRadius * sin(dAnglmid);
DoDrawArc( vX1
,vY1
,vXm
,vYm
,vXc
,vYc
DoDrawArc( vX1, vY1
,vXm, vYm
,vXc, vYc
);
DoDrawArc( vXm
,vYm
,vX2
,vY2
,vXc
,vYc
DoDrawArc( vXm, vYm
,vX2, vY2
,vXc, vYc
);
return;
}
@ -461,8 +454,8 @@ void wxDC::DoDrawArc(
vPtlPos.x = vX1; // Loads x-coordinate
vPtlPos.y = vY1; // Loads y-coordinate
::GpiMove(m_hPS, &vPtlPos); // Sets current position
vPtlArc[0].x = vXm;
vPtlArc[0].y = vYm;
vPtlArc[0].x = vXm;
vPtlArc[0].y = vYm;
vPtlArc[1].x = vX2;
vPtlArc[1].y = vY2;
::GpiPointArc(m_hPS, vPtlArc); // Draws the arc
@ -962,22 +955,19 @@ void wxDC::SetFont(
//
if (m_hOldFont)
{
// ::SelectObject(GetHdc(), (HFONT) m_hOldFont);
m_hOldFont = 0;
}
m_font = rFont;
if (!rFont.Ok())
{
if (m_hOldFont)
// ::SelectObject(GetHdc(), (HFONT) m_hOldFont);
m_hOldFont = 0;
}
if (m_font.Ok() && m_font.GetResourceHandle())
m_font.SetPS(m_hPS); // this will realize the font
if (m_font.Ok())
{
HFONT hFont = (HFONT)0; //::SelectObject(GetHdc(), (HFONT) m_font.GetResourceHandle());
HFONT hFont = m_font.GetResourceHandle();
if (hFont == (HFONT) NULL)
{
wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
@ -985,7 +975,7 @@ void wxDC::SetFont(
if (!m_hOldFont)
m_hOldFont = (WXHFONT) hFont;
}
}
} // end of wxDC::SetFont
void wxDC::SetPen(
const wxPen& rPen

View File

@ -34,17 +34,19 @@
struct WXDLLEXPORT wxPaintDCInfo
{
wxPaintDCInfo(wxWindow *win, wxDC *dc)
wxPaintDCInfo( wxWindow* pWin
,wxDC* pDC
)
{
hwnd = win->GetHWND();
hdc = dc->GetHDC();
count = 1;
m_hWnd = pWin->GetHWND();
m_hDC = pDC->GetHDC();
m_nCount = 1;
}
WXHWND hwnd; // window for this DC
WXHDC hdc; // the DC handle
size_t count; // usage count
};
WXHWND m_hWnd; // window for this DC
WXHDC m_hDC; // the DC handle
size_t m_nCount; // usage count
}; // end of wxPaintDCInfot
#include "wx/arrimpl.cpp"
@ -85,13 +87,15 @@ wxWindowDC::wxWindowDC()
m_pCanvas = NULL;
}
wxWindowDC::wxWindowDC(wxWindow *the_canvas)
wxWindowDC::wxWindowDC(
wxWindow* pTheCanvas
)
{
ERRORID vError;
wxString sError;
m_pCanvas = the_canvas;
m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas) );
m_pCanvas = pTheCanvas;
m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(pTheCanvas) );
m_nDCCount++;
//
// default under PM is that Window and Client DC's are the same
@ -153,18 +157,20 @@ wxClientDC::wxClientDC()
m_pCanvas = NULL;
}
wxClientDC::wxClientDC(wxWindow *the_canvas)
wxClientDC::wxClientDC(
wxWindow* pTheCanvas
)
{
SIZEL vSizl = { 0,0};
ERRORID vError;
wxString sError;
m_pCanvas = the_canvas;
m_pCanvas = pTheCanvas;
//
// default under PM is that Window and Client DC's are the same
//
m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas));
m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(pTheCanvas));
m_hPS = ::GpiCreatePS( wxGetInstance()
,m_hDC
,&vSizl
@ -191,7 +197,7 @@ wxClientDC::wxClientDC(wxWindow *the_canvas)
,wxSOLID
)
);
}
} // end of wxClientDC::wxClientDC
wxClientDC::~wxClientDC()
{
@ -205,7 +211,7 @@ wxClientDC::~wxClientDC()
//
m_hDC = 0;
}
}
} // end of wxClientDC::~wxClientDC
// ----------------------------------------------------------------------------
// wxPaintDC
@ -259,13 +265,45 @@ wxPaintDC::wxPaintDC(
if (pInfo)
{
m_hDC = pInfo->hdc;
pInfo->count++;
m_hDC = pInfo->m_hDC;
pInfo->m_nCount++;
}
else // not in cache, create a new one
{
SIZEL vSizl = { 0,0};
HPS hPS;
HRGN hRgn;
memset(&g_paintStruct, '\0', sizeof(RECTL));
if (!::WinQueryUpdateRect(GetWinHwnd(m_pCanvas), &g_paintStruct))
{
wxLogLastError("CreateRectRgn");
// return;
}
m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(m_pCanvas));
m_hPS = ::GpiCreatePS( wxGetInstance()
,m_hDC
,&vSizl
,PU_PELS | GPIF_LONG | GPIA_ASSOC
);
// Set the wxWindows color table
::GpiCreateLogColorTable( m_hPS
,0L
,LCOLF_CONSECRGB
,0L
,(LONG)wxTheColourDatabase->m_nSize
,(PLONG)wxTheColourDatabase->m_palTable
);
::GpiCreateLogColorTable( m_hPS
,0L
,LCOLF_RGB
,0L
,0L
,NULL
);
#if 0
hPS = ::WinBeginPaint( GetWinHwnd(m_pCanvas)
,NULLHANDLE
,&g_paintStruct
@ -289,6 +327,8 @@ wxPaintDC::wxPaintDC(
,NULL
);
}
#endif
m_bIsPaintTime = TRUE;
m_hDC = (WXHDC) -1; // to satisfy those anonizmous efforts
m_vRclPaint = g_paintStruct;
@ -303,17 +343,17 @@ wxPaintDC::~wxPaintDC()
{
SelectOldObjects(m_hDC);
size_t index;
wxPaintDCInfo *info = FindInCache(&index);
size_t nIndex;
wxPaintDCInfo* pInfo = FindInCache(&nIndex);
wxCHECK_RET( info, wxT("existing DC should have a cache entry") );
wxCHECK_RET( pInfo, wxT("existing DC should have a cache entry") );
if ( !--info->count )
if ( !--pInfo->m_nCount )
{
::WinEndPaint(m_hPS);
m_hPS = m_hOldPS;
m_bIsPaintTime = FALSE;
ms_cache.Remove(index);
ms_cache.Remove(nIndex);
}
//else: cached DC entry is still in use
@ -322,20 +362,23 @@ wxPaintDC::~wxPaintDC()
}
}
wxPaintDCInfo *wxPaintDC::FindInCache(size_t *index) const
wxPaintDCInfo* wxPaintDC::FindInCache(
size_t* pIndex
) const
{
wxPaintDCInfo *info = NULL;
size_t nCache = ms_cache.GetCount();
for ( size_t n = 0; n < nCache; n++ )
wxPaintDCInfo* pInfo = NULL;
size_t nCache = ms_cache.GetCount();
for (size_t n = 0; n < nCache; n++)
{
info = &ms_cache[n];
if ( info->hwnd == m_pCanvas->GetHWND() )
pInfo = &ms_cache[n];
if (pInfo->m_hWnd == m_pCanvas->GetHWND())
{
if ( index )
*index = n;
if (pIndex)
*pIndex = n;
break;
}
}
return pInfo;
} // end of wxPaintDC::FindInCache
return info;
}

File diff suppressed because it is too large Load Diff

View File

@ -52,199 +52,231 @@
// convert to/from the string representation: format is
// encodingid;facename[;charset]
bool wxNativeEncodingInfo::FromString(const wxString& s)
bool wxNativeEncodingInfo::FromString(
const wxString& rsStr
)
{
wxStringTokenizer tokenizer(s, _T(";"));
wxStringTokenizer vTokenizer(rsStr, _T(";"));
wxString sEncid = vTokenizer.GetNextToken();
long lEnc;
wxString encid = tokenizer.GetNextToken();
long enc;
if ( !encid.ToLong(&enc) )
if (!sEncid.ToLong(&lEnc))
return FALSE;
encoding = (wxFontEncoding)enc;
facename = tokenizer.GetNextToken();
if ( !facename )
encoding = (wxFontEncoding)lEnc;
facename = vTokenizer.GetNextToken();
if (!facename)
return FALSE;
wxString tmp = tokenizer.GetNextToken();
if ( !tmp )
wxString sTmp = vTokenizer.GetNextToken();
if (!sTmp)
{
// default charset (don't use DEFAULT_CHARSET though because of subtle
// Windows 9x/NT differences in handling it)
// TODO: what is this for OS/2?
// charset = ANSI_CHARSET;
charset = 850;
}
else
{
if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
if ( wxSscanf(sTmp, _T("%u"), &charset) != 1 )
{
// should be a number!
return FALSE;
}
}
return TRUE;
}
} // end of wxNativeEncodingInfo::FromString
wxString wxNativeEncodingInfo::ToString() const
{
wxString s;
wxString sStr;
s << (long)encoding << _T(';') << facename;
sStr << (long)encoding << _T(';') << facename;
// TODO: what is this for OS/2?
/*
if ( charset != ANSI_CHARSET )
if (charset != 850)
{
s << _T(';') << charset;
sStr << _T(';') << charset;
}
*/
return s;
}
return sStr;
} // end of wxNativeEncodingInfo::ToString
// ----------------------------------------------------------------------------
// helper functions
// ----------------------------------------------------------------------------
bool wxGetNativeFontEncoding(wxFontEncoding encoding,
wxNativeEncodingInfo *info)
bool wxGetNativeFontEncoding(
wxFontEncoding vEncoding
, wxNativeEncodingInfo* pInfo
)
{
wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
if ( encoding == wxFONTENCODING_DEFAULT )
wxCHECK_MSG(pInfo, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
if (vEncoding == wxFONTENCODING_DEFAULT)
{
encoding = wxFont::GetDefaultEncoding();
vEncoding = wxFont::GetDefaultEncoding();
}
switch ( encoding )
switch (vEncoding)
{
// TODO: fix this for OS2
/*
// although this function is supposed to return an exact match, do do
// some mappings here for the most common case of "standard" encoding
case wxFONTENCODING_SYSTEM:
case wxFONTENCODING_ISO8859_1:
case wxFONTENCODING_ISO8859_15:
case wxFONTENCODING_CP1252:
info->charset = ANSI_CHARSET;
break;
case wxFONTENCODING_CP1250:
info->charset = EASTEUROPE_CHARSET;
pInfo->charset = 1250;
break;
case wxFONTENCODING_ISO8859_2:
case wxFONTENCODING_CP1252:
pInfo->charset = 1252;
break;
case wxFONTENCODING_ISO8859_4:
case wxFONTENCODING_ISO8859_10:
pInfo->charset = 921; // what is baltic?
break;
case wxFONTENCODING_ISO8859_5:
case wxFONTENCODING_CP1251:
info->charset = RUSSIAN_CHARSET;
pInfo->charset = 1251;
break;
case wxFONTENCODING_CP1253:
info->charset = GREEK_CHARSET;
case wxFONTENCODING_ISO8859_6:
pInfo->charset = 864;
break;
case wxFONTENCODING_CP1254:
info->charset = TURKISH_CHARSET;
case wxFONTENCODING_ISO8859_7:
pInfo->charset = 869;
break;
case wxFONTENCODING_CP1255:
info->charset = HEBREW_CHARSET;
case wxFONTENCODING_ISO8859_8:
pInfo->charset = 862;
break;
case wxFONTENCODING_CP1256:
info->charset = ARABIC_CHARSET;
case wxFONTENCODING_ISO8859_9:
pInfo->charset = 857;
break;
case wxFONTENCODING_CP1257:
info->charset = BALTIC_CHARSET;
break;
case wxFONTENCODING_CP874:
info->charset = THAI_CHARSET;
case wxFONTENCODING_ISO8859_11:
pInfo->charset = 874; // what is thai
break;
case wxFONTENCODING_CP437:
info->charset = OEM_CHARSET;
pInfo->charset = 437;
break;
*/
default:
// no way to translate this encoding into a Windows charset
return FALSE;
wxFAIL_MSG(wxT("unsupported encoding"));
// fall through
case wxFONTENCODING_SYSTEM:
pInfo->charset = 850;
break;
}
return TRUE;
}
} // end of wxGetNativeFontEncoding
bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
bool wxTestFontEncoding(
const wxNativeEncodingInfo& rInfo
)
{
// TODO:
/*
// try to create such font
LOGFONT lf;
wxZeroMemory(lf); // all default values
FATTRS vLogFont;
HPS hPS;
lf.lfCharSet = info.charset;
strncpy(lf.lfFaceName, info.facename, sizeof(lf.lfFaceName));
hPS = ::WinGetPS(HWND_DESKTOP);
HFONT hfont = ::CreateFontIndirect(&lf);
if ( !hfont )
memset(&vLogFont, '\0', sizeof(FATTRS)); // all default values
vLogFont.usRecordLength = sizeof(FATTRS);
vLogFont.usCodePage = rInfo.charset;
vLogFont.lMaxBaselineExt = 0L; // Outline fonts should use 0
vLogFont.lAveCharWidth = 0L; // Outline fonts should use 0
vLogFont.fsFontUse = FATTR_FONTUSE_OUTLINE | // only outline fonts allowed
FATTR_FONTUSE_TRANSFORMABLE; // may be transformed
strncpy(vLogFont.szFacename, rInfo.facename.c_str(), sizeof(vLogFont.szFacename));
if (!::GpiCreateLogFont( hPS
,NULL
,1L
,&vLogFont
))
{
// no such font
::WinReleasePS(hPS);
return FALSE;
}
::DeleteObject((HGDIOBJ)hfont);
*/
::WinReleasePS(hPS);
return TRUE;
}
} // end of wxTestFontEncoding
// ----------------------------------------------------------------------------
// wxFont <-> LOGFONT conversion
// ----------------------------------------------------------------------------
#if 0
void wxFillLogFont(LOGFONT *logFont, const wxFont *font)
void wxFillLogFont(
LOGFONT* pLogFont // OS2 GPI FATTRS
, PFACENAMEDESC pFaceName
, const wxFont* pFont
)
{
int ff_family;
wxString ff_face;
wxString sFace;
USHORT uWeight;
int nItalic;
switch ( font->GetFamily() )
pLogFont->fsSelection = 0;
pLogFont->fsSelection = FATTR_SEL_OUTLINE; // we will alway use only outlines
pFaceName->usWeightClass = 0;
pFaceName->flOptions = 0;
switch (pFont->GetFamily())
{
case wxSCRIPT:
ff_family = FF_SCRIPT;
ff_face = _T("Script");
sFace = _T("Script");
break;
case wxDECORATIVE:
ff_family = FF_DECORATIVE;
break;
case wxROMAN:
ff_family = FF_ROMAN;
ff_face = _T("Times New Roman");
sFace = _T("Times New Roman");
break;
case wxTELETYPE:
case wxMODERN:
ff_family = FF_MODERN;
ff_face = _T("Courier New");
sFace = _T("Courier New");
break;
case wxSWISS:
ff_family = FF_SWISS;
ff_face = _T("Arial");
sFace = _T("WarpSans");
break;
case wxDEFAULT:
default:
ff_family = FF_SWISS;
ff_face = _T("MS Sans Serif");
sFace = _T("Helv");
}
BYTE ff_italic;
switch ( font->GetStyle() )
switch (pFont->GetWeight())
{
default:
wxFAIL_MSG(_T("unknown font weight"));
uWeight = FWEIGHT_DONT_CARE;
break;
case wxNORMAL:
uWeight = FWEIGHT_NORMAL;
break;
case wxLIGHT:
uWeight = FWEIGHT_LIGHT;
break;
case wxBOLD:
uWeight = FWEIGHT_BOLD;
pLogFont->fsSelection |= FATTR_SEL_BOLD;
break;
case wxFONTWEIGHT_MAX:
uWeight = FWEIGHT_ULTRA_BOLD;
pLogFont->fsSelection |= FATTR_SEL_BOLD;
break;
}
pFaceName->usWeightClass |= uWeight;
switch (pFont->GetStyle())
{
case wxITALIC:
case wxSLANT:
ff_italic = 1;
nItalic = FTYPE_ITALIC;
pLogFont->fsSelection |= FATTR_SEL_ITALIC;
break;
default:
@ -252,214 +284,236 @@ void wxFillLogFont(LOGFONT *logFont, const wxFont *font)
// fall through
case wxNORMAL:
ff_italic = 0;
}
int ff_weight;
switch ( font->GetWeight() )
{
default:
wxFAIL_MSG(_T("unknown font weight"));
// fall through
case wxNORMAL:
ff_weight = FW_NORMAL;
break;
case wxLIGHT:
ff_weight = FW_LIGHT;
break;
case wxBOLD:
ff_weight = FW_BOLD;
nItalic = 0;
break;
}
pFaceName->flOptions |= nItalic;
if(pFont->GetUnderlined())
pLogFont->fsSelection |= FATTR_SEL_UNDERSCORE;
#if 0
HDC dc = ::GetDC(NULL);
int ppInch = ::GetDeviceCaps(dc, LOGPIXELSY);
::ReleaseDC(NULL, dc);
#else
// New behaviour: apparently ppInch varies according to Large/Small Fonts
// setting in Windows. This messes up fonts. So, set ppInch to a constant
// 96 dpi.
static const int ppInch = 96;
#endif // 0/1
//
// In PM a font's height is expressed in points. A point equals
// approximately 1/72 of an inch. We'll assume for now that,
// like Windows, that fonts are 96 dpi.
//
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
LONG lStart = CAPS_FAMILY;
LONG lCount = CAPS_VERTICAL_RESOLUTION;
LONG alArray[CAPS_VERTICAL_RESOLUTION];
LONG lRes;
int nPpInch;
#if wxFONT_SIZE_COMPATIBILITY
// Incorrect, but compatible with old wxWindows behaviour
int nHeight = (font->GetPointSize()*ppInch/72);
#else
// Correct for Windows compatibility
int nHeight = - (font->GetPointSize()*ppInch/72);
#endif
wxString facename = font->GetFaceName();
if ( !!facename )
::DevQueryCaps(hDC, lStart, lCount, alArray);
lRes = alArray[CAPS_VERTICAL_RESOLUTION-1];
if (lRes > 0)
nPpInch = (int)(lRes/39.6); // lres is in pixels per meter
else
nPpInch = 96;
int nHeight = (pFont->GetPointSize() * nPpInch/72);
wxString sFacename = pFont->GetFaceName();
if (!!sFacename)
{
ff_face = facename;
sFace = sFacename;
}
//else: ff_face is a reasonable default facename for this font family
// deal with encoding now
wxNativeEncodingInfo info;
wxFontEncoding encoding = font->GetEncoding();
if ( !wxGetNativeFontEncoding(encoding, &info) )
//
// Deal with encoding now
//
wxNativeEncodingInfo vInfo;
wxFontEncoding vEncoding = pFont->GetEncoding();
if (!wxGetNativeFontEncoding( vEncoding
,&vInfo
))
{
if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
if ( !wxTheFontMapper->GetAltForEncoding( vEncoding
,&vInfo
))
{
// unsupported encoding, replace with the default
info.charset = ANSI_CHARSET;
//
// Unsupported encoding, replace with the default
//
vInfo.charset = 850;
}
}
if ( !info.facename.IsEmpty() )
if (!vInfo.facename.IsEmpty() )
{
// the facename determined by the encoding overrides everything else
ff_face = info.facename;
//
// The facename determined by the encoding overrides everything else
//
sFace = vInfo.facename;
}
// transfer all the data to LOGFONT
logFont->lfHeight = nHeight;
logFont->lfWidth = 0;
logFont->lfEscapement = 0;
logFont->lfOrientation = 0;
logFont->lfWeight = ff_weight;
logFont->lfItalic = ff_italic;
logFont->lfUnderline = (BYTE)font->GetUnderlined();
logFont->lfStrikeOut = 0;
logFont->lfCharSet = info.charset;
logFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
logFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
logFont->lfQuality = PROOF_QUALITY;
logFont->lfPitchAndFamily = DEFAULT_PITCH | ff_family;
wxStrncpy(logFont->lfFaceName, ff_face, WXSIZEOF(logFont->lfFaceName));
}
//
// Transfer all the data to LOGFONT
//
pLogFont->usRecordLength = sizeof(FATTRS);
wxStrcpy(pLogFont->szFacename, sFace.c_str());
pLogFont->usCodePage = vInfo.charset;
pLogFont->fsFontUse |= FATTR_FONTUSE_OUTLINE |
FATTR_FONTUSE_TRANSFORMABLE;
} // end of wxFillLogFont
wxFont wxCreateFontFromLogFont(const LOGFONT *logFont)
wxFont wxCreateFontFromLogFont(
const LOGFONT* pLogFont
, const PFONTMETRICS pFM
, PFACENAMEDESC pFaceName
)
{
DEBUG_PRINTF(wxCreateFontFromLogFont)
//
// Extract family from facename
//
int nFontFamily;
// extract family from pitch-and-family
int lfFamily = logFont->lfPitchAndFamily;
if ( lfFamily & FIXED_PITCH )
lfFamily -= FIXED_PITCH;
if ( lfFamily & VARIABLE_PITCH )
lfFamily -= VARIABLE_PITCH;
if (strcmp(pLogFont->szFacename, "Times New Roman") == 0)
nFontFamily = wxROMAN;
else if (strcmp(pLogFont->szFacename, "WarpSans") == 0)
nFontFamily = wxSWISS;
else if (strcmp(pLogFont->szFacename, "Script") == 0)
nFontFamily = wxSCRIPT;
else if (strcmp(pLogFont->szFacename, "Courier New") == 0)
nFontFamily = wxMODERN;
else
nFontFamily = wxSWISS;
int fontFamily;
switch ( lfFamily )
//
// Weight and Style
//
int nFontWeight = wxNORMAL;
switch (pFaceName->usWeightClass)
{
case FF_ROMAN:
fontFamily = wxROMAN;
break;
case FF_SWISS:
fontFamily = wxSWISS;
break;
case FF_SCRIPT:
fontFamily = wxSCRIPT;
break;
case FF_MODERN:
fontFamily = wxMODERN;
break;
case FF_DECORATIVE:
fontFamily = wxDECORATIVE;
case FWEIGHT_LIGHT:
nFontWeight = wxLIGHT;
break;
default:
fontFamily = wxSWISS;
}
// weight and style
int fontWeight = wxNORMAL;
switch ( logFont->lfWeight )
{
case FW_LIGHT:
fontWeight = wxLIGHT;
case FWEIGHT_NORMAL:
nFontWeight = wxNORMAL;
break;
default:
case FW_NORMAL:
fontWeight = wxNORMAL;
break;
case FW_BOLD:
fontWeight = wxBOLD;
case FWEIGHT_BOLD:
nFontWeight = wxBOLD;
break;
}
int fontStyle = logFont->lfItalic ? wxITALIC : wxNORMAL;
int nFontStyle;
bool fontUnderline = logFont->lfUnderline != 0;
if(pLogFont->fsSelection & FATTR_SEL_ITALIC)
nFontStyle = wxITALIC;
else
nFontStyle = wxNORMAL;
wxString fontFace = logFont->lfFaceName;
bool bFontUnderline = (pLogFont->fsSelection & FATTR_SEL_UNDERSCORE);
wxString sFontFace = pLogFont->szFacename;
int nFontPoints = pFM->lEmHeight;
wxFontEncoding vFontEncoding;
// font size
HDC dc = ::GetDC(NULL);
// remember that 1pt = 1/72inch
int height = abs(logFont->lfHeight);
int fontPoints = (72*height)/GetDeviceCaps(dc, LOGPIXELSY);
::ReleaseDC(NULL, dc);
wxFontEncoding fontEncoding;
switch ( logFont->lfCharSet )
switch (pLogFont->usCodePage)
{
default:
wxFAIL_MSG(wxT("unsupported charset"));
// fall through
case ANSI_CHARSET:
fontEncoding = wxFONTENCODING_CP1252;
case 850:
vFontEncoding = wxFONTENCODING_CP1252;
break;
#ifdef __WIN32__
case EASTEUROPE_CHARSET:
fontEncoding = wxFONTENCODING_CP1250;
case 1250:
vFontEncoding = wxFONTENCODING_CP1250;
break;
case BALTIC_CHARSET:
fontEncoding = wxFONTENCODING_CP1257;
case 921:
vFontEncoding = wxFONTENCODING_CP1257;
break;
case RUSSIAN_CHARSET:
fontEncoding = wxFONTENCODING_CP1251;
case 866:
vFontEncoding = wxFONTENCODING_CP1251;
break;
case ARABIC_CHARSET:
fontEncoding = wxFONTENCODING_CP1256;
case 864:
vFontEncoding = wxFONTENCODING_CP1256;
break;
case GREEK_CHARSET:
fontEncoding = wxFONTENCODING_CP1253;
case 869:
vFontEncoding = wxFONTENCODING_CP1253;
break;
case HEBREW_CHARSET:
fontEncoding = wxFONTENCODING_CP1255;
case 862:
vFontEncoding = wxFONTENCODING_CP1255;
break;
case TURKISH_CHARSET:
fontEncoding = wxFONTENCODING_CP1254;
case 857:
vFontEncoding = wxFONTENCODING_CP1254;
break;
case THAI_CHARSET:
fontEncoding = wxFONTENCODING_CP437;
case 874:
vFontEncoding = wxFONTENCODING_CP437;
break;
#endif
case OEM_CHARSET:
fontEncoding = wxFONTENCODING_CP437;
case 437:
vFontEncoding = wxFONTENCODING_CP437;
break;
}
return wxFont(fontPoints, fontFamily, fontStyle,
fontWeight, fontUnderline, fontFace,
fontEncoding);
}
#endif // 0
return wxFont( nFontPoints
,nFontFamily
,nFontStyle
,nFontWeight
,bFontUnderline
,sFontFace
,vFontEncoding
);
} // end of wxCreateFontFromLogFont
int wxGpiStrcmp(
char* s0
, char* s1
)
{ int l0;
int l1;
int l;
int d;
int d1;
int i;
int rc;
rc = 0;
if(s0 == NULL)
{
if(s1 == NULL)
return 0;
else
return 32;
}
else if(s1 == NULL)
return 32;
l0 = strlen(s0);
l1 = strlen(s1);
l = l0;
if(l0 != l1)
{
rc++;
if(l1 < l0)
l = l1;
}
for(i=0;i<l;i++)
{
d = s0[i]-s1[i];
if(!d)
continue;
d1 = toupper(s0[i]) - toupper(s1[i]);
if(!d1)
continue;
rc += abs(d);
}
return rc;
}

View File

@ -1026,20 +1026,6 @@ bool wxFrame::OS2Create(
wxLogError("Error sizing client. Error: %s\n", sError);
return FALSE;
}
/*
uCtlCount = SHORT1FROMMP(::WinSendMsg(GetHWND(), WM_FORMATFRAME, (MPARAM)vSwp, (MPARAM)vRect));
for (int i = 0; i < uCtlCount; i++)
{
if (vSwp[i].hwnd == GetHWND())
memcpy(&m_vSwp, &vSwp[i], sizeof(SWP));
else if (vSwp[i].hwnd == m_hVScroll)
memcpy(&m_vSwpVScroll, &vSwp[i], sizeof(SWP));
else if (vSwp[i].hwnd == m_hHScroll)
memcpy(&m_vSwpVScroll, &vSwp[i], sizeof(SWP));
else if (vSwp[i].hwnd == m_hTitleBar)
memcpy(&m_vSwpTitleBar, &vSwp[i], sizeof(SWP));
}*/
return TRUE;
} // end of wxFrame::OS2Create
@ -1290,7 +1276,8 @@ bool wxFrame::HandlePaint()
}
else
{
return wxWindow::HandlePaint();
wxWindow::HandlePaint();
return TRUE;
}
}
else