#include "wx/generic/imaglist.h"
#ifndef wxUSE_GENERIC_LIST_EXTENSIONS
-#define wxUSE_GENERIC_LIST_EXTENSIONS 0
+#define wxUSE_GENERIC_LIST_EXTENSIONS 1
#endif
// ============================================================================
~wxListHeaderWindow();
wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
- long style = 0, const wxString &name = "columntitles" );
+ long style = 0, const wxString &name = "wxlistctrlcolumntitles" );
void DoDrawRect( wxDC *dc, int x, int y, int w, int h );
void OnPaint( wxPaintEvent &event );
void DrawCurrent();
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
int style = 0,
const wxValidator& validator = wxDefaultValidator,
- const wxString &name = "wxListTextCtrlText" );
+ const wxString &name = "listctrltextctrl" );
void OnChar( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
wxListMainWindow();
wxListMainWindow( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
- long style = 0, const wxString &name = "listctrl" );
+ long style = 0, const wxString &name = "listctrlmainwindow" );
~wxListMainWindow();
void RefreshLine( wxListLineData *line );
void OnPaint( wxPaintEvent &event );
case wxLC_ICON:
{
m_bound_all.width = m_spacing;
- m_bound_all.height = m_spacing+13;
wxNode *node = m_items.First();
if (node)
{
wxListItemData *item = (wxListItemData*)node->Data();
wxString s = item->GetText();
+ if (s.IsEmpty()) s = wxT("H");
wxCoord lw,lh;
dc->GetTextExtent( s, &lw, &lh );
+ if (lh < 15) lh = 15;
+ lw += 4;
+ lh += 3;
+
+ m_bound_all.height = m_spacing+lh;
if (lw > m_spacing) m_bound_all.width = lw;
+ m_bound_label.width = lw;
+ m_bound_label.height = lh;
+
+ if (item->HasImage())
+ {
+ int w = 0;
+ int h = 0;
+ m_owner->GetImageSize( item->GetImage(), w, h );
+ m_bound_icon.width = w + 8;
+ m_bound_icon.height = h + 8;
+ }
+
+ if (!item->HasText())
+ {
+ m_bound_hilight.width = m_bound_icon.width;
+ m_bound_hilight.height = m_bound_icon.height;
+ }
+ else
+ {
+ m_bound_hilight.width = m_bound_label.width;
+ m_bound_hilight.height = m_bound_label.height;
+ }
}
break;
}
if (node)
{
wxListItemData *item = (wxListItemData*)node->Data();
+
wxString s = item->GetText();
+ if (s.IsEmpty()) s = wxT("H");
wxCoord lw,lh;
dc->GetTextExtent( s, &lw, &lh );
+ if (lh < 15) lh = 15;
+ lw += 4;
+ lh += 3;
+ m_bound_label.width = lw;
+ m_bound_label.height = lh;
+
m_bound_all.width = lw;
m_bound_all.height = lh;
+
if (item->HasImage())
{
-#ifdef __WIN16__
int w = 0;
int h = 0;
-#else
- wxCoord w = 0;
- wxCoord h = 0;
-#endif
m_owner->GetImageSize( item->GetImage(), w, h );
+ m_bound_icon.width = w;
+ m_bound_icon.height = h;
+
m_bound_all.width += 4 + w;
if (h > m_bound_all.height) m_bound_all.height = h;
}
+
+ m_bound_hilight.width = m_bound_all.width;
+ m_bound_hilight.height = m_bound_all.height;
}
break;
}
while (node)
{
wxListItemData *item = (wxListItemData*)node->Data();
- wxString s;
- item->GetText( s );
- if (s.IsNull()) s = "H";
+ wxString s = item->GetText();
+ if (s.IsEmpty()) s = wxT("H");
wxCoord lw,lh;
dc->GetTextExtent( s, &lw, &lh );
if (lh < 15) lh = 15;
+ lw += 4;
+ lh += 3;
+
item->SetSize( item->GetWidth(), lh );
m_bound_all.width += lw;
m_bound_all.height = lh;
{
case wxLC_ICON:
{
- AssignRect( m_bound_icon, 0, 0, 0, 0 );
- AssignRect( m_bound_label, 0, 0, 0, 0 );
- AssignRect( m_bound_hilight, m_bound_all );
wxNode *node = m_items.First();
if (node)
{
wxListItemData *item = (wxListItemData*)node->Data();
if (item->HasImage())
{
- wxListItemData *item = (wxListItemData*)node->Data();
- int w = 0;
- int h = 0;
- m_owner->GetImageSize( item->GetImage(), w, h );
- m_bound_icon.x = m_bound_all.x + (m_spacing/2) - (w/2);
- m_bound_icon.y = m_bound_all.y + m_spacing - h - 5;
- m_bound_icon.width = w;
- m_bound_icon.height = h;
- if (!item->HasText())
- {
- AssignRect( m_bound_hilight, m_bound_icon );
- m_bound_hilight.x -= 5;
- m_bound_hilight.y -= 5;
- m_bound_hilight.width += 9;
- m_bound_hilight.height += 9;
- }
+ m_bound_icon.x = m_bound_all.x + 4 + (m_spacing/2) - (m_bound_icon.width/2);
+ m_bound_icon.y = m_bound_all.y + 4;
}
if (item->HasText())
{
- wxString s;
- item->GetText( s );
- wxCoord lw,lh;
- dc->GetTextExtent( s, &lw, &lh );
if (m_bound_all.width > m_spacing)
- m_bound_label.x = m_bound_all.x;
+ m_bound_label.x = m_bound_all.x + 2;
else
- m_bound_label.x = m_bound_all.x + (m_spacing/2) - lw/2;
- m_bound_label.y = m_bound_all.y + m_bound_all.height - lh;
- m_bound_label.width = lw;
- m_bound_label.height = lh;
- AssignRect( m_bound_hilight, m_bound_label );
- m_bound_hilight.x -= 2;
- m_bound_hilight.y -= 2;
- m_bound_hilight.width += 4;
- m_bound_hilight.height += 4;
+ m_bound_label.x = m_bound_all.x + 2 + (m_spacing/2) - (m_bound_label.width/2);
+ m_bound_label.y = m_bound_all.y + m_bound_all.height + 2 - m_bound_label.height;
+ m_bound_hilight.x = m_bound_label.x - 2;
+ m_bound_hilight.y = m_bound_label.y - 2;
+ }
+ else
+ {
+ m_bound_hilight.x = m_bound_icon.x - 4;
+ m_bound_hilight.y = m_bound_icon.y - 4;
}
}
break;
}
case wxLC_LIST:
{
- AssignRect( m_bound_label, m_bound_all );
- m_bound_all.x -= 2;
- m_bound_all.y -= 2;
- m_bound_all.width += 4;
- m_bound_all.height += 3;
- AssignRect( m_bound_hilight, m_bound_all );
- AssignRect( m_bound_icon, 0, 0, 0, 0 );
+ m_bound_hilight.x = m_bound_all.x;
+ m_bound_hilight.y = m_bound_all.y;
+ m_bound_label.y = m_bound_all.y + 2;
wxNode *node = m_items.First();
if (node)
{
{
m_bound_icon.x = m_bound_all.x + 2;
m_bound_icon.y = m_bound_all.y + 2;
- int w;
- int h;
- m_owner->GetImageSize( item->GetImage(), w, h );
- m_bound_icon.width = w;
- m_bound_icon.height = h;
- m_bound_label.x += 4 + w;
- m_bound_label.width -= 4 + w;
+ m_bound_label.x = m_bound_all.x + 6 + m_bound_icon.width;
+ }
+ else
+ {
+ m_bound_label.x = m_bound_all.x + 2;
}
}
break;
}
case wxLC_REPORT:
{
- wxCoord lw,lh;
- dc->GetTextExtent( "H", &lw, &lh );
- if (lh < 15) lh = 15;
m_bound_all.x = 0;
- m_bound_all.y -= 0;
- m_bound_all.height = lh+3;
m_bound_all.width = window_width;
AssignRect( m_bound_hilight, m_bound_all );
- AssignRect( m_bound_label, m_bound_all );
- AssignRect( m_bound_icon, 0, 0, 0, 0 );
+ m_bound_label.x = m_bound_all.x + 2;
+ m_bound_label.y = m_bound_all.y + 2;
wxNode *node = m_items.First();
if (node)
{
wxListItemData *item = (wxListItemData*)node->Data();
- wxString s;
- item->GetText( s );
- if (s.IsEmpty()) s = wxT("H");
- wxCoord lw,lh;
- dc->GetTextExtent( s, &lw, &lh );
- if (lh < 15) lh = 15;
- m_bound_label.width = lw;
- m_bound_label.height = lh;
if (item->HasImage())
{
m_bound_icon.x = m_bound_all.x + 2;
m_bound_icon.y = m_bound_all.y + 2;
- int w;
- int h;
- m_owner->GetImageSize( item->GetImage(), w, h );
- m_bound_icon.width = w;
- m_bound_icon.height = h;
- m_bound_label.x += 4 + w;
+ m_bound_label.x += 4 + m_bound_icon.width;
}
}
break;
void wxListLineData::DoDraw( wxDC *dc, bool hilight, bool paintBG )
{
- wxCoord dev_x = 0;
- wxCoord dev_y = 0;
+ int dev_x = 0;
+ int dev_y = 0;
m_owner->CalcScrolledPosition( m_bound_all.x, m_bound_all.y, &dev_x, &dev_y );
wxCoord dev_w = m_bound_all.width;
wxCoord dev_h = m_bound_all.height;
if (event.KeyCode() == WXK_TAB)
{
wxNavigationKeyEvent nevent;
+ nevent.SetWindowChange( event.ControlDown() );
nevent.SetDirection( !event.ShiftDown() );
nevent.SetEventObject( GetParent()->GetParent() );
nevent.SetCurrentFocus( m_parent );
}
case WXK_SPACE:
{
- m_current->ReverseHilight();
- RefreshLine( m_current );
+ if (m_mode & wxLC_SINGLE_SEL)
+ {
+ wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, GetParent()->GetId() );
+ le.SetEventObject( GetParent() );
+ le.m_itemIndex = GetIndexOfLine( m_current );
+ m_current->GetItem( 0, le.m_item );
+ GetParent()->GetEventHandler()->ProcessEvent( le );
+ }
+ else
+ {
+ m_current->ReverseHilight();
+ RefreshLine( m_current );
+ }
break;
}
case WXK_INSERT:
We don't even allow the wxScrolledWindow::AdjustScrollbars() call
*/
+ m_dirty = TRUE;
}
void wxListMainWindow::DrawImage( int index, wxDC *dc, int x, int y )
line->CalculateSize( &dc, iconSpacing );
int dummy = 0;
line->GetSize( dummy, lineSpacing );
- lineSpacing += 4;
+ lineSpacing += 1;
int clientWidth = 0;
int clientHeight = 0;
for (int tries = 0; tries < 2; tries++)
{
entireWidth = 0;
- int x = 5; // painting is done at x-2
- int y = 5; // painting is done at y-2
+ int x = 2;
+ int y = 2;
int maxWidth = 0;
m_visibleLines = 0;
int m_currentVisibleLines = 0;
if (y+lineSpacing-6 >= clientHeight) // -6 for earlier "line breaking"
{
m_currentVisibleLines = 0;
- y = 5;
+ y = 2;
x += maxWidth+6;
entireWidth += maxWidth+6;
maxWidth = 0;