Font fixes for the font dialog

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2002-08-11 23:47:44 +00:00
parent 9bc138582e
commit 07df68c89a
5 changed files with 186 additions and 74 deletions

View File

@@ -22,20 +22,40 @@
class WXDLLEXPORT wxFontDialog: public wxFontDialogBase class WXDLLEXPORT wxFontDialog: public wxFontDialogBase
{ {
DECLARE_DYNAMIC_CLASS(wxFontDialog)
public: public:
wxFontDialog(); wxFontDialog() : wxFontDialogBase() { /* must be Create()d later */ }
wxFontDialog(wxWindow *parent, const wxFontData& rData); wxFontDialog (wxWindow* pParent) : wxFontDialogBase(pParent) { Create(pParent); }
wxFontDialog( wxWindow* pParent
,const wxFontData& rData
)
: wxFontDialogBase( pParent
,rData
)
{
Create( pParent
,rData
);
}
bool Create(wxWindow *parent, const wxFontData& rData); virtual int ShowModal();
int ShowModal(); //
wxFontData& GetFontData() { return m_fontData; } // Deprecated interface, don't use
//
//EK protected: wxFontDialog( wxWindow* pParent
wxWindow* m_dialogParent; ,const wxFontData* pData
wxFontData m_fontData; )
}; : wxFontDialogBase( pParent
,pData
)
{
Create( pParent
,pData
);
}
protected:
DECLARE_DYNAMIC_CLASS(wxFontDialog)
}; // end of CLASS wxFontDialog
#endif #endif
// _WX_FONTDLG_H_ // _WX_FONTDLG_H_

View File

