]> git.saurik.com Git - wxWidgets.git/commitdiff
wxPen code to fully enable pens and their use in wxDC's.
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 27 Nov 2000 04:16:24 +0000 (04:16 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 27 Nov 2000 04:16:24 +0000 (04:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/colour.cpp
src/os2/dc.cpp
src/os2/dcclient.cpp
src/os2/pen.cpp

index a5e9556dac285940a5a1f07a91bf98991b0c2ec5..90469cec7279bff94e83cd09836574a7475d5ed8 100644 (file)
@@ -38,7 +38,7 @@ wxColour::wxColour (
     m_cGreen  = cGreen;
     m_cBlue   = cBlue;
     m_bIsInit = TRUE;
-    m_vPixel  = PALETTERGB (m_cRed, m_cGreen, m_cBlue);
+    m_vPixel  = OS2RGB (m_cRed, m_cGreen, m_cBlue);
 } // end of wxColour::wxColour
 
 wxColour::wxColour (
@@ -84,7 +84,7 @@ void wxColour::InitFromName(
         m_cBlue = 0;
         m_bIsInit = FALSE;
     }
-    m_vPixel = PALETTERGB (m_cRed, m_cGreen, m_cBlue);
+    m_vPixel = OS2RGB (m_cRed, m_cGreen, m_cBlue);
 } // end of wxColour::InitFromName
 
 wxColour::~wxColour ()
@@ -101,7 +101,7 @@ void wxColour::Set (
     m_cGreen  = cGreen;
     m_cBlue   = cBlue;
     m_bIsInit = TRUE;
-    m_vPixel  = PALETTERGB (m_cRed, m_cGreen, m_cBlue);
+    m_vPixel  = OS2RGB (m_cRed, m_cGreen, m_cBlue);
 } // end of wxColour::Set
 
 //
index 134f3f66a925f2fb0f563c77fd7510e0581c8252..3f0fae3eb12d494423d4b60543b7ccc33e274750 100644 (file)
@@ -364,7 +364,6 @@ void wxDC::DoDrawLine(
     vPoint[0].y = vY1;
     vPoint[1].x = vX2;
     vPoint[1].y = vY2;
-    // ::GpiSetColor(m_hPS,CLR_RED); //DEbug
     ::GpiMove(m_hPS, &vPoint[0]);
     ::GpiLine(m_hPS, &vPoint[1]);
 }
@@ -631,7 +630,7 @@ void wxDC::DoDrawRectangle(
     vPoint[0].x = vX;
     vPoint[0].y = vY;
     vPoint[1].x = vX + vWidth;
-    vPoint[1].y = vY - vHeight;      //mustdie !!! ??
+    vPoint[1].y = vY - vHeight;
     ::GpiMove(m_hPS, &vPoint[0]);
     lColor       = m_brush.GetColour().GetPixel();
     lBorderColor = m_pen.GetColour().GetPixel();
@@ -643,8 +642,7 @@ void wxDC::DoDrawRectangle(
         if(m_brush.GetStyle() == wxTRANSPARENT)
             lControl = DRO_OUTLINE;
 
-//EK    ::GpiSetColor(m_hPS,lBorderColor);
-        ::GpiSetColor(m_hPS,CLR_GREEN);
+        ::GpiSetColor(m_hPS, CLR_GREEN);
         ::GpiBox( m_hPS       // handle to a presentation space
                  ,lControl   // draw the box outline ? or ?
                  ,&vPoint[1]  // address of the corner
@@ -1001,66 +999,29 @@ void wxDC::SetPen(
     if (!m_pen.Ok())
         return;
 
-    int                             nWidth = m_pen.GetWidth();
+    if (m_hOldPen)
+        m_hOldPen = 0L;
+    m_pen = rPen;
 
-    if (nWidth <= 0)
-    {
-        nWidth = 1;
-    }
-    else
+    if (!m_pen.Ok())
     {
-        double                      dW = 0.5 +
-                                       ( fabs((double) XLOG2DEVREL(nWidth)) +
-                                         fabs((double) YLOG2DEVREL(nWidth))
-                                       ) / 2.0;
-        nWidth = (int)dW;
+        if (m_hOldPen)
+        {
+            m_pen.SetPS((HPS)m_hOldPen);
+        }
+        m_hOldPen = 0L;
     }
-    wxColour                        vColor = m_pen.GetColour();
-
-    ::GpiSetColor( m_hPS
-                  ,vColor.GetPixel()
-                 ); //DEbug ??
 
-    int                             nLinetype;
-    int                             nStyle = m_pen.GetStyle();
-
-    nLinetype = LINETYPE_DEFAULT;
-    switch(nStyle)
+    if (m_pen.Ok())
     {
-        case wxDOT:
-            nLinetype = LINETYPE_DOT;
-            break;
-
-        case wxLONG_DASH:
-            nLinetype = LINETYPE_LONGDASH;
-            break;
-
-        case wxSHORT_DASH:
-            nLinetype = LINETYPE_SHORTDASH;
-            break;
-
-        case wxDOT_DASH:
-            nLinetype = LINETYPE_DASHDOT;
-            break;
-
-        case wxTRANSPARENT:
-            nLinetype = LINETYPE_INVISIBLE;
-            break;
-
-        case wxSOLID:
-            nLinetype = LINETYPE_SOLID;
-            break;
+        if (m_pen.GetResourceHandle())
+        {
+            m_pen.SetPS(m_hPS);
+            if (!m_hOldPen)
+                m_hOldPen = m_pen.GetPS();
+        }
     }
-    ::GpiSetLineType( m_hPS
-                     ,nLinetype
-                    );
 
-    nWidth =  m_pen.GetWidth();
-    ::GpiSetLineWidth( m_hPS
-                      ,MAKEFIXED( nWidth
-                                 ,0
-                                )
-                     );
 }
 
 void wxDC::SetBrush(
@@ -1254,7 +1215,18 @@ void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
 
 void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
 {
-    // TODO:
+    RECTL                           vRect;
+
+    ::GpiQueryPageViewport( m_hPS
+                           ,&vRect
+                          );
+    vRect.xLeft += x;
+    vRect.xRight += x;
+    vRect.yBottom -= y;
+    vRect.yTop -= y;
+    ::GpiSetPageViewport( m_hPS
+                         ,&vRect
+                        );
 };
 
 // ---------------------------------------------------------------------------
index af77090fd1610087023c5fa8f7bcf3b95f79efaf..7c4950211d3cc90e42135dd8941b6779d9f4ed31 100644 (file)
@@ -82,51 +82,66 @@ static RECT        g_paintStruct;
 
 wxWindowDC::wxWindowDC()
 {
-  m_pCanvas = NULL;
+    m_pCanvas = NULL;
 }
 
 wxWindowDC::wxWindowDC(wxWindow *the_canvas)
 {
-  m_pCanvas = the_canvas;
-  m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas) );
-  m_nDCCount++;
-  //
-  // default under PM is that Window and Client DC's are the same
-  // so we offer a separate Presentation Space to use for the
-  // entire window.  Otherwise, calling BeginPaint will just create
-  // chached-micro client presentation space
-  //
-   m_hPS = GpiCreatePS( m_hab
-                       ,m_hDC
-                       ,&m_PageSize
-                       ,PU_PELS | GPIF_LONG | GPIA_ASSOC
-                      );
-  ::GpiAssociate(m_hPS, NULLHANDLE);
-  ::GpiAssociate(m_hPS, m_hDC);
-  SetBackground(wxBrush(m_pCanvas->GetBackgroundColour(), wxSOLID));
-}
-
-wxWindowDC::~wxWindowDC()
-{
-  if (m_pCanvas && m_hDC)
-  {
-    SelectOldObjects(m_hDC);
+    ERRORID                         vError;
+    wxString                        sError;
 
+    m_pCanvas = the_canvas;
+    m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas) );
+    m_nDCCount++;
     //
-    // In PM one does not explicitly close or release an open WindowDC
-    // They automatically close with the window, unless explicitly detached
-    // but we need to destroy our PS
+    // default under PM is that Window and Client DC's are the same
+    // so we offer a separate Presentation Space to use for the
+    // entire window.  Otherwise, calling BeginPaint will just create
+    // chached-micro client presentation space
     //
-    if(m_hPS)
+     m_hPS = GpiCreatePS( m_hab
+                         ,m_hDC
+                         ,&m_PageSize
+                         ,PU_PELS | GPIF_LONG | GPIA_ASSOC
+                        );
+    ::GpiAssociate(m_hPS, NULLHANDLE);
+    ::GpiAssociate(m_hPS, m_hDC);
+    // Set the wxWindows color table
+    if (!::GpiCreateLogColorTable( m_hPS
+                                  ,0L
+                                  ,LCOLF_CONSECRGB
+                                  ,0L
+                                  ,(LONG)wxTheColourDatabase->m_nSize
+                                  ,(PLONG)wxTheColourDatabase->m_palTable
+                                 ))
     {
-        ::GpiAssociate(m_hPS, NULLHANDLE);
-        ::GpiDestroyPS(m_hPS);
+        vError = ::WinGetLastError(vHabmain);
+        sError = wxPMErrorToStr(vError);
+        wxLogError("Unable to set current color table. Error: %s\n", sError);
     }
-    m_hPS = NULLHANDLE;
-    m_hDC = NULLHANDLE;
-  }
+    SetBackground(wxBrush(m_pCanvas->GetBackgroundColour(), wxSOLID));
+}
+
+wxWindowDC::~wxWindowDC()
+{
+    if (m_pCanvas && m_hDC)
+    {
+        SelectOldObjects(m_hDC);
 
-  m_nDCCount--;
+        //
+        // In PM one does not explicitly close or release an open WindowDC
+        // They automatically close with the window, unless explicitly detached
+        // but we need to destroy our PS
+        //
+        if(m_hPS)
+        {
+            ::GpiAssociate(m_hPS, NULLHANDLE);
+            ::GpiDestroyPS(m_hPS);
+        }
+        m_hPS = NULLHANDLE;
+        m_hDC = NULLHANDLE;
+    }
+    m_nDCCount--;
 }
 
 // ----------------------------------------------------------------------------
@@ -135,12 +150,14 @@ wxWindowDC::~wxWindowDC()
 
 wxClientDC::wxClientDC()
 {
-  m_pCanvas = NULL;
+    m_pCanvas = NULL;
 }
 
 wxClientDC::wxClientDC(wxWindow *the_canvas)
 {
     SIZEL                           vSizl = { 0,0};
+    ERRORID                         vError;
+    wxString                        sError;
 
     m_pCanvas = the_canvas;
 
@@ -154,6 +171,19 @@ wxClientDC::wxClientDC(wxWindow *the_canvas)
                           ,PU_PELS | GPIF_LONG | GPIA_ASSOC
                          );
 
+    // Set the wxWindows color table
+    if (!::GpiCreateLogColorTable( m_hPS
+                                  ,0L
+                                  ,LCOLF_CONSECRGB
+                                  ,0L
+                                  ,(LONG)wxTheColourDatabase->m_nSize
+                                  ,(PLONG)wxTheColourDatabase->m_palTable
+                                 ))
+    {
+        vError = ::WinGetLastError(vHabmain);
+        sError = wxPMErrorToStr(vError);
+        wxLogError("Unable to set current color table. Error: %s\n", sError);
+    }
     //
     // Default mode is BM_LEAVEALONE so we make no call Set the mix
     //
@@ -165,15 +195,16 @@ wxClientDC::wxClientDC(wxWindow *the_canvas)
 
 wxClientDC::~wxClientDC()
 {
-  if ( m_pCanvas && GetHdc() )
-  {
-    SelectOldObjects(m_hDC);
-
-    // We don't explicitly release Device contexts in PM and
-    // the cached micro PS is already gone
+    if ( m_pCanvas && GetHdc() )
+    {
+        SelectOldObjects(m_hDC);
 
-    m_hDC = 0;
-  }
+        //
+        // We don't explicitly release Device contexts in PM and
+        // the cached micro PS is already gone
+        //
+        m_hDC = 0;
+    }
 }
 
 // ----------------------------------------------------------------------------
@@ -209,6 +240,7 @@ wxPaintDC::wxPaintDC(
 )
 {
     wxCHECK_RET(pCanvas, wxT("NULL canvas in wxPaintDC ctor"));
+    RECTL                           vRect;
 
 #ifdef __WXDEBUG__
     if (g_isPainting <= 0)
@@ -242,6 +274,20 @@ wxPaintDC::wxPaintDC(
         {
             m_hOldPS = m_hPS;
             m_hPS = hPS;
+            ::GpiCreateLogColorTable( m_hPS
+                                     ,0L
+                                     ,LCOLF_CONSECRGB
+                                     ,0L
+                                     ,(LONG)wxTheColourDatabase->m_nSize
+                                     ,(PLONG)wxTheColourDatabase->m_palTable
+                                    );
+            ::GpiCreateLogColorTable( m_hPS
+                                     ,0L
+                                     ,LCOLF_RGB
+                                     ,0L
+                                     ,0L
+                                     ,NULL
+                                    );
         }
         m_bIsPaintTime   = TRUE;
         m_hDC = (WXHDC) -1; // to satisfy those anonizmous efforts
index 1e99b340b287a0c579d6bfb1f6f5fb76eb8935c1..4e47b28cbbf69834c286b8db198b5bcf1c2878e6 100644 (file)
@@ -28,123 +28,286 @@ IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
 
 wxPenRefData::wxPenRefData()
 {
-    m_style = wxSOLID;
-    m_width = 1;
-    m_join = wxJOIN_ROUND ;
-    m_cap = wxCAP_ROUND ;
-    m_nbDash = 0 ;
-    m_dash = (wxPMDash*)NULL;
-    m_hPen = 0;
-}
-
-wxPenRefData::wxPenRefData(const wxPenRefData& data)
+    m_nStyle  = wxSOLID;
+    m_nWidth  = 1;
+    m_nJoin   = wxJOIN_ROUND ;
+    m_nCap    = wxCAP_ROUND ;
+    m_hPen    = 0L;
+} // end of wxPenRefData::wxPenRefData
+
+wxPenRefData::wxPenRefData(
+  const wxPenRefData&               rData
+)
 {
-    m_style = data.m_style;
-    m_width = data.m_width;
-    m_join = data.m_join;
-    m_cap = data.m_cap;
-    m_nbDash = data.m_nbDash;
-    m_dash = data.m_dash;
-    m_colour = data.m_colour;
-/* TODO: null data
-    m_hPen = 0;
-*/
-}
+    m_nStyle  = rData.m_nStyle;
+    m_nWidth  = rData.m_nWidth;
+    m_nJoin   = rData.m_nJoin;
+    m_nCap    = rData.m_nCap;
+    m_vColour = rData.m_vColour;
+    m_hPen    = 0L;
+} // end of wxPenRefData::wxPenRefData
 
 wxPenRefData::~wxPenRefData()
 {
-    // TODO: delete data
-}
+} // end of wxPenRefData::~wxPenRefData
 
+//
 // Pens
-
+//
 wxPen::wxPen()
 {
     if ( wxThePenList )
         wxThePenList->AddPen(this);
-}
+} // end of wxPen::wxPen
 
 wxPen::~wxPen()
 {
     if (wxThePenList)
         wxThePenList->RemovePen(this);
-}
+} // end of wxPen::wxPen
 
 // Should implement Create
