#include "wx/generic/imaglist.h"
#include "wx/dynarray.h"
+#ifdef __WXGTK__
+#include <gtk/gtk.h>
+#include "wx/gtk/win_gtk.h"
+#endif
+
#ifndef wxUSE_GENERIC_LIST_EXTENSIONS
#define wxUSE_GENERIC_LIST_EXTENSIONS 1
#endif
m_bound_all.width = 0;
m_bound_all.height = 0;
wxNode *node = m_items.First();
+ if (node)
+ {
+ wxListItemData *item = (wxListItemData*)node->Data();
+ if (item->HasImage())
+ {
+ int w = 0;
+ int h = 0;
+ m_owner->GetImageSize( item->GetImage(), w, h );
+ m_bound_icon.width = w;
+ m_bound_icon.height = h;
+ }
+ else
+ {
+ m_bound_icon.width = 0;
+ m_bound_icon.height = 0;
+ }
+ }
while (node)
{
wxListItemData *item = (wxListItemData*)node->Data();
m_bound_all.height = lh;
node = node->Next();
}
+ m_bound_label.width = m_bound_all.width;
+ m_bound_label.height = m_bound_all.height;
break;
}
}
void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
{
+#ifdef __WXGTK__
+ GtkStateType state = GTK_STATE_NORMAL;
+ if (!m_parent->IsEnabled()) state = GTK_STATE_INSENSITIVE;
+
+ x = dc->XLOG2DEV( x );
+
+ gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window, state, GTK_SHADOW_OUT,
+ (GdkRectangle*) NULL, m_wxwindow, "button", x-1, y-1, w+2, h+2);
+#else
const int m_corner = 1;
dc->SetBrush( *wxTRANSPARENT_BRUSH );
dc->DrawRectangle( x, y, 1, h ); // left (outer)
dc->DrawLine( x, y+h-1, x+1, y+h-1 );
dc->DrawLine( x+w-1, y, x+w-1, y+1 );
+#endif
}
// shift the DC origin to match the position of the main window horz
// do *not* use the listctrl colour for headers - one day we will have a
// function to set it separately
- dc.SetTextForeground( *wxBLACK );
+ //dc.SetTextForeground( *wxBLACK );
+ dc.SetTextForeground(wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOWTEXT ));
int x = 1; // left of the header rect
const int y = 1; // top
if (m_mode & wxLC_REPORT)
{
+ wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
+ dc.SetPen(pen);
+ dc.SetBrush(* wxTRANSPARENT_BRUSH);
+
+ wxSize clientSize = GetClientSize();
+
int lineSpacing = 0;
wxListLineData *line = &m_lines[0];
int dummy = 0;
size_t i_to = y_s / lineSpacing + m_visibleLines+2;
if (i_to >= m_lines.GetCount()) i_to = m_lines.GetCount();
- for (size_t i = y_s / lineSpacing; i < i_to; i++)
+ size_t i;
+ for (i = y_s / lineSpacing; i < i_to; i++)
{
m_lines[i].Draw( &dc );
+ // Draw horizontal rule if required
+ if (GetWindowStyle() & wxLC_HRULES)
+ dc.DrawLine(0, i*lineSpacing, clientSize.x, i*lineSpacing);
+ }
+
+ // Draw last horizontal rule
+ if ((i > (size_t) (y_s / lineSpacing)) && (GetWindowStyle() & wxLC_HRULES))
+ dc.DrawLine(0, i*lineSpacing, clientSize.x, i*lineSpacing);
+
+ // Draw vertical rules if required
+ if ((GetWindowStyle() & wxLC_VRULES) && (GetItemCount() > 0))
+ {
+ int col = 0;
+ wxRect firstItemRect;
+ wxRect lastItemRect;
+ GetItemRect(0, firstItemRect);
+ GetItemRect(GetItemCount() - 1, lastItemRect);
+ int x = firstItemRect.GetX();
+ for (col = 0; col < GetColumnCount(); col++)
+ {
+ int colWidth = GetColumnWidth(col);
+ x += colWidth ;
+ dc.DrawLine(x, firstItemRect.GetY() - 1, x, lastItemRect.GetBottom() + 1);
+ }
}
}
else
void wxListMainWindow::EditLabel( long item )
{
- wxCHECK_RET( ((size_t)item < m_lines.GetCount()),
+ wxCHECK_RET( ((size_t)item < m_lines.GetCount()),
wxT("wrong index in wxListCtrl::Edit()") );
m_currentEdit = &m_lines[(size_t)item];
void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
+ event.SetEventObject( GetParent() );
if (GetParent()->GetEventHandler()->ProcessEvent( event)) return;
if (!m_current) return;
else if (event.ShiftDown())
{
size_t j;
-
+
m_current = line;
int numOfCurrent = -1;
if (index != wxNOT_FOUND)
{
index -= steps;
- if (index < 0) index = 0;
+ if (index < 0) index = 0;
OnArrowChar( &m_lines[index], event.ShiftDown() );
}
break;
if (index != wxNOT_FOUND)
{
index += steps;
- if ((size_t)index >= m_lines.GetCount())
+ if ((size_t)index >= m_lines.GetCount())
index = m_lines.GetCount()-1;
OnArrowChar( &m_lines[index], event.ShiftDown() );
}
if (index != wxNOT_FOUND)
{
index += m_visibleLines;
- if ((size_t)index >= m_lines.GetCount())
+ if ((size_t)index >= m_lines.GetCount())
index = m_lines.GetCount()-1;
OnArrowChar( &m_lines[index], event.ShiftDown() );
}
wxClientDC dc(this);
dc.SetFont( GetFont() );
int max = 10;
-
+
for (size_t i = 0; i < m_lines.GetCount(); i++)
{
wxListLineData *line = &m_lines[i];
{
wxListLineData *line = &m_lines[i];
long ret = line->IsHit( x, y );
- if (ret & flags)
+ if (ret) // & flags) // No: flags is output-only so may be garbage at this point
{
flags = (int)ret;
return count;
else
{
m_lines.Add( line );
+ item.m_itemId = m_lines.GetCount()-1;
}
}
m_imageListNormal = (wxImageList *) NULL;
m_imageListSmall = (wxImageList *) NULL;
m_imageListState = (wxImageList *) NULL;
+ m_ownsImageListNormal = m_ownsImageListSmall = m_ownsImageListState = FALSE;
m_mainWin = (wxListMainWindow*) NULL;
m_headerWin = (wxListHeaderWindow*) NULL;
}
wxListCtrl::~wxListCtrl()
{
+ if (m_ownsImageListNormal) delete m_imageListNormal;
+ if (m_ownsImageListSmall) delete m_imageListSmall;
+ if (m_ownsImageListState) delete m_imageListState;
}
bool wxListCtrl::Create(wxWindow *parent,
m_imageListNormal = (wxImageList *) NULL;
m_imageListSmall = (wxImageList *) NULL;
m_imageListState = (wxImageList *) NULL;
+ m_ownsImageListNormal = m_ownsImageListSmall = m_ownsImageListState = FALSE;
m_mainWin = (wxListMainWindow*) NULL;
m_headerWin = (wxListHeaderWindow*) NULL;
void wxListCtrl::SetImageList( wxImageList *imageList, int which )
{
+ if ( which == wxIMAGE_LIST_NORMAL )
+ {
+ if (m_ownsImageListNormal) delete m_imageListNormal;
+ m_imageListNormal = imageList;
+ m_ownsImageListNormal = FALSE;
+ }
+ else if ( which == wxIMAGE_LIST_SMALL )
+ {
+ if (m_ownsImageListSmall) delete m_imageListSmall;
+ m_imageListSmall = imageList;
+ m_ownsImageListSmall = FALSE;
+ }
+ else if ( which == wxIMAGE_LIST_STATE )
+ {
+ if (m_ownsImageListState) delete m_imageListState;
+ m_imageListState = imageList;
+ m_ownsImageListState = FALSE;
+ }
+
m_mainWin->SetImageList( imageList, which );
}
+void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
+{
+ SetImageList(imageList, which);
+ if ( which == wxIMAGE_LIST_NORMAL )
+ m_ownsImageListNormal = TRUE;
+ else if ( which == wxIMAGE_LIST_SMALL )
+ m_ownsImageListSmall = TRUE;
+ else if ( which == wxIMAGE_LIST_STATE )
+ m_ownsImageListState = TRUE;
+}
+
bool wxListCtrl::Arrange( int WXUNUSED(flag) )
{
return 0;