Applied patch for better pattern support.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2003-09-09 11:59:25 +00:00
parent 42036ca82a
commit 411bdf7415
2 changed files with 126 additions and 202 deletions

View File

@@ -1835,45 +1835,41 @@ void wxDC::MacInstallFont() const
wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ; wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
} }
Pattern gHatchPatterns[] = Pattern gPatterns[] =
{ { // hatch patterns
{ { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } ,
{ { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } ,
{ { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } ,
{ { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } ,
{ { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } ,
{ { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } ,
{ { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } ,
// dash patterns
{ 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } , // DOT
{ 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } , // LONG_DASH
{ 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } , // SHORT_DASH
{ 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } , // DOT_DASH
} ; } ;
static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) static void wxMacGetPattern(int penStyle, Pattern *pattern)
{ {
int theIndex = 1 ; int index = 0; // solid pattern by default
switch(hatchStyle) switch(penStyle)
{ {
case wxBDIAGONAL_HATCH: // hatches
theIndex = 2; case wxBDIAGONAL_HATCH: index = 1; break;
break; case wxFDIAGONAL_HATCH: index = 2; break;
case wxFDIAGONAL_HATCH: case wxCROSS_HATCH: index = 3; break;
theIndex = 3; case wxHORIZONTAL_HATCH: index = 4; break;
break; case wxVERTICAL_HATCH: index = 5; break;
case wxCROSS_HATCH: case wxCROSSDIAG_HATCH: index = 6; break;
theIndex = 4; // dashes
break; case wxDOT: index = 7; break;
case wxHORIZONTAL_HATCH: case wxLONG_DASH: index = 8; break;
theIndex = 5; case wxSHORT_DASH: index = 9; break;
break; case wxDOT_DASH: index = 10; break;
case wxVERTICAL_HATCH:
theIndex = 6;
break;
case wxCROSSDIAG_HATCH:
theIndex = 7;
break;
default:
theIndex = 1; // solid pattern
break;
} }
*pattern = gHatchPatterns[theIndex-1] ; *pattern = gPatterns[index];
} }
void wxDC::MacInstallPen() const void wxDC::MacInstallPen() const
@@ -1892,62 +1888,28 @@ void wxDC::MacInstallPen() const
if ( penWidth == 0 ) if ( penWidth == 0 )
penWidth = 1 ; penWidth = 1 ;
::PenSize(penWidth, penWidth); ::PenSize(penWidth, penWidth);
int penStyle = m_pen.GetStyle(); int penStyle = m_pen.GetStyle();
if (penStyle == wxSOLID) Pattern pat;
if (penStyle == wxUSER_DASH)
{ {
::PenPat(GetQDGlobalsBlack(&blackColor)); // FIXME: there should be exactly 8 items in the dash
wxDash* dash ;
int number = m_pen.GetDashes(&dash) ;
int index = 0;
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = dash[index] ;
if (index < number - 1)
index++;
} }
else if (IS_HATCH(penStyle))
{
Pattern pat ;
wxMacGetHatchPattern(penStyle, &pat);
::PenPat(&pat);
} }
else else
{ {
Pattern pat = *GetQDGlobalsBlack(&blackColor) ; wxMacGetPattern(penStyle, &pat);
switch( penStyle )
{
case wxDOT :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0xCC ;
}
break ;
case wxLONG_DASH :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0xFE ;
}
break ;
case wxSHORT_DASH :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0xEE ;
}
break ;
case wxDOT_DASH :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0x6F ;
}
break ;
case wxUSER_DASH :
{
wxDash* dash ;
m_pen.GetDashes(&dash) ;
// right now we don't allocate larger pixmaps
// int number =
m_pen.GetDashes(&dash) ;
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = dash[0] ;
}
}
break ;
} }
::PenPat(&pat); ::PenPat(&pat);
}
short mode = patCopy ; short mode = patCopy ;
// todo : // todo :
switch( m_logicalFunction ) switch( m_logicalFunction )
@@ -2018,7 +1980,7 @@ void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background )
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
wxMacGetHatchPattern(brushStyle, &pat); wxMacGetPattern(brushStyle, &pat);
::BackPat(&pat); ::BackPat(&pat);
} }
else else
@@ -2048,7 +2010,7 @@ void wxDC::MacInstallBrush() const
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
wxMacGetHatchPattern(brushStyle, &pat); wxMacGetPattern(brushStyle, &pat);
::PenPat(&pat); ::PenPat(&pat);
} }
else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )

