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
// ------------------
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); }
wxDataViewTextCtrlWrapper *m_textctrlWrapper;
bool m_lastOnSame;
- wxBrush *m_highlightBrush,
- *m_highlightUnfocusedBrush;
bool m_hasFocus;
int m_dragCount;
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 );
wxDataViewMainWindow::~wxDataViewMainWindow()
{
delete m_renameTimer;
- delete m_highlightBrush;
- delete m_highlightUnfocusedBrush;
}
void wxDataViewMainWindow::OnRenameTimer()
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;
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
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.
// ----------------------------------------------------------------------------
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);
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:
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 );
+ }
+}
+