]> git.saurik.com Git - wxWidgets.git/commitdiff
Font updates for OS/2
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 11 Dec 2000 04:36:46 +0000 (04:36 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 11 Dec 2000 04:36:46 +0000 (04:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8906 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/font.h
include/wx/os2/private.h
src/os2/app.cpp
src/os2/dc.cpp
src/os2/dcclient.cpp
src/os2/font.cpp
src/os2/fontutil.cpp
src/os2/frame.cpp

index d645c30e389f713fe67fc58b04c3a5ff80e148dd..410e0bc200abc30f0bc2a0d333bbcc112c716ed2 100644 (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(int size,
-           int family,
-           int style,
-           int weight,
-           bool underlined = FALSE,
-           const wxString& face = wxEmptyString,
-           wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
+    wxFont(const wxFont& rFont) { Init(); Ref(rFont); }
+
+    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);
-
-    // 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;
-
-    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);
-
-    // implementation only from now on
+    //
+    // Assignment
+    //
+    wxFont& operator=(const wxFont& rFont);
+
+    //
+    // 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 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
     // -------------------------------
-
-    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:
+    void OS2SelectMatchingFontByName(void);
+
     DECLARE_DYNAMIC_CLASS(wxFont)
-};
+}; // end of wxFont
 
-#endif
-    // _WX_FONT_H_
+#endif // _WX_FONT_H_
index 1c83c9da7ed1216181e23b00a627ba006c4762c7..d42540d24b5dc2617697aa203e615e7e3dd17367 100644 (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);
index 35f7a8481cca145ce0709b01431eb97d1d172a16..2260c6d2c675d5337e9d3da2ca3512e61fce4559 100644 (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)
                            ))
     {
index 2de4ebe67253fd915852dcf918445633458620b2..411e93b2f1f0e52252c94128ee9239c635804f31 100644 (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
index 7c4950211d3cc90e42135dd8941b6779d9f4ed31..a5cc0f7fee148674cea5da049c6b2f2b076c0ad9 100644 (file)
 
 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;
-}
index 19c715f7a25445e70d12c2ad2cb36848d764b8eb..38289bdeba19644d3a0803e9fd6d087595f3248b 100644 (file)
@@ -8,36 +8,6 @@
 // Copyright:   (c) David Webster
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
-#define DEBUG_PRINTF(NAME)   { static int raz=0; \
-  printf( #NAME " %i\n",raz); fflush(stdout);       \
-   raz++;                                        \
- }
-
- #include <malloc.h>
- #include <stdio.h>
-
- int HeapCheck(void)
- {
-    int  rc;
-
-    if (_HEAPOK != (rc = _heapchk()))
-    {
-       switch(rc)
-       {
-          case _HEAPEMPTY:
-             puts("The heap has not been initialized.");
-             break;
-          case _HEAPBADNODE:
-             puts("A memory node is corrupted or the heap is damaged.");
-             break;
-          case _HEAPBADBEGIN:
-             puts("The heap specified is not valid.");
-             break;
-       }
-       fflush(stdout);
-    }
-    return 0;
- }
 
 // ============================================================================
 // declarations
 
 #include "wx/os2/private.h"
 
-    IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
 
-    #if wxUSE_PORTABLE_FONTS_IN_MSW
-        IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject)
-    #endif
+#if wxUSE_PORTABLE_FONTS_IN_MSW
+    IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject)
+#endif
 
 // ----------------------------------------------------------------------------
 // wxFontRefData - the internal description of the font
@@ -85,53 +55,65 @@ public:
 
     wxFontRefData(const wxFontRefData& data)
     {
-        Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
-             data.m_underlined, data.m_faceName, data.m_encoding);
+        Init(data.m_nPointSize, data.m_nFamily, data.m_nStyle, data.m_nWeight,
+             data.m_bUnderlined, data.m_sFaceName, data.m_vEncoding);
 
-        m_fontId = data.m_fontId;
+        m_nFontId = data.m_nFontId;
     }
 
-    wxFontRefData(int size,
-                  int family,
-                  int style,
-                  int weight,
-                  bool underlined,
-                  const wxString& faceName,
-                  wxFontEncoding encoding)
+    wxFontRefData( int             nSize
+                  ,int             nFamily
+                  ,int             nStyle
+                  ,int             nWeight
+                  ,bool            bUnderlined
+                  ,const wxString& sFaceName
+                  ,wxFontEncoding  vEncoding
+                 )
     {
-        Init(size, family, style, weight, underlined, faceName, encoding);
+        Init(nSize, nFamily, nStyle, nWeight, bUnderlined, sFaceName, vEncoding);
     }
 
     virtual ~wxFontRefData();
 
 protected:
     // common part of all ctors
-    void Init(int size,
-              int family,
-              int style,
-              int weight,
-              bool underlined,
-              const wxString& faceName,
-              wxFontEncoding encoding);
-
+    void Init( int             nSize
+              ,int             nFamily
+              ,int             nStyle
+              ,int             nWeight
+              ,bool            bUnderlined
+              ,const wxString& rsFaceName
+              ,wxFontEncoding  vEncoding
+             );
+
+    //
     // If TRUE, the pointer to the actual font is temporary and SHOULD NOT BE
     // DELETED by destructor
