Updated testconf
Added dashed pens etc. Made tree ctrl sample crash.. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3047 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
|
||||
class wxPen;
|
||||
|
||||
typedef char wxDash;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPen
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -51,11 +53,17 @@ class wxPen: public wxGDIObject
|
||||
void SetJoin( int joinStyle );
|
||||
void SetStyle( int style );
|
||||
void SetWidth( int width );
|
||||
void SetDashes( int number_of_dashes, const wxDash *dash );
|
||||
|
||||
wxColour &GetColour() const;
|
||||
int GetCap() const;
|
||||
int GetJoin() const;
|
||||
int GetStyle() const;
|
||||
int GetWidth() const;
|
||||
int GetDashes(wxDash **ptr) const;
|
||||
int GetDashCount() const;
|
||||
wxDash* GetDash() const;
|
||||
|
||||
bool Ok() const;
|
||||
|
||||
void Unshare();
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
class wxPen;
|
||||
|
||||
typedef char wxDash;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPen
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -51,11 +53,17 @@ class wxPen: public wxGDIObject
|
||||
void SetJoin( int joinStyle );
|
||||
void SetStyle( int style );
|
||||
void SetWidth( int width );
|
||||
void SetDashes( int number_of_dashes, const wxDash *dash );
|
||||
|
||||
wxColour &GetColour() const;
|
||||
int GetCap() const;
|
||||
int GetJoin() const;
|
||||
int GetStyle() const;
|
||||
int GetWidth() const;
|
||||
int GetDashes(wxDash **ptr) const;
|
||||
int GetDashCount() const;
|
||||
wxDash* GetDash() const;
|
||||
|
||||
bool Ok() const;
|
||||
|
||||
void Unshare();
|
||||
|
@@ -340,8 +340,8 @@ void MyFrame::OnAddItem(wxCommandEvent& WXUNUSED(event))
|
||||
text.Printf("Item #%d", ++s_num);
|
||||
|
||||
m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(),
|
||||
text,
|
||||
MyTreeCtrl::TreeCtrlIcon_File);
|
||||
text /*,
|
||||
MyTreeCtrl::TreeCtrlIcon_File */ );
|
||||
}
|
||||
|
||||
void MyFrame::OnIncIndent(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -452,7 +452,8 @@ void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
|
||||
else
|
||||
str.Printf("%s child %d", "Folder", n + 1);
|
||||
|
||||
int image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
|
||||
// int image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
|
||||
int image = depth == 1 ? -1 : TreeCtrlIcon_Folder;
|
||||
wxTreeItemId id = AppendItem(idParent, str, image, image,
|
||||
new MyTreeItemData(str));
|
||||
|
||||
|
@@ -410,7 +410,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
#endif
|
||||
|
||||
SetBackgroundColour( *wxWHITE );
|
||||
m_dottedPen = wxPen( *wxBLACK, 0, 0 );
|
||||
m_dottedPen = wxPen( "GREY", 0, wxDOT );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1390,13 +1390,13 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
|
||||
dc.SetPen( *wxGREY_PEN );
|
||||
dc.SetBrush( *wxWHITE_BRUSH );
|
||||
dc.DrawRectangle( horizX+(m_indent-5), y-4, 11, 9 );
|
||||
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
dc.DrawLine( horizX+(m_indent-2), y, horizX+(m_indent+3), y );
|
||||
|
||||
if (!item->IsExpanded())
|
||||
{
|
||||
dc.DrawLine( horizX+m_indent, y-2, horizX+m_indent, y+3 );
|
||||
}
|
||||
|
||||
dc.SetPen( m_dottedPen );
|
||||
}
|
||||
|
||||
if (item->HasHilight())
|
||||
@@ -1412,7 +1412,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
|
||||
|
||||
PaintItem(item, dc);
|
||||
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
dc.SetPen( m_dottedPen );
|
||||
dc.SetTextForeground( *wxBLACK );
|
||||
dc.SetBrush( *wxWHITE_BRUSH );
|
||||
}
|
||||
@@ -1423,7 +1423,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
|
||||
|
||||
PaintItem(item, dc);
|
||||
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
dc.SetPen( m_dottedPen );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -864,9 +864,9 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
if (!m_window) return;
|
||||
|
||||
gint width = m_pen.GetWidth();
|
||||
// CMB: if width is non-zero scale it with the dc
|
||||
if (width <= 0)
|
||||
{
|
||||
// CMB: if width is non-zero scale it with the dc
|
||||
width = 1;
|
||||
}
|
||||
else
|
||||
@@ -877,14 +877,83 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
width = (int)w;
|
||||
}
|
||||
|
||||
const static char dotted[] = {1, 1};
|
||||
const static char short_dashed[] = {2, 2};
|
||||
const static char long_dashed[] = {2, 4};
|
||||
const static char dotted_dashed[] = {3, 3, 1, 3};
|
||||
|
||||
// We express dash pattern in pen width unit, so we are
|
||||
// independent of zoom factor and so on...
|
||||
int req_nb_dash;
|
||||
const char *req_dash;
|
||||
|
||||
GdkLineStyle lineStyle = GDK_LINE_SOLID;
|
||||
switch (m_pen.GetStyle())
|
||||
{
|
||||
case wxSOLID: { lineStyle = GDK_LINE_SOLID; break; }
|
||||
case wxDOT: { lineStyle = GDK_LINE_ON_OFF_DASH; break; }
|
||||
case wxLONG_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; break; }
|
||||
case wxSHORT_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; break; }
|
||||
case wxDOT_DASH: { lineStyle = GDK_LINE_DOUBLE_DASH; break; }
|
||||
case wxUSER_DASH:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = m_pen.GetDashCount();
|
||||
req_dash = m_pen.GetDash();
|
||||
break;
|
||||
}
|
||||
case wxDOT:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 2;
|
||||
req_dash = dotted;
|
||||
break;
|
||||
}
|
||||
case wxLONG_DASH:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 2;
|
||||
req_dash = long_dashed;
|
||||
break;
|
||||
}
|
||||
case wxSHORT_DASH:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 2;
|
||||
req_dash = short_dashed;
|
||||
break;
|
||||
}
|
||||
case wxDOT_DASH:
|
||||
{
|
||||
// lineStyle = GDK_LINE_DOUBLE_DASH;
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 4;
|
||||
req_dash = dotted_dashed;
|
||||
break;
|
||||
}
|
||||
|
||||
case wxTRANSPARENT:
|
||||
case wxSTIPPLE:
|
||||
case wxSOLID:
|
||||
default:
|
||||
{
|
||||
lineStyle = GDK_LINE_SOLID;
|
||||
req_dash = (wxDash*)NULL;
|
||||
req_nb_dash = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (req_dash && req_nb_dash)
|
||||
{
|
||||
char *real_req_dash = new char[req_nb_dash];
|
||||
if (real_req_dash)
|
||||
{
|
||||
for (int i = 0; i < req_nb_dash; i++)
|
||||
real_req_dash[i] = req_dash[i] * width;
|
||||
gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash );
|
||||
delete[] real_req_dash;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No Memory. We use non-scaled dash pattern...
|
||||
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
|
||||
}
|
||||
}
|
||||
|
||||
GdkCapStyle capStyle = GDK_CAP_ROUND;
|
||||
|
@@ -24,7 +24,7 @@ class wxPenRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
|
||||
wxPenRefData(void);
|
||||
wxPenRefData();
|
||||
wxPenRefData( const wxPenRefData& data );
|
||||
|
||||
int m_width;
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
int m_joinStyle;
|
||||
int m_capStyle;
|
||||
wxColour m_colour;
|
||||
int m_countDashes;
|
||||
wxDash *m_dash;
|
||||
};
|
||||
|
||||
wxPenRefData::wxPenRefData()
|
||||
@@ -40,6 +42,8 @@ wxPenRefData::wxPenRefData()
|
||||
m_style = wxSOLID;
|
||||
m_joinStyle = wxJOIN_ROUND;
|
||||
m_capStyle = wxCAP_ROUND;
|
||||
m_dash = (wxDash*) NULL;
|
||||
m_countDashes = 0;
|
||||
}
|
||||
|
||||
wxPenRefData::wxPenRefData( const wxPenRefData& data )
|
||||
@@ -49,6 +53,12 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data )
|
||||
m_joinStyle = data.m_joinStyle;
|
||||
m_capStyle = data.m_capStyle;
|
||||
m_colour = data.m_colour;
|
||||
m_countDashes = data.m_countDashes;
|
||||
/*
|
||||
if (data.m_dash) TODO
|
||||
m_dash = new
|
||||
*/
|
||||
m_dash = data.m_dash;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -106,6 +116,13 @@ void wxPen::SetColour( const wxColour &colour )
|
||||
M_PENDATA->m_colour = colour;
|
||||
}
|
||||
|
||||
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
|
||||
{
|
||||
Unshare();
|
||||
M_PENDATA->m_countDashes = number_of_dashes;
|
||||
M_PENDATA->m_dash = (wxDash *)dash; /* TODO */
|
||||
}
|
||||
|
||||
void wxPen::SetColour( int red, int green, int blue )
|
||||
{
|
||||
Unshare();
|
||||
@@ -136,6 +153,22 @@ void wxPen::SetWidth( int width )
|
||||
M_PENDATA->m_width = width;
|
||||
}
|
||||
|
||||
int wxPen::GetDashes( wxDash **ptr ) const
|
||||
{
|
||||
*ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL);
|
||||
return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
|
||||
}
|
||||
|
||||
int wxPen::GetDashCount() const
|
||||
{
|
||||
return (M_PENDATA->m_countDashes);
|
||||
}
|
||||
|
||||
wxDash* wxPen::GetDash() const
|
||||
{
|
||||
return (M_PENDATA->m_dash);
|
||||
}
|
||||
|
||||
int wxPen::GetCap() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, _T("invalid pen") );
|
||||
|
@@ -864,9 +864,9 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
if (!m_window) return;
|
||||
|
||||
gint width = m_pen.GetWidth();
|
||||
// CMB: if width is non-zero scale it with the dc
|
||||
if (width <= 0)
|
||||
{
|
||||
// CMB: if width is non-zero scale it with the dc
|
||||
width = 1;
|
||||
}
|
||||
else
|
||||
@@ -877,14 +877,83 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
width = (int)w;
|
||||
}
|
||||
|
||||
const static char dotted[] = {1, 1};
|
||||
const static char short_dashed[] = {2, 2};
|
||||
const static char long_dashed[] = {2, 4};
|
||||
const static char dotted_dashed[] = {3, 3, 1, 3};
|
||||
|
||||
// We express dash pattern in pen width unit, so we are
|
||||
// independent of zoom factor and so on...
|
||||
int req_nb_dash;
|
||||
const char *req_dash;
|
||||
|
||||
GdkLineStyle lineStyle = GDK_LINE_SOLID;
|
||||
switch (m_pen.GetStyle())
|
||||
{
|
||||
case wxSOLID: { lineStyle = GDK_LINE_SOLID; break; }
|
||||
case wxDOT: { lineStyle = GDK_LINE_ON_OFF_DASH; break; }
|
||||
case wxLONG_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; break; }
|
||||
case wxSHORT_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; break; }
|
||||
case wxDOT_DASH: { lineStyle = GDK_LINE_DOUBLE_DASH; break; }
|
||||
case wxUSER_DASH:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = m_pen.GetDashCount();
|
||||
req_dash = m_pen.GetDash();
|
||||
break;
|
||||
}
|
||||
case wxDOT:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 2;
|
||||
req_dash = dotted;
|
||||
break;
|
||||
}
|
||||
case wxLONG_DASH:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 2;
|
||||
req_dash = long_dashed;
|
||||
break;
|
||||
}
|
||||
case wxSHORT_DASH:
|
||||
{
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 2;
|
||||
req_dash = short_dashed;
|
||||
break;
|
||||
}
|
||||
case wxDOT_DASH:
|
||||
{
|
||||
// lineStyle = GDK_LINE_DOUBLE_DASH;
|
||||
lineStyle = GDK_LINE_ON_OFF_DASH;
|
||||
req_nb_dash = 4;
|
||||
req_dash = dotted_dashed;
|
||||
break;
|
||||
}
|
||||
|
||||
case wxTRANSPARENT:
|
||||
case wxSTIPPLE:
|
||||
case wxSOLID:
|
||||
default:
|
||||
{
|
||||
lineStyle = GDK_LINE_SOLID;
|
||||
req_dash = (wxDash*)NULL;
|
||||
req_nb_dash = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (req_dash && req_nb_dash)
|
||||
{
|
||||
char *real_req_dash = new char[req_nb_dash];
|
||||
if (real_req_dash)
|
||||
{
|
||||
for (int i = 0; i < req_nb_dash; i++)
|
||||
real_req_dash[i] = req_dash[i] * width;
|
||||
gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash );
|
||||
delete[] real_req_dash;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No Memory. We use non-scaled dash pattern...
|
||||
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
|
||||
}
|
||||
}
|
||||
|
||||
GdkCapStyle capStyle = GDK_CAP_ROUND;
|
||||
|
@@ -24,7 +24,7 @@ class wxPenRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
|
||||
wxPenRefData(void);
|
||||
wxPenRefData();
|
||||
wxPenRefData( const wxPenRefData& data );
|
||||
|
||||
int m_width;
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
int m_joinStyle;
|
||||
int m_capStyle;
|
||||
wxColour m_colour;
|
||||
int m_countDashes;
|
||||
wxDash *m_dash;
|
||||
};
|
||||
|
||||
wxPenRefData::wxPenRefData()
|
||||
@@ -40,6 +42,8 @@ wxPenRefData::wxPenRefData()
|
||||
m_style = wxSOLID;
|
||||
m_joinStyle = wxJOIN_ROUND;
|
||||
m_capStyle = wxCAP_ROUND;
|
||||
m_dash = (wxDash*) NULL;
|
||||
m_countDashes = 0;
|
||||
}
|
||||
|
||||
wxPenRefData::wxPenRefData( const wxPenRefData& data )
|
||||
@@ -49,6 +53,12 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data )
|
||||
m_joinStyle = data.m_joinStyle;
|
||||
m_capStyle = data.m_capStyle;
|
||||
m_colour = data.m_colour;
|
||||
m_countDashes = data.m_countDashes;
|
||||
/*
|
||||
if (data.m_dash) TODO
|
||||
m_dash = new
|
||||
*/
|
||||
m_dash = data.m_dash;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -106,6 +116,13 @@ void wxPen::SetColour( const wxColour &colour )
|
||||
M_PENDATA->m_colour = colour;
|
||||
}
|
||||
|
||||
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
|
||||
{
|
||||
Unshare();
|
||||
M_PENDATA->m_countDashes = number_of_dashes;
|
||||
M_PENDATA->m_dash = (wxDash *)dash; /* TODO */
|
||||
}
|
||||
|
||||
void wxPen::SetColour( int red, int green, int blue )
|
||||
{
|
||||
Unshare();
|
||||
@@ -136,6 +153,22 @@ void wxPen::SetWidth( int width )
|
||||
M_PENDATA->m_width = width;
|
||||
}
|
||||
|
||||
int wxPen::GetDashes( wxDash **ptr ) const
|
||||
{
|
||||
*ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL);
|
||||
return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
|
||||
}
|
||||
|
||||
int wxPen::GetDashCount() const
|
||||
{
|
||||
return (M_PENDATA->m_countDashes);
|
||||
}
|
||||
|
||||
wxDash* wxPen::GetDash() const
|
||||
{
|
||||
return (M_PENDATA->m_dash);
|
||||
}
|
||||
|
||||
int wxPen::GetCap() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), -1, _T("invalid pen") );
|
||||
|
Reference in New Issue
Block a user