implemented Freeze/Thaw() for the generic listctrl
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12287 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -158,20 +158,24 @@ public:
|
|||||||
|
|
||||||
// We have to hand down a few functions
|
// We have to hand down a few functions
|
||||||
|
|
||||||
bool SetBackgroundColour( const wxColour &colour );
|
virtual void Freeze();
|
||||||
bool SetForegroundColour( const wxColour &colour );
|
virtual void Thaw();
|
||||||
bool SetFont( const wxFont &font );
|
|
||||||
|
virtual bool SetBackgroundColour( const wxColour &colour );
|
||||||
|
virtual bool SetForegroundColour( const wxColour &colour );
|
||||||
|
virtual wxColour GetBackgroundColour() const;
|
||||||
|
virtual wxColour GetForegroundColour() const;
|
||||||
|
virtual bool SetFont( const wxFont &font );
|
||||||
|
virtual bool SetCursor( const wxCursor &cursor );
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
void SetDropTarget( wxDropTarget *dropTarget );
|
virtual void SetDropTarget( wxDropTarget *dropTarget );
|
||||||
wxDropTarget *GetDropTarget() const;
|
virtual wxDropTarget *GetDropTarget() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool SetCursor( const wxCursor &cursor );
|
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
|
||||||
wxColour GetBackgroundColour() const;
|
|
||||||
wxColour GetForegroundColour() const;
|
virtual void SetFocus();
|
||||||
bool DoPopupMenu( wxMenu *menu, int x, int y );
|
|
||||||
void SetFocus();
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
// --------------
|
// --------------
|
||||||
|
@@ -73,6 +73,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
|
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
|
||||||
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
|
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
|
||||||
EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
|
EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
|
||||||
|
EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
|
||||||
|
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
|
||||||
|
|
||||||
EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
|
EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -188,7 +190,7 @@ MyFrame::MyFrame(const wxChar *title, int x, int y, int w, int h)
|
|||||||
|
|
||||||
wxMenu *menuList = new wxMenu;
|
wxMenu *menuList = new wxMenu;
|
||||||
menuList->Append(LIST_FOCUS_LAST, _T("&Make last item current\tCtrl-L"));
|
menuList->Append(LIST_FOCUS_LAST, _T("&Make last item current\tCtrl-L"));
|
||||||
menuList->Append(LIST_TOGGLE_FIRST, _T("&Toggle first item\tCtrl-T"));
|
menuList->Append(LIST_TOGGLE_FIRST, _T("To&ggle first item\tCtrl-G"));
|
||||||
menuList->Append(LIST_DESELECT_ALL, _T("&Deselect All\tCtrl-D"));
|
menuList->Append(LIST_DESELECT_ALL, _T("&Deselect All\tCtrl-D"));
|
||||||
menuList->Append(LIST_SELECT_ALL, _T("S&elect All\tCtrl-A"));
|
menuList->Append(LIST_SELECT_ALL, _T("S&elect All\tCtrl-A"));
|
||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
@@ -201,6 +203,9 @@ MyFrame::MyFrame(const wxChar *title, int x, int y, int w, int h)
|
|||||||
menuList->Append(LIST_DELETE, _T("&Delete first item\tCtrl-X"));
|
menuList->Append(LIST_DELETE, _T("&Delete first item\tCtrl-X"));
|
||||||
menuList->Append(LIST_DELETE_ALL, _T("Delete &all items"));
|
menuList->Append(LIST_DELETE_ALL, _T("Delete &all items"));
|
||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
|
menuList->Append(LIST_FREEZE, _T("Free&ze\tCtrl-Z"));
|
||||||
|
menuList->Append(LIST_THAW, _T("Tha&w\tCtrl-W"));
|
||||||
|
menuList->AppendSeparator();
|
||||||
menuList->Append(LIST_TOGGLE_MULTI_SEL, _T("&Multiple selection\tCtrl-M"),
|
menuList->Append(LIST_TOGGLE_MULTI_SEL, _T("&Multiple selection\tCtrl-M"),
|
||||||
_T("Toggle multiple selection"), TRUE);
|
_T("Toggle multiple selection"), TRUE);
|
||||||
|
|
||||||
@@ -260,6 +265,20 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnFreeze(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("Freezing the control"));
|
||||||
|
|
||||||
|
m_listCtrl->Freeze();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnThaw(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("Thawing the control"));
|
||||||
|
|
||||||
|
m_listCtrl->Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnFocusLast(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnFocusLast(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
long index = m_listCtrl->GetItemCount() - 1;
|
long index = m_listCtrl->GetItemCount() - 1;
|
||||||
|
@@ -103,6 +103,8 @@ public:
|
|||||||
void OnToggleMultiSel(wxCommandEvent& event);
|
void OnToggleMultiSel(wxCommandEvent& event);
|
||||||
void OnShowColInfo(wxCommandEvent& event);
|
void OnShowColInfo(wxCommandEvent& event);
|
||||||
void OnShowSelInfo(wxCommandEvent& event);
|
void OnShowSelInfo(wxCommandEvent& event);
|
||||||
|
void OnFreeze(wxCommandEvent& event);
|
||||||
|
void OnThaw(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnUpdateShowColInfo(wxUpdateUIEvent& event);
|
void OnUpdateShowColInfo(wxUpdateUIEvent& event);
|
||||||
|
|
||||||
@@ -152,6 +154,8 @@ enum
|
|||||||
LIST_SHOW_COL_INFO,
|
LIST_SHOW_COL_INFO,
|
||||||
LIST_SHOW_SEL_INFO,
|
LIST_SHOW_SEL_INFO,
|
||||||
LIST_FOCUS_LAST,
|
LIST_FOCUS_LAST,
|
||||||
|
LIST_FREEZE,
|
||||||
|
LIST_THAW,
|
||||||
|
|
||||||
LIST_CTRL = 1000
|
LIST_CTRL = 1000
|
||||||
};
|
};
|
||||||
|
@@ -611,7 +611,13 @@ public:
|
|||||||
// bring the current item into view
|
// bring the current item into view
|
||||||
void MoveToFocus() { MoveToItem(m_current); }
|
void MoveToFocus() { MoveToItem(m_current); }
|
||||||
|
|
||||||
|
// start editing the label of the given item
|
||||||
void EditLabel( long item );
|
void EditLabel( long item );
|
||||||
|
|
||||||
|
// suspend/resume redrawing the control
|
||||||
|
void Freeze();
|
||||||
|
void Thaw();
|
||||||
|
|
||||||
void OnRenameTimer();
|
void OnRenameTimer();
|
||||||
void OnRenameAccept();
|
void OnRenameAccept();
|
||||||
|
|
||||||
@@ -843,6 +849,9 @@ private:
|
|||||||
wxBrush *m_highlightBrush,
|
wxBrush *m_highlightBrush,
|
||||||
*m_highlightUnfocusedBrush;
|
*m_highlightUnfocusedBrush;
|
||||||
|
|
||||||
|
// if this is > 0, the control is frozen and doesn't redraw itself
|
||||||
|
size_t m_freezeCount;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxListMainWindow);
|
DECLARE_DYNAMIC_CLASS(wxListMainWindow);
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
@@ -2227,6 +2236,8 @@ void wxListMainWindow::Init()
|
|||||||
m_currentEdit =
|
m_currentEdit =
|
||||||
m_lineLastClicked =
|
m_lineLastClicked =
|
||||||
m_lineBeforeLastClicked = (size_t)-1;
|
m_lineBeforeLastClicked = (size_t)-1;
|
||||||
|
|
||||||
|
m_freezeCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListMainWindow::InitScrolling()
|
void wxListMainWindow::InitScrolling()
|
||||||
@@ -2662,15 +2673,30 @@ void wxListMainWindow::RefreshSelected()
|
|||||||
#endif // !__WXGTK__/__WXGTK__
|
#endif // !__WXGTK__/__WXGTK__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListMainWindow::Freeze()
|
||||||
|
{
|
||||||
|
m_freezeCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListMainWindow::Thaw()
|
||||||
|
{
|
||||||
|
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") );
|
||||||
|
|
||||||
|
if ( !--m_freezeCount )
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
// Note: a wxPaintDC must be constructed even if no drawing is
|
// Note: a wxPaintDC must be constructed even if no drawing is
|
||||||
// done (a Windows requirement).
|
// done (a Windows requirement).
|
||||||
wxPaintDC dc( this );
|
wxPaintDC dc( this );
|
||||||
|
|
||||||
if ( IsEmpty() )
|
if ( IsEmpty() || m_freezeCount )
|
||||||
{
|
{
|
||||||
// empty control. nothing to draw
|
// nothing to draw or not the moment to draw it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5210,4 +5236,14 @@ void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
|
|||||||
m_mainWin->RefreshLines(itemFrom, itemTo);
|
m_mainWin->RefreshLines(itemFrom, itemTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListCtrl::Freeze()
|
||||||
|
{
|
||||||
|
m_mainWin->Freeze();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListCtrl::Thaw()
|
||||||
|
{
|
||||||
|
m_mainWin->Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_LISTCTRL
|
#endif // wxUSE_LISTCTRL
|
||||||
|
Reference in New Issue
Block a user