-    bool          m_temporary;
-
-    int           m_fontId;
-
-    // font characterstics
-    int           m_pointSize;
-    int           m_family;
-    int           m_style;
-    int           m_weight;
-    bool          m_underlined;
-    wxString      m_faceName;
-    wxFontEncoding m_encoding;
-
-    // Windows font handle
-    WXHFONT       m_hFont;
-};
+    //
+    bool                            m_bTemporary;
+    int                             m_nFontId;
+
+    //
+    // Font characterstics
+    //
+    int                             m_nPointSize;
+    int                             m_nFamily;
+    int                             m_nStyle;
+    int                             m_nWeight;
+    bool                            m_bUnderlined;
+    wxString                        m_sFaceName;
+    wxFontEncoding                  m_vEncoding;
+
+    //
+    // Some PM specific stuff
+    //
+    WXHFONT                         m_hFont;
+    PFONTMETRICS                    m_pFM;       // array of FONTMETRICS structs
+    int                             m_nNumFonts; // number of fonts in array
+    HPS                             m_hPS;       // PS handle this font belongs to
+    FATTRS                          m_vFattrs;   // Current fattrs struct
+    FACENAMEDESC                    m_vFname;    // Current facename struct
+}; // end of CLASS wxFontRefData
 
 // ============================================================================
 // implementation
@@ -141,40 +123,38 @@ protected:
 // wxFontRefData
 // ----------------------------------------------------------------------------
 
-void wxFontRefData::Init(int pointSize,
-                         int family,
-                         int style,
-                         int weight,
-                         bool underlined,
-                         const wxString& faceName,
-                         wxFontEncoding encoding)
+void wxFontRefData::Init(
+  int                               nPointSize
+, int                               nFamily
+, int                               nStyle
+, int                               nWeight
+, bool                              bUnderlined
+, const wxString&                   rsFaceName
+, wxFontEncoding                    vEncoding
+)
 {
-    m_style = style;
-    m_pointSize = pointSize;
-    m_family = family;
-    m_style = style;
-    m_weight = weight;
-    m_underlined = underlined;
-    m_faceName = faceName;
-    m_encoding = encoding;
-
-    m_fontId = 0;
-    m_temporary = FALSE;
-
-    m_hFont = 0;
-}
+    m_nStyle      = nStyle;
+    m_nPointSize  = nPointSize;
+    m_nFamily     = nFamily;
+    m_nStyle      = nStyle;
+    m_nWeight     = nWeight;
+    m_bUnderlined = bUnderlined;
+    m_sFaceName   = rsFaceName;
+    m_vEncoding   = vEncoding;
+    m_nFontId     = 0;
+    m_bTemporary  = FALSE;
+
+    m_hFont       = 0;
+    m_pFM         = (PFONTMETRICS)NULL;
+    m_hPS         = NULLHANDLE;
+    m_nNumFonts   = 0;
+} // end of wxFontRefData::Init
 
 wxFontRefData::~wxFontRefData()
 {
-DEBUG_PRINTF(wxFontRefData::~wxFontRefData!!!)
-// TODO:
-//    if ( m_hFont )
-//    {
-//        if ( !::DeleteObject((HFONT) m_hFont) )
-//        {
-//            wxLogLastError("DeleteObject(font)");
-//        }
-//    }
+    if (m_pFM)
+        delete [] m_pFM;
+    m_pFM = (PFONTMETRICS)NULL;
 }
 
 // ----------------------------------------------------------------------------
@@ -183,47 +163,42 @@ DEBUG_PRINTF(wxFontRefData::~wxFontRefData!!!)
 
 void wxFont::Init()
 {
-
-DEBUG_PRINTF(wxFontRefData::~wxFontRefData!!!)
-
     if ( wxTheFontList )
         wxTheFontList->Append(this);
 }
 
-/* Constructor for a font. Note that the real construction is done
- * in wxDC::SetFont, when information is available about scaling etc.
- */
-bool wxFont::Create(int pointSize,
-                    int family,
-                    int style,
-                    int weight,
-                    bool underlined,
-                    const wxString& faceName,
-                    wxFontEncoding encoding)
+// ----------------------------------------------------------------------------
+// Constructor for a font. Note that the real construction is done
+// in wxDC::SetFont, when information is available about scaling etc.
+// ----------------------------------------------------------------------------
+bool wxFont::Create(
+  int                               nPointSize
+, int                               nFamily
+, int                               nStyle
+, int                               nWeight
+, bool                              bUnderlined
+, const wxString&                   rsFaceName
+, wxFontEncoding                    vEncoding
+)
 {
     UnRef();
-DEBUG_PRINTF(wxFontRefData::~wxFontRefData!!!)
-    m_refData = new wxFontRefData(pointSize, family, style, weight,
-                                  underlined, faceName, encoding);
-
+    m_refData = new wxFontRefData( nPointSize
+                                  ,nFamily
+                                  ,nStyle
+                                  ,nWeight
+                                  ,bUnderlined
+                                  ,rsFaceName
+                                  ,vEncoding
+                                 );
     RealizeResource();
-
     return TRUE;
-}
+} // end of wxFont::Create
 
 wxFont::~wxFont()
 {
-  int l;
-  l = sizeof(*this);
-HeapCheck();
- _heap_check();
-
-    if ( wxTheFontList )
+    if (wxTheFontList)
         wxTheFontList->DeleteObject(this);
-HeapCheck();
- _heap_check();
-
-}
+} // end of wxFont::~wxFont
 
 // ----------------------------------------------------------------------------
 // real implementation
