+ 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(wxT("Unable to set current color table to RGB mode. Error: %s\n"), sError.c_str());
+ return false;
+ }
+ if (M_PENDATA->m_nStyle == wxPENSTYLE_TRANSPARENT)
+ {
+ return true;
+ }
+
+ COLORREF vPmColour = 0L;
+ USHORT uLineType = (USHORT)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;
+ if (M_PENDATA->m_nWidth < 1)
+ M_PENDATA->m_nWidth = 1;
+ 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(wxT("Can't set Gpi attributes for a LINEBUNDLE. Error: %s\n"), sError.c_str());
+ return false;
+ }
+
+ ULONG flAttrMask = 0L;
+ ULONG flDefMask = 0L;
+ switch(M_PENDATA->m_nStyle)
+ {
+ case wxPENSTYLE_STIPPLE:
+ ::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()
+ );
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SET | ABB_SYMBOL;
+ flDefMask = ABB_REF_POINT;
+ break;
+
+ case wxPENSTYLE_BDIAGONAL_HATCH:
+ m_vAreaBundle.usSymbol = PATSYM_DIAG3;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+
+ case wxPENSTYLE_CROSSDIAG_HATCH:
+ m_vAreaBundle.usSymbol = PATSYM_DIAGHATCH;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+
+ case wxPENSTYLE_FDIAGONAL_HATCH:
+ m_vAreaBundle.usSymbol = PATSYM_DIAG1;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+
+ case wxPENSTYLE_CROSS_HATCH:
+ m_vAreaBundle.usSymbol = PATSYM_HATCH;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+
+ case wxPENSTYLE_HORIZONTAL_HATCH:
+ m_vAreaBundle.usSymbol = PATSYM_HORIZ;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+
+ case wxPENSTYLE_VERTICAL_HATCH:
+ m_vAreaBundle.usSymbol = PATSYM_VERT;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+
+ default:
+ m_vAreaBundle.usSymbol = PATSYM_SOLID;
+ m_vAreaBundle.usSet = LCID_DEFAULT;
+ flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL;
+ flDefMask = ABB_SET | ABB_REF_POINT;
+ break;
+ }
+
+ m_vAreaBundle.lColor = vPmColour;
+ m_vAreaBundle.lBackColor = RGB_WHITE;
+ m_vAreaBundle.usMixMode = FM_OVERPAINT;
+ m_vAreaBundle.usBackMixMode = BM_OVERPAINT;
+
+ bOk = ::GpiSetAttrs( M_PENDATA->m_hPen
+ ,PRIM_AREA
+ ,flAttrMask
+ ,flDefMask
+ ,&m_vAreaBundle
+ );
+ if (!bOk)
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError(wxT("Can't set Gpi attributes for an AREABUNDLE. Error: %s\n"), sError.c_str());
+ }
+
+ return (bool)bOk;
+ }
+ return false;
+} // end of wxPen::RealizeResource
+
+WXHANDLE wxPen::GetResourceHandle() const
+{
+ if (!M_PENDATA)
+ return 0;