Just use the already existing wxRenderer::DrawItemSelectionRect()
from wxListCtrl and wxTreeCtrl; and document it... git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -143,6 +143,21 @@ The \arg{sortArrow} parameter can be one of
|
|||||||
drawing of a text or bitmap label can be passed in \arg{params}.
|
drawing of a text or bitmap label can be passed in \arg{params}.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxRendererNative::DrawItemSelectionRect}\label{wxrenderernativedrawitemselectionrect}
|
||||||
|
|
||||||
|
\func{void}{DrawItemSelectionRect}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
|
||||||
|
|
||||||
|
Draw a selection rectangle underneath the text as used e.g.
|
||||||
|
in a \helpref{wxListCtrl}{wxlistctrl}. The supported \arg{flags}
|
||||||
|
are \texttt{wxCONTROL\_SELECTED} for items which are selected
|
||||||
|
(e.g. often a blue rectangle) and \texttt{wxCONTROL\_CURRENT}
|
||||||
|
for the item that has the focus (often a dotted line around
|
||||||
|
the item's text). \texttt{wxCONTROL\_CURRENT} may be used
|
||||||
|
to indicate if the control has the focus (othewise the
|
||||||
|
the selection rectangle is e.g. often grey and not blue).
|
||||||
|
This may be ignored by the renderer or deduced by the
|
||||||
|
code directly from the \arg{win}.
|
||||||
|
|
||||||
\membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}
|
\membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}
|
||||||
|
|
||||||
\func{void}{DrawPushButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
|
\func{void}{DrawPushButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
|
||||||
|
@@ -52,12 +52,6 @@
|
|||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
#include "wx/gtk/private.h"
|
|
||||||
#include "wx/gtk/win_gtk.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: If using the wxListBox visual attributes works everywhere then this can
|
// NOTE: If using the wxListBox visual attributes works everywhere then this can
|
||||||
// be removed, as well as the #else case below.
|
// be removed, as well as the #else case below.
|
||||||
@@ -1456,17 +1450,11 @@ void wxListLineData::Draw( wxDC *dc )
|
|||||||
{
|
{
|
||||||
if (highlighted)
|
if (highlighted)
|
||||||
{
|
{
|
||||||
wxRect rect2( m_gi->m_rectHighlight );
|
int flags = wxCONTROL_SELECTED;
|
||||||
m_owner->CalcScrolledPosition( rect2.x, rect2.y, &rect2.x, &rect2.y );
|
if (m_owner->HasFocus())
|
||||||
|
flags |= wxCONTROL_FOCUSED;
|
||||||
gtk_paint_flat_box( m_owner->m_widget->style,
|
wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, m_gi->m_rectHighlight, flags );
|
||||||
GTK_PIZZA(m_owner->m_wxwindow)->bin_window,
|
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
GTK_SHADOW_NONE,
|
|
||||||
NULL,
|
|
||||||
m_owner->m_wxwindow,
|
|
||||||
"cell_even",
|
|
||||||
rect2.x, rect2.y, rect2.width, rect2.height );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1521,17 +1509,10 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
|
|||||||
{
|
{
|
||||||
if (highlighted)
|
if (highlighted)
|
||||||
{
|
{
|
||||||
wxRect rect2( rectHL );
|
int flags = wxCONTROL_SELECTED;
|
||||||
m_owner->CalcScrolledPosition( rect2.x, rect2.y, &rect2.x, &rect2.y );
|
if (m_owner->HasFocus())
|
||||||
|
flags |= wxCONTROL_FOCUSED;
|
||||||
gtk_paint_flat_box( m_owner->m_widget->style,
|
wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, rectHL, flags );
|
||||||
GTK_PIZZA(m_owner->m_wxwindow)->bin_window,
|
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
GTK_SHADOW_NONE,
|
|
||||||
NULL,
|
|
||||||
m_owner->m_wxwindow,
|
|
||||||
"cell_even",
|
|
||||||
rect2.x, rect2.y, rect2.width, rect2.height );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2801,15 +2782,7 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||||
dc.DrawRectangle( rect );
|
dc.DrawRectangle( rect );
|
||||||
#else
|
#else
|
||||||
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, wxCONTROL_CURRENT|wxCONTROL_FOCUSED );
|
||||||
|
|
||||||
gtk_paint_focus( m_widget->style,
|
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"treeview",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -45,11 +45,6 @@
|
|||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
#include "wx/gtk/private.h"
|
|
||||||
#include "wx/gtk/win_gtk.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// array types
|
// array types
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -2250,25 +2245,12 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
int flags = wxCONTROL_SELECTED;
|
||||||
|
if (m_hasFocus)
|
||||||
gtk_paint_flat_box( m_widget->style,
|
flags |= wxCONTROL_FOCUSED;
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
GTK_SHADOW_NONE,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"cell_even",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
|
|
||||||
if ((item == m_current) && (m_hasFocus))
|
if ((item == m_current) && (m_hasFocus))
|
||||||
gtk_paint_focus( m_widget->style,
|
flags |= wxCONTROL_CURRENT;
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, flags );
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"treeview",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -2284,28 +2266,15 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
dc.DrawRectangle( rect );
|
dc.DrawRectangle( rect );
|
||||||
#else
|
#else
|
||||||
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
|
||||||
rect.x -= 1;
|
rect.x -= 1;
|
||||||
rect.width += 2;
|
rect.width += 2;
|
||||||
|
|
||||||
gtk_paint_flat_box( m_widget->style,
|
int flags = wxCONTROL_SELECTED;
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
if (m_hasFocus)
|
||||||
GTK_STATE_SELECTED,
|
flags |= wxCONTROL_FOCUSED;
|
||||||
GTK_SHADOW_NONE,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"cell_even",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
|
|
||||||
if ((item == m_current) && (m_hasFocus))
|
if ((item == m_current) && (m_hasFocus))
|
||||||
gtk_paint_focus( m_widget->style,
|
flags |= wxCONTROL_CURRENT;
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, flags );
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"treeview",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// On GTK+ 2, drawing a 'normal' background is wrong for themes that
|
// On GTK+ 2, drawing a 'normal' background is wrong for themes that
|
||||||
@@ -2324,27 +2293,15 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
|
||||||
rect.x -= 1;
|
rect.x -= 1;
|
||||||
rect.width += 2;
|
rect.width += 2;
|
||||||
|
|
||||||
gtk_paint_flat_box( m_widget->style,
|
int flags = wxCONTROL_SELECTED;
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
if (m_hasFocus)
|
||||||
GTK_STATE_SELECTED,
|
flags |= wxCONTROL_FOCUSED;
|
||||||
GTK_SHADOW_NONE,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"cell_even",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
|
|
||||||
if ((item == m_current) && (m_hasFocus))
|
if ((item == m_current) && (m_hasFocus))
|
||||||
gtk_paint_focus( m_widget->style,
|
flags |= wxCONTROL_CURRENT;
|
||||||
GTK_PIZZA(m_wxwindow)->bin_window,
|
wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, flags );
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
NULL,
|
|
||||||
m_wxwindow,
|
|
||||||
"treeview",
|
|
||||||
rect.x, rect.y, rect.width, rect.height );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -513,18 +513,17 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow *win,
|
|||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
if (flags & wxCONTROL_SELECTED)
|
if (flags & wxCONTROL_SELECTED)
|
||||||
{
|
{
|
||||||
if (flags & wxCONTROL_FOCUSED)
|
// the wxCONTROL_FOCUSED state is deduced
|
||||||
state = GTK_STATE_SELECTED;
|
// directly from the m_wxwindow by GTK+
|
||||||
else
|
state = GTK_STATE_SELECTED;
|
||||||
state = GTK_STATE_INSENSITIVE;
|
|
||||||
|
|
||||||
gtk_paint_flat_box( win->m_wxwindow->style,
|
gtk_paint_flat_box( win->m_widget->style,
|
||||||
gdk_window,
|
gdk_window,
|
||||||
state,
|
state,
|
||||||
GTK_SHADOW_NONE,
|
GTK_SHADOW_NONE,
|
||||||
NULL,
|
NULL,
|
||||||
win->m_wxwindow,
|
win->m_wxwindow,
|
||||||
"treeview",
|
"cell_even",
|
||||||
dc.LogicalToDeviceX(rect.x),
|
dc.LogicalToDeviceX(rect.x),
|
||||||
dc.LogicalToDeviceY(rect.y),
|
dc.LogicalToDeviceY(rect.y),
|
||||||
rect.width,
|
rect.width,
|
||||||
@@ -533,8 +532,15 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow *win,
|
|||||||
|
|
||||||
if (flags & wxCONTROL_CURRENT)
|
if (flags & wxCONTROL_CURRENT)
|
||||||
{
|
{
|
||||||
dc.SetPen( *wxBLACK_PEN );
|
gtk_paint_focus( win->m_widget->style,
|
||||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
gdk_window,
|
||||||
dc.DrawRectangle( rect );
|
GTK_STATE_SELECTED,
|
||||||
|
NULL,
|
||||||
|
win->m_wxwindow,
|
||||||
|
"treeview",
|
||||||
|
dc.LogicalToDeviceX(rect.x),
|
||||||
|
dc.LogicalToDeviceY(rect.y),
|
||||||
|
rect.width,
|
||||||
|
rect.height );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user