@@ -234,7 +209,11 @@ HeapCheck();
 
 bool wxFont::RealizeResource()
 {
-DEBUG_PRINTF(wxFont::RealizeResource)
+    LONG                            lNumFonts = 0L;
+    LONG                            lTemp = 0L;
+    PFONTMETRICS                    pFM = NULL;
+    ERRORID                         vError;
+
     if ( GetResourceHandle() )
     {
         // VZ: the old code returned FALSE in this case, but it doesn't seem
@@ -244,231 +223,194 @@ DEBUG_PRINTF(wxFont::RealizeResource)
        return TRUE;
     }
 
-    HPS          hps;
-    FATTRS       fAttrs;
-    FACENAMEDESC fName;
-    LONG         fLid;
-
-    fAttrs.usRecordLength = sizeof(FATTRS);
-    fAttrs.fsFontUse = FATTR_FONTUSE_OUTLINE |       // only outline fonts allowed
-                       FATTR_FONTUSE_TRANSFORMABLE;  // may be transformed
-    fAttrs.fsType = 0;
-    fAttrs.lMaxBaselineExt = fAttrs.lAveCharWidth = 0;
-    fAttrs.idRegistry = 0;
-    fAttrs.lMatch = 0;
-
-    fName.usSize = sizeof(FACENAMEDESC);
-    fName.usWidthClass = FWIDTH_NORMAL;
-    fName.usReserved = 0;
-    fName.flOptions = 0;
+    LONG                            flId;
+    bool                            bInternalPS = FALSE;  // if we have to create one
 
-    wxString ff_face;
-
-// OS/2 combines the family with styles to give a facename
-
-    switch ( M_FONTDATA->m_family )
+    //
+    // Now cheking
+    //
+    flId = 1L;
+    if (!M_FONTDATA->m_hPS)
     {
-        case wxSCRIPT:
-        case wxDECORATIVE:
-        case wxROMAN:
-            ff_face = wxT("Times New Roman") ;
-            break;
-
-        case wxTELETYPE:
-        case wxMODERN:
-            ff_face = wxT("Courier") ;
-            break;
-
-        case wxSWISS:
-        case wxDEFAULT:
-        default:
-            ff_face = wxT("Helvetica") ;
+        M_FONTDATA->m_hPS = ::WinGetPS(HWND_DESKTOP);
+        bInternalPS = TRUE;
     }
 
-    switch ( M_FONTDATA->m_style )
+    if (M_FONTDATA->m_pFM)
     {
-        case wxITALIC:
-        case wxSLANT:
-            fAttrs.fsSelection = FATTR_SEL_ITALIC;
-            break;
-
-        default:
-            wxFAIL_MSG(wxT("unknown font slant"));
-            // fall through
-
-        case wxNORMAL:
-            fAttrs.fsSelection = 0;
+        delete [] M_FONTDATA->m_pFM;
+        M_FONTDATA->m_pFM = NULL;
     }
-
-    switch ( M_FONTDATA->m_weight )
+    //
+    // Determine the number of fonts.
+    //
+    lNumFonts = ::GpiQueryFonts( M_FONTDATA->m_hPS
+                                ,QF_PUBLIC
+                                ,NULL
+                                ,&lTemp
+                                ,(LONG) sizeof(FONTMETRICS)
+                                ,NULL
+                               );
+
+    //
+    // Allocate space for the font metrics.
+    //
+    pFM = new FONTMETRICS[lNumFonts + 1];
+
+    //
+    // Retrieve the font metrics.
+    //
+    lTemp = lNumFonts;
+    lTemp = ::GpiQueryFonts( M_FONTDATA->m_hPS
+                            ,QF_PUBLIC
+                            ,NULL
+                            ,&lTemp
+                            ,(LONG) sizeof(FONTMETRICS)
+                            ,pFM
+                           );
+    SetFM( pFM
+          ,(int)lNumFonts
+         );
+
+    wxString                        sVals;
+
+    for (int i = 0; i < lNumFonts; i++)
     {
-        default:
-            wxFAIL_MSG(wxT("unknown font weight"));
-            // fall through
-
-        case wxNORMAL:
-            fName.usWeightClass = FWEIGHT_NORMAL;
-            break;
-
-        case wxLIGHT:
-            fName.usWeightClass = FWEIGHT_LIGHT;
-            break;
-
-        case wxBOLD:
-            fName.usWeightClass = FWEIGHT_BOLD;
-            break;
-    }
-
-    if( M_FONTDATA->m_underlined )
-        fAttrs.fsSelection |= FATTR_SEL_UNDERSCORE;
-
-    wxFontEncoding encoding = M_FONTDATA->m_encoding;
-    if ( encoding == wxFONTENCODING_DEFAULT )
-    {
-        encoding = wxFont::GetDefaultEncoding();
+         sVals << "Face: " <<M_FONTDATA->m_pFM[i].szFacename
+               << "Family: " <<M_FONTDATA->m_pFM[i].szFamilyname
+               << " PointSize: " << M_FONTDATA->m_pFM[i].lEmHeight
+               << " Height: " << M_FONTDATA->m_pFM[i].lXHeight
+               ;
+         sVals = "";
     }
+    M_FONTDATA->m_vFattrs.usRecordLength = sizeof(FATTRS);
+    M_FONTDATA->m_vFattrs.fsFontUse = FATTR_FONTUSE_OUTLINE |       // only outline fonts allowed
+                                      FATTR_FONTUSE_TRANSFORMABLE;  // may be transformed
+    M_FONTDATA->m_vFattrs.fsType = 0;
+    M_FONTDATA->m_vFattrs.lMaxBaselineExt = M_FONTDATA->m_vFattrs.lAveCharWidth = 0;
+    M_FONTDATA->m_vFattrs.idRegistry = 0;
+    M_FONTDATA->m_vFattrs.lMatch = 0;
 
-    switch ( encoding )
-    {
-        case wxFONTENCODING_ISO8859_1:
-        case wxFONTENCODING_ISO8859_15:
-        case wxFONTENCODING_CP1250:
-            fAttrs.usCodePage = 1250;
-            break;
-
-        case wxFONTENCODING_ISO8859_2:
-        case wxFONTENCODING_CP1252:
-            fAttrs.usCodePage = 1252;
-            break;
-
-        case wxFONTENCODING_ISO8859_4:
-        case wxFONTENCODING_ISO8859_10:
-            fAttrs.usCodePage = 850; // what is baltic?
-            break;
-
-        case wxFONTENCODING_ISO8859_5:
-        case wxFONTENCODING_CP1251:
-            fAttrs.usCodePage = 1251;
-            break;
-
-        case wxFONTENCODING_ISO8859_6:
-            fAttrs.usCodePage = 850;  // what is arabic?
-            break;
-
-        case wxFONTENCODING_ISO8859_7:
-            fAttrs.usCodePage = 850;  // what is greek
-            break;
-
-        case wxFONTENCODING_ISO8859_8:
-            fAttrs.usCodePage = 850; // what is hebrew?
-            break;
-
-        case wxFONTENCODING_ISO8859_9:
-            fAttrs.usCodePage = 857;
-            break;
-
-        case wxFONTENCODING_ISO8859_11:
-            fAttrs.usCodePage = 850; // what is thai
-            break;
-
-        case wxFONTENCODING_CP437:
-            fAttrs.usCodePage = 437;
-            break;
-
-        default:
-            wxFAIL_MSG(wxT("unsupported encoding"));
-            // fall through
-
-        case wxFONTENCODING_SYSTEM:
-            fAttrs.usCodePage = 850; // what is ANSI?
-            break;
-    }
+    M_FONTDATA->m_vFname.usSize = sizeof(FACENAMEDESC);
+    M_FONTDATA->m_vFname.usWidthClass = FWIDTH_NORMAL;
+    M_FONTDATA->m_vFname.usReserved = 0;
+    M_FONTDATA->m_vFname.flOptions = 0;
 
-// Now cheking
-    fLid = 1;
-    hps  = ::WinGetPS( HWND_DESKTOP );
+    OS2SelectMatchingFontByName();
 
-    long numLids = ::GpiQueryNumberSetIds( hps );
-    long gpiError;
+    long                            lNumLids = ::GpiQueryNumberSetIds(M_FONTDATA->m_hPS);
+    long                            lGpiError;
 
+    //
     // First we should generate unique id
-    if( numLids )
+    //
+    if(lNumLids )
     {
-        long Types[255];
-        STR8 Names[255];
-        long lIds[255];
-
-        if( !GpiQuerySetIds(hps, numLids, Types, Names, lIds) )
+        long                        alTypes[255];
+        STR8                        azNames[255];
+        long                        alIds[255];
+
+        if(!::GpiQuerySetIds( M_FONTDATA->m_hPS
+                             ,lNumLids
+                             ,alTypes
+                             ,azNames
+                             ,alIds
+                            ))
         {
-            ::WinReleasePS( hps );
+            if (bInternalPS)
+                ::WinReleasePS(M_FONTDATA->m_hPS);
             return 0;
         }
 
-        for(unsigned long LCNum = 0; LCNum < numLids; LCNum++)
-            if(lIds[LCNum] == fLid)
-               ++fLid;
-        if(fLid > 254)  // wow, no id available!
+        for(unsigned long LCNum = 0; LCNum < lNumLids; LCNum++)
+            if(alIds[LCNum] == flId)
+               ++flId;
+        if(flId > 254)  // wow, no id available!
         {
-           ::WinReleasePS( hps );
+            if (bInternalPS)
+               ::WinReleasePS(M_FONTDATA->m_hPS);
            return 0;
         }
     }
 
-    // now building facestring
-    if(::GpiQueryFaceString(hps, ff_face.c_str(), &fName, FACESIZE, fAttrs.szFacename) == GPI_ERROR)
+    //
+    // Release and delete the current font
+    //
+    ::GpiSetCharSet(M_FONTDATA->m_hPS, LCID_DEFAULT);/* release the font before deleting */
+    ::GpiDeleteSetId(M_FONTDATA->m_hPS, 1L);         /* delete the logical font          */
+
+    //
+    // Now build a facestring
+    //
+    char                            zFacename[128];
+    strcpy(zFacename, M_FONTDATA->m_vFattrs.szFacename);
+
+    if(::GpiQueryFaceString( M_FONTDATA->m_hPS
+                            ,zFacename
+                            ,&M_FONTDATA->m_vFname
+                            ,FACESIZE
+                            ,M_FONTDATA->m_vFattrs.szFacename
+                           ) == GPI_ERROR)
     {
-       ::WinReleasePS( hps );
-       return 0;
+        vError = ::WinGetLastError(vHabmain);
     }
 
-    // now creating font
-    WXHFONT hFont = (WXHFONT)0;
+    strcpy(zFacename, M_FONTDATA->m_vFattrs.szFacename);
 
-    if(::GpiCreateLogFont(hps, NULL, fLid, &fAttrs) != GPI_ERROR)
-       M_FONTDATA->m_hFont = hFont = (WXHFONT)1;
+    if(::GpiCreateLogFont( M_FONTDATA->m_hPS
+                          ,NULL
+                          ,flId
+                          ,&M_FONTDATA->m_vFattrs
+                         ) != GPI_ERROR)
+       M_FONTDATA->m_hFont = (WXHFONT)1;
 
-    if( hFont )
-        ::GpiDeleteSetId(hps, fLid);
 
-    ::WinReleasePS( hps );
+    if (bInternalPS)
+    {
+        if(M_FONTDATA->m_hFont)
+            ::GpiDeleteSetId( M_FONTDATA->m_hPS
+                             ,flId
+                            );
 
-    if ( !hFont )
+        ::WinReleasePS(M_FONTDATA->m_hPS);
+    }
+    else
+        ::GpiSetCharSet(M_FONTDATA->m_hPS, flId); // sets font for presentation space
+    if (!M_FONTDATA->m_hFont)
     {
         wxLogLastError("CreateFont");
     }
+    M_FONTDATA->m_nFontId = flId;
+    return(M_FONTDATA->m_hFont != 0);
+} // end of wxFont::RealizeResource
 