-wxPen::wxPen(const wxColour& col, int Width, int Style)
+wxPen::wxPen(
+  const wxColour&                   rColour
+, int                               nWidth
+, int                               nStyle
+)
 {
     m_refData = new wxPenRefData;
 
-    M_PENDATA->m_colour = col;
-//  M_PENDATA->m_stipple = NULL;
-    M_PENDATA->m_width = Width;
-    M_PENDATA->m_style = Style;
-    M_PENDATA->m_join = wxJOIN_ROUND ;
-    M_PENDATA->m_cap = wxCAP_ROUND ;
-    M_PENDATA->m_nbDash = 0 ;
-    M_PENDATA->m_dash = (wxPMDash*)NULL;
-    M_PENDATA->m_hPen = 0 ;
-
-// TODO:
-/*
-    if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
-        (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
-        (Style == wxUSER_DASH))
-        M_PENDATA->m_width = 1;
-*/
+    M_PENDATA->m_vColour = rColour;
+    M_PENDATA->m_nWidth  = nWidth;
+    M_PENDATA->m_nStyle  = nStyle;
+    M_PENDATA->m_nJoin   = wxJOIN_ROUND ;
+    M_PENDATA->m_nCap    = wxCAP_ROUND ;
+    M_PENDATA->m_hPen    = 0L;
+
     RealizeResource();
 
     if ( wxThePenList )
         wxThePenList->AddPen(this);
-}
+} // end of wxPen::wxPen
 