@@ -351,7 +351,7 @@ void wxFontRefData::Init(
if (m_hPS == NULLHANDLE) if (m_hPS == NULLHANDLE)
{ {
m_hPS = ::WinGetPS(HWND_DESKTOP); m_hPS = ::WinGetPS(HWND_DESKTOP);
m_bInternalPS; m_bInternalPS = TRUE;
} }
else else
m_hPS = (HPS)hPS; m_hPS = (HPS)hPS;
@@ -386,7 +386,15 @@ bool wxFontRefData::Alloc(
); );
m_bNativeFontInfoOk = TRUE; m_bNativeFontInfoOk = TRUE;
} }
else
{
if (flId == 0L)
flId = 1L;
else
flId++;
if (flId > 254)
flId = 1L;
}
if((lRc = ::GpiCreateLogFont( m_hPS if((lRc = ::GpiCreateLogFont( m_hPS
,NULL ,NULL
,flId ,flId
@@ -418,23 +426,33 @@ bool wxFontRefData::Alloc(
// The GpiCreateLogFont will do enough by selecting the right family, // The GpiCreateLogFont will do enough by selecting the right family,
// and face name. // and face name.
// //
if (strcmp(m_vNativeFontInfo.fa.szFacename, "Times New Roman") == 0) if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Times New Roman") == 0)
m_nFamily = wxROMAN; m_nFamily = wxROMAN;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Tms Rmn") == 0) else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Times New Roman MT 30") == 0)
m_nFamily = wxROMAN;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "@Times New Roman MT 30") == 0)
m_nFamily = wxROMAN;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Tms Rmn") == 0)
m_nFamily = wxROMAN;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "WarpSans") == 0)
m_nFamily = wxDECORATIVE;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helvitica") == 0)
m_nFamily = wxSWISS; m_nFamily = wxSWISS;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "WarpSans") == 0) else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helv") == 0)
m_nFamily = wxSWISS; m_nFamily = wxSWISS;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Helvitica") == 0) else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Script") == 0)
m_nFamily = wxSWISS;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Helv") == 0)
m_nFamily = wxSWISS;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Script") == 0)
m_nFamily = wxSCRIPT; m_nFamily = wxSCRIPT;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier New") == 0) else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Courier New") == 0)
m_nFamily = wxTELETYPE; m_nFamily = wxTELETYPE;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier") == 0) else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Courier") == 0)
m_nFamily = wxTELETYPE; m_nFamily = wxTELETYPE;
else if (strcmp(m_vNativeFontInfo.fa.szFacename, "System VIO") == 0) else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System Monospaced") == 0)
m_nFamily = wxTELETYPE;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System VIO") == 0)
m_nFamily = wxTELETYPE;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System Proportional") == 0)
m_nFamily = wxMODERN;
else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Arial") == 0)
m_nFamily = wxMODERN; m_nFamily = wxMODERN;
else else
m_nFamily = wxSWISS; m_nFamily = wxSWISS;
@@ -567,13 +585,33 @@ wxFontFamily wxNativeFontInfo::GetFamily() const
// //
// Extract family from facename // Extract family from facename
// //
if (strcmp(fa.szFacename, "Times New Roman") == 0) if (strcmp(fm.szFamilyname, "Times New Roman") == 0)
nFamily = wxROMAN; nFamily = wxROMAN;
else if (strcmp(fa.szFacename, "WarpSans") == 0) else if (strcmp(fm.szFamilyname, "Times New Roman MT 30") == 0)
nFamily = wxROMAN;
else if (strcmp(fm.szFamilyname, "@Times New Roman MT 30") == 0)
nFamily = wxROMAN;
else if (strcmp(fm.szFamilyname, "Tms Rmn") == 0)
nFamily = wxROMAN;
else if (strcmp(fm.szFamilyname, "WarpSans") == 0)
nFamily = wxDECORATIVE;
else if (strcmp(fm.szFamilyname, "Helvitica") == 0)
nFamily = wxSWISS; nFamily = wxSWISS;
else if (strcmp(fa.szFacename, "Script") == 0) else if (strcmp(fm.szFamilyname, "Helv") == 0)
nFamily = wxSWISS;
else if (strcmp(fm.szFamilyname, "Script") == 0)
nFamily = wxSCRIPT; nFamily = wxSCRIPT;
else if (strcmp(fa.szFacename, "Courier New") == 0) else if (strcmp(fm.szFamilyname, "Courier New") == 0)
nFamily = wxTELETYPE;
else if (strcmp(fm.szFamilyname, "Courier") == 0)
nFamily = wxTELETYPE;
else if (strcmp(fm.szFamilyname, "System Monospaced") == 0)
nFamily = wxTELETYPE;
else if (strcmp(fm.szFamilyname, "System VIO") == 0)
nFamily = wxTELETYPE;
else if (strcmp(fm.szFamilyname, "System Proportional") == 0)
nFamily = wxMODERN;
else if (strcmp(fm.szFamilyname, "Arial") == 0)
nFamily = wxMODERN; nFamily = wxMODERN;
else else
nFamily = wxSWISS; nFamily = wxSWISS;
@@ -660,29 +698,32 @@ void wxNativeFontInfo::SetFamily(
switch (eFamily) switch (eFamily)
{ {
case wxSCRIPT: case wxSCRIPT:
sFacename = _T("Script"); sFacename = wxT("Script");
break; break;
case wxDECORATIVE: case wxDECORATIVE:
sFacename = _T("Times New Roman"); sFacename = wxT("WarpSans");
break; break;
case wxROMAN: case wxROMAN:
sFacename = _T("Times New Roman"); sFacename = wxT("Times New Roman");
break; break;
case wxTELETYPE: case wxTELETYPE:
sFacename = wxT("Courier New") ;
break;
case wxMODERN: case wxMODERN:
sFacename = _T("Courier New"); sFacename = wxT("Arial") ;
break; break;
case wxSWISS: case wxSWISS:
sFacename = _T("WarpSans"); sFacename = wxT("Helv") ;
break; break;
case wxDEFAULT: case wxDEFAULT:
default: default:
sFacename = _T("Helv"); sFacename = wxT("System Proportional") ;
} }
if (!wxStrlen(fa.szFacename) ) if (!wxStrlen(fa.szFacename) )

View File

@@ -32,35 +32,87 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define wxDIALOG_DEFAULT_X 300
#define wxDIALOG_DEFAULT_Y 300
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
/*
* wxFontDialog
*/
wxFontDialog::wxFontDialog()
{
m_dialogParent = NULL;
}
wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& rData)
{
Create(parent, rData);
}
bool wxFontDialog::Create(wxWindow *parent, const wxFontData& rData)
{
m_dialogParent = parent;
m_fontData = rData;
return TRUE;
}
int wxFontDialog::ShowModal() int wxFontDialog::ShowModal()
{ {
// TODO: show (maybe create) the dialog FONTDLG vFontDlg;
return wxID_CANCEL; char zCurrentFont[FACESIZE];
} HWND hWndFontDlg;
FONTMETRICS vFm;
FACENAMEDESC vFn;
memset(&vFontDlg, '\0', sizeof(FONTDLG));
zCurrentFont[0] = '\0';
//
// Set the fontdlg fields
//
vFontDlg.cbSize = sizeof(FONTDLG);
vFontDlg.hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
vFontDlg.hpsPrinter = NULL;
vFontDlg.pszFamilyname = zCurrentFont;
vFontDlg.fxPointSize = MAKEFIXED(12,0);
vFontDlg.usFamilyBufLen = FACESIZE;
vFontDlg.fl = FNTS_CENTER;
vFontDlg.clrFore = CLR_BLACK;
vFontDlg.clrBack = CLR_WHITE;
hWndFontDlg = WinFontDlg( HWND_DESKTOP
,GetParent()->GetHWND()
,&vFontDlg
);
if (hWndFontDlg && vFontDlg.lReturn == DID_OK)
{
wxColour vColour((unsigned long)0x00000000);
wxNativeFontInfo vInfo;
m_fontData.fontColour = vColour;
memset(&vFn, '\0', sizeof(FACENAMEDESC));
vFn.usSize = sizeof(FACENAMEDESC);
vFn.usWeightClass = vFontDlg.usWeight;
vFn.usWidthClass = vFontDlg.usWidth;
memcpy(&vInfo.fa, &vFontDlg.fAttrs, sizeof(FATTRS));
memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC));
//
// Debugging
//
wxFont vChosenFont(vInfo);
int nFamily;
int nPointSize;
int nStyle;
int nWeight;
bool bUnderlined;
wxString sFaceName;
wxNativeFontInfo* pInfo;
nFamily = vChosenFont.GetFamily();
nPointSize = vChosenFont.GetPointSize();
nStyle = vChosenFont.GetStyle();
nWeight = vChosenFont.GetWeight();
bUnderlined = vChosenFont.GetUnderlined();
sFaceName = vChosenFont.GetFaceName();
pInfo = vChosenFont.GetNativeFontInfo();
m_fontData.chosenFont = vChosenFont;
nFamily = m_fontData.chosenFont.GetFamily();
nPointSize = m_fontData.chosenFont.GetPointSize();
nStyle = m_fontData.chosenFont.GetStyle();
nWeight = m_fontData.chosenFont.GetWeight();
bUnderlined = m_fontData.chosenFont.GetUnderlined();
sFaceName = m_fontData.chosenFont.GetFaceName();
pInfo = m_fontData.chosenFont.GetNativeFontInfo();
m_fontData.EncodingInfo().facename = vFontDlg.fAttrs.szFacename;
m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;
return wxID_OK;
}
return wxID_CANCEL;
} // end of wxFontDialg::ShowModal

