+}
+
+#endif // wxHAVE_EXT_CREATE_PEN
+
+bool wxPenRefData::Alloc()
+{
+ if ( m_hPen )
+ return false;
+
+ if ( m_style == wxPENSTYLE_TRANSPARENT )
+ {
+ m_hPen = (HPEN)::GetStockObject(NULL_PEN);
+ return true;
+ }
+
+ const COLORREF col = m_colour.GetPixel();
+
+#ifdef wxHAVE_EXT_CREATE_PEN
+ // Only NT can display dashed or dotted lines with width > 1
+ static const int os = wxGetOsVersion();
+ if ( os != wxOS_WINDOWS_NT &&
+ (m_style == wxPENSTYLE_DOT ||
+ m_style == wxPENSTYLE_LONG_DASH ||
+ m_style == wxPENSTYLE_SHORT_DASH ||
+ m_style == wxPENSTYLE_DOT_DASH ||
+ m_style == wxPENSTYLE_USER_DASH) &&
+ m_width > 1 )
+ {
+ m_width = 1;
+ }
+
+ // check if it's a standard kind of pen which can be created with just
+ // CreatePen()
+ if ( m_join == wxJOIN_ROUND &&
+ m_cap == wxCAP_ROUND &&
+ m_style != wxPENSTYLE_USER_DASH &&
+ m_style != wxPENSTYLE_STIPPLE &&
+ (m_width <= 1 || m_style == wxPENSTYLE_SOLID) )
+#endif // !wxHAVE_EXT_CREATE_PEN
+ {
+ m_hPen = ::CreatePen(ConvertPenStyle(m_style), m_width, col);
+ }
+#ifdef wxHAVE_EXT_CREATE_PEN
+ else // need to use ExtCreatePen()
+ {
+ DWORD styleMSW = PS_GEOMETRIC |
+ ConvertPenStyle(m_style) |
+ ConvertJoinStyle(m_join) |
+ ConvertCapStyle(m_cap);
+
+ LOGBRUSH lb;
+ switch( m_style )
+ {
+ case wxPENSTYLE_STIPPLE:
+ lb.lbStyle = BS_PATTERN;
+ lb.lbHatch = wxPtrToUInt(m_stipple.GetHBITMAP());
+ break;
+
+ case wxPENSTYLE_BDIAGONAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_BDIAGONAL;
+ break;
+
+ case wxPENSTYLE_CROSSDIAG_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_DIAGCROSS;
+ break;
+
+ case wxPENSTYLE_FDIAGONAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_FDIAGONAL;
+ break;
+
+ case wxPENSTYLE_CROSS_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_CROSS;
+ break;
+
+ case wxPENSTYLE_HORIZONTAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_HORIZONTAL;
+ break;
+
+ case wxPENSTYLE_VERTICAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_VERTICAL;
+ break;
+
+ default:
+ lb.lbStyle = BS_SOLID;
+#ifdef __WXDEBUG__
+ // this should be unnecessary (it's unused) but suppresses the
+ // Purify messages about uninitialized memory read
+ lb.lbHatch = 0;