-wxPen::wxPen(const wxBitmap& stipple, int Width)
+wxPen::wxPen(
+  const wxBitmap&                   rStipple
+, int                               nWidth
+)
 {
     m_refData = new wxPenRefData;
 
-    M_PENDATA->m_stipple = stipple;
-    M_PENDATA->m_width = Width;
-    M_PENDATA->m_style = wxSTIPPLE;
-    M_PENDATA->m_join = wxJOIN_ROUND ;
-    M_PENDATA->m_cap = wxCAP_ROUND ;
-    M_PENDATA->m_nbDash = 0 ;
-    M_PENDATA->m_dash = (wxPMDash*)NULL;
-    M_PENDATA->m_hPen = 0 ;
+    M_PENDATA->m_vStipple = rStipple;
+    M_PENDATA->m_nWidth   = nWidth;
+    M_PENDATA->m_nStyle   = wxSTIPPLE;
+    M_PENDATA->m_nJoin    = wxJOIN_ROUND ;
+    M_PENDATA->m_nCap     = wxCAP_ROUND ;
+    M_PENDATA->m_hPen     = 0;
 
     RealizeResource();
 
     if ( wxThePenList )
         wxThePenList->AddPen(this);
-}
+} // end of wxPen::wxPen
 
 bool wxPen::RealizeResource()
 {
-    // TODO: create actual pen
+    BOOL                            bOk;
+    ERRORID                         vError;
+    wxString                        sError;
+
+    if (M_PENDATA && M_PENDATA->m_hPen == 0L)
+    {
+        SIZEL                   vSize = {0, 0};
+        DEVOPENSTRUC            vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
+        HDC                     hDC = ::DevOpenDC( vHabmain
+                                                  ,OD_MEMORY
+                                                  ,"*"
+                                                  ,5L
+                                                  ,(PDEVOPENDATA)&vDop
+                                                  ,NULLHANDLE
+                                                 );
+        M_PENDATA->m_hPen = (WXHPEN)::GpiCreatePS( vHabmain
+                                                  ,hDC
+                                                  ,&vSize
+                                                  ,PU_PELS | GPIT_MICRO | GPIA_ASSOC
+                                                 );
+    }
+    if (M_PENDATA)
+    {
+        //
+        // Set the color table to RGB mode
+        //
+        if (!::GpiCreateLogColorTable( (HPS)M_PENDATA->m_hPen
+                                      ,0L
+                                      ,LCOLF_RGB
+                                      ,0L
+                                      ,0L
+                                      ,NULL
+                                     ))
+        {
+            vError = ::WinGetLastError(vHabmain);
+            sError = wxPMErrorToStr(vError);
+            wxLogError("Unable to set current color table to RGB mode. Error: %s\n", sError);
+            return FALSE;
+        }
+        if (M_PENDATA->m_nStyle == wxTRANSPARENT)
+        {
+            return TRUE;
+        }
+
+        COLORREF                    vPmColour = 0L;
+        USHORT                      uLineType = wx2os2PenStyle(M_PENDATA->m_nStyle);
+
+        vPmColour = M_PENDATA->m_vColour.GetPixel();
+
+        USHORT                      uJoin = 0L;
+
+        switch(M_PENDATA->m_nJoin)
+        {
+            case wxJOIN_BEVEL:
+                uJoin = LINEJOIN_BEVEL;
+                break;
+
+            case wxJOIN_MITER:
+                uJoin = LINEJOIN_MITRE;
+                break;
+
+            case wxJOIN_ROUND:
+                uJoin = LINEJOIN_ROUND;
+                break;
+        }
+
+        USHORT                      uCap = 0L;
+
+        switch(M_PENDATA->m_nCap)
+        {
+            case wxCAP_PROJECTING:
+                uCap = LINEEND_SQUARE;
+                break;
+
+            case wxCAP_BUTT:
+                uCap = LINEEND_FLAT;
+                break;
+
+            case wxCAP_ROUND:
+                uCap = LINEEND_ROUND;
+                break;
+        }
+        m_vLineBundle.lColor     = (LONG)vPmColour;
+        m_vLineBundle.usMixMode  = FM_OVERPAINT;
+        m_vLineBundle.fxWidth    = M_PENDATA->m_nWidth;
+        m_vLineBundle.lGeomWidth = M_PENDATA->m_nWidth;
+        m_vLineBundle.usType     = uLineType;
+        m_vLineBundle.usEnd      = uCap;
+        m_vLineBundle.usJoin     = uJoin;
+
+        bOk = ::GpiSetAttrs( M_PENDATA->m_hPen
+                            ,PRIM_LINE
+                            ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE | LBB_END | LBB_JOIN
+                            ,0L
+                            ,&m_vLineBundle
+                           );
+        if (!bOk)
+        {
+            vError = ::WinGetLastError(vHabmain);
+            sError = wxPMErrorToStr(vError);
+            wxLogError("Can't set Gpi attributes for a LINEBUNDLE. Error: %s\n", sError);
+            return FALSE;
+        }
+
+        switch(M_PENDATA->m_nStyle)
+        {
+            case wxSTIPPLE:
+                ::GpiSetBitmapId( M_PENDATA->m_hPen
+                                 ,(USHORT)M_PENDATA->m_vStipple.GetHBITMAP()
+                                 ,(USHORT)M_PENDATA->m_vStipple.GetId()
+                                );
+                ::GpiSetPatternSet( M_PENDATA->m_hPen
+                                   ,(USHORT)M_PENDATA->m_vStipple.GetId()
+                                  );
+                break;
+
+            case wxBDIAGONAL_HATCH:
+                m_vAreaBundle.usSymbol = PATSYM_DIAG3;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+
+            case wxCROSSDIAG_HATCH:
+                m_vAreaBundle.usSymbol = PATSYM_DIAGHATCH;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+
+            case wxFDIAGONAL_HATCH:
+                m_vAreaBundle.usSymbol = PATSYM_DIAG1;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+
+            case wxCROSS_HATCH:
+                m_vAreaBundle.usSymbol = PATSYM_HATCH;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+
+            case wxHORIZONTAL_HATCH:
+                m_vAreaBundle.usSymbol = PATSYM_HORIZ;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+
+            case wxVERTICAL_HATCH:
+                m_vAreaBundle.usSymbol = PATSYM_VERT;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+
+            default:
+                m_vAreaBundle.usSymbol = PATSYM_SOLID;
+                m_vAreaBundle.usSet = LCID_DEFAULT;
+                break;
+        }
+
+        m_vAreaBundle.lColor        = vPmColour;
+        m_vAreaBundle.lBackColor    = CLR_DEFAULT;
+        m_vAreaBundle.usMixMode     = FM_OVERPAINT;
+        m_vAreaBundle.usBackMixMode = BM_OVERPAINT;
+
+        bOk = ::GpiSetAttrs( M_PENDATA->m_hPen
+                            ,PRIM_AREA
+                            ,ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE |
+                             ABB_SET | ABB_SYMBOL
+                            ,ABB_REF_POINT
+                            ,&m_vAreaBundle
+                           );
+        if (!bOk)
+        {
+            vError = ::WinGetLastError(vHabmain);
+            sError = wxPMErrorToStr(vError);
+            wxLogError("Can't set Gpi attributes for an AREABUNDLE. Error: %s\n", sError);
+        }
+        return bOk;
+    }
     return FALSE;
-}
+} // end of wxPen::RealizeResource
 
 WXHANDLE wxPen::GetResourceHandle()
 {
-    if ( !M_PENDATA )
+    if (!M_PENDATA)
         return 0;
     else
         return (WXHANDLE)M_PENDATA->m_hPen;
-}
+} // end of wxPen::GetResourceHandle
 