View File

@@ -453,16 +453,19 @@ void wxOS2SelectMatchingFontByName(
break; break;
case wxDECORATIVE: case wxDECORATIVE:
sFaceName = wxT("WarpSans");
break;
case wxROMAN: case wxROMAN:
sFaceName = wxT("Tms Rmn"); sFaceName = wxT("Times New Roman");
break; break;
case wxTELETYPE: case wxTELETYPE:
sFaceName = wxT("Courier") ; sFaceName = wxT("Courier New") ;
break; break;
case wxMODERN: case wxMODERN:
sFaceName = wxT("System VIO") ; sFaceName = wxT("Arial") ;
break; break;
case wxSWISS: case wxSWISS:
@@ -471,7 +474,7 @@ void wxOS2SelectMatchingFontByName(
case wxDEFAULT: case wxDEFAULT:
default: default:
sFaceName = wxT("System VIO") ; sFaceName = wxT("System Proportional") ;
} }
switch (pFont->GetWeight()) switch (pFont->GetWeight())

View File

@@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL
CODE LOADONCALL CODE LOADONCALL
EXPORTS EXPORTS
;From library: H:\DEV\WX2\WXWINDOWS\LIB\wx.lib ;From library: F:\Dev\Wx2\WxWindows\lib\wx.lib
;From object file: dummy.cpp ;From object file: dummy.cpp
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
wxDummyChar wxDummyChar
@@ -1955,7 +1955,7 @@ EXPORTS
wxEVT_NC_LEFT_DCLICK wxEVT_NC_LEFT_DCLICK
wxEVT_INIT_DIALOG wxEVT_INIT_DIALOG
wxEVT_COMMAND_SET_FOCUS wxEVT_COMMAND_SET_FOCUS
;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
ConvertToIeeeExtended ConvertToIeeeExtended
ConvertFromIeeeExtended ConvertFromIeeeExtended
@@ -4302,6 +4302,8 @@ EXPORTS
ClearData__18wxMimeTypesManagerFv ClearData__18wxMimeTypesManagerFv
;wxArrayFileTypeInfo::operator=(const wxArrayFileTypeInfo&) ;wxArrayFileTypeInfo::operator=(const wxArrayFileTypeInfo&)
__as__19wxArrayFileTypeInfoFRC19wxArrayFileTypeInfo __as__19wxArrayFileTypeInfoFRC19wxArrayFileTypeInfo
;wxFileType::GetOpenCommand(const wxString&) const
GetOpenCommand__10wxFileTypeCFRC8wxString
;wxFileType::GetOpenCommand(wxString*,const wxFileType::MessageParameters&) const ;wxFileType::GetOpenCommand(wxString*,const wxFileType::MessageParameters&) const
GetOpenCommand__10wxFileTypeCFP8wxStringRCQ2_10wxFileType17MessageParameters GetOpenCommand__10wxFileTypeCFP8wxStringRCQ2_10wxFileType17MessageParameters
;wxFileType::GetMimeType(wxString*) const ;wxFileType::GetMimeType(wxString*) const
@@ -6178,7 +6180,7 @@ EXPORTS
Read32__17wxTextInputStreamFv Read32__17wxTextInputStreamFv
;wxTextInputStream::SkipIfEndOfLine(char) ;wxTextInputStream::SkipIfEndOfLine(char)
SkipIfEndOfLine__17wxTextInputStreamFc SkipIfEndOfLine__17wxTextInputStreamFc
;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
unzReadCurrentFile unzReadCurrentFile
unzGetCurrentFileInfo unzGetCurrentFileInfo
@@ -12779,12 +12781,6 @@ EXPORTS
;wxConstructorForwxFontDialog() ;wxConstructorForwxFontDialog()
wxConstructorForwxFontDialog__Fv wxConstructorForwxFontDialog__Fv
__vft12wxFontDialog8wxObject __vft12wxFontDialog8wxObject
;wxFontDialog::Create(wxWindow*,const wxFontData&)
Create__12wxFontDialogFP8wxWindowRC10wxFontData
;wxFontDialog::wxFontDialog(wxWindow*,const wxFontData&)
__ct__12wxFontDialogFP8wxWindowRC10wxFontData
;wxFontDialog::wxFontDialog()
__ct__12wxFontDialogFv
;wxFontDialog::ShowModal() ;wxFontDialog::ShowModal()
ShowModal__12wxFontDialogFv ShowModal__12wxFontDialogFv
;wxFontDialog::sm_classwxFontDialog ;wxFontDialog::sm_classwxFontDialog