-    return hFont != 0;
-}
-
-bool wxFont::FreeResource(bool force)
+bool wxFont::FreeResource(
+  bool                              bForce
+)
 {
-    if ( GetResourceHandle() )
+    if (GetResourceHandle())
     {
-// TODO:
-//        if ( !::DeleteObject((HFONT) M_FONTDATA->m_hFont) )
-//        {
-//            wxLogLastError("DeleteObject(font)");
-//        }
-
         M_FONTDATA->m_hFont = 0;
-
+        ::GpiDeleteSetId( M_FONTDATA->m_hPS
+                         ,M_FONTDATA->m_nFontId
+                        );
         return TRUE;
     }
     return FALSE;
-}
+} // end of wxFont::FreeResource
 
 WXHANDLE wxFont::GetResourceHandle()
 {
-    if ( !M_FONTDATA )
+    if (!M_FONTDATA)
         return 0;
     else
-        return (WXHANDLE)M_FONTDATA->m_hFont ;
-}
+        return (WXHANDLE)M_FONTDATA->m_hFont;
+} // end of wxFont::GetResourceHandle
 
 bool wxFont::IsFree() const
 {
     return (M_FONTDATA && (M_FONTDATA->m_hFont == 0));
-}
+} // end of wxFont::IsFree
 
 void wxFont::Unshare()
 {
@@ -483,74 +425,111 @@ void wxFont::Unshare()
         UnRef();
         m_refData = ref;
     }
