Added wxRenderer method for drawing selection
rect if an item in a list has ben selected. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -186,6 +186,18 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0) = 0;
|
||||
|
||||
// draw rectangle indicating that an item in e.g. a list control
|
||||
// has been selected or focused
|
||||
//
|
||||
// flags may use
|
||||
// wxCONTROL_SELECTED (item is selected, e.g. draw background)
|
||||
// wxCONTROL_CURRENT (item is the current item, e.g. dotted border)
|
||||
// wxCONTROL_FOCUSED (the whole control has focus, e.g. blue background vs. grey otherwise)
|
||||
virtual void DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0) = 0;
|
||||
|
||||
// geometry functions
|
||||
// ------------------
|
||||
|
||||
@@ -300,6 +312,12 @@ public:
|
||||
int flags = 0 )
|
||||
{ m_rendererNative.DrawPushButton( win, dc, rect, flags ); }
|
||||
|
||||
virtual void DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0 )
|
||||
{ m_rendererNative.DrawItemSelectionRect( win, dc, rect, flags ); }
|
||||
|
||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win)
|
||||
{ return m_rendererNative.GetSplitterParams(win); }
|
||||
|
||||
|
@@ -202,8 +202,6 @@ private:
|
||||
wxDataViewTextCtrlWrapper *m_textctrlWrapper;
|
||||
bool m_lastOnSame;
|
||||
|
||||
wxBrush *m_highlightBrush,
|
||||
*m_highlightUnfocusedBrush;
|
||||
bool m_hasFocus;
|
||||
|
||||
int m_dragCount;
|
||||
@@ -876,24 +874,6 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i
|
||||
m_lineBeforeLastClicked = (size_t) -1;
|
||||
m_lineSelectSingleOnUp = (size_t) -1;
|
||||
|
||||
m_highlightBrush = new wxBrush
|
||||
(
|
||||
wxSystemSettings::GetColour
|
||||
(
|
||||
wxSYS_COLOUR_HIGHLIGHT
|
||||
),
|
||||
wxSOLID
|
||||
);
|
||||
|
||||
m_highlightUnfocusedBrush = new wxBrush
|
||||
(
|
||||
wxSystemSettings::GetColour
|
||||
(
|
||||
wxSYS_COLOUR_BTNSHADOW
|
||||
),
|
||||
wxSOLID
|
||||
);
|
||||
|
||||
m_hasFocus = false;
|
||||
|
||||
SetBackgroundColour( *wxWHITE );
|
||||
@@ -904,8 +884,6 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i
|
||||
wxDataViewMainWindow::~wxDataViewMainWindow()
|
||||
{
|
||||
delete m_renameTimer;
|
||||
delete m_highlightBrush;
|
||||
delete m_highlightUnfocusedBrush;
|
||||
}
|
||||
|
||||
void wxDataViewMainWindow::OnRenameTimer()
|
||||
@@ -1054,31 +1032,47 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
size_t item_count = wxMin( (int)(((update.y + update.height) / m_lineHeight) - item_start + 1),
|
||||
(int)(model->GetNumberOfRows()-item_start) );
|
||||
|
||||
|
||||
|
||||
if (m_hasFocus)
|
||||
dc.SetBrush( *m_highlightBrush );
|
||||
else
|
||||
dc.SetBrush( *m_highlightUnfocusedBrush );
|
||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
||||
|
||||
size_t item;
|
||||
for (item = item_start; item < item_start+item_count; item++)
|
||||
{
|
||||
if (m_selection.Index( item ) != wxNOT_FOUND)
|
||||
{
|
||||
int flags = wxCONTROL_SELECTED;
|
||||
if (item == m_currentRow)
|
||||
flags |= wxCONTROL_CURRENT;
|
||||
if (m_hasFocus)
|
||||
flags |= wxCONTROL_FOCUSED;
|
||||
wxRect rect( 0, item*m_lineHeight+1, GetEndOfLastCol(), m_lineHeight-2 );
|
||||
dc.DrawRectangle( rect );
|
||||
wxRendererNative::Get().DrawItemSelectionRect
|
||||
(
|
||||
this,
|
||||
dc,
|
||||
rect,
|
||||
flags
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item == m_currentRow)
|
||||
{
|
||||
int flags = wxCONTROL_CURRENT;
|
||||
if (m_hasFocus)
|
||||
flags |= wxCONTROL_FOCUSED; // should have no effect
|
||||
wxRect rect( 0, item*m_lineHeight+1, GetEndOfLastCol(), m_lineHeight-2 );
|
||||
wxRendererNative::Get().DrawItemSelectionRect
|
||||
(
|
||||
this,
|
||||
dc,
|
||||
rect,
|
||||
flags
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
if (HasCurrentRow())
|
||||
{
|
||||
wxRect rect( 0, m_currentRow*m_lineHeight+1, GetEndOfLastCol(), m_lineHeight-2 );
|
||||
dc.DrawRectangle( rect );
|
||||
}
|
||||
|
||||
wxRect cell_rect;
|
||||
cell_rect.x = 0;
|
||||
cell_rect.height = m_lineHeight;
|
||||
|
@@ -88,6 +88,11 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual void DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
||||
|
||||
virtual wxRendererVersion GetVersion() const
|
||||
@@ -428,6 +433,52 @@ wxRendererGeneric::DrawPushButton(wxWindow *win,
|
||||
dc.DrawRectangle(rect);
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererGeneric::DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags )
|
||||
{
|
||||
if (flags & wxCONTROL_SELECTED)
|
||||
{
|
||||
if (flags & wxCONTROL_FOCUSED)
|
||||
{
|
||||
wxBrush brush(
|
||||
wxSystemSettings::GetColour
|
||||
(
|
||||
wxSYS_COLOUR_HIGHLIGHT
|
||||
),
|
||||
wxSOLID
|
||||
);
|
||||
dc.SetBrush( brush );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxBrush brush(
|
||||
wxSystemSettings::GetColour
|
||||
(
|
||||
wxSYS_COLOUR_BTNSHADOW
|
||||
),
|
||||
wxSOLID
|
||||
);
|
||||
dc.SetBrush( brush );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
}
|
||||
|
||||
|
||||
if (flags & wxCONTROL_CURRENT)
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
else
|
||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
||||
|
||||
dc.DrawRectangle( rect );
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A module to allow cleanup of generic renderer.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -1437,6 +1437,12 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_treeview = gtk_tree_view_new();
|
||||
gtk_container_add (GTK_CONTAINER (m_widget), m_treeview);
|
||||
|
||||
if (style & wxDV_MULTIPLE)
|
||||
{
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
|
||||
gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
|
||||
}
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
|
||||
|
@@ -88,6 +88,11 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual void DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0);
|
||||
|
||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
||||
|
||||
private:
|
||||
@@ -505,3 +510,43 @@ wxRendererGTK::DrawPushButton(wxWindow *win,
|
||||
rect.x, rect.y, rect.width, rect.height
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererGTK::DrawItemSelectionRect(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags )
|
||||
{
|
||||
// for reason why we do this, see DrawDropArrow
|
||||
wxWindowDC& wdc = (wxWindowDC&)dc;
|
||||
wxASSERT ( wdc.IsKindOf(CLASSINFO(wxWindowDC)) );
|
||||
|
||||
GtkStateType state;
|
||||
if (flags & wxCONTROL_SELECTED)
|
||||
{
|
||||
if (flags & wxCONTROL_FOCUSED)
|
||||
state = GTK_STATE_SELECTED;
|
||||
else
|
||||
state = GTK_STATE_INSENSITIVE;
|
||||
|
||||
gtk_paint_flat_box( win->m_wxwindow->style,
|
||||
GTK_PIZZA(win->m_wxwindow)->bin_window,
|
||||
state,
|
||||
GTK_SHADOW_NONE,
|
||||
NULL,
|
||||
win->m_wxwindow,
|
||||
"treeview",
|
||||
dc.LogicalToDeviceX(rect.x),
|
||||
dc.LogicalToDeviceY(rect.y),
|
||||
rect.width,
|
||||
rect.height );
|
||||
}
|
||||
|
||||
if (flags & wxCONTROL_CURRENT)
|
||||
{
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
dc.DrawRectangle( rect );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user