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:
Vadim Zeitlin 2001-11-03 17:06:29 +00:00
parent 4fb788e466
commit c5c528fc7f
4 changed files with 76 additions and 13 deletions

View File

@ -158,20 +158,24 @@ public:
// We have to hand down a few functions
bool SetBackgroundColour( const wxColour &colour );
bool SetForegroundColour( const wxColour &colour );
bool SetFont( const wxFont &font );
virtual void Freeze();
virtual void Thaw();
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
void SetDropTarget( wxDropTarget *dropTarget );
wxDropTarget *GetDropTarget() const;
virtual void SetDropTarget( wxDropTarget *dropTarget );
virtual wxDropTarget *GetDropTarget() const;
#endif
bool SetCursor( const wxCursor &cursor );
wxColour GetBackgroundColour() const;
wxColour GetForegroundColour() const;
bool DoPopupMenu( wxMenu *menu, int x, int y );
void SetFocus();
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
virtual void SetFocus();
// implementation
// --------------

View File

@ -73,6 +73,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
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)
END_EVENT_TABLE()
@ -188,7 +190,7 @@ MyFrame::MyFrame(const wxChar *title, int x, int y, int w, int h)
wxMenu *menuList = new wxMenu;
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_SELECT_ALL, _T("S&elect All\tCtrl-A"));
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_ALL, _T("Delete &all items"));
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"),
_T("Toggle multiple selection"), TRUE);
@ -260,6 +265,20 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
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))
{
long index = m_listCtrl->GetItemCount() - 1;

View File

@ -103,6 +103,8 @@ public:
void OnToggleMultiSel(wxCommandEvent& event);
void OnShowColInfo(wxCommandEvent& event);
void OnShowSelInfo(wxCommandEvent& event);
void OnFreeze(wxCommandEvent& event);
void OnThaw(wxCommandEvent& event);
void OnUpdateShowColInfo(wxUpdateUIEvent& event);
@ -152,6 +154,8 @@ enum
LIST_SHOW_COL_INFO,
LIST_SHOW_SEL_INFO,
LIST_FOCUS_LAST,
LIST_FREEZE,
LIST_THAW,
LIST_CTRL = 1000
};

View File

@ -611,7 +611,13 @@ public:
// bring the current item into view
void MoveToFocus() { MoveToItem(m_current); }
// start editing the label of the given item
void EditLabel( long item );
// suspend/resume redrawing the control
void Freeze();
void Thaw();
void OnRenameTimer();
void OnRenameAccept();
@ -843,6 +849,9 @@ private:
wxBrush *m_highlightBrush,
*m_highlightUnfocusedBrush;
// if this is > 0, the control is frozen and doesn't redraw itself
size_t m_freezeCount;
DECLARE_DYNAMIC_CLASS(wxListMainWindow);
DECLARE_EVENT_TABLE()
};
@ -2227,6 +2236,8 @@ void wxListMainWindow::Init()
m_currentEdit =
m_lineLastClicked =
m_lineBeforeLastClicked = (size_t)-1;
m_freezeCount = 0;
}
void wxListMainWindow::InitScrolling()
@ -2662,15 +2673,30 @@ void wxListMainWindow::RefreshSelected()
#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) )
{
// Note: a wxPaintDC must be constructed even if no drawing is
// done (a Windows requirement).
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;
}
@ -5210,4 +5236,14 @@ void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
m_mainWin->RefreshLines(itemFrom, itemTo);
}
void wxListCtrl::Freeze()
{
m_mainWin->Freeze();
}
void wxListCtrl::Thaw()
{
m_mainWin->Thaw();
}
#endif // wxUSE_LISTCTRL