[ 1492053 ] Add wxVListBox style callbacks to wxOwnerDrawnComboBox.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2006-06-14 18:38:47 +00:00
parent ec09e18d35
commit 40b26d752d
7 changed files with 151 additions and 130 deletions

View File

@@ -396,79 +396,14 @@ END_EVENT_TABLE()
// ----------------------------------------------------------------------------
// wxOwnerDrawnComboBox with custom paint list items
// ----------------------------------------------------------------------------
/*
class wxPenStyleComboBox : public wxOwnerDrawnComboBox
{
public:
virtual bool OnDrawListItem( wxDC& dc, const wxRect& rect, int item, int flags )
{
wxRect r(rect);
r.Deflate(3);
r.height -= 2;
int pen_style = wxSOLID;
if ( item == 1 )
pen_style = wxTRANSPARENT;
else if ( item == 2 )
pen_style = wxDOT;
else if ( item == 3 )
pen_style = wxLONG_DASH;
else if ( item == 4 )
pen_style = wxSHORT_DASH;
else if ( item == 5 )
pen_style = wxDOT_DASH;
else if ( item == 6 )
pen_style = wxBDIAGONAL_HATCH;
else if ( item == 7 )
pen_style = wxCROSSDIAG_HATCH;
else if ( item == 8 )
pen_style = wxFDIAGONAL_HATCH;
else if ( item == 9 )
pen_style = wxCROSS_HATCH;
else if ( item == 10 )
pen_style = wxHORIZONTAL_HATCH;
else if ( item == 11 )
pen_style = wxVERTICAL_HATCH;
wxPen pen( dc.GetTextForeground(), 3, pen_style );
// Get text colour as pen colour
dc.SetPen ( pen );
if ( !(flags & wxCP_PAINTING_CONTROL) )
{
dc.DrawText(GetString( item ),
r.x + 3,
(r.y + 0) + ( (r.height/2) - dc.GetCharHeight() )/2
);
dc.DrawLine( r.x+5, r.y+((r.height/4)*3), r.x+r.width - 5, r.y+((r.height/4)*3) );
}
else
{
dc.DrawLine( r.x+5, r.y+r.height/2, r.x+r.width - 5, r.y+r.height/2 );
}
return true;
}
virtual wxCoord OnMeasureListItem( int WXUNUSED(item) )
{
return 24;
}
virtual wxCoord OnMeasureListItemWidth( int WXUNUSED(item) )
{
return -1; // default - will be measured from text width
}
};
*/
class wxPenStylePopup : public wxVListBoxComboPopup
{
public:
virtual void OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const
virtual void OnDrawItem( wxDC& dc,
const wxRect& rect,
int item,
int flags ) const
{
if ( item == wxNOT_FOUND )
return;
@@ -506,7 +441,7 @@ public:
// Get text colour as pen colour
dc.SetPen ( pen );
if ( !(flags & wxCP_PAINTING_CONTROL) )
if ( !(flags & wxODCB_PAINTING_CONTROL) )
{
dc.DrawText(GetString( item ),
r.x + 3,
@@ -824,15 +759,13 @@ MyFrame::MyFrame(const wxString& title)
// When defining derivative class for callbacks, we need
// to use two-stage creation (or redefine the common wx
// constructor).
odc = new wxOwnerDrawnComboBox(panel,wxID_ANY,wxEmptyString,
wxDefaultPosition, wxDefaultSize,
arrItems,
wxCB_READONLY //wxNO_BORDER | wxCB_READONLY
);
odc = new wxPenStyleComboBox();
odc->Create(panel,wxID_ANY,wxEmptyString,
wxDefaultPosition, wxDefaultSize,
arrItems,
wxCB_READONLY //wxNO_BORDER | wxCB_READONLY
);
odc->SetPopupControl( new wxPenStylePopup() );
//m_odc->SetCustomPaintWidth( 60 );
odc->SetSelection(0);
odc->SetButtonPosition(-2, // width adjustment
-6, // height adjustment