View File

@@ -1835,45 +1835,41 @@ void wxDC::MacInstallFont() const
wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ; wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
} }
Pattern gHatchPatterns[] = Pattern gPatterns[] =
{ { // hatch patterns
{ { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } ,
{ { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } ,
{ { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } ,
{ { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } ,
{ { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } ,
{ { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } ,
{ { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } ,
// dash patterns
{ 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } , // DOT
{ 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } , // LONG_DASH
{ 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } , // SHORT_DASH
{ 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } , // DOT_DASH
} ; } ;
static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) static void wxMacGetPattern(int penStyle, Pattern *pattern)
{ {
int theIndex = 1 ; int index = 0; // solid pattern by default
switch(hatchStyle) switch(penStyle)
{ {
case wxBDIAGONAL_HATCH: // hatches
theIndex = 2; case wxBDIAGONAL_HATCH: index = 1; break;
break; case wxFDIAGONAL_HATCH: index = 2; break;
case wxFDIAGONAL_HATCH: case wxCROSS_HATCH: index = 3; break;
theIndex = 3; case wxHORIZONTAL_HATCH: index = 4; break;
break; case wxVERTICAL_HATCH: index = 5; break;
case wxCROSS_HATCH: case wxCROSSDIAG_HATCH: index = 6; break;
theIndex = 4; // dashes
break; case wxDOT: index = 7; break;
case wxHORIZONTAL_HATCH: case wxLONG_DASH: index = 8; break;
theIndex = 5; case wxSHORT_DASH: index = 9; break;
break; case wxDOT_DASH: index = 10; break;
case wxVERTICAL_HATCH:
theIndex = 6;
break;
case wxCROSSDIAG_HATCH:
theIndex = 7;
break;
default:
theIndex = 1; // solid pattern
break;
} }
*pattern = gHatchPatterns[theIndex-1] ; *pattern = gPatterns[index];
} }
void wxDC::MacInstallPen() const void wxDC::MacInstallPen() const
@@ -1892,62 +1888,28 @@ void wxDC::MacInstallPen() const
if ( penWidth == 0 ) if ( penWidth == 0 )
penWidth = 1 ; penWidth = 1 ;
::PenSize(penWidth, penWidth); ::PenSize(penWidth, penWidth);
int penStyle = m_pen.GetStyle(); int penStyle = m_pen.GetStyle();
if (penStyle == wxSOLID) Pattern pat;
if (penStyle == wxUSER_DASH)
{ {
::PenPat(GetQDGlobalsBlack(&blackColor)); // FIXME: there should be exactly 8 items in the dash
wxDash* dash ;
int number = m_pen.GetDashes(&dash) ;
int index = 0;
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = dash[index] ;
if (index < number - 1)
index++;
} }
else if (IS_HATCH(penStyle))
{
Pattern pat ;
wxMacGetHatchPattern(penStyle, &pat);
::PenPat(&pat);
} }
else else
{ {
Pattern pat = *GetQDGlobalsBlack(&blackColor) ; wxMacGetPattern(penStyle, &pat);
switch( penStyle )
{
case wxDOT :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0xCC ;
}
break ;
case wxLONG_DASH :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0xFE ;
}
break ;
case wxSHORT_DASH :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0xEE ;
}
break ;
case wxDOT_DASH :
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = 0x6F ;
}
break ;
case wxUSER_DASH :
{
wxDash* dash ;
m_pen.GetDashes(&dash) ;
// right now we don't allocate larger pixmaps
// int number =
m_pen.GetDashes(&dash) ;
for ( int i = 0 ; i < 8 ; ++i )
{
pat.pat[i] = dash[0] ;
}
}
break ;
} }
::PenPat(&pat); ::PenPat(&pat);
}
short mode = patCopy ; short mode = patCopy ;
// todo : // todo :
switch( m_logicalFunction ) switch( m_logicalFunction )
@@ -2018,7 +1980,7 @@ void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background )
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
wxMacGetHatchPattern(brushStyle, &pat); wxMacGetPattern(brushStyle, &pat);
::BackPat(&pat); ::BackPat(&pat);
} }
else else
@@ -2048,7 +2010,7 @@ void wxDC::MacInstallBrush() const
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
wxMacGetHatchPattern(brushStyle, &pat); wxMacGetPattern(brushStyle, &pat);
::PenPat(&pat); ::PenPat(&pat);
} }
else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )