#include "wx/listctrl.h"
-#if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__)) && !defined(__WXMAC__)
+#if ((!defined(__WXMSW__) && !(defined(__WXMAC__) && wxOSX_USE_CARBON)) || defined(__WXUNIVERSAL__))
// if we have a native version, its implementation file does all this
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
#include "wx/dcscreen.h"
#include "wx/math.h"
#include "wx/settings.h"
+ #include "wx/sizer.h"
#endif
#include "wx/imaglist.h"
#ifdef __WXMAC__
#include "wx/osx/private.h"
+ // for themeing support
+ #include <Carbon/Carbon.h>
#endif
#else
static const int EXTRA_WIDTH = 4;
#endif
+
+#ifdef __WXGTK__
+static const int EXTRA_HEIGHT = 6;
+#else
static const int EXTRA_HEIGHT = 4;
+#endif
// margin between the window and the items
static const int EXTRA_BORDER_X = 2;
// needs refresh
bool m_dirty;
+ // Update main window's column later
+ bool m_sendSetColumnWidth;
+ int m_colToSend;
+ int m_widthToSend;
+
+ virtual void OnInternalIdle();
+
private:
// common part of all ctors
void Init();
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxListHeaderDataList)
-class wxListMainWindow : public wxScrolledCanvas
+class wxListMainWindow : public wxWindow
{
public:
wxListMainWindow();
void OnPaint( wxPaintEvent &event );
+ void OnChildFocus(wxChildFocusEvent& event);
+
void DrawImage( int index, wxDC *dc, int x, int y );
void GetImageSize( int index, int &width, int &height ) const;
int GetTextLength( const wxString &s ) const;
// override base class virtual to reset m_lineHeight when the font changes
virtual bool SetFont(const wxFont& font)
{
- if ( !wxScrolledCanvas::SetFont(font) )
+ if ( !wxWindow::SetFont(font) )
return false;
m_lineHeight = 0;
#ifdef __WXMAC__
{
if (m_owner->HasFocus()
-#if !defined(__WXUNIVERSAL__)
+#if !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON
&& IsControlActive( (ControlRef)m_owner->GetHandle() )
#endif
)
{
int flags = wxCONTROL_SELECTED;
if (m_owner->HasFocus()
-#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
+#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON
&& IsControlActive( (ControlRef)m_owner->GetHandle() )
#endif
)
void wxListHeaderWindow::Init()
{
- m_currentCursor = (wxCursor *) NULL;
+ m_currentCursor = NULL;
m_isDragging = false;
m_dirty = false;
+ m_sendSetColumnWidth = false;
}
wxListHeaderWindow::wxListHeaderWindow()
{
Init();
- m_owner = (wxListMainWindow *) NULL;
- m_resizeCursor = (wxCursor *) NULL;
+ m_owner = NULL;
+ m_resizeCursor = NULL;
}
wxListHeaderWindow::wxListHeaderWindow( wxWindow *win,
// scrollbar: this allows us to always use logical coords
void wxListHeaderWindow::AdjustDC(wxDC& dc)
{
+ wxGenericListCtrl *parent = m_owner->GetListCtrl();
+
int xpix;
- m_owner->GetScrollPixelsPerUnit( &xpix, NULL );
+ parent->GetScrollPixelsPerUnit( &xpix, NULL );
int view_start;
- m_owner->GetViewStart( &view_start, NULL );
+ parent->GetViewStart( &view_start, NULL );
int org_x = 0;
void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
+ wxGenericListCtrl *parent = m_owner->GetListCtrl();
+
wxPaintDC dc( this );
- PrepareDC( dc );
AdjustDC( dc );
dc.SetFont( GetFont() );
// width and height of the entire header window
int w, h;
GetClientSize( &w, &h );
- m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
+ parent->CalcUnscrolledPosition(w, 0, &w, NULL);
dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
dc.SetTextForeground(GetForegroundColour());
flags |= wxCONTROL_SELECTED;
#endif
+ if (i == 0)
+ flags |= wxCONTROL_SPECIAL; // mark as first column
+
wxRendererNative::Get().DrawHeaderButton
(
this,
x += wCol;
}
+
+ // Fill in what's missing to the right of the columns, otherwise we will
+ // leave an unpainted area when columns are removed (and it looks better)
+ if ( x < w )
+ {
+ wxRendererNative::Get().DrawHeaderButton
+ (
+ this,
+ dc,
+ wxRect(x, HEADER_OFFSET_Y, w - x, h),
+ wxCONTROL_DIRTY // mark as last column
+ );
+ }
+}
+
+void wxListHeaderWindow::OnInternalIdle()
+{
+ wxWindow::OnInternalIdle();
+
+ if (m_sendSetColumnWidth)
+ {
+ m_owner->SetColumnWidth( m_colToSend, m_widthToSend );
+ m_sendSetColumnWidth = false;
+ }
}
void wxListHeaderWindow::DrawCurrent()
{
#if 1
- m_owner->SetColumnWidth( m_column, m_currentX - m_minX );
+ // m_owner->SetColumnWidth( m_column, m_currentX - m_minX );
+ m_sendSetColumnWidth = true;
+ m_colToSend = m_column;
+ m_widthToSend = m_currentX - m_minX;
#else
int x1 = m_currentX;
int y1 = 0;
void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
{
+ wxGenericListCtrl *parent = m_owner->GetListCtrl();
+
// we want to work with logical coords
int x;
- m_owner->CalcUnscrolledPosition(event.GetX(), 0, &x, NULL);
+ parent->CalcUnscrolledPosition(event.GetX(), 0, &x, NULL);
int y = event.GetY();
if (m_isDragging)
// there
int w = 0;
GetClientSize( &w, NULL );
- m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
+ parent->CalcUnscrolledPosition(w, 0, &w, NULL);
w -= 6;
// erase the line if it was drawn
m_text = text;
m_aboutToFinish = false;
+ wxGenericListCtrl *parent = m_owner->GetListCtrl();
+
wxRect rectLabel = owner->GetLineLabelRect(itemEdit);
- m_owner->CalcScrolledPosition(rectLabel.x, rectLabel.y,
+ parent->CalcScrolledPosition(rectLabel.x, rectLabel.y,
&rectLabel.x, &rectLabel.y);
m_text->Create(owner, wxID_ANY, m_startValue,
EVT_SET_FOCUS (wxListMainWindow::OnSetFocus)
EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus)
EVT_SCROLLWIN (wxListMainWindow::OnScroll)
+ EVT_CHILD_FOCUS (wxListMainWindow::OnChildFocus)
END_EVENT_TABLE()
void wxListMainWindow::Init()
m_headerWidth =
m_lineHeight = 0;
- m_small_image_list = (wxImageList *) NULL;
- m_normal_image_list = (wxImageList *) NULL;
+ m_small_image_list = NULL;
+ m_normal_image_list = NULL;
m_small_spacing = 30;
m_normal_spacing = 40;
Init();
m_highlightBrush =
- m_highlightUnfocusedBrush = (wxBrush *) NULL;
+ m_highlightUnfocusedBrush = NULL;
}
wxListMainWindow::wxListMainWindow( wxWindow *parent,
const wxSize& size,
long style,
const wxString &name )
- : wxScrolledCanvas( parent, id, pos, size,
- style | wxHSCROLL | wxVSCROLL, name )
+ : wxWindow( parent, id, pos, size, style, name )
{
Init();
wxBRUSHSTYLE_SOLID
);
- SetScrollbars( 0, 0, 0, 0, 0, 0 );
-
wxVisualAttributes attr = wxGenericListCtrl::GetClassDefaultAttributes();
SetOwnForegroundColour( attr.colFg );
SetOwnBackgroundColour( attr.colBg );
wxRect rect = GetLineRect(line);
- CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ GetListCtrl()->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
RefreshRect( rect );
}
rect.width = GetClientSize().x;
rect.height = GetLineY(lineTo) - rect.y + GetLineHeight();
- CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ GetListCtrl()->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
RefreshRect( rect );
}
else // !report
wxRect rect;
rect.x = 0;
rect.y = GetLineY(lineFrom);
- CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ GetListCtrl()->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
wxSize size = GetClientSize();
rect.width = size.x;
}
if ( m_dirty )
- {
- // delay the repainting until we calculate all the items positions
- return;
- }
+ RecalculatePositions( false );
- PrepareDC( dc );
+ GetListCtrl()->PrepareDC( dc );
int dev_x, dev_y;
- CalcScrolledPosition( 0, 0, &dev_x, &dev_y );
+ GetListCtrl()->CalcScrolledPosition( 0, 0, &dev_x, &dev_y );
dc.SetFont( GetFont() );
}
}
+void wxListMainWindow::OnChildFocus(wxChildFocusEvent& WXUNUSED(event))
+{
+ // Do nothing here. This prevents the default handler in wxScrolledWindow
+ // from needlessly scrolling the window when the edit control is
+ // dismissed. See ticket #9563.
+}
+
void wxListMainWindow::SendNotify( size_t line,
wxEventType command,
const wxPoint& point )
int x = event.GetX();
int y = event.GetY();
- CalcUnscrolledPosition( x, y, &x, &y );
+ GetListCtrl()->CalcUnscrolledPosition( x, y, &x, &y );
// where did we hit it (if we did)?
long hitResult = 0;
ResetVisibleLinesRange();
if (rect.y < view_y)
- Scroll( -1, rect.y / hLine );
+ GetListCtrl()->Scroll( -1, rect.y / hLine );
if (rect.y + rect.height + 5 > view_y + client_h)
- Scroll( -1, (rect.y + rect.height - client_h + hLine) / hLine );
+ GetListCtrl()->Scroll( -1, (rect.y + rect.height - client_h + hLine) / hLine );
#ifdef __WXMAC__
// At least on Mac the visible lines value will get reset inside of
if (rect.y + rect.height - 5 > view_y + client_h)
sy = (rect.y + rect.height - client_h + hLine) / hLine;
- Scroll(sx, sy);
+ GetListCtrl()->Scroll(sx, sy);
}
}
int hLine = GetLineHeight();
- Scroll(-1, top + dy / hLine);
+ GetListCtrl()->Scroll(-1, top + dy / hLine);
#ifdef __WXMAC__
// see comment in MoveToItem() for why we do this
wxWindow *parent = GetParent();
// propagate the key event upwards
- wxKeyEvent ke( wxEVT_KEY_DOWN );
- ke.m_shiftDown = event.m_shiftDown;
- ke.m_controlDown = event.m_controlDown;
- ke.m_altDown = event.m_altDown;
- ke.m_metaDown = event.m_metaDown;
- ke.m_keyCode = event.m_keyCode;
- ke.m_x = event.m_x;
- ke.m_y = event.m_y;
+ wxKeyEvent ke(event);
ke.SetEventObject( parent );
- if (parent->GetEventHandler()->ProcessEvent( ke )) return;
+ if (parent->GetEventHandler()->ProcessEvent( ke ))
+ return;
event.Skip();
}
wxWindow *parent = GetParent();
// propagate the key event upwards
- wxKeyEvent ke( wxEVT_KEY_UP );
- ke.m_shiftDown = event.m_shiftDown;
- ke.m_controlDown = event.m_controlDown;
- ke.m_altDown = event.m_altDown;
- ke.m_metaDown = event.m_metaDown;
- ke.m_keyCode = event.m_keyCode;
- ke.m_x = event.m_x;
- ke.m_y = event.m_y;
- ke.SetEventObject( parent );
- if (parent->GetEventHandler()->ProcessEvent( ke )) return;
+ wxKeyEvent ke(event);
+ if (parent->GetEventHandler()->ProcessEvent( ke ))
+ return;
event.Skip();
}
parent->GetEventHandler()->ProcessEvent( le );
}
- // propagate the char event upwards
- wxKeyEvent ke( wxEVT_CHAR );
- ke.m_shiftDown = event.m_shiftDown;
- ke.m_controlDown = event.m_controlDown;
- ke.m_altDown = event.m_altDown;
- ke.m_metaDown = event.m_metaDown;
- ke.m_keyCode = event.m_keyCode;
- ke.m_x = event.m_x;
- ke.m_y = event.m_y;
- ke.SetEventObject( parent );
- if (parent->GetEventHandler()->ProcessEvent( ke )) return;
+ if ( (event.GetKeyCode() != WXK_UP) &&
+ (event.GetKeyCode() != WXK_DOWN) &&
+ (event.GetKeyCode() != WXK_RIGHT) &&
+ (event.GetKeyCode() != WXK_LEFT) &&
+ (event.GetKeyCode() != WXK_PAGEUP) &&
+ (event.GetKeyCode() != WXK_PAGEDOWN) &&
+ (event.GetKeyCode() != WXK_END) &&
+ (event.GetKeyCode() != WXK_HOME) )
+ {
+ // propagate the char event upwards
+ wxKeyEvent ke(event);
+ ke.SetEventObject( parent );
+ if (parent->GetEventHandler()->ProcessEvent( ke ))
+ return;
+ }
if ( HandleAsNavigationKey(event) )
return;
_T("SetColumnWidth() can only be called in report mode.") );
m_dirty = true;
+
wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
if ( headerWin )
headerWin->m_dirty = true;
{
for ( int i = 0; i < count; i++ )
{
- wxRect r;
- GetItemRect(i, r);
+ // we need logical, not physical, coordinates here, so use
+ // GetLineRect() instead of GetItemRect()
+ wxRect r = GetLineRect(i);
wxCoord x = r.GetRight(),
y = r.GetBottom();
bool
wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect) const
{
- wxCHECK_MSG( InReportView(), false,
+ wxCHECK_MSG( subItem == wxLIST_GETSUBITEMRECT_WHOLEITEM || InReportView(),
+ false,
_T("GetSubItemRect only meaningful in report view") );
wxCHECK_MSG( item >= 0 && (size_t)item < GetItemCount(), false,
_T("invalid item in GetSubItemRect") );
rect.width = GetColumnWidth(subItem);
}
- CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y);
+ GetListCtrl()->CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y);
return true;
}
ResetVisibleLinesRange();
- SetScrollbars( SCROLL_UNIT_X, lineHeight,
+ GetListCtrl()->SetScrollbars( SCROLL_UNIT_X, lineHeight,
GetHeaderWidth() / SCROLL_UNIT_X,
(entireHeight + lineHeight - 1) / lineHeight,
- GetScrollPos(wxHORIZONTAL),
- GetScrollPos(wxVERTICAL),
+ GetListCtrl()->GetScrollPos(wxHORIZONTAL),
+ GetListCtrl()->GetScrollPos(wxVERTICAL),
true );
}
else // !report
}
}
- SetScrollbars
+ GetListCtrl()->SetScrollbars
(
SCROLL_UNIT_X,
lineHeight,
(x + SCROLL_UNIT_X) / SCROLL_UNIT_X,
(y + lineHeight) / lineHeight,
- GetScrollPos( wxHORIZONTAL ),
- GetScrollPos( wxVERTICAL ),
+ GetListCtrl()->GetScrollPos( wxHORIZONTAL ),
+ GetListCtrl()->GetScrollPos( wxVERTICAL ),
true
);
}
}
}
- SetScrollbars
+ GetListCtrl()->SetScrollbars
(
SCROLL_UNIT_X,
lineHeight,
(entireWidth + SCROLL_UNIT_X) / SCROLL_UNIT_X,
0,
- GetScrollPos( wxHORIZONTAL ),
+ GetListCtrl()->GetScrollPos( wxHORIZONTAL ),
0,
true
);
long wxListMainWindow::HitTest( int x, int y, int &flags ) const
{
- CalcUnscrolledPosition( x, y, &x, &y );
+ GetListCtrl()->CalcUnscrolledPosition( x, y, &x, &y );
size_t count = GetItemCount();
// sorting
// ----------------------------------------------------------------------------
-wxListCtrlCompare list_ctrl_compare_func_2;
-long list_ctrl_compare_data;
+static wxListCtrlCompare list_ctrl_compare_func_2;
+static long list_ctrl_compare_data;
int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData **arg2 )
{
void wxListMainWindow::OnScroll(wxScrollWinEvent& event)
{
- // FIXME
-#if ( defined(__WXGTK__) || defined(__WXMAC__) ) && !defined(__WXUNIVERSAL__)
- wxScrolledCanvas::OnScroll(event);
-#else
- HandleOnScroll( event );
-#endif
-
// update our idea of which lines are shown when we redraw the window the
// next time
ResetVisibleLinesRange();
BEGIN_EVENT_TABLE(wxGenericListCtrl,wxControl)
EVT_SIZE(wxGenericListCtrl::OnSize)
+ EVT_SCROLLWIN(wxGenericListCtrl::OnScroll)
END_EVENT_TABLE()
-wxGenericListCtrl::wxGenericListCtrl()
+void wxGenericListCtrl::Init()
{
- m_imageListNormal = (wxImageList *) NULL;
- m_imageListSmall = (wxImageList *) NULL;
- m_imageListState = (wxImageList *) NULL;
+ m_imageListNormal = NULL;
+ m_imageListSmall = NULL;
+ m_imageListState = NULL;
m_ownsImageListNormal =
m_ownsImageListSmall =
m_ownsImageListState = false;
- m_mainWin = (wxListMainWindow*) NULL;
- m_headerWin = (wxListHeaderWindow*) NULL;
- m_headerHeight = 0;
+ m_mainWin = NULL;
+ m_headerWin = NULL;
+ m_headerHeight = wxRendererNative::Get().GetHeaderButtonHeight(this);
}
wxGenericListCtrl::~wxGenericListCtrl()
delete m_imageListState;
}
-void wxGenericListCtrl::CalculateAndSetHeaderHeight()
+void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded()
{
- if ( m_headerWin )
- {
-#ifdef __WXMAC__
- SInt32 h;
- GetThemeMetric( kThemeMetricListHeaderHeight, &h );
-#else
- // we use 'g' to get the descent, too
- int w, h, d;
- m_headerWin->GetTextExtent(wxT("Hg"), &w, &h, &d);
- h += d + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT;
-#endif
-
- // only update if changed
- if ( h != m_headerHeight )
- {
- m_headerHeight = h;
+ bool needs_header = HasHeader();
+ bool has_header = (m_headerWin != NULL);
- if ( HasHeader() )
- ResizeReportView(true);
- else //why is this needed if it doesn't have a header?
- m_headerWin->SetSize(m_headerWin->GetSize().x, m_headerHeight);
- }
- }
-}
+ if (needs_header == has_header)
+ return;
-void wxGenericListCtrl::CreateHeaderWindow()
-{
- m_headerWin = new wxListHeaderWindow
+ if (needs_header)
+ {
+ m_headerWin = new wxListHeaderWindow
(
this, wxID_ANY, m_mainWin,
wxPoint(0,0),
wxSize(GetClientSize().x, m_headerHeight),
wxTAB_TRAVERSAL
);
- CalculateAndSetHeaderHeight();
+
+#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
+ wxFont font;
+#if wxOSX_USE_ATSU_TEXT
+ font.MacCreateFromThemeFont( kThemeSmallSystemFont );
+#else
+ font.MacCreateFromUIFont( kCTFontSystemFontType );
+#endif
+ m_headerWin->SetFont( font );
+#endif
+
+ GetSizer()->Prepend( m_headerWin, 0, wxGROW );
+ }
+ else
+ {
+ GetSizer()->Detach( m_headerWin );
+
+ delete m_headerWin;
+
+ m_headerWin = NULL;
+ }
}
bool wxGenericListCtrl::Create(wxWindow *parent,
const wxValidator &validator,
const wxString &name)
{
- m_imageListNormal =
- m_imageListSmall =
- m_imageListState = (wxImageList *) NULL;
- m_ownsImageListNormal =
- m_ownsImageListSmall =
- m_ownsImageListState = false;
-
- m_mainWin = (wxListMainWindow*) NULL;
- m_headerWin = (wxListHeaderWindow*) NULL;
+ Init();
- m_headerHeight = 0;
+ // just like in other ports, an assert will fail if the user doesn't give any type style:
+ wxASSERT_MSG( (style & wxLC_MASK_TYPE),
+ _T("wxListCtrl style should have exactly one mode bit set") );
- if ( !(style & wxLC_MASK_TYPE) )
- {
- style = style | wxLC_LIST;
- }
-
- if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
+ if ( !wxControl::Create( parent, id, pos, size, style|wxVSCROLL|wxHSCROLL, validator, name ) )
return false;
- // this window itself shouldn't get the focus, only m_mainWin should
- SetCanFocus(false);
-
- // don't create the inner window with the border
+#ifdef __WXGTK__
style &= ~wxBORDER_MASK;
+ style |= wxBORDER_THEME;
+#endif
m_mainWin = new wxListMainWindow( this, wxID_ANY, wxPoint(0, 0), size, style );
-#ifdef __WXMAC__
- // Human Interface Guidelines ask us for a special font in this case
- if ( GetWindowVariant() == wxWINDOW_VARIANT_NORMAL )
+ SetTargetWindow( m_mainWin );
+
+ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+ sizer->Add( m_mainWin, 1, wxGROW );
+ SetSizer( sizer );
+
+ CreateOrDestroyHeaderWindowAsNeeded();
+
+ SetInitialSize(size);
+
+ return true;
+}
+
+wxBorder wxGenericListCtrl::GetDefaultBorder() const
+{
+ return wxBORDER_THEME;
+}
+
+#ifdef __WXMSW__
+WXLRESULT wxGenericListCtrl::MSWWindowProc(WXUINT nMsg,
+ WXWPARAM wParam,
+ WXLPARAM lParam)
+{
+ WXLRESULT rc = wxControl::MSWWindowProc(nMsg, wParam, lParam);
+
+#ifndef __WXWINCE__
+ // we need to process arrows ourselves for scrolling
+ if ( nMsg == WM_GETDLGCODE )
{
- wxFont font;
- font.MacCreateFromThemeFont( kThemeViewsFont );
- SetFont( font );
+ rc |= DLGC_WANTARROWS;
}
#endif
- if ( InReportView() )
- {
- CreateHeaderWindow();
-
-#ifdef __WXMAC__
- if (m_headerWin)
- {
- wxFont font;
- font.MacCreateFromThemeFont( kThemeSmallSystemFont );
- m_headerWin->SetFont( font );
- CalculateAndSetHeaderHeight();
- }
+ return rc;
+}
#endif
- if ( HasFlag(wxLC_NO_HEADER) )
- // VZ: why do we create it at all then?
- m_headerWin->Show( false );
- }
+wxSize wxGenericListCtrl::GetSizeAvailableForScrollTarget(const wxSize& size)
+{
+ wxSize newsize = size;
+ if (m_headerWin)
+ newsize.y -= m_headerWin->GetSize().y;
- SetInitialSize(size);
+ return newsize;
+}
- return true;
+void wxGenericListCtrl::OnScroll(wxScrollWinEvent& event)
+{
+ // update our idea of which lines are shown when we redraw
+ // the window the next time
+ m_mainWin->ResetVisibleLinesRange();
+
+ HandleOnScroll( event );
+
+ if ( event.GetOrientation() == wxHORIZONTAL && HasHeader() )
+ {
+ m_headerWin->Refresh();
+ m_headerWin->Update();
+ }
}
void wxGenericListCtrl::SetSingleStyle( long style, bool add )
{
if (m_mainWin)
{
- m_mainWin->DeleteEverything();
+ // m_mainWin->DeleteEverything(); wxMSW doesn't do that
- // has the header visibility changed?
- bool hasHeader = HasHeader();
- bool willHaveHeader = (flag & wxLC_REPORT) && !(flag & wxLC_NO_HEADER);
+ CreateOrDestroyHeaderWindowAsNeeded();
- if ( hasHeader != willHaveHeader )
- {
- // toggle it
- if ( hasHeader )
- {
- if ( m_headerWin )
- {
- // don't delete, just hide, as we can reuse it later
- m_headerWin->Show(false);
- }
- //else: nothing to do
- }
- else // must show header
- {
- if (!m_headerWin)
- {
- CreateHeaderWindow();
- }
- else // already have it, just show
- {
- m_headerWin->Show( true );
- }
- }
-
- ResizeReportView(willHaveHeader);
- }
+ GetSizer()->Layout();
}
wxWindow::SetWindowStyleFlag( flag );
return info.GetBackgroundColour();
}
-int wxGenericListCtrl::GetScrollPos( int orient ) const
-{
- return m_mainWin->GetScrollPos( orient );
-}
-
-void wxGenericListCtrl::SetScrollPos( int orient, int pos, bool refresh )
-{
- m_mainWin->SetScrollPos( orient, pos, refresh );
-}
-
void wxGenericListCtrl::SetItemFont( long item, const wxFont &f )
{
wxListItem info;
else if (which == wxIMAGE_LIST_STATE)
return m_imageListState;
- return (wxImageList *) NULL;
+ return NULL;
}
void wxGenericListCtrl::SetImageList( wxImageList *imageList, int which )
m_mainWin->DeleteColumn( col );
// if we don't have the header any longer, we need to relayout the window
- if ( !GetColumnCount() )
- ResizeReportView(false /* no header */);
+ // if ( !GetColumnCount() )
+
return true;
}
// if we hadn't had a header before but have one now
// then we need to relayout the window
- if ( GetColumnCount() == 1 && m_mainWin->HasHeader() )
- ResizeReportView(true /* have header */);
+ // if ( GetColumnCount() == 1 && m_mainWin->HasHeader() )
m_headerWin->Refresh();
void wxGenericListCtrl::OnSize(wxSizeEvent& WXUNUSED(event))
{
- if ( !m_mainWin )
- return;
+ if (!m_mainWin) return;
- ResizeReportView(m_mainWin->HasHeader());
- m_mainWin->RecalculatePositions();
-}
+ // We need to override OnSize so that our scrolled
+ // window a) does call Layout() to use sizers for
+ // positioning the controls but b) does not query
+ // the sizer for their size and use that for setting
+ // the scrollable area as set that ourselves by
+ // calling SetScrollbar() further down.
-void wxGenericListCtrl::ResizeReportView(bool showHeader)
-{
- int cw, ch;
- GetClientSize( &cw, &ch );
+ Layout();
- if ( showHeader )
- {
- m_headerWin->SetSize( 0, 0, cw, m_headerHeight );
- if(ch > m_headerHeight)
- m_mainWin->SetSize( 0, m_headerHeight + 1,
- cw, ch - m_headerHeight - 1 );
- else
- m_mainWin->SetSize( 0, m_headerHeight + 1,
- cw, 0);
- }
- else // no header window
- {
- m_mainWin->SetSize( 0, 0, cw, ch );
- }
+ m_mainWin->RecalculatePositions();
+
+ AdjustScrollbars();
}
void wxGenericListCtrl::OnInternalIdle()
{
wxWindow::OnInternalIdle();
- // do it only if needed
- if ( !m_mainWin->m_dirty )
- return;
-
- m_mainWin->RecalculatePositions();
+ if (m_mainWin->m_dirty)
+ m_mainWin->RecalculatePositions();
}
// ----------------------------------------------------------------------------
if (m_headerWin)
{
m_headerWin->SetFont( font );
- CalculateAndSetHeaderHeight();
+ // CalculateAndSetHeaderHeight();
}
Refresh();
#else
wxUnusedVar(variant);
wxVisualAttributes attr;
- attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT);
attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
return attr;