-}
+} // end of wxFont::Unshare
 
 // ----------------------------------------------------------------------------
 // change font attribute: we recreate font when doing it
 // ----------------------------------------------------------------------------
 
-void wxFont::SetPointSize(int pointSize)
+void wxFont::SetPointSize(
+  int                               nPointSize
+)
 {
     Unshare();
 
-    M_FONTDATA->m_pointSize = pointSize;
+    M_FONTDATA->m_nPointSize = nPointSize;
 
     RealizeResource();
-}
+} // end of wxFont::SetPointSize
 
-void wxFont::SetFamily(int family)
+void wxFont::SetFamily(
+  int                               nFamily
+)
 {
     Unshare();
 
-    M_FONTDATA->m_family = family;
+    M_FONTDATA->m_nFamily = nFamily;
 
     RealizeResource();
-}
+} // end of wxFont::SetFamily
 
-void wxFont::SetStyle(int style)
+void wxFont::SetStyle(
+  int                               nStyle
+)
 {
     Unshare();
 
-    M_FONTDATA->m_style = style;
+    M_FONTDATA->m_nStyle = nStyle;
 
     RealizeResource();
-}
+} // end of wxFont::SetStyle
 
-void wxFont::SetWeight(int weight)
+void wxFont::SetWeight(
+  int                               nWeight
+)
 {
     Unshare();
 
-    M_FONTDATA->m_weight = weight;
+    M_FONTDATA->m_nWeight = nWeight;
 
     RealizeResource();
-}
+} // end of wxFont::SetWeight
 
-void wxFont::SetFaceName(const wxString& faceName)
+void wxFont::SetFaceName(
+  const wxString&                   rsFaceName
+)
 {
     Unshare();
 
-    M_FONTDATA->m_faceName = faceName;
+    M_FONTDATA->m_sFaceName = rsFaceName;
 
     RealizeResource();
-}
+} // end of wxFont::SetFaceName
 
-void wxFont::SetUnderlined(bool underlined)
+void wxFont::SetUnderlined(
+  bool                              bUnderlined
+)
 {
     Unshare();
 
-    M_FONTDATA->m_underlined = underlined;
+    M_FONTDATA->m_bUnderlined = bUnderlined;
 
     RealizeResource();
-}
+} // end of wxFont::SetUnderlined
 
-void wxFont::SetEncoding(wxFontEncoding encoding)
+void wxFont::SetEncoding(
+  wxFontEncoding                    vEncoding
+)
 {
     Unshare();
 
-    M_FONTDATA->m_encoding = encoding;
+    M_FONTDATA->m_vEncoding = vEncoding;
 
     RealizeResource();
-}
+} // end of wxFont::SetEncoding
+
+void wxFont::SetPS(
+  HPS                               hPS
+)
+{
+    Unshare();
+
+    M_FONTDATA->m_hPS = hPS;
+
+    RealizeResource();
+} // end of wxFont::SetPS
+
+void wxFont::SetFM(
+  PFONTMETRICS                      pFM
+, int                               nNumFonts
+)
+{
+    //
+    // Don't realize the font with this one
+    //
+    M_FONTDATA->m_pFM = pFM;
+    M_FONTDATA->m_nNumFonts = nNumFonts;
+} // end of wxFont::SetFM
 
 // ----------------------------------------------------------------------------
 // accessors