-bool wxPen::FreeResource(bool force)
+bool wxPen::FreeResource(
+  bool                              bForce
+)
 {
     if (M_PENDATA && (M_PENDATA->m_hPen != 0))
     {
-// TODO:        DeleteObject((HPEN) M_PENDATA->m_hPen);
         M_PENDATA->m_hPen = 0;
         return TRUE;
     }
     else return FALSE;
-}
+} // end of wxPen::FreeResource
 
 bool wxPen::IsFree() const
 {
-  return (M_PENDATA && M_PENDATA->m_hPen == 0);
+    return (M_PENDATA && M_PENDATA->m_hPen == 0);
 }
 
 void wxPen::Unshare()
@@ -160,124 +323,133 @@ void wxPen::Unshare()
         UnRef();
         m_refData = ref;
     }
-}
+} // end of wxPen::Unshare
 
-void wxPen::SetColour(const wxColour& col)
+void wxPen::SetColour(
+  const wxColour&                   rColour
+)
 {
     Unshare();
-
-    M_PENDATA->m_colour = col;
-
+    M_PENDATA->m_vColour = rColour;
     RealizeResource();
-}
+} // end of wxPen::SetColour
 
-void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
+void wxPen::SetColour(
+  unsigned char                     cRed
+, unsigned char                     cGreen
+, unsigned char                     cBlue
+)
 {
     Unshare();
-
-    M_PENDATA->m_colour.Set(r, g, b);
-
+    M_PENDATA->m_vColour.Set(cRed, cGreen, cBlue);
     RealizeResource();
-}
+} // end of wxPen::SetColour
 
