]> git.saurik.com Git - wxWidgets.git/commitdiff
Font fixes for the font dialog
authorDavid Webster <Dave.Webster@bhmi.com>
Sun, 11 Aug 2002 23:47:44 +0000 (23:47 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Sun, 11 Aug 2002 23:47:44 +0000 (23:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/fontdlg.h
src/os2/font.cpp
src/os2/fontdlg.cpp
src/os2/fontutil.cpp
src/os2/wx23.def

index 6fb9d30bf85585ba947e6b7a6a3ca24b4c0cfd16..4dff23ca4b07043c963629b5f112751977759c38 100644 (file)
 
 class WXDLLEXPORT wxFontDialog: public wxFontDialogBase
 {
 
 class WXDLLEXPORT wxFontDialog: public wxFontDialogBase
 {
-DECLARE_DYNAMIC_CLASS(wxFontDialog)
 public:
 public:
-    wxFontDialog();
-    wxFontDialog(wxWindow *parent, const wxFontData& rData);
-
-    bool Create(wxWindow *parent, const wxFontData& rData);
-
-    int ShowModal();
-    wxFontData& GetFontData() { return m_fontData; }
-
-//EK protected:
-    wxWindow*   m_dialogParent;
-    wxFontData  m_fontData;
-};
+    wxFontDialog() : wxFontDialogBase() { /* must be Create()d later */ }
+    wxFontDialog (wxWindow* pParent) : wxFontDialogBase(pParent) { Create(pParent); }
+    wxFontDialog( wxWindow*         pParent
+                 ,const wxFontData& rData
+                )
+                : wxFontDialogBase( pParent
+                                   ,rData
+                                  )
+    {
+        Create( pParent
+               ,rData
+              );
+    }
+
+    virtual int ShowModal();
+
+    //
+    // Deprecated interface, don't use
+    //
+    wxFontDialog( wxWindow*         pParent
+                 ,const wxFontData* pData
+                )
+                : wxFontDialogBase( pParent
+                                   ,pData
+                                  )
+    {
+        Create( pParent
+               ,pData
+              );
+    }
+protected:
+    DECLARE_DYNAMIC_CLASS(wxFontDialog)
+}; // end of CLASS wxFontDialog
 
 #endif
     // _WX_FONTDLG_H_
 
 #endif
     // _WX_FONTDLG_H_
index 49aaf4ccdc26f617a452184d56ccc8a718652cce..1429413d812b62e4aea109d19b9d3419603aa1d4 100644 (file)
@@ -351,7 +351,7 @@ void wxFontRefData::Init(
     if (m_hPS == NULLHANDLE)
     {
         m_hPS = ::WinGetPS(HWND_DESKTOP);
     if (m_hPS == NULLHANDLE)
     {
         m_hPS = ::WinGetPS(HWND_DESKTOP);
-        m_bInternalPS;
+        m_bInternalPS = TRUE;
     }
     else
         m_hPS = (HPS)hPS;
     }
     else
         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
                                  ,NULL
                                  ,flId
     if((lRc = ::GpiCreateLogFont( m_hPS
                                  ,NULL
                                  ,flId
@@ -418,23 +426,33 @@ bool wxFontRefData::Alloc(
     // The GpiCreateLogFont will do enough by selecting the right family,
     // and face name.
     //
     // The GpiCreateLogFont will do enough by selecting the right family,
     // 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)
-        m_nFamily = wxSWISS;
-    else if (strcmp(m_vNativeFontInfo.fa.szFacename, "WarpSans") == 0)
-        m_nFamily = wxSWISS;
-    else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Helvitica") == 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, "Helv") == 0)
+    else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helv") == 0)
         m_nFamily = wxSWISS;
         m_nFamily = wxSWISS;
-    else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Script") == 0)
+    else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "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;
     else
         m_nFamily = wxSWISS;
         m_nFamily = wxMODERN;
     else
         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;
+    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;
         nFamily = wxROMAN;
-    else if (strcmp(fa.szFacename, "WarpSans") == 0)
+    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;
+    else if (strcmp(fm.szFamilyname, "Helv") == 0)
         nFamily = wxSWISS;
         nFamily = wxSWISS;
-    else if (strcmp(fa.szFacename, "Script") == 0)
+    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;
     else
         nFamily = wxSWISS;
         nFamily = wxMODERN;
     else
         nFamily = wxSWISS;
@@ -660,29 +698,32 @@ void wxNativeFontInfo::SetFamily(
     switch (eFamily)
     {
         case wxSCRIPT:
     switch (eFamily)
     {
         case wxSCRIPT:
-            sFacename = _T("Script");
+            sFacename = wxT("Script");
             break;
 
         case wxDECORATIVE:
             break;
 
         case wxDECORATIVE:
-            sFacename = _T("Times New Roman");
+            sFacename = wxT("WarpSans");
             break;
 
         case wxROMAN:
             break;
 
         case wxROMAN:
-            sFacename = _T("Times New Roman");
+            sFacename = wxT("Times New Roman");
             break;
 
         case wxTELETYPE:
             break;
 
         case wxTELETYPE:
+            sFacename = wxT("Courier New") ;
+            break;
+
         case wxMODERN:
         case wxMODERN:
-            sFacename = _T("Courier New");
+            sFacename = wxT("Arial") ;
             break;
 
         case wxSWISS:
             break;
 
         case wxSWISS:
-            sFacename = _T("WarpSans");
+            sFacename = wxT("Helv") ;
             break;
 
         case wxDEFAULT:
         default:
             break;
 
         case wxDEFAULT:
         default:
-            sFacename = _T("Helv");
+            sFacename = wxT("System Proportional") ;
     }
 
     if (!wxStrlen(fa.szFacename) )
     }
 
     if (!wxStrlen(fa.szFacename) )
index 56afb1cc61b7d1b85b856f4099711618c76c2288..1cb0f7981b0bf46dceb686d08dc101c2f48c85de 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.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()
+int wxFontDialog::ShowModal()
 {
 {
-    m_dialogParent = NULL;
-}
+    FONTDLG                         vFontDlg;
+    char                            zCurrentFont[FACESIZE];
+    HWND                            hWndFontDlg;
+    FONTMETRICS                     vFm;
+    FACENAMEDESC                    vFn;
 
 
-wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& rData)
-{
-    Create(parent, rData);
-}
+    memset(&vFontDlg, '\0', sizeof(FONTDLG));
+    zCurrentFont[0] = '\0';
 
 
-bool wxFontDialog::Create(wxWindow *parent, const wxFontData& rData)
-{
-    m_dialogParent = parent;
+    //
+    // 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;
 
 
-    m_fontData = rData;
-    return TRUE;
-}
+    hWndFontDlg = WinFontDlg( HWND_DESKTOP
+                             ,GetParent()->GetHWND()
+                             ,&vFontDlg
+                            );
+    if (hWndFontDlg && vFontDlg.lReturn == DID_OK)
+    {
+        wxColour                    vColour((unsigned long)0x00000000);
+        wxNativeFontInfo            vInfo;
 
 
-int wxFontDialog::ShowModal()
-{
-    // TODO: show (maybe create) the dialog
+        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;
     return wxID_CANCEL;
-}
+} // end of wxFontDialg::ShowModal
 
 
index 86f9063dfe0314e46837b54c893cd6fbe39a7b60..d8560ba6783f24cbfcd17049f0af708c996343f8 100644 (file)
@@ -453,16 +453,19 @@ void wxOS2SelectMatchingFontByName(
             break;
 
         case wxDECORATIVE:
             break;
 
         case wxDECORATIVE:
+            sFaceName = wxT("WarpSans");
+            break;
+
         case wxROMAN:
         case wxROMAN:
-            sFaceName = wxT("Tms Rmn");
+            sFaceName = wxT("Times New Roman");
             break;
 
         case wxTELETYPE:
             break;
 
         case wxTELETYPE:
-            sFaceName = wxT("Courier") ;
+            sFaceName = wxT("Courier New") ;
             break;
 
         case wxMODERN:
             break;
 
         case wxMODERN:
-            sFaceName = wxT("System VIO") ;
+            sFaceName = wxT("Arial") ;
             break;
 
         case wxSWISS:
             break;
 
         case wxSWISS:
@@ -471,7 +474,7 @@ void wxOS2SelectMatchingFontByName(
 
         case wxDEFAULT:
         default:
 
         case wxDEFAULT:
         default:
-            sFaceName = wxT("System VIO") ;
+            sFaceName = wxT("System Proportional") ;
     }
 
     switch (pFont->GetWeight())
     }
 
     switch (pFont->GetWeight())
index 8ef798c78e3f4454d65c27f2ed16f6fc52787127..dad736e0e38b094b3dc6eccc752b508aac1de7d7 100644 (file)
@@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL
 CODE LOADONCALL
 
 EXPORTS
 CODE LOADONCALL
 
 EXPORTS
-;From library:  H:\DEV\WX2\WXWINDOWS\LIB\wx.lib
+;From library:  F:\Dev\Wx2\WxWindows\lib\wx.lib
   ;From object file:  dummy.cpp
     ;PUBDEFs (Symbols available from object file):
       wxDummyChar
   ;From object file:  dummy.cpp
     ;PUBDEFs (Symbols available from object file):
       wxDummyChar
@@ -1955,7 +1955,7 @@ EXPORTS
       wxEVT_NC_LEFT_DCLICK
       wxEVT_INIT_DIALOG
       wxEVT_COMMAND_SET_FOCUS
       wxEVT_NC_LEFT_DCLICK
       wxEVT_INIT_DIALOG
       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):
       ConvertToIeeeExtended
       ConvertFromIeeeExtended
     ;PUBDEFs (Symbols available from object file):
       ConvertToIeeeExtended
       ConvertFromIeeeExtended
@@ -4302,6 +4302,8 @@ EXPORTS
       ClearData__18wxMimeTypesManagerFv
       ;wxArrayFileTypeInfo::operator=(const wxArrayFileTypeInfo&)
       __as__19wxArrayFileTypeInfoFRC19wxArrayFileTypeInfo
       ClearData__18wxMimeTypesManagerFv
       ;wxArrayFileTypeInfo::operator=(const wxArrayFileTypeInfo&)
       __as__19wxArrayFileTypeInfoFRC19wxArrayFileTypeInfo
+      ;wxFileType::GetOpenCommand(const wxString&) const
+      GetOpenCommand__10wxFileTypeCFRC8wxString
       ;wxFileType::GetOpenCommand(wxString*,const wxFileType::MessageParameters&) const
       GetOpenCommand__10wxFileTypeCFP8wxStringRCQ2_10wxFileType17MessageParameters
       ;wxFileType::GetMimeType(wxString*) const
       ;wxFileType::GetOpenCommand(wxString*,const wxFileType::MessageParameters&) const
       GetOpenCommand__10wxFileTypeCFP8wxStringRCQ2_10wxFileType17MessageParameters
       ;wxFileType::GetMimeType(wxString*) const
@@ -6178,7 +6180,7 @@ EXPORTS
       Read32__17wxTextInputStreamFv
       ;wxTextInputStream::SkipIfEndOfLine(char)
       SkipIfEndOfLine__17wxTextInputStreamFc
       Read32__17wxTextInputStreamFv
       ;wxTextInputStream::SkipIfEndOfLine(char)
       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):
       unzReadCurrentFile
       unzGetCurrentFileInfo
     ;PUBDEFs (Symbols available from object file):
       unzReadCurrentFile
       unzGetCurrentFileInfo
@@ -12779,12 +12781,6 @@ EXPORTS
       ;wxConstructorForwxFontDialog()
       wxConstructorForwxFontDialog__Fv
       __vft12wxFontDialog8wxObject
       ;wxConstructorForwxFontDialog()
       wxConstructorForwxFontDialog__Fv
       __vft12wxFontDialog8wxObject
-      ;wxFontDialog::Create(wxWindow*,const wxFontData&)
-      Create__12wxFontDialogFP8wxWindowRC10wxFontData
-      ;wxFontDialog::wxFontDialog(wxWindow*,const wxFontData&)
-      __ct__12wxFontDialogFP8wxWindowRC10wxFontData
-      ;wxFontDialog::wxFontDialog()
-      __ct__12wxFontDialogFv
       ;wxFontDialog::ShowModal()
       ShowModal__12wxFontDialogFv
       ;wxFontDialog::sm_classwxFontDialog
       ;wxFontDialog::ShowModal()
       ShowModal__12wxFontDialogFv
       ;wxFontDialog::sm_classwxFontDialog