@@ -558,51 +537,253 @@ void wxFont::SetEncoding(wxFontEncoding encoding)
 
 int wxFont::GetPointSize() const
 {
-DEBUG_PRINTF(wxFont::GetPointSize)
     wxFontRefData*                  pTmp;
 
     pTmp = M_FONTDATA;
     if(pTmp)
-      return pTmp->m_pointSize;
+      return pTmp->m_nPointSize;
     else
         return 10;
-}
+} // end of wxFont::GetPointSize
 
 int wxFont::GetFamily() const
 {
-    return M_FONTDATA->m_family;
-}
+    return M_FONTDATA->m_nFamily;
+} // end of wxFont::GetFamily
 
 int wxFont::GetFontId() const
 {
-    return M_FONTDATA->m_fontId;
-}
+    return M_FONTDATA->m_nFontId;
+} // end of wxFont::GetFontId
 
 int wxFont::GetStyle() const
 {
-    return M_FONTDATA->m_style;
-}
+    return M_FONTDATA->m_nStyle;
+} // end of wxFont::GetStyle
 
 int wxFont::GetWeight() const
 {
-    return M_FONTDATA->m_weight;
+    return M_FONTDATA->m_nWeight;
 }
 
 bool wxFont::GetUnderlined() const
 {
-    return M_FONTDATA->m_underlined;
-}
+    return M_FONTDATA->m_bUnderlined;
+} // end of wxFont::GetUnderlined
 
 wxString wxFont::GetFaceName() const
 {
-    wxString str;
+    wxString                        sStr;
+
     if ( M_FONTDATA )
-        str = M_FONTDATA->m_faceName ;
-    return str;
-}
+        sStr = M_FONTDATA->m_sFaceName ;
+    return sStr;
+} // end of wxFont::GetFaceName
 
 wxFontEncoding wxFont::GetEncoding() const
 {
-    return M_FONTDATA->m_encoding;
+    return M_FONTDATA->m_vEncoding;
+} // end of wxFont::GetEncoding
+
+HPS wxFont::GetPS() const
+{
+    return M_FONTDATA->m_hPS;
+} // end of wxFont::GetPS
+
+void wxFont::OS2SelectMatchingFontByName()
+{
+    int                             i;
+    int                             nDiff0;
+    int                             nDiff;
+    int                             nIs;
+    int                             nIndex;
+    int                             nMinDiff;
+    int                             nMinDiff0;
+    int                             nApirc;
+    int                             anDiff[16];
+    int                             anMinDiff[16];
+    STR8                            zFn;
+    char                            zFontFaceName[FACESIZE];
+    wxString                        sFaceName;
+    USHORT                          usWeightClass;
+    int                             fsSelection = 0;
+
+    nMinDiff0 = 0xf000;
+    for(i = 0;i < 16; i++)
+        anMinDiff[i] = nMinDiff0;
+
+    switch (GetFamily())
+    {
+        case wxSCRIPT:
+            sFaceName = wxT("Script");
+            break;
+
+        case wxDECORATIVE:
+        case wxROMAN:
+            sFaceName = wxT("Times New Roman");
+            break;
+
+        case wxTELETYPE:
+        case wxMODERN:
+            sFaceName = wxT("Courier") ;
+            break;
+
+        case wxSWISS:
+            sFaceName = wxT("WarpSans") ;
+            break;
+
+        case wxDEFAULT:
+        default:
+            sFaceName = wxT("Helv") ;
+    }
+
+    switch (GetWeight())
+    {
+        default:
+            wxFAIL_MSG(_T("unknown font weight"));
+            // fall through
+            usWeightClass = FWEIGHT_DONT_CARE;
+            break;
+
+        case wxNORMAL:
+            usWeightClass = FWEIGHT_NORMAL;
+            break;
+
+        case wxLIGHT:
+            usWeightClass = FWEIGHT_LIGHT;
+            break;
+
+        case wxBOLD:
+            usWeightClass = FWEIGHT_BOLD;
+            break;
+
+         case wxFONTWEIGHT_MAX:
+            usWeightClass = FWEIGHT_ULTRA_BOLD;
+            break;
+    }
+    M_FONTDATA->m_vFname.usWeightClass = usWeightClass;
+
+    switch (GetStyle())
+    {
+        case wxITALIC:
+        case wxSLANT:
+            fsSelection = FM_SEL_ITALIC;
+            M_FONTDATA->m_vFname.flOptions = FTYPE_ITALIC;
+            break;
+
+        default:
+            wxFAIL_MSG(wxT("unknown font slant"));
+            // fall through
+
+        case wxNORMAL:
+            fsSelection  = 0;
+            break;
+    }
+
+    wxStrncpy(zFontFaceName, sFaceName.c_str(), WXSIZEOF(zFontFaceName));
+    M_FONTDATA->m_nPointSize = GetPointSize();
+    nIndex = 0;
+    for(i = 0, nIs = 0; i < M_FONTDATA->m_nNumFonts; i++)
+    {
+        // Debug code
+        int nPointSize = M_FONTDATA->m_nPointSize;
+        int nEmHeight = 0;
+        int nXHeight  = 0;
+        anDiff[0] = wxGpiStrcmp(M_FONTDATA->m_pFM[i].szFamilyname, zFontFaceName);
+        anDiff[1] = abs(M_FONTDATA->m_pFM[i].lEmHeight - M_FONTDATA->m_nPointSize);
+        anDiff[2] = abs(M_FONTDATA->m_pFM[i].usWeightClass -  usWeightClass);
+        anDiff[3] = abs((M_FONTDATA->m_pFM[i].fsSelection & 0x2f) -  fsSelection);
+        if(anDiff[0] == 0)
+        {
+            nEmHeight = (int)M_FONTDATA->m_pFM[i].lEmHeight;
+            nXHeight  =(int)M_FONTDATA->m_pFM[i].lXHeight;
+            if( (nIs & 0x01) == 0)
+            {
+                nIs = 1;
+                nIndex = i;
+                anMinDiff[1] = anDiff[1];
+                anMinDiff[2] = anDiff[2];
+                anMinDiff[3] = anDiff[3];
+            }
+            else if(anDiff[3] < anMinDiff[3])
+            {
+                nIndex = i;
+                anMinDiff[3] = anDiff[3];
+            }
+            else if(anDiff[2] < anMinDiff[2])
+            {
+                nIndex = i;
+                anMinDiff[2] = anDiff[2];
+            }
+            else if(anDiff[1] < anMinDiff[1])
+            {
+                nIndex = i;
+                anMinDiff[1] = anDiff[1];
+            }
+            anMinDiff[0] = 0;
+        }
+        else if(anDiff[0] < anMinDiff[0])
+        {
+              nIs = 2;
+              nIndex = i;
+              anMinDiff[3] = anDiff[3];
+              anMinDiff[2] = anDiff[2];
+              anMinDiff[1] = anDiff[1];
+              anMinDiff[0] = anDiff[0];
+        }
+        else if(anDiff[0] == anMinDiff[0])
+        {
+            if(anDiff[3] < anMinDiff[3])
+            {
+                nIndex = i;
+                anMinDiff[3] = anDiff[3];
+                nIs = 2;
+            }
+            else if(anDiff[2] < anMinDiff[2])
+            {
+                nIndex = i;
+                anMinDiff[2] = anDiff[2];
+                nIs = 2;
+            }
+            else if(anDiff[1] < anMinDiff[1])
+            {
+                nIndex = i;
+                anMinDiff[1] = anDiff[1];
+                nIs = 2;
+            }
+        }
+    }
+
+    M_FONTDATA->m_vFattrs.usRecordLength = sizeof(FATTRS);                        // sets size of structure
+    M_FONTDATA->m_vFattrs.fsSelection    = M_FONTDATA->m_pFM[nIndex].fsSelection; // uses default selection
+    M_FONTDATA->m_vFattrs.lMatch         = M_FONTDATA->m_pFM[nIndex].lMatch;      // force match
+    M_FONTDATA->m_vFattrs.idRegistry     = M_FONTDATA->m_pFM[nIndex].idRegistry;  // uses default registry
+    M_FONTDATA->m_vFattrs.usCodePage     = M_FONTDATA->m_pFM[nIndex].usCodePage;  // code-page
+    if(M_FONTDATA->m_pFM[nIndex].lMatch)
+    {
+        M_FONTDATA->m_vFattrs.lMaxBaselineExt = M_FONTDATA->m_pFM[nIndex].lMaxBaselineExt; // requested font height
+        M_FONTDATA->m_vFattrs.lAveCharWidth   = M_FONTDATA->m_pFM[nIndex].lAveCharWidth ;  // requested font width
+    }
+    else
+    {
+        M_FONTDATA->m_vFattrs.lMaxBaselineExt = 0;
+        M_FONTDATA->m_vFattrs.lAveCharWidth   = 0;
+    }
+    M_FONTDATA->m_vFattrs.fsType    = 0;// pfm->fsType;              /* uses default type       */
+    M_FONTDATA->m_vFattrs.fsFontUse = 0;
+
+    wxStrcpy(M_FONTDATA->m_vFattrs.szFacename, M_FONTDATA->m_pFM[nIndex].szFacename);
+    // Debug
+    strcpy(zFontFaceName, M_FONTDATA->m_pFM[nIndex].szFacename);
+    strcpy(zFontFaceName, M_FONTDATA->m_vFattrs.szFacename);
+
+    if(usWeightClass >= FWEIGHT_BOLD)
+        M_FONTDATA->m_vFattrs.fsSelection |= FATTR_SEL_BOLD;
+    if(GetUnderlined())
+        M_FONTDATA->m_vFattrs.fsSelection |= FATTR_SEL_UNDERSCORE;
+    if(fsSelection & FM_SEL_ITALIC)
+        M_FONTDATA->m_vFattrs.fsSelection |= FATTR_SEL_ITALIC;
 }
 