-void wxPen::SetWidth(int Width)
+void wxPen::SetPS(
+  HPS                               hPS
+)
 {
     Unshare();
-
-    M_PENDATA->m_width = Width;
-
+    if (M_PENDATA->m_hPen)
+        ::GpiDestroyPS(M_PENDATA->m_hPen);
+    M_PENDATA->m_hPen = hPS;
     RealizeResource();
-}
+} // end of WxWinGdi_CPen::SetPS
 
-void wxPen::SetStyle(int Style)
+void wxPen::SetWidth(
+  int                               nWidth
+)
 {
     Unshare();
-
-    M_PENDATA->m_style = Style;
-
+    M_PENDATA->m_nWidth = nWidth;
     RealizeResource();
-}
+} // end of wxPen::SetWidth
 
-void wxPen::SetStipple(const wxBitmap& Stipple)
+void wxPen::SetStyle(
+  int                               nStyle
+)
 {
     Unshare();
-
-    M_PENDATA->m_stipple = Stipple;
-    M_PENDATA->m_style = wxSTIPPLE;
-
+    M_PENDATA->m_nStyle = nStyle;
     RealizeResource();
-}
+} // end of wxPen::SetStyle
 
-void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
+void wxPen::SetStipple(
+  const wxBitmap&                   rStipple
+)
 {
     Unshare();
-
-    M_PENDATA->m_nbDash = nb_dashes;
-    M_PENDATA->m_dash = (wxPMDash *)Dash;
-
+    M_PENDATA->m_vStipple = rStipple;
+    M_PENDATA->m_nStyle = wxSTIPPLE;
     RealizeResource();
-}
+} // end of wxPen::SetStipple
 
