long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
const wxString &name = "listctrl" );
void OnSize( wxSizeEvent &event );
- bool GetColumn( int col, wxListItem& item );
+ bool GetColumn( int col, wxListItem& item ) const;
bool SetColumn( int col, wxListItem& item );
- int GetColumnWidth( int col );
+ int GetColumnWidth( int col ) const;
bool SetColumnWidth( int col, int width);
- int GetCountPerPage(void); // not the same in wxGLC as in Windows, I think
+ int GetCountPerPage(void) const; // not the same in wxGLC as in Windows, I think
// wxText& GetEditControl(void) const; // not supported in wxGLC
- bool GetItem( wxListItem& info );
+ bool GetItem( wxListItem& info ) const;
bool SetItem( wxListItem& info ) ;
long SetItem( long index, int col, const wxString& label, int imageId = -1 );
- int GetItemState( long item, long stateMask );
+ int GetItemState( long item, long stateMask ) const;
bool SetItemState( long item, long state, long stateMask);
bool SetItemImage( long item, int image, int selImage);
- wxString GetItemText( long item );
+ wxString GetItemText( long item ) const;
void SetItemText( long item, const wxString& str );
- long GetItemData( long item );
+ long GetItemData( long item ) const;
bool SetItemData( long item, long data );
- bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS );
- bool GetItemPosition( long item, wxPoint& pos );
+ bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ) const;
+ bool GetItemPosition( long item, wxPoint& pos ) const;
bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
- int GetItemCount(void);
+ int GetItemCount(void) const;
void SetItemSpacing( int spacing, bool isSmall = FALSE );
- int GetItemSpacing( bool isSmall );
- int GetSelectedItemCount(void);
+ int GetItemSpacing( bool isSmall ) const;
+ int GetSelectedItemCount(void) const;
// wxColour GetTextColour(void) const; // wxGLC has colours for every Item (see wxListItem)
// void SetTextColour(const wxColour& col);
- long GetTopItem(void);
+ long GetTopItem(void) const;
void SetSingleStyle( long style, bool add = TRUE ) ;
void SetWindowStyleFlag(long style);
void RecreateWindow(void) {};
long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const;
- wxImageList *GetImageList(int which);
+ wxImageList *GetImageList(int which) const;
void SetImageList(wxImageList *imageList, int which) ;
bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
bool DeleteItem( long item );
void wxListMainWindow::MoveToFocus( void )
{
if (!m_current) return;
-/*
+
int x = 0;
int y = 0;
int w = 0;
int y_s = m_yScroll*GetScrollPos( wxVERTICAL );
if ((y > y_s) && (y+h < y_s+h_p)) return;
if (y-y_s < 5) SetScrollPos( wxVERTICAL, (y-5)/m_yScroll );
- if (y+h+5 > y_s+h_p) SetScrollPos( wxVERTICAL, (y+h-h_p+h+5)/m_yScroll );
+ if (y+h+5 > y_s+h_p) SetScrollPos( wxVERTICAL, (y+h-h_p+h+15)/m_yScroll );
+ m_dirty = TRUE;
}
else
{
int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL );
if ((x > x_s) && (x+w < x_s+w_p)) return;
if (x-x_s < 5) SetScrollPos( wxHORIZONTAL, (x-5)/m_xScroll );
- if (x+w > x_s+w_p) SetScrollPos( wxHORIZONTAL, (x+w-w_p+5)/m_xScroll );
+ if (x+w-5 > x_s+w_p) SetScrollPos( wxHORIZONTAL, (x+w-w_p+15)/m_xScroll );
+ m_dirty = TRUE;
}
-*/
}
void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
void wxListMainWindow::CalculatePositions( void )
{
+ if (!m_lines.First()) return;
+
wxPaintDC dc( this );
dc.SetFont( *GetFont() );
int iconSpacing = 0;
if (m_mode & wxLC_ICON) iconSpacing = m_normal_spacing;
if (m_mode & wxLC_SMALL_ICON) iconSpacing = m_small_spacing;
- wxNode *node = m_lines.First();
- while (node)
- {
- wxListLineData *line = (wxListLineData*)node->Data();
- line->CalculateSize( &dc, iconSpacing );
- node = node->Next();
- }
-
+
+ // we take the first line (which also can be an icon or
+ // an a text item in wxLC_ICON and wxLC_LIST modes) to
+ // measure the size of the line
+
int lineWidth = 0;
int lineHeight = 0;
int lineSpacing = 0;
- node = m_lines.First();
- if (node)
- {
- wxListLineData *line = (wxListLineData*)node->Data();
- int dummy = 0;
- line->GetSize( dummy, lineSpacing );
- lineSpacing += 4;
- }
- else
- {
- // just in case
- lineSpacing = 4 + (int)dc.GetCharHeight();
- }
+ wxListLineData *line = (wxListLineData*)m_lines.First()->Data();
+ line->CalculateSize( &dc, iconSpacing );
+ int dummy = 0;
+ line->GetSize( dummy, lineSpacing );
+ lineSpacing += 4;
int clientWidth = 0;
int clientHeight = 0;
if (m_mode & wxLC_REPORT)
{
int x = 4;
- int y = 3;
+ int y = 1;
int entireHeight = m_lines.Number() * lineSpacing + 10;
- SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+10) / m_yScroll, 0, 0, TRUE );
+ int scroll_pos = GetScrollPos( wxVERTICAL );
+ SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+10) / m_yScroll, 0, scroll_pos, TRUE );
GetClientSize( &clientWidth, &clientHeight );
- node = m_lines.First();
+ wxNode* node = m_lines.First();
while (node)
{
wxListLineData *line = (wxListLineData*)node->Data();
+ line->CalculateSize( &dc, iconSpacing );
line->SetPosition( &dc, x, y, clientWidth );
int col_x = 2;
for (int i = 0; i < GetColumnCount(); i++)
}
else
{
- // At first, we try without any scrollbar
+ // at first we try without any scrollbar. if the items don't
+ // fit into the window, we recalculate after subtracting an
+ // approximated 15 pt for the horizontal scrollbar
+
GetSize( &clientWidth, &clientHeight );
int entireWidth = 0;
{
entireWidth = 0;
int x = 5;
- int y = 6;
+ int y = 3;
int maxWidth = 0;
- node = m_lines.First();
+ wxNode *node = m_lines.First();
while (node)
{
wxListLineData *line = (wxListLineData*)node->Data();
+ line->CalculateSize( &dc, iconSpacing );
line->SetPosition( &dc, x, y, clientWidth );
line->GetSize( lineWidth, lineHeight );
if (lineWidth > maxWidth) maxWidth = lineWidth;
y += lineSpacing;
- if (y+lineHeight > clientHeight-4)
+ if (y+lineSpacing-8 > clientHeight-6)
{
- y = 6;
+ y = 3;
x += maxWidth+13;
entireWidth += maxWidth+13;
maxWidth = 0;
}
node = node->Next();
- if (!node) entireWidth += maxWidth;
- if ((tries == 0) && (entireWidth > clientWidth))
- {
- clientHeight -= 14; // scrollbar height
- break;
- }
- if (!node) tries = 1;
+ if (!node) entireWidth += maxWidth;
+ if ((tries == 0) && (entireWidth > clientWidth))
+ {
+ clientHeight -= 15; // scrollbar height
+ break;
+ }
+ if (!node) tries = 1; // everything fits, no second try required
}
}
- SetScrollbars( m_xScroll, m_yScroll, (entireWidth+15) / m_xScroll, 0, 0, 0, TRUE );
+ int scroll_pos = GetScrollPos( wxHORIZONTAL );
+ SetScrollbars( m_xScroll, m_yScroll, (entireWidth+15) / m_xScroll, 0, scroll_pos, 0, TRUE );
}
m_visibleLines = (clientHeight-4) / (lineSpacing);
}
wxWindow::SetWindowStyleFlag( flag );
}
-bool wxListCtrl::GetColumn(int col, wxListItem &item)
+bool wxListCtrl::GetColumn(int col, wxListItem &item) const
{
m_mainWin->GetColumn( col, item );
return TRUE;
return TRUE;
}
-int wxListCtrl::GetColumnWidth( int col )
+int wxListCtrl::GetColumnWidth( int col ) const
{
return m_mainWin->GetColumnWidth( col );
}
return TRUE;
}
-int wxListCtrl::GetCountPerPage(void)
+int wxListCtrl::GetCountPerPage(void) const
{
return m_mainWin->GetCountPerPage(); // different from Windows ?
}
}
*/
-bool wxListCtrl::GetItem( wxListItem &info )
+bool wxListCtrl::GetItem( wxListItem &info ) const
{
m_mainWin->GetItem( info );
return TRUE;
return TRUE;
}
-int wxListCtrl::GetItemState( long item, long stateMask )
+int wxListCtrl::GetItemState( long item, long stateMask ) const
{
return m_mainWin->GetItemState( item, stateMask );
}
return TRUE;
}
-wxString wxListCtrl::GetItemText( long item )
+wxString wxListCtrl::GetItemText( long item ) const
{
wxListItem info;
info.m_itemId = item;
m_mainWin->SetItem( info );
}
-long wxListCtrl::GetItemData( long item )
+long wxListCtrl::GetItemData( long item ) const
{
wxListItem info;
info.m_itemId = item;
return TRUE;
}
-bool wxListCtrl::GetItemRect( long item, wxRectangle &rect, int WXUNUSED(code) )
+bool wxListCtrl::GetItemRect( long item, wxRectangle &rect, int WXUNUSED(code) ) const
{
m_mainWin->GetItemRect( item, rect );
return TRUE;
}
-bool wxListCtrl::GetItemPosition( long item, wxPoint& pos )
+bool wxListCtrl::GetItemPosition( long item, wxPoint& pos ) const
{
m_mainWin->GetItemPosition( item, pos );
return TRUE;
return 0;
}
-int wxListCtrl::GetItemCount(void)
+int wxListCtrl::GetItemCount(void) const
{
return m_mainWin->GetItemCount();
}
m_mainWin->SetItemSpacing( spacing, isSmall );
}
-int wxListCtrl::GetItemSpacing( bool isSmall )
+int wxListCtrl::GetItemSpacing( bool isSmall ) const
{
return m_mainWin->GetItemSpacing( isSmall );
}
-int wxListCtrl::GetSelectedItemCount(void)
+int wxListCtrl::GetSelectedItemCount(void) const
{
return m_mainWin->GetSelectedItemCount();
}
}
*/
-long wxListCtrl::GetTopItem(void)
+long wxListCtrl::GetTopItem(void) const
{
return 0;
}
return m_mainWin->GetNextItem( item, geom, state );
}
-wxImageList *wxListCtrl::GetImageList(int which)
+wxImageList *wxListCtrl::GetImageList(int which) const
{
if (which == wxIMAGE_LIST_NORMAL)
{