+
+
index c5e987133b94e6b8fbab8d66446bf13a84849f23..39c0d8548d1c06eb79e52298c41eb2ff742afbe7 100644 (file)
 // 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;
+        case wxFONTENCODING_CP1250:
+            pInfo->charset = 1250;
             break;
 
-        case wxFONTENCODING_CP1250:
-            info->charset = EASTEUROPE_CHARSET;
+        case wxFONTENCODING_ISO8859_2:
+        case wxFONTENCODING_CP1252:
+            pInfo->charset = 1252;
             break;
 
-        case wxFONTENCODING_CP1251:
-            info->charset = RUSSIAN_CHARSET;
+        case wxFONTENCODING_ISO8859_4:
+        case wxFONTENCODING_ISO8859_10:
+            pInfo->charset = 921; // what is baltic?
             break;
 
-        case wxFONTENCODING_CP1253:
-            info->charset = GREEK_CHARSET;
+        case wxFONTENCODING_ISO8859_5:
+        case wxFONTENCODING_CP1251:
+            pInfo->charset = 1251;
             break;
 
-        case wxFONTENCODING_CP1254:
-            info->charset = TURKISH_CHARSET;
+        case wxFONTENCODING_ISO8859_6:
+            pInfo->charset = 864;
             break;
 
-        case wxFONTENCODING_CP1255:
-            info->charset = HEBREW_CHARSET;
+        case wxFONTENCODING_ISO8859_7:
+            pInfo->charset = 869;
             break;
 
-        case wxFONTENCODING_CP1256:
-            info->charset = ARABIC_CHARSET;
+        case wxFONTENCODING_ISO8859_8:
+            pInfo->charset = 862;
             break;
 
