#include "wx/mac/private.h"
#endif
+#ifdef __WXGTK__
+ #include "wx/gtk/private.h"
+ #include "wx/gtk/win_gtk.h"
+#endif
+
+
// NOTE: If using the wxListBox visual attributes works everywhere then this can
// be removed, as well as the #else case below.
static const int LINE_SPACING = 0;
// extra margins around the text label
+#ifdef __WXGTK__
+static const int EXTRA_WIDTH = 6;
+#else
static const int EXTRA_WIDTH = 4;
+#endif
static const int EXTRA_HEIGHT = 4;
// margin between the window and the items
if ( item->HasText() )
{
if (m_gi->m_rectAll.width > spacing)
- m_gi->m_rectLabel.x = m_gi->m_rectAll.x + 2;
+ m_gi->m_rectLabel.x = m_gi->m_rectAll.x + (EXTRA_WIDTH/2);
else
- m_gi->m_rectLabel.x = m_gi->m_rectAll.x + 2 + (spacing / 2) - (m_gi->m_rectLabel.width / 2);
+ m_gi->m_rectLabel.x = m_gi->m_rectAll.x + (EXTRA_WIDTH/2) + (spacing / 2) - (m_gi->m_rectLabel.width / 2);
m_gi->m_rectLabel.y = m_gi->m_rectAll.y + m_gi->m_rectAll.height + 2 - m_gi->m_rectLabel.height;
m_gi->m_rectHighlight.x = m_gi->m_rectLabel.x - 2;
m_gi->m_rectHighlight.y = m_gi->m_rectLabel.y - 2;
{
m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 2;
m_gi->m_rectIcon.y = m_gi->m_rectAll.y + 2;
- m_gi->m_rectLabel.x = m_gi->m_rectAll.x + 6 + m_gi->m_rectIcon.width;
+ m_gi->m_rectLabel.x = m_gi->m_rectAll.x + 4 + (EXTRA_WIDTH/2) + m_gi->m_rectIcon.width;
}
else
{
- m_gi->m_rectLabel.x = m_gi->m_rectAll.x + 2;
+ m_gi->m_rectLabel.x = m_gi->m_rectAll.x + (EXTRA_WIDTH/2);
}
break;
wxListItemAttr *attr = GetAttr();
if ( SetAttributes(dc, attr, highlighted) )
+#ifndef __WXGTK__
+ {
dc->DrawRectangle( m_gi->m_rectHighlight );
+ }
+#else
+ {
+ if (highlighted)
+ {
+ wxRect rect2( m_gi->m_rectHighlight );
+ m_owner->CalcScrolledPosition( rect2.x, rect2.y, &rect2.x, &rect2.y );
+
+ gtk_paint_flat_box( m_owner->m_widget->style,
+ 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
+ {
+ dc->DrawRectangle( m_gi->m_rectHighlight );
+ }
+ }
+#endif
// just for debugging to better see where the items are
#if 0
// GetAttr() and move these lines into the loop below
wxListItemAttr *attr = GetAttr();
if ( SetAttributes(dc, attr, highlighted) )
+#ifndef __WXGTK__
+ {
dc->DrawRectangle( rectHL );
+ }
+#else
+ {
+ if (highlighted)
+ {
+ wxRect rect2( rectHL );
+ m_owner->CalcScrolledPosition( rect2.x, rect2.y, &rect2.x, &rect2.y );
+
+ gtk_paint_flat_box( m_owner->m_widget->style,
+ 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
+ {
+ dc->DrawRectangle( rectHL );
+ }
+ }
+#endif
wxCoord x = rect.x + HEADER_OFFSET_X,
yMid = rect.y + rect.height/2;
+#ifdef __WXGTK__
+ // This probably needs to be done
+ // on all platforms as the icons
+ // otherwise nearly touch the border
+ x += 2;
+#endif
size_t col = 0;
for ( wxListItemDataList::compatibility_iterator node = m_items.GetFirst();
{
if ( m_hasFocus )
{
+ wxRect rect( GetLineHighlightRect( m_current ) );
+#ifndef __WXGTK__
dc.SetPen( *wxBLACK_PEN );
dc.SetBrush( *wxTRANSPARENT_BRUSH );
- dc.DrawRectangle( GetLineHighlightRect( m_current ) );
+ dc.DrawRectangle( rect );
+#else
+ CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+
+ 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
#include "wx/mac/private.h"
#endif
+#ifdef __WXGTK__
+ #include "wx/gtk/private.h"
+ #include "wx/gtk/win_gtk.h"
+#endif
+
// -----------------------------------------------------------------------------
// array types
// -----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxGenericTreeCtrl, wxTreeCtrlBase)
EVT_PAINT (wxGenericTreeCtrl::OnPaint)
+ EVT_SIZE (wxGenericTreeCtrl::OnSize)
EVT_MOUSE_EVENTS (wxGenericTreeCtrl::OnMouse)
EVT_CHAR (wxGenericTreeCtrl::OnChar)
EVT_SET_FOCUS (wxGenericTreeCtrl::OnSetFocus)
int x, w, h;
x=0;
GetVirtualSize(&w, &h);
- dc.DrawRectangle(x, item->GetY()+offset, w, total_h-offset);
+ wxRect rect( x, item->GetY()+offset, w, total_h-offset);
+#ifndef __WXGTK__
+ dc.DrawRectangle(rect);
+#else
+ if (!item->IsSelected())
+ {
+ dc.DrawRectangle(rect);
+ }
+ else
+ {
+ CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+
+ gtk_paint_flat_box( m_widget->style,
+ 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))
+ 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
}
else
{
// If it's selected, and there's an image, then we should
// take care to leave the area under the image painted in the
// background colour.
- dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset,
- item->GetWidth() - image_w + 2, total_h-offset );
+ wxRect rect( item->GetX() + image_w - 2, item->GetY()+offset,
+ item->GetWidth() - image_w + 2, total_h-offset );
+#ifndef __WXGTK__
+ dc.DrawRectangle( rect );
+#else
+ CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ rect.x -= 1;
+ rect.width += 2;
+
+ gtk_paint_flat_box( m_widget->style,
+ 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))
+ 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
}
// On GTK+ 2, drawing a 'normal' background is wrong for themes that
// don't allow backgrounds to be customized. Not drawing the background,
// except for custom item backgrounds, works for both kinds of theme.
else if (drawItemBackground)
{
- dc.DrawRectangle( item->GetX()-2, item->GetY()+offset,
- item->GetWidth()+2, total_h-offset );
+ wxRect rect( item->GetX()-2, item->GetY()+offset,
+ item->GetWidth()+2, total_h-offset );
+#ifndef __WXGTK__
+ dc.DrawRectangle( rect );
+#else
+ if ( attr && attr->HasBackgroundColour() )
+ {
+ dc.DrawRectangle( rect );
+ }
+ else
+ {
+ CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ rect.x -= 1;
+ rect.width += 2;
+
+ gtk_paint_flat_box( m_widget->style,
+ 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))
+ 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
}
}
// wxWidgets callbacks
// -----------------------------------------------------------------------------
+void wxGenericTreeCtrl::OnSize( wxSizeEvent &event )
+{
+#ifdef __WXGTK__
+ if (HasFlag( wxTR_FULL_ROW_HIGHLIGHT) && m_current)
+ RefreshLine( m_current );
+#endif
+
+ event.Skip(true);
+}
+
void wxGenericTreeCtrl::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
wxPaintDC dc(this);