-void wxPen::SetJoin(int Join)
+void wxPen::SetDashes(
+  int                               nNbDashes
+, const wxDash*                     pDash
+)
+{
+    //
+    // Does nothing under OS/2
+    //
+} // end of wxPen::SetDashes
+
+void wxPen::SetJoin(
+  int                               nJoin
+)
 {
     Unshare();
-
-    M_PENDATA->m_join = Join;
-
+    M_PENDATA->m_nJoin = nJoin;
     RealizeResource();
-}
+} // end of wxPen::SetJoin
 
-void wxPen::SetCap(int Cap)
+void wxPen::SetCap(
+  int                               nCap
+)
 {
     Unshare();
-
-    M_PENDATA->m_cap = Cap;
-
+    M_PENDATA->m_nCap = nCap;
     RealizeResource();
-}
+} // end of wxPen::SetCap
 
-int wx2os2PenStyle(int wx_style)
+int wx2os2PenStyle(
+  int                               nWxStyle
+)
 {
-    int cstyle = 0;
-// TODO:
-/*
-    switch (wx_style)
+    int                             nPMStyle = 0;
+
+    switch (nWxStyle)
     {
-       case wxDOT:
-           cstyle = PS_DOT;
-       break;
-
-       case wxDOT_DASH:
-          cstyle = PS_DASHDOT;
-          break;
-
-       case wxSHORT_DASH:
-       case wxLONG_DASH:
-           cstyle = PS_DASH;
-          break;
-
-       case wxTRANSPARENT:
-           cstyle = PS_NULL;
-          break;
-
-       case wxUSER_DASH:
-#ifdef __WIN32__
-           // Win32s doesn't have PS_USERSTYLE
-          if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
-              cstyle = PS_USERSTYLE;
-          else
-               cstyle = PS_DOT; // We must make a choice... This is mine!
-#else
-           cstyle = PS_DASH;
-#endif
-           break;
-       case wxSOLID:
-       default:
-           cstyle = PS_SOLID;
-           break;
-   }
-*/
-   return cstyle;
-}
+        case wxDOT:
+            nPMStyle = LINETYPE_DOT;
+            break;
+
+        case wxDOT_DASH:
+            nPMStyle = LINETYPE_DASHDOT;
+            break;
+
+        case wxSHORT_DASH:
+            nPMStyle = LINETYPE_SHORTDASH;
+            break;
+
+        case wxLONG_DASH:
+            nPMStyle = LINETYPE_LONGDASH;
+            break;
+
+        case wxTRANSPARENT:
+            nPMStyle = LINETYPE_INVISIBLE;
+            break;
+
+        case wxUSER_DASH:
+            nPMStyle = LINETYPE_DASHDOUBLEDOT; // We must make a choice... This is mine!
+            break;
+
+        case wxSOLID:
+        default:
+            nPMStyle = LINETYPE_SOLID;
+            break;
+    }
+    return nPMStyle;
+} // end of wx2os2PenStyle