-        case wxFONTENCODING_CP1257:
-            info->charset = BALTIC_CHARSET;
+        case wxFONTENCODING_ISO8859_9:
+            pInfo->charset = 857;
             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
-
-    lf.lfCharSet = info.charset;
-    strncpy(lf.lfFaceName, info.facename, sizeof(lf.lfFaceName));
-
-    HFONT hfont = ::CreateFontIndirect(&lf);
-    if ( !hfont )
+    FATTRS                          vLogFont;
+    HPS                             hPS;
+
+    hPS = ::WinGetPS(HWND_DESKTOP);
+
+    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;
-
-    switch ( font->GetFamily() )
+    wxString                        sFace;
+    USHORT                          uWeight;
+    int                             nItalic;
+
+    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");
-    }
-
-    BYTE ff_italic;
-    switch ( font->GetStyle() )
-    {
-        case wxITALIC:
-        case wxSLANT:
-            ff_italic = 1;
-            break;
-
-        default:
-            wxFAIL_MSG(wxT("unknown font slant"));
-            // fall through
-
-        case wxNORMAL:
-            ff_italic = 0;
+            sFace = _T("Helv");
     }
 
-    int ff_weight;
-    switch ( font->GetWeight() )
+    switch (pFont->GetWeight())
     {
         default:
             wxFAIL_MSG(_T("unknown font weight"));
-            // fall through
+            uWeight = FWEIGHT_DONT_CARE;
+            break;
 
         case wxNORMAL:
-            ff_weight = FW_NORMAL;
+            uWeight = FWEIGHT_NORMAL;
             break;
 
         case wxLIGHT:
-            ff_weight = FW_LIGHT;
+            uWeight = FWEIGHT_LIGHT;
             break;
 
         case wxBOLD:
-            ff_weight = FW_BOLD;
+            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;
 
-#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
-
-#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
+    switch (pFont->GetStyle())
+    {
+        case wxITALIC:
+        case wxSLANT:
+            nItalic = FTYPE_ITALIC;
+            pLogFont->fsSelection |= FATTR_SEL_ITALIC;
+            break;
+
+        default:
+            wxFAIL_MSG(wxT("unknown font slant"));
+            // fall through
 
-    wxString facename = font->GetFaceName();
-    if ( !!facename )
+        case wxNORMAL:
+            nItalic = 0;
+            break;
+    }
+    pFaceName->flOptions |= nItalic;
+    if(pFont->GetUnderlined())
+        pLogFont->fsSelection |= FATTR_SEL_UNDERSCORE;
+
+    //
+    // 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;
+
+
+    ::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));
-}
-
-wxFont wxCreateFontFromLogFont(const LOGFONT *logFont)
+    //
+    // 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*                    pLogFont
+, const PFONTMETRICS                pFM
+, PFACENAMEDESC                     pFaceName
+)
 {
-DEBUG_PRINTF(wxCreateFontFromLogFont)
-
-    // extract family from pitch-and-family
-    int lfFamily = logFont->lfPitchAndFamily;
-    if ( lfFamily & FIXED_PITCH )
-        lfFamily -= FIXED_PITCH;
-    if ( lfFamily & VARIABLE_PITCH )
-        lfFamily -= VARIABLE_PITCH;
-
-    int fontFamily;
-    switch ( lfFamily )
-    {
-        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;
-            break;
+    //
+    // Extract family from facename
+    //
+    int                             nFontFamily;
+
+    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;
 
-        default:
-            fontFamily = wxSWISS;
-    }
+    //
+    // Weight and Style
+    //
+    int                             nFontWeight = wxNORMAL;
 
-    // weight and style
-    int fontWeight = wxNORMAL;
-    switch ( logFont->lfWeight )
+    switch (pFaceName->usWeightClass)
     {
-        case FW_LIGHT:
-            fontWeight = wxLIGHT;
+        case FWEIGHT_LIGHT:
+            nFontWeight = wxLIGHT;
             break;
 
         default:
-        case FW_NORMAL:
-            fontWeight = wxNORMAL;
+        case FWEIGHT_NORMAL:
+            nFontWeight = wxNORMAL;
             break;
 
-        case FW_BOLD:
-            fontWeight = wxBOLD;
+        case FWEIGHT_BOLD:
+            nFontWeight = wxBOLD;
             break;
     }
 
-    int fontStyle = logFont->lfItalic ? wxITALIC : wxNORMAL;
-
-    bool fontUnderline = logFont->lfUnderline != 0;
+    int                             nFontStyle;
 
-    wxString fontFace = logFont->lfFaceName;
-
-    // font size
-    HDC dc = ::GetDC(NULL);
-
-    // remember that 1pt = 1/72inch
-    int height = abs(logFont->lfHeight);
-    int fontPoints = (72*height)/GetDeviceCaps(dc, LOGPIXELSY);
+    if(pLogFont->fsSelection & FATTR_SEL_ITALIC)
+        nFontStyle = wxITALIC;
+    else
+        nFontStyle = wxNORMAL;
 
-    ::ReleaseDC(NULL, dc);
+    bool                            bFontUnderline = (pLogFont->fsSelection & FATTR_SEL_UNDERSCORE);
+    wxString                        sFontFace = pLogFont->szFacename;
+    int                             nFontPoints = pFM->lEmHeight;
+    wxFontEncoding                  vFontEncoding;
 
-    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);
+    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;
 }
-#endif // 0
 
index 4c0870f57707e00e505a16c977306d67dc44f872..e02374f85d17d376f76f64e8be9f9b4566728faf 100644 (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