fixes for user dash handling (patch 717736)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,6 +42,7 @@ All GUI ports:
|
|||||||
- implemented alignment for wxGrid bool editor and renderer
|
- implemented alignment for wxGrid bool editor and renderer
|
||||||
- support wxListCtrl columns alignment for all platforms and not just MSW
|
- support wxListCtrl columns alignment for all platforms and not just MSW
|
||||||
- added wxToolBar Add/InsertTool(tool) (Janusz Piwowarski)
|
- added wxToolBar Add/InsertTool(tool) (Janusz Piwowarski)
|
||||||
|
- fixed user dash handling for MSW and GTK (Ken Edwards)
|
||||||
- WXR resources can now be used in Unicode builds
|
- WXR resources can now be used in Unicode builds
|
||||||
- it is now possible to use several wxFileHistory objects in the same menu
|
- it is now possible to use several wxFileHistory objects in the same menu
|
||||||
by giving them different base IDs (Dimitri Schoolwerth)
|
by giving them different base IDs (Dimitri Schoolwerth)
|
||||||
|
@@ -53,6 +53,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define M_PENDATA ((wxPenRefData *)m_refData)
|
#define M_PENDATA ((wxPenRefData *)m_refData)
|
||||||
|
#define wxPENDATA(x) ((wxPenRefData *)(x).m_refData)
|
||||||
|
|
||||||
// Pen
|
// Pen
|
||||||
class WXDLLEXPORT wxPen: public wxGDIObject
|
class WXDLLEXPORT wxPen: public wxGDIObject
|
||||||
@@ -66,8 +67,28 @@ public:
|
|||||||
~wxPen();
|
~wxPen();
|
||||||
|
|
||||||
inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
|
inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
|
||||||
inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; }
|
inline bool operator == (const wxPen& pen) const
|
||||||
inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; }
|
{
|
||||||
|
// It is impossible to know if the user dashes have changed,
|
||||||
|
// so we must assume that they have
|
||||||
|
if ( m_refData && pen.m_refData )
|
||||||
|
{
|
||||||
|
if ( M_PENDATA->m_nbDash != 0 || wxPENDATA(pen)->m_nbDash != 0 )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return m_refData == pen.m_refData;
|
||||||
|
}
|
||||||
|
inline bool operator != (const wxPen& pen) const
|
||||||
|
{
|
||||||
|
// It is impossible to know if the user dashes have changed,
|
||||||
|
// so we must assume that they have
|
||||||
|
if ( m_refData && pen.m_refData )
|
||||||
|
{
|
||||||
|
if ( M_PENDATA->m_nbDash != 0 || wxPENDATA(pen)->m_nbDash != 0 )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return m_refData != pen.m_refData;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool Ok() const { return (m_refData != NULL) ; }
|
virtual bool Ok() const { return (m_refData != NULL) ; }
|
||||||
|
|
||||||
|
@@ -464,18 +464,27 @@ void MyCanvas::DrawTestLines( int x, int y, int width, wxDC &dc )
|
|||||||
|
|
||||||
dc.DrawText(_T("User dash"), x + 150, y + 140);
|
dc.DrawText(_T("User dash"), x + 150, y + 140);
|
||||||
wxPen ud( wxT("black"), width, wxUSER_DASH );
|
wxPen ud( wxT("black"), width, wxUSER_DASH );
|
||||||
wxDash dash1[1];
|
wxDash dash1[6];
|
||||||
dash1[0] = 0;
|
dash1[0] = 8; // Long dash <---------+
|
||||||
ud.SetDashes( 1, dash1 );
|
dash1[1] = 2; // Short gap |
|
||||||
|
dash1[2] = 3; // Short dash |
|
||||||
|
dash1[3] = 2; // Short gap |
|
||||||
|
dash1[4] = 3; // Short dash |
|
||||||
|
dash1[5] = 2; // Short gap and repeat +
|
||||||
|
ud.SetDashes( 6, dash1 );
|
||||||
|
dc.SetPen( ud );
|
||||||
dc.DrawLine( x+20, y+140, 100, y+140 );
|
dc.DrawLine( x+20, y+140, 100, y+140 );
|
||||||
dash1[0] = 1;
|
dash1[0] = 5; // Make first dash shorter
|
||||||
ud.SetDashes( 1, dash1 );
|
ud.SetDashes( 6, dash1 );
|
||||||
|
dc.SetPen( ud );
|
||||||
dc.DrawLine( x+20, y+150, 100, y+150 );
|
dc.DrawLine( x+20, y+150, 100, y+150 );
|
||||||
dash1[0] = 2;
|
dash1[2] = 5; // Make second dash longer
|
||||||
ud.SetDashes( 1, dash1 );
|
ud.SetDashes( 6, dash1 );
|
||||||
|
dc.SetPen( ud );
|
||||||
dc.DrawLine( x+20, y+160, 100, y+160 );
|
dc.DrawLine( x+20, y+160, 100, y+160 );
|
||||||
dash1[0] = 0x7F;
|
dash1[4] = 5; // Make third dash longer
|
||||||
ud.SetDashes( 1, dash1 );
|
ud.SetDashes( 6, dash1 );
|
||||||
|
dc.SetPen( ud );
|
||||||
dc.DrawLine( x+20, y+170, 100, y+170 );
|
dc.DrawLine( x+20, y+170, 100, y+170 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,6 +52,11 @@ public:
|
|||||||
|
|
||||||
bool operator == (const wxPenRefData& data) const
|
bool operator == (const wxPenRefData& data) const
|
||||||
{
|
{
|
||||||
|
// It is impossible to tell if the dashes have changed
|
||||||
|
// so the only thing to do is assume they have
|
||||||
|
if (m_countDashes != 0 || data.m_countDashes != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
m_width == data.m_width &&
|
m_width == data.m_width &&
|
||||||
m_joinStyle == data.m_joinStyle &&
|
m_joinStyle == data.m_joinStyle &&
|
||||||
|
@@ -52,6 +52,11 @@ public:
|
|||||||
|
|
||||||
bool operator == (const wxPenRefData& data) const
|
bool operator == (const wxPenRefData& data) const
|
||||||
{
|
{
|
||||||
|
// It is impossible to tell if the dashes have changed
|
||||||
|
// so the only thing to do is assume they have
|
||||||
|
if (m_countDashes != 0 || data.m_countDashes != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
m_width == data.m_width &&
|
m_width == data.m_width &&
|
||||||
m_joinStyle == data.m_joinStyle &&
|
m_joinStyle == data.m_joinStyle &&
|
||||||
|
@@ -232,8 +232,9 @@ bool wxPen::RealizeResource()
|
|||||||
if (M_PENDATA->m_style==wxUSER_DASH && M_PENDATA->m_nbDash && M_PENDATA->m_dash)
|
if (M_PENDATA->m_style==wxUSER_DASH && M_PENDATA->m_nbDash && M_PENDATA->m_dash)
|
||||||
{
|
{
|
||||||
real_dash = new wxMSWDash[M_PENDATA->m_nbDash];
|
real_dash = new wxMSWDash[M_PENDATA->m_nbDash];
|
||||||
|
int rw = M_PENDATA->m_width > 1 ? M_PENDATA->m_width : 1;
|
||||||
for ( int i = 0; i < M_PENDATA->m_nbDash; i++ )
|
for ( int i = 0; i < M_PENDATA->m_nbDash; i++ )
|
||||||
real_dash[i] = M_PENDATA->m_dash[i] * M_PENDATA->m_width;
|
real_dash[i] = M_PENDATA->m_dash[i] * rw;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user