1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: listctrl.cpp
|
|
|
|
// Purpose: wxListCtrl sample
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 06:55:54 -05:00
|
|
|
// Copyright: (c) Julian Smart
|
1999-07-23 19:41:45 -04:00
|
|
|
// Licence: wxWindows license
|
1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
2005-08-23 11:54:39 -04:00
|
|
|
#if !defined(__WXMSW__) && !defined(__WXPM__)
|
2000-02-24 18:40:42 -05:00
|
|
|
#include "mondrian.xpm"
|
2005-08-23 11:54:39 -04:00
|
|
|
#endif
|
2000-02-24 18:40:42 -05:00
|
|
|
|
2005-08-23 11:54:39 -04:00
|
|
|
#ifndef __WXMSW__
|
2000-02-24 18:40:42 -05:00
|
|
|
#include "bitmaps/toolbrai.xpm"
|
|
|
|
#include "bitmaps/toolchar.xpm"
|
|
|
|
#include "bitmaps/tooldata.xpm"
|
|
|
|
#include "bitmaps/toolnote.xpm"
|
|
|
|
#include "bitmaps/tooltodo.xpm"
|
|
|
|
#include "bitmaps/toolchec.xpm"
|
|
|
|
#include "bitmaps/toolgame.xpm"
|
|
|
|
#include "bitmaps/tooltime.xpm"
|
|
|
|
#include "bitmaps/toolword.xpm"
|
|
|
|
#include "bitmaps/small1.xpm"
|
1998-12-07 03:27:06 -05:00
|
|
|
#endif
|
|
|
|
|
2000-03-17 18:02:03 -05:00
|
|
|
#include "wx/imaglist.h"
|
1998-05-22 15:57:05 -04:00
|
|
|
#include "wx/listctrl.h"
|
2000-02-05 20:30:21 -05:00
|
|
|
#include "wx/timer.h" // for wxStopWatch
|
2000-02-07 20:07:48 -05:00
|
|
|
#include "wx/colordlg.h" // for wxGetColourFromUser
|
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
#include "listtest.h"
|
|
|
|
|
2005-05-22 17:31:42 -04:00
|
|
|
const wxChar *SMALL_VIRTUAL_VIEW_ITEMS[][2] =
|
|
|
|
{
|
|
|
|
{ _T("Cat"), _T("meow") },
|
|
|
|
{ _T("Cow"), _T("moo") },
|
|
|
|
{ _T("Crow"), _T("caw") },
|
|
|
|
{ _T("Dog"), _T("woof") },
|
|
|
|
{ _T("Duck"), _T("quack") },
|
|
|
|
{ _T("Mouse"), _T("squeak") },
|
|
|
|
{ _T("Owl"), _T("hoo") },
|
|
|
|
{ _T("Pig"), _T("oink") },
|
|
|
|
{ _T("Pigeon"), _T("coo") },
|
|
|
|
{ _T("Sheep"), _T("baaah") },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
2001-07-04 21:27:38 -04:00
|
|
|
EVT_SIZE(MyFrame::OnSize)
|
|
|
|
|
1999-07-23 19:41:45 -04:00
|
|
|
EVT_MENU(LIST_QUIT, MyFrame::OnQuit)
|
|
|
|
EVT_MENU(LIST_ABOUT, MyFrame::OnAbout)
|
|
|
|
EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView)
|
|
|
|
EVT_MENU(LIST_REPORT_VIEW, MyFrame::OnReportView)
|
|
|
|
EVT_MENU(LIST_ICON_VIEW, MyFrame::OnIconView)
|
|
|
|
EVT_MENU(LIST_ICON_TEXT_VIEW, MyFrame::OnIconTextView)
|
|
|
|
EVT_MENU(LIST_SMALL_ICON_VIEW, MyFrame::OnSmallIconView)
|
|
|
|
EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW, MyFrame::OnSmallIconTextView)
|
2001-07-04 21:27:38 -04:00
|
|
|
EVT_MENU(LIST_VIRTUAL_VIEW, MyFrame::OnVirtualView)
|
2005-05-22 17:31:42 -04:00
|
|
|
EVT_MENU(LIST_SMALL_VIRTUAL_VIEW, MyFrame::OnSmallVirtualView)
|
2001-07-04 21:27:38 -04:00
|
|
|
|
2001-08-13 11:41:18 -04:00
|
|
|
EVT_MENU(LIST_FOCUS_LAST, MyFrame::OnFocusLast)
|
2000-03-13 12:20:39 -05:00
|
|
|
EVT_MENU(LIST_TOGGLE_FIRST, MyFrame::OnToggleFirstSel)
|
1999-07-23 19:41:45 -04:00
|
|
|
EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll)
|
|
|
|
EVT_MENU(LIST_SELECT_ALL, MyFrame::OnSelectAll)
|
2001-06-23 18:24:33 -04:00
|
|
|
EVT_MENU(LIST_DELETE, MyFrame::OnDelete)
|
2001-07-06 17:18:15 -04:00
|
|
|
EVT_MENU(LIST_ADD, MyFrame::OnAdd)
|
2002-05-26 06:53:51 -04:00
|
|
|
EVT_MENU(LIST_EDIT, MyFrame::OnEdit)
|
1999-07-23 19:41:45 -04:00
|
|
|
EVT_MENU(LIST_DELETE_ALL, MyFrame::OnDeleteAll)
|
1999-12-01 17:07:25 -05:00
|
|
|
EVT_MENU(LIST_SORT, MyFrame::OnSort)
|
2000-02-07 20:07:48 -05:00
|
|
|
EVT_MENU(LIST_SET_FG_COL, MyFrame::OnSetFgColour)
|
|
|
|
EVT_MENU(LIST_SET_BG_COL, MyFrame::OnSetBgColour)
|
2000-02-10 13:12:44 -05:00
|
|
|
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
|
2000-07-15 15:51:35 -04:00
|
|
|
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
|
2001-07-07 18:42:35 -04:00
|
|
|
EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
|
2001-11-03 12:06:29 -05:00
|
|
|
EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
|
|
|
|
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
|
2004-09-18 07:01:00 -04:00
|
|
|
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
|
2001-07-04 21:27:38 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
|
2005-08-23 11:54:39 -04:00
|
|
|
EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
|
1998-05-22 15:57:05 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
|
1999-07-23 19:41:45 -04:00
|
|
|
EVT_LIST_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnBeginDrag)
|
|
|
|
EVT_LIST_BEGIN_RDRAG(LIST_CTRL, MyListCtrl::OnBeginRDrag)
|
|
|
|
EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL, MyListCtrl::OnBeginLabelEdit)
|
|
|
|
EVT_LIST_END_LABEL_EDIT(LIST_CTRL, MyListCtrl::OnEndLabelEdit)
|
|
|
|
EVT_LIST_DELETE_ITEM(LIST_CTRL, MyListCtrl::OnDeleteItem)
|
2000-02-06 08:51:01 -05:00
|
|
|
EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL, MyListCtrl::OnDeleteAllItems)
|
2004-09-30 15:13:38 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2_4
|
1999-07-23 19:41:45 -04:00
|
|
|
EVT_LIST_GET_INFO(LIST_CTRL, MyListCtrl::OnGetInfo)
|
|
|
|
EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
|
2004-09-30 15:13:38 -04:00
|
|
|
#endif
|
1999-07-23 19:41:45 -04:00
|
|
|
EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyListCtrl::OnSelected)
|
|
|
|
EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
|
|
|
|
EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
|
|
|
|
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
|
2001-11-16 11:31:17 -05:00
|
|
|
EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
|
2001-08-31 21:01:51 -04:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
EVT_LIST_COL_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
|
2001-08-31 21:01:51 -04:00
|
|
|
EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL, MyListCtrl::OnColRightClick)
|
|
|
|
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnColBeginDrag)
|
|
|
|
EVT_LIST_COL_DRAGGING(LIST_CTRL, MyListCtrl::OnColDragging)
|
|
|
|
EVT_LIST_COL_END_DRAG(LIST_CTRL, MyListCtrl::OnColEndDrag)
|
|
|
|
|
2001-07-19 20:25:09 -04:00
|
|
|
EVT_LIST_CACHE_HINT(LIST_CTRL, MyListCtrl::OnCacheHint)
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
EVT_CHAR(MyListCtrl::OnChar)
|
1998-05-22 15:57:05 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
// number of items in list/report view
|
|
|
|
static const int NUM_ITEMS = 30;
|
|
|
|
|
|
|
|
// number of items in icon/small icon view
|
|
|
|
static const int NUM_ICONS = 9;
|
|
|
|
|
2003-07-26 13:34:12 -04:00
|
|
|
int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData))
|
1999-12-01 17:07:25 -05:00
|
|
|
{
|
|
|
|
// inverse the order
|
2003-07-26 13:34:12 -04:00
|
|
|
if (item1 < item2)
|
|
|
|
return -1;
|
|
|
|
if (item1 > item2)
|
|
|
|
return 1;
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
return 0;
|
1999-12-01 17:07:25 -05:00
|
|
|
}
|
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
// `Main program' equivalent, creating windows and returning main app frame
|
2000-02-07 20:07:48 -05:00
|
|
|
bool MyApp::OnInit()
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
|
|
|
// Create the main frame window
|
2001-08-02 14:59:50 -04:00
|
|
|
MyFrame *frame = new MyFrame(wxT("wxListCtrl Test"), 50, 50, 450, 340);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
// Show the frame
|
2004-05-20 13:02:02 -04:00
|
|
|
frame->Show(true);
|
1999-07-23 19:41:45 -04:00
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
SetTopWindow(frame);
|
|
|
|
|
2004-05-20 13:02:02 -04:00
|
|
|
return true;
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// My frame constructor
|
2000-02-24 18:40:42 -05:00
|
|
|
MyFrame::MyFrame(const wxChar *title, int x, int y, int w, int h)
|
2005-05-22 17:31:42 -04:00
|
|
|
: wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2005-05-22 17:31:42 -04:00
|
|
|
m_listCtrl = NULL;
|
|
|
|
m_logWindow = NULL;
|
|
|
|
m_smallVirtual = false;
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
// Give it an icon
|
|
|
|
SetIcon( wxICON(mondrian) );
|
|
|
|
|
|
|
|
// Make an image list containing large icons
|
2004-05-20 13:02:02 -04:00
|
|
|
m_imageListNormal = new wxImageList(32, 32, true);
|
|
|
|
m_imageListSmall = new wxImageList(16, 16, true);
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
2002-12-15 05:23:11 -05:00
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon1"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon2"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon3"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon4"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon5"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon6"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon7"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon8"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
m_imageListNormal->Add( wxIcon(_T("icon9"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
|
|
|
|
|
|
|
m_imageListSmall->Add( wxIcon(_T("iconsmall"), wxBITMAP_TYPE_ICO_RESOURCE) );
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
#else
|
|
|
|
m_imageListNormal->Add( wxIcon( toolbrai_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( toolchar_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( tooldata_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( toolnote_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( tooltodo_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( toolchec_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( toolgame_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( tooltime_xpm ) );
|
|
|
|
m_imageListNormal->Add( wxIcon( toolword_xpm ) );
|
|
|
|
|
|
|
|
m_imageListSmall->Add( wxIcon( small1_xpm) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Make a menubar
|
|
|
|
wxMenu *menuFile = new wxMenu;
|
2001-07-04 21:27:38 -04:00
|
|
|
menuFile->Append(LIST_ABOUT, _T("&About"));
|
2000-02-24 18:40:42 -05:00
|
|
|
menuFile->AppendSeparator();
|
2001-07-04 21:27:38 -04:00
|
|
|
menuFile->Append(LIST_QUIT, _T("E&xit\tAlt-X"));
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
wxMenu *menuView = new wxMenu;
|
2001-07-04 21:27:38 -04:00
|
|
|
menuView->Append(LIST_LIST_VIEW, _T("&List view\tF1"));
|
|
|
|
menuView->Append(LIST_REPORT_VIEW, _T("&Report view\tF2"));
|
|
|
|
menuView->Append(LIST_ICON_VIEW, _T("&Icon view\tF3"));
|
|
|
|
menuView->Append(LIST_ICON_TEXT_VIEW, _T("Icon view with &text\tF4"));
|
|
|
|
menuView->Append(LIST_SMALL_ICON_VIEW, _T("&Small icon view\tF5"));
|
|
|
|
menuView->Append(LIST_SMALL_ICON_TEXT_VIEW, _T("Small icon &view with text\tF6"));
|
2005-05-22 17:31:42 -04:00
|
|
|
menuView->Append(LIST_VIRTUAL_VIEW, _T("&Virtual view\tF7"));
|
|
|
|
menuView->Append(LIST_SMALL_VIRTUAL_VIEW, _T("Small virtual vie&w\tF8"));
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
wxMenu *menuList = new wxMenu;
|
2001-08-13 11:41:18 -04:00
|
|
|
menuList->Append(LIST_FOCUS_LAST, _T("&Make last item current\tCtrl-L"));
|
2001-11-03 12:06:29 -05:00
|
|
|
menuList->Append(LIST_TOGGLE_FIRST, _T("To&ggle first item\tCtrl-G"));
|
2001-07-04 21:27:38 -04:00
|
|
|
menuList->Append(LIST_DESELECT_ALL, _T("&Deselect All\tCtrl-D"));
|
|
|
|
menuList->Append(LIST_SELECT_ALL, _T("S&elect All\tCtrl-A"));
|
2001-07-07 18:42:35 -04:00
|
|
|
menuList->AppendSeparator();
|
2001-07-04 21:27:38 -04:00
|
|
|
menuList->Append(LIST_SHOW_COL_INFO, _T("Show &column info\tCtrl-C"));
|
2001-07-07 18:42:35 -04:00
|
|
|
menuList->Append(LIST_SHOW_SEL_INFO, _T("Show &selected items\tCtrl-S"));
|
2000-02-24 18:40:42 -05:00
|
|
|
menuList->AppendSeparator();
|
2001-07-04 21:27:38 -04:00
|
|
|
menuList->Append(LIST_SORT, _T("&Sort\tCtrl-S"));
|
2000-02-24 18:40:42 -05:00
|
|
|
menuList->AppendSeparator();
|
2001-07-06 17:18:15 -04:00
|
|
|
menuList->Append(LIST_ADD, _T("&Append an item\tCtrl-P"));
|
2002-05-26 06:53:51 -04:00
|
|
|
menuList->Append(LIST_EDIT, _T("&Edit the item\tCtrl-E"));
|
2001-07-06 17:18:15 -04:00
|
|
|
menuList->Append(LIST_DELETE, _T("&Delete first item\tCtrl-X"));
|
2001-07-04 21:27:38 -04:00
|
|
|
menuList->Append(LIST_DELETE_ALL, _T("Delete &all items"));
|
2000-02-24 18:40:42 -05:00
|
|
|
menuList->AppendSeparator();
|
2001-11-03 12:06:29 -05:00
|
|
|
menuList->Append(LIST_FREEZE, _T("Free&ze\tCtrl-Z"));
|
|
|
|
menuList->Append(LIST_THAW, _T("Tha&w\tCtrl-W"));
|
|
|
|
menuList->AppendSeparator();
|
2004-09-18 07:01:00 -04:00
|
|
|
menuList->AppendCheckItem(LIST_TOGGLE_LINES, _T("Toggle &lines\tCtrl-I"));
|
2001-07-04 21:27:38 -04:00
|
|
|
menuList->Append(LIST_TOGGLE_MULTI_SEL, _T("&Multiple selection\tCtrl-M"),
|
2004-05-20 13:02:02 -04:00
|
|
|
_T("Toggle multiple selection"), true);
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
wxMenu *menuCol = new wxMenu;
|
2001-07-04 21:27:38 -04:00
|
|
|
menuCol->Append(LIST_SET_FG_COL, _T("&Foreground colour..."));
|
|
|
|
menuCol->Append(LIST_SET_BG_COL, _T("&Background colour..."));
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
wxMenuBar *menubar = new wxMenuBar;
|
2001-07-04 21:27:38 -04:00
|
|
|
menubar->Append(menuFile, _T("&File"));
|
|
|
|
menubar->Append(menuView, _T("&View"));
|
|
|
|
menubar->Append(menuList, _T("&List"));
|
|
|
|
menubar->Append(menuCol, _T("&Colour"));
|
2000-02-24 18:40:42 -05:00
|
|
|
SetMenuBar(menubar);
|
|
|
|
|
2004-05-20 13:02:02 -04:00
|
|
|
m_panel = new wxPanel(this, wxID_ANY);
|
|
|
|
m_logWindow = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString,
|
2000-02-24 18:40:42 -05:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxTE_MULTILINE | wxSUNKEN_BORDER);
|
|
|
|
|
|
|
|
m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_logWindow));
|
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
RecreateList(wxLC_REPORT | wxLC_SINGLE_SEL);
|
2000-02-24 18:40:42 -05:00
|
|
|
|
2004-07-19 11:36:01 -04:00
|
|
|
#if wxUSE_STATUSBAR
|
2000-02-24 18:40:42 -05:00
|
|
|
CreateStatusBar(3);
|
2004-07-19 11:36:01 -04:00
|
|
|
#endif // wxUSE_STATUSBAR
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-07 20:07:48 -05:00
|
|
|
MyFrame::~MyFrame()
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
delete wxLog::SetActiveTarget(m_logOld);
|
|
|
|
|
|
|
|
delete m_imageListNormal;
|
|
|
|
delete m_imageListSmall;
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2001-07-04 21:27:38 -04:00
|
|
|
void MyFrame::OnSize(wxSizeEvent& event)
|
2003-11-06 14:28:24 -05:00
|
|
|
{
|
|
|
|
DoSize();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::DoSize()
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-07-04 21:27:38 -04:00
|
|
|
if ( !m_logWindow )
|
|
|
|
return;
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2001-07-04 21:27:38 -04:00
|
|
|
wxSize size = GetClientSize();
|
|
|
|
wxCoord y = (2*size.y)/3;
|
|
|
|
m_listCtrl->SetSize(0, 0, size.x, y);
|
|
|
|
m_logWindow->SetSize(0, y + 1, size.x, size.y - y);
|
1999-07-02 11:30:00 -04:00
|
|
|
}
|
|
|
|
|
2004-02-08 10:16:21 -05:00
|
|
|
bool MyFrame::CheckNonVirtual() const
|
|
|
|
{
|
|
|
|
if ( !m_listCtrl->HasFlag(wxLC_VIRTUAL) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// "this" == whatever
|
|
|
|
wxLogWarning(_T("Can't do this in virtual view, sorry."));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-07-04 21:27:38 -04:00
|
|
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
1999-07-02 11:30:00 -04:00
|
|
|
{
|
2004-05-20 13:02:02 -04:00
|
|
|
Close(true);
|
1999-07-02 11:30:00 -04:00
|
|
|
}
|
|
|
|
|
1998-08-17 11:48:25 -04:00
|
|
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2002-05-26 06:53:51 -04:00
|
|
|
wxMessageDialog dialog(this, _T("List test sample\nJulian Smart (c) 1997"),
|
|
|
|
_T("About list test"), wxOK|wxCANCEL);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1999-07-23 19:41:45 -04:00
|
|
|
dialog.ShowModal();
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2003-07-26 13:34:12 -04:00
|
|
|
void MyFrame::OnFreeze(wxCommandEvent& WXUNUSED(event))
|
2001-11-03 12:06:29 -05:00
|
|
|
{
|
|
|
|
wxLogMessage(_T("Freezing the control"));
|
|
|
|
|
|
|
|
m_listCtrl->Freeze();
|
|
|
|
}
|
|
|
|
|
2003-07-26 13:34:12 -04:00
|
|
|
void MyFrame::OnThaw(wxCommandEvent& WXUNUSED(event))
|
2001-11-03 12:06:29 -05:00
|
|
|
{
|
|
|
|
wxLogMessage(_T("Thawing the control"));
|
|
|
|
|
|
|
|
m_listCtrl->Thaw();
|
|
|
|
}
|
|
|
|
|
2004-09-18 07:01:00 -04:00
|
|
|
void MyFrame::OnToggleLines(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
m_listCtrl->SetSingleStyle(wxLC_HRULES | wxLC_VRULES, event.IsChecked());
|
|
|
|
}
|
|
|
|
|
2001-08-13 11:41:18 -04:00
|
|
|
void MyFrame::OnFocusLast(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
long index = m_listCtrl->GetItemCount() - 1;
|
|
|
|
if ( index == -1 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_listCtrl->SetItemState(index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
|
|
|
m_listCtrl->EnsureVisible(index);
|
|
|
|
}
|
|
|
|
|
2000-03-13 12:20:39 -05:00
|
|
|
void MyFrame::OnToggleFirstSel(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2004-01-08 03:43:16 -05:00
|
|
|
m_listCtrl->SetItemState(0, (~m_listCtrl->GetItemState(0, wxLIST_STATE_SELECTED) ) & wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
2000-03-13 12:20:39 -05:00
|
|
|
}
|
|
|
|
|
1998-08-23 16:06:24 -04:00
|
|
|
void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2004-02-08 10:16:21 -05:00
|
|
|
if ( !CheckNonVirtual() )
|
|
|
|
return;
|
|
|
|
|
1999-07-23 19:41:45 -04:00
|
|
|
int n = m_listCtrl->GetItemCount();
|
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
m_listCtrl->SetItemState(i,0,wxLIST_STATE_SELECTED);
|
1998-08-23 16:06:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2004-02-08 10:16:21 -05:00
|
|
|
if ( !CheckNonVirtual() )
|
|
|
|
return;
|
|
|
|
|
1999-07-23 19:41:45 -04:00
|
|
|
int n = m_listCtrl->GetItemCount();
|
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
m_listCtrl->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
1998-08-23 16:06:24 -04:00
|
|
|
}
|
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// changing listctrl modes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void MyFrame::RecreateList(long flags, bool withText)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-07-07 12:52:27 -04:00
|
|
|
// we could avoid recreating it if we don't set/clear the wxLC_VIRTUAL
|
|
|
|
// style, but it is more trouble to do it than not
|
|
|
|
#if 0
|
|
|
|
if ( !m_listCtrl || ((flags & wxLC_VIRTUAL) !=
|
|
|
|
(m_listCtrl->GetWindowStyleFlag() & wxLC_VIRTUAL)) )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
delete m_listCtrl;
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
m_listCtrl = new MyListCtrl(m_panel, LIST_CTRL,
|
2001-07-07 12:52:27 -04:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
flags |
|
2002-05-26 06:53:51 -04:00
|
|
|
wxSUNKEN_BORDER | wxLC_EDIT_LABELS);
|
2001-07-07 12:52:27 -04:00
|
|
|
|
|
|
|
switch ( flags & wxLC_MASK_TYPE )
|
|
|
|
{
|
|
|
|
case wxLC_LIST:
|
|
|
|
InitWithListItems();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxLC_ICON:
|
|
|
|
InitWithIconItems(withText);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxLC_SMALL_ICON:
|
2004-05-20 13:02:02 -04:00
|
|
|
InitWithIconItems(withText, true);
|
2001-07-07 12:52:27 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wxLC_REPORT:
|
|
|
|
if ( flags & wxLC_VIRTUAL )
|
|
|
|
InitWithVirtualItems();
|
|
|
|
else
|
|
|
|
InitWithReportItems();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( _T("unknown listctrl mode") );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-06 14:28:24 -05:00
|
|
|
DoSize();
|
2001-07-07 12:52:27 -04:00
|
|
|
|
1999-06-11 13:27:57 -04:00
|
|
|
m_logWindow->Clear();
|
2001-07-07 12:52:27 -04:00
|
|
|
}
|
2000-02-06 15:36:00 -05:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
RecreateList(wxLC_LIST);
|
|
|
|
}
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::InitWithListItems()
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < NUM_ITEMS; i++ )
|
1999-06-11 13:27:57 -04:00
|
|
|
{
|
2001-07-04 21:27:38 -04:00
|
|
|
m_listCtrl->InsertItem(i, wxString::Format(_T("Item %d"), i));
|
1999-06-11 13:27:57 -04:00
|
|
|
}
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
1998-08-17 11:48:25 -04:00
|
|
|
void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-07-07 12:52:27 -04:00
|
|
|
RecreateList(wxLC_REPORT);
|
|
|
|
}
|
1999-07-23 19:41:45 -04:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::InitWithReportItems()
|
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
m_listCtrl->SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2003-01-02 16:00:17 -05:00
|
|
|
// note that under MSW for SetColumnWidth() to work we need to create the
|
|
|
|
// items with images initially even if we specify dummy image id
|
2001-09-02 19:47:42 -04:00
|
|
|
wxListItem itemCol;
|
2003-01-02 16:00:17 -05:00
|
|
|
itemCol.SetText(_T("Column 1"));
|
|
|
|
itemCol.SetImage(-1);
|
2001-09-02 19:47:42 -04:00
|
|
|
m_listCtrl->InsertColumn(0, itemCol);
|
2003-01-02 16:00:17 -05:00
|
|
|
|
|
|
|
itemCol.SetText(_T("Column 2"));
|
|
|
|
itemCol.SetAlign(wxLIST_FORMAT_CENTRE);
|
2001-09-02 19:47:42 -04:00
|
|
|
m_listCtrl->InsertColumn(1, itemCol);
|
2003-01-02 16:00:17 -05:00
|
|
|
|
|
|
|
itemCol.SetText(_T("Column 3"));
|
|
|
|
itemCol.SetAlign(wxLIST_FORMAT_RIGHT);
|
2001-09-02 19:47:42 -04:00
|
|
|
m_listCtrl->InsertColumn(2, itemCol);
|
1999-06-11 13:27:57 -04:00
|
|
|
|
2000-02-05 20:30:21 -05:00
|
|
|
// to speed up inserting we hide the control temporarily
|
|
|
|
m_listCtrl->Hide();
|
|
|
|
|
|
|
|
wxStopWatch sw;
|
|
|
|
|
|
|
|
for ( int i = 0; i < NUM_ITEMS; i++ )
|
1999-06-11 13:27:57 -04:00
|
|
|
{
|
2001-07-09 11:58:24 -04:00
|
|
|
m_listCtrl->InsertItemInReportView(i);
|
1999-06-11 13:27:57 -04:00
|
|
|
}
|
1999-12-04 17:34:54 -05:00
|
|
|
|
2000-02-05 20:30:21 -05:00
|
|
|
m_logWindow->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
|
|
|
|
NUM_ITEMS, sw.Time()));
|
|
|
|
m_listCtrl->Show();
|
|
|
|
|
1999-12-04 06:56:28 -05:00
|
|
|
// we leave all mask fields to 0 and only change the colour
|
1999-12-04 17:34:54 -05:00
|
|
|
wxListItem item;
|
|
|
|
item.m_itemId = 0;
|
1999-12-06 05:43:35 -05:00
|
|
|
item.SetTextColour(*wxRED);
|
1999-12-04 17:34:54 -05:00
|
|
|
m_listCtrl->SetItem( item );
|
|
|
|
|
|
|
|
item.m_itemId = 2;
|
1999-12-04 19:20:58 -05:00
|
|
|
item.SetTextColour(*wxGREEN);
|
1999-12-04 17:34:54 -05:00
|
|
|
m_listCtrl->SetItem( item );
|
1999-12-04 19:20:58 -05:00
|
|
|
item.m_itemId = 4;
|
1999-12-04 17:34:54 -05:00
|
|
|
item.SetTextColour(*wxLIGHT_GREY);
|
1999-12-04 19:20:58 -05:00
|
|
|
item.SetFont(*wxITALIC_FONT);
|
|
|
|
item.SetBackgroundColour(*wxRED);
|
1999-12-04 17:34:54 -05:00
|
|
|
m_listCtrl->SetItem( item );
|
1999-07-23 19:41:45 -04:00
|
|
|
|
1999-12-04 19:20:58 -05:00
|
|
|
m_listCtrl->SetTextColour(*wxBLUE);
|
|
|
|
m_listCtrl->SetBackgroundColour(*wxLIGHT_GREY);
|
|
|
|
|
1999-06-11 13:27:57 -04:00
|
|
|
m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
|
|
|
m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
|
|
|
|
m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE );
|
2005-07-22 18:29:20 -04:00
|
|
|
|
|
|
|
// test SetItemFont too
|
|
|
|
m_listCtrl->SetItemFont(0, *wxITALIC_FONT);
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::InitWithIconItems(bool withText, bool sameIcon)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
m_listCtrl->SetImageList(m_imageListNormal, wxIMAGE_LIST_NORMAL);
|
|
|
|
m_listCtrl->SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
for ( int i = 0; i < NUM_ICONS; i++ )
|
1999-07-23 19:41:45 -04:00
|
|
|
{
|
2001-07-07 12:52:27 -04:00
|
|
|
int image = sameIcon ? 0 : i;
|
|
|
|
|
|
|
|
if ( withText )
|
|
|
|
{
|
|
|
|
m_listCtrl->InsertItem(i, wxString::Format(_T("Label %d"), i),
|
|
|
|
image);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_listCtrl->InsertItem(i, image);
|
|
|
|
}
|
1999-07-23 19:41:45 -04:00
|
|
|
}
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::OnIconView(wxCommandEvent& WXUNUSED(event))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2004-05-20 13:02:02 -04:00
|
|
|
RecreateList(wxLC_ICON, false);
|
2001-07-07 12:52:27 -04:00
|
|
|
}
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::OnIconTextView(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
RecreateList(wxLC_ICON);
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
1998-08-17 11:48:25 -04:00
|
|
|
void MyFrame::OnSmallIconView(wxCommandEvent& WXUNUSED(event))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2004-05-20 13:02:02 -04:00
|
|
|
RecreateList(wxLC_SMALL_ICON, false);
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
1998-08-17 11:48:25 -04:00
|
|
|
void MyFrame::OnSmallIconTextView(wxCommandEvent& WXUNUSED(event))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-07-07 12:52:27 -04:00
|
|
|
RecreateList(wxLC_SMALL_ICON);
|
1999-07-23 19:41:45 -04:00
|
|
|
}
|
|
|
|
|
2001-07-04 21:27:38 -04:00
|
|
|
void MyFrame::OnVirtualView(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2005-05-22 17:31:42 -04:00
|
|
|
m_smallVirtual = false;
|
|
|
|
RecreateList(wxLC_REPORT | wxLC_VIRTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSmallVirtualView(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_smallVirtual = true;
|
2001-07-07 12:52:27 -04:00
|
|
|
RecreateList(wxLC_REPORT | wxLC_VIRTUAL);
|
|
|
|
}
|
2001-07-04 21:27:38 -04:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
void MyFrame::InitWithVirtualItems()
|
|
|
|
{
|
2002-08-27 05:38:11 -04:00
|
|
|
m_listCtrl->SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
|
|
|
|
|
2005-05-22 17:31:42 -04:00
|
|
|
if ( m_smallVirtual )
|
|
|
|
{
|
|
|
|
m_listCtrl->InsertColumn(0, _T("Animal"));
|
|
|
|
m_listCtrl->InsertColumn(1, _T("Sound"));
|
|
|
|
m_listCtrl->SetItemCount(WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_listCtrl->InsertColumn(0, _T("First Column"));
|
|
|
|
m_listCtrl->InsertColumn(1, _T("Second Column"));
|
|
|
|
m_listCtrl->SetColumnWidth(0, 150);
|
|
|
|
m_listCtrl->SetColumnWidth(1, 150);
|
|
|
|
m_listCtrl->SetItemCount(1000000);
|
|
|
|
}
|
2001-07-04 21:27:38 -04:00
|
|
|
}
|
|
|
|
|
1999-12-01 17:07:25 -05:00
|
|
|
void MyFrame::OnSort(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2000-02-05 20:30:21 -05:00
|
|
|
wxStopWatch sw;
|
|
|
|
|
1999-12-01 17:07:25 -05:00
|
|
|
m_listCtrl->SortItems(MyCompareFunction, 0);
|
2000-02-05 20:30:21 -05:00
|
|
|
|
|
|
|
m_logWindow->WriteText(wxString::Format(_T("Sorting %d items took %ld ms\n"),
|
|
|
|
m_listCtrl->GetItemCount(),
|
|
|
|
sw.Time()));
|
1999-12-01 17:07:25 -05:00
|
|
|
}
|
|
|
|
|
2003-07-26 13:34:12 -04:00
|
|
|
void MyFrame::OnShowSelInfo(wxCommandEvent& WXUNUSED(event))
|
2001-07-07 18:42:35 -04:00
|
|
|
{
|
|
|
|
int selCount = m_listCtrl->GetSelectedItemCount();
|
|
|
|
wxLogMessage(_T("%d items selected:"), selCount);
|
|
|
|
|
|
|
|
// don't show too many items
|
|
|
|
size_t shownCount = 0;
|
|
|
|
|
|
|
|
long item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
|
|
|
|
wxLIST_STATE_SELECTED);
|
|
|
|
while ( item != -1 )
|
|
|
|
{
|
|
|
|
wxLogMessage(_T("\t%ld (%s)"),
|
|
|
|
item, m_listCtrl->GetItemText(item).c_str());
|
|
|
|
|
|
|
|
if ( ++shownCount > 10 )
|
|
|
|
{
|
|
|
|
wxLogMessage(_T("\t... more selected items snipped..."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
item = m_listCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
|
|
|
|
wxLIST_STATE_SELECTED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-26 13:34:12 -04:00
|
|
|
void MyFrame::OnShowColInfo(wxCommandEvent& WXUNUSED(event))
|
2000-07-15 15:51:35 -04:00
|
|
|
{
|
|
|
|
int count = m_listCtrl->GetColumnCount();
|
2001-08-02 14:59:50 -04:00
|
|
|
wxLogMessage(wxT("%d columns:"), count);
|
2000-07-15 15:51:35 -04:00
|
|
|
for ( int c = 0; c < count; c++ )
|
|
|
|
{
|
2001-08-02 14:59:50 -04:00
|
|
|
wxLogMessage(wxT("\tcolumn %d has width %d"), c,
|
2000-07-15 15:51:35 -04:00
|
|
|
m_listCtrl->GetColumnWidth(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnUpdateShowColInfo(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
event.Enable( (m_listCtrl->GetWindowStyleFlag() & wxLC_REPORT) != 0 );
|
|
|
|
}
|
|
|
|
|
2000-02-10 13:12:44 -05:00
|
|
|
void MyFrame::OnToggleMultiSel(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
long flags = m_listCtrl->GetWindowStyleFlag();
|
|
|
|
if ( flags & wxLC_SINGLE_SEL )
|
2001-07-07 12:52:27 -04:00
|
|
|
flags &= ~wxLC_SINGLE_SEL;
|
2000-02-10 13:12:44 -05:00
|
|
|
else
|
2001-07-07 12:52:27 -04:00
|
|
|
flags |= wxLC_SINGLE_SEL;
|
|
|
|
|
2001-08-02 14:59:50 -04:00
|
|
|
m_logWindow->WriteText(wxString::Format(wxT("Current selection mode: %sle\n"),
|
2002-05-26 06:53:51 -04:00
|
|
|
(flags & wxLC_SINGLE_SEL) ? _T("sing") : _T("multip")));
|
2000-02-10 13:12:44 -05:00
|
|
|
|
2001-07-07 12:52:27 -04:00
|
|
|
RecreateList(flags);
|
2000-02-10 13:12:44 -05:00
|
|
|
}
|
|
|
|
|
2004-03-23 17:18:06 -05:00
|
|
|
void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
event.Check((m_listCtrl->GetWindowStyleFlag() & wxLC_SINGLE_SEL) == 0);
|
|
|
|
}
|
|
|
|
|
2000-02-07 20:07:48 -05:00
|
|
|
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_listCtrl->SetForegroundColour(wxGetColourFromUser(this));
|
|
|
|
m_listCtrl->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSetBgColour(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_listCtrl->SetBackgroundColour(wxGetColourFromUser(this));
|
|
|
|
m_listCtrl->Refresh();
|
|
|
|
}
|
|
|
|
|
2001-07-06 17:18:15 -04:00
|
|
|
void MyFrame::OnAdd(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_listCtrl->InsertItem(m_listCtrl->GetItemCount(), _T("Appended item"));
|
|
|
|
}
|
|
|
|
|
2002-05-26 06:53:51 -04:00
|
|
|
void MyFrame::OnEdit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
long itemCur = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
|
|
|
|
wxLIST_STATE_FOCUSED);
|
|
|
|
|
|
|
|
if ( itemCur != -1 )
|
|
|
|
{
|
|
|
|
m_listCtrl->EditLabel(itemCur);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_logWindow->WriteText(_T("No item to edit"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-23 18:24:33 -04:00
|
|
|
void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
if ( m_listCtrl->GetItemCount() )
|
|
|
|
{
|
|
|
|
m_listCtrl->DeleteItem(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-26 06:53:51 -04:00
|
|
|
m_logWindow->WriteText(_T("Nothing to delete"));
|
2001-06-23 18:24:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-23 19:41:45 -04:00
|
|
|
void MyFrame::OnDeleteAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2000-02-05 20:30:21 -05:00
|
|
|
wxStopWatch sw;
|
1999-07-23 19:41:45 -04:00
|
|
|
|
2004-11-06 18:49:28 -05:00
|
|
|
size_t itemCount = m_listCtrl->GetItemCount();
|
|
|
|
|
1999-07-23 19:41:45 -04:00
|
|
|
m_listCtrl->DeleteAllItems();
|
|
|
|
|
2000-02-05 20:30:21 -05:00
|
|
|
m_logWindow->WriteText(wxString::Format(_T("Deleting %d items took %ld ms\n"),
|
2004-11-06 18:49:28 -05:00
|
|
|
itemCount,
|
2000-02-05 20:30:21 -05:00
|
|
|
sw.Time()));
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// MyListCtrl
|
|
|
|
|
2001-07-19 20:25:09 -04:00
|
|
|
void MyListCtrl::OnCacheHint(wxListEvent& event)
|
|
|
|
{
|
2001-08-02 14:59:50 -04:00
|
|
|
wxLogMessage( wxT("OnCacheHint: cache items %ld..%ld"),
|
2001-07-19 20:25:09 -04:00
|
|
|
event.GetCacheFrom(), event.GetCacheTo() );
|
|
|
|
}
|
|
|
|
|
2001-09-02 19:47:42 -04:00
|
|
|
void MyListCtrl::SetColumnImage(int col, int image)
|
|
|
|
{
|
|
|
|
wxListItem item;
|
|
|
|
item.SetMask(wxLIST_MASK_IMAGE);
|
|
|
|
item.SetImage(image);
|
|
|
|
SetColumn(col, item);
|
|
|
|
}
|
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
void MyListCtrl::OnColClick(wxListEvent& event)
|
|
|
|
{
|
2001-09-02 19:47:42 -04:00
|
|
|
int col = event.GetColumn();
|
2005-08-28 09:27:08 -04:00
|
|
|
|
|
|
|
// set or unset image
|
2005-08-28 21:59:36 -04:00
|
|
|
static bool x = false;
|
2005-08-28 09:27:08 -04:00
|
|
|
x = !x;
|
|
|
|
SetColumnImage(col, x ? 0 : -1);
|
2001-09-02 19:47:42 -04:00
|
|
|
|
|
|
|
wxLogMessage( wxT("OnColumnClick at %d."), col );
|
1999-08-24 16:26:06 -04:00
|
|
|
}
|
|
|
|
|
2001-08-31 21:01:51 -04:00
|
|
|
void MyListCtrl::OnColRightClick(wxListEvent& event)
|
|
|
|
{
|
2001-09-02 19:47:42 -04:00
|
|
|
int col = event.GetColumn();
|
2002-03-11 07:32:56 -05:00
|
|
|
if ( col != -1 )
|
|
|
|
{
|
|
|
|
SetColumnImage(col, -1);
|
|
|
|
}
|
2001-09-02 19:47:42 -04:00
|
|
|
|
2004-09-03 10:35:45 -04:00
|
|
|
// Show popupmenu at position
|
|
|
|
wxMenu menu(wxT("Test"));
|
|
|
|
menu.Append(LIST_ABOUT, _T("&About"));
|
2005-08-23 11:54:39 -04:00
|
|
|
PopupMenu(&menu, event.GetPoint());
|
2004-09-03 10:35:45 -04:00
|
|
|
|
2001-08-31 21:01:51 -04:00
|
|
|
wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() );
|
|
|
|
}
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
void MyListCtrl::LogColEvent(const wxListEvent& event, const wxChar *name)
|
|
|
|
{
|
|
|
|
const int col = event.GetColumn();
|
|
|
|
|
|
|
|
wxLogMessage(wxT("%s: column %d (width = %d or %d)."),
|
|
|
|
name,
|
|
|
|
col,
|
|
|
|
event.GetItem().GetWidth(),
|
|
|
|
GetColumnWidth(col));
|
|
|
|
}
|
|
|
|
|
2001-08-31 21:01:51 -04:00
|
|
|
void MyListCtrl::OnColBeginDrag(wxListEvent& event)
|
|
|
|
{
|
2002-12-04 09:11:26 -05:00
|
|
|
LogColEvent( event, wxT("OnColBeginDrag") );
|
2003-03-17 08:24:45 -05:00
|
|
|
|
|
|
|
if ( event.GetColumn() == 0 )
|
|
|
|
{
|
|
|
|
wxLogMessage(_T("Resizing this column shouldn't work."));
|
|
|
|
|
|
|
|
event.Veto();
|
|
|
|
}
|
2001-08-31 21:01:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyListCtrl::OnColDragging(wxListEvent& event)
|
|
|
|
{
|
2002-12-04 09:11:26 -05:00
|
|
|
LogColEvent( event, wxT("OnColDragging") );
|
2001-08-31 21:01:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyListCtrl::OnColEndDrag(wxListEvent& event)
|
|
|
|
{
|
2002-12-04 09:11:26 -05:00
|
|
|
LogColEvent( event, wxT("OnColEndDrag") );
|
2001-08-31 21:01:51 -04:00
|
|
|
}
|
|
|
|
|
1999-08-16 08:18:40 -04:00
|
|
|
void MyListCtrl::OnBeginDrag(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-08-25 11:41:46 -04:00
|
|
|
const wxPoint& pt = event.m_pointDrag;
|
|
|
|
|
|
|
|
int flags;
|
|
|
|
wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."),
|
|
|
|
pt.x, pt.y, HitTest(pt, flags) );
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
1999-08-16 08:18:40 -04:00
|
|
|
void MyListCtrl::OnBeginRDrag(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-08-02 14:59:50 -04:00
|
|
|
wxLogMessage( wxT("OnBeginRDrag at %d,%d."),
|
2000-02-24 18:40:42 -05:00
|
|
|
event.m_pointDrag.x, event.m_pointDrag.y );
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
1999-08-16 08:18:40 -04:00
|
|
|
void MyListCtrl::OnBeginLabelEdit(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2001-08-02 14:59:50 -04:00
|
|
|
wxLogMessage( wxT("OnBeginLabelEdit: %s"), event.m_item.m_text.c_str());
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
1999-08-16 08:18:40 -04:00
|
|
|
void MyListCtrl::OnEndLabelEdit(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2003-10-07 05:06:58 -04:00
|
|
|
wxLogMessage( wxT("OnEndLabelEdit: %s"),
|
|
|
|
event.IsEditCancelled() ? _T("[cancelled]")
|
|
|
|
: event.m_item.m_text.c_str());
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-22 10:22:21 -05:00
|
|
|
void MyListCtrl::OnDeleteItem(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
LogEvent(event, _T("OnDeleteItem"));
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-24 18:40:42 -05:00
|
|
|
void MyListCtrl::OnDeleteAllItems(wxListEvent& event)
|
2000-02-06 08:51:01 -05:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
LogEvent(event, _T("OnDeleteAllItems"));
|
2000-02-06 08:51:01 -05:00
|
|
|
}
|
|
|
|
|
2004-09-30 15:13:38 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2_4
|
1999-08-16 08:18:40 -04:00
|
|
|
void MyListCtrl::OnGetInfo(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
wxString msg;
|
1999-07-23 19:41:45 -04:00
|
|
|
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T("OnGetInfo (") << event.m_item.m_itemId << _T(", ") << event.m_item.m_col << _T(")");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_STATE )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_MASK_STATE");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_TEXT )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_MASK_TEXT");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_IMAGE )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_MASK_IMAGE");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_DATA )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_MASK_DATA");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_SET_ITEM )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_SET_ITEM");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_WIDTH )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_MASK_WIDTH");
|
1999-07-23 19:41:45 -04:00
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_FORMAT )
|
2002-05-26 06:53:51 -04:00
|
|
|
msg << _T(" wxLIST_MASK_WIDTH");
|
1999-07-23 19:41:45 -04:00
|
|
|
|
|
|
|
if ( event.m_item.m_mask & wxLIST_MASK_TEXT )
|
|
|
|
{
|
2002-05-26 06:53:51 -04:00
|
|
|
event.m_item.m_text = _T("My callback text");
|
1999-07-23 19:41:45 -04:00
|
|
|
}
|
2000-02-24 18:40:42 -05:00
|
|
|
|
|
|
|
wxLogMessage(msg);
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-22 10:22:21 -05:00
|
|
|
void MyListCtrl::OnSetInfo(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
LogEvent(event, _T("OnSetInfo"));
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
2004-09-30 15:13:38 -04:00
|
|
|
#endif
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1999-09-29 18:47:56 -04:00
|
|
|
void MyListCtrl::OnSelected(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
LogEvent(event, _T("OnSelected"));
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1999-11-16 11:59:10 -05:00
|
|
|
if ( GetWindowStyle() & wxLC_REPORT )
|
1999-09-29 18:47:56 -04:00
|
|
|
{
|
1999-11-16 11:59:10 -05:00
|
|
|
wxListItem info;
|
|
|
|
info.m_itemId = event.m_itemIndex;
|
|
|
|
info.m_col = 1;
|
|
|
|
info.m_mask = wxLIST_MASK_TEXT;
|
|
|
|
if ( GetItem(info) )
|
|
|
|
{
|
2001-08-02 14:59:50 -04:00
|
|
|
wxLogMessage(wxT("Value of the 2nd field of the selected item: %s"),
|
2000-02-24 18:40:42 -05:00
|
|
|
info.m_text.c_str());
|
1999-11-16 11:59:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-02 14:59:50 -04:00
|
|
|
wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
|
1999-11-16 11:59:10 -05:00
|
|
|
}
|
1999-09-29 18:47:56 -04:00
|
|
|
}
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-22 10:22:21 -05:00
|
|
|
void MyListCtrl::OnDeselected(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
LogEvent(event, _T("OnDeselected"));
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-22 10:22:21 -05:00
|
|
|
void MyListCtrl::OnActivated(wxListEvent& event)
|
1998-12-16 03:06:02 -05:00
|
|
|
{
|
2000-02-24 18:40:42 -05:00
|
|
|
LogEvent(event, _T("OnActivated"));
|
1998-12-16 03:06:02 -05:00
|
|
|
}
|
|
|
|
|
2001-11-16 11:31:17 -05:00
|
|
|
void MyListCtrl::OnFocused(wxListEvent& event)
|
|
|
|
{
|
|
|
|
LogEvent(event, _T("OnFocused"));
|
2002-08-27 05:38:11 -04:00
|
|
|
|
|
|
|
event.Skip();
|
2001-11-16 11:31:17 -05:00
|
|
|
}
|
|
|
|
|
1999-05-14 10:44:03 -04:00
|
|
|
void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2005-07-02 18:14:52 -04:00
|
|
|
long item;
|
|
|
|
|
2002-09-10 21:08:02 -04:00
|
|
|
switch ( event.GetKeyCode() )
|
2001-07-09 11:58:24 -04:00
|
|
|
{
|
2001-11-20 19:43:54 -05:00
|
|
|
case 'c': // colorize
|
|
|
|
case 'C':
|
2001-07-11 12:22:12 -04:00
|
|
|
{
|
|
|
|
wxListItem info;
|
|
|
|
info.m_itemId = event.GetIndex();
|
|
|
|
GetItem(info);
|
|
|
|
|
|
|
|
wxListItemAttr *attr = info.GetAttributes();
|
|
|
|
if ( !attr || !attr->HasTextColour() )
|
|
|
|
{
|
|
|
|
info.SetTextColour(*wxCYAN);
|
|
|
|
|
|
|
|
SetItem(info);
|
2001-11-20 19:43:54 -05:00
|
|
|
|
|
|
|
RefreshItem(info.m_itemId);
|
2001-07-11 12:22:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-11-20 19:43:54 -05:00
|
|
|
case 'n': // next
|
|
|
|
case 'N':
|
2005-07-02 18:14:52 -04:00
|
|
|
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
|
|
|
|
if ( item++ == GetItemCount() - 1 )
|
|
|
|
{
|
|
|
|
item = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxLogMessage(_T("Focusing item %ld"), item);
|
|
|
|
|
|
|
|
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
|
|
|
EnsureVisible(item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'r': // show bounding Rect
|
|
|
|
case 'R':
|
2001-11-20 19:43:54 -05:00
|
|
|
{
|
2005-07-02 18:14:52 -04:00
|
|
|
item = event.GetIndex();
|
|
|
|
wxRect r;
|
|
|
|
if ( !GetItemRect(item, r) )
|
2001-11-20 19:43:54 -05:00
|
|
|
{
|
2005-07-02 18:14:52 -04:00
|
|
|
wxLogError(_T("Failed to retrieve rect of item %ld"), item);
|
|
|
|
break;
|
2001-11-20 19:43:54 -05:00
|
|
|
}
|
|
|
|
|
2005-07-02 18:14:52 -04:00
|
|
|
wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
|
|
|
|
item, r.x, r.y, r.x + r.width, r.y + r.height);
|
2001-11-20 19:43:54 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-07-09 11:58:24 -04:00
|
|
|
case WXK_DELETE:
|
2005-07-02 18:14:52 -04:00
|
|
|
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
|
|
|
while ( item != -1 )
|
2001-07-23 10:57:01 -04:00
|
|
|
{
|
2005-07-02 18:14:52 -04:00
|
|
|
DeleteItem(item);
|
2001-07-23 10:57:01 -04:00
|
|
|
|
2005-07-02 18:14:52 -04:00
|
|
|
wxLogMessage(_T("Item %ld deleted"), item);
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2005-07-02 18:14:52 -04:00
|
|
|
// -1 because the indices were shifted by DeleteItem()
|
|
|
|
item = GetNextItem(item - 1,
|
|
|
|
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
2001-07-23 10:57:01 -04:00
|
|
|
}
|
2001-07-09 11:58:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_INSERT:
|
|
|
|
if ( GetWindowStyle() & wxLC_REPORT )
|
|
|
|
{
|
|
|
|
if ( GetWindowStyle() & wxLC_VIRTUAL )
|
|
|
|
{
|
|
|
|
SetItemCount(GetItemCount() + 1);
|
|
|
|
}
|
|
|
|
else // !virtual
|
|
|
|
{
|
|
|
|
InsertItemInReportView(event.GetIndex());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//else: fall through
|
|
|
|
|
|
|
|
default:
|
|
|
|
LogEvent(event, _T("OnListKeyDown"));
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
2000-07-15 15:51:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyListCtrl::OnChar(wxKeyEvent& event)
|
|
|
|
{
|
|
|
|
wxLogMessage(_T("Got char event."));
|
|
|
|
|
2001-11-20 19:43:54 -05:00
|
|
|
switch ( event.GetKeyCode() )
|
|
|
|
{
|
|
|
|
case 'n':
|
|
|
|
case 'N':
|
|
|
|
case 'c':
|
|
|
|
case 'C':
|
|
|
|
// these are the keys we process ourselves
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
event.Skip();
|
|
|
|
}
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2000-02-24 18:40:42 -05:00
|
|
|
void MyListCtrl::LogEvent(const wxListEvent& event, const wxChar *eventName)
|
|
|
|
{
|
2000-07-15 15:51:35 -04:00
|
|
|
wxLogMessage(_T("Item %ld: %s (item text = %s, data = %ld)"),
|
|
|
|
event.GetIndex(), eventName,
|
|
|
|
event.GetText().c_str(), event.GetData());
|
2000-02-24 18:40:42 -05:00
|
|
|
}
|
1998-12-16 03:06:02 -05:00
|
|
|
|
2001-07-04 21:27:38 -04:00
|
|
|
wxString MyListCtrl::OnGetItemText(long item, long column) const
|
|
|
|
{
|
2005-05-22 17:31:42 -04:00
|
|
|
if ( GetItemCount() == WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS) )
|
|
|
|
{
|
|
|
|
return SMALL_VIRTUAL_VIEW_ITEMS[item][column];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wxString::Format(_T("Column %ld of item %ld"), column, item);
|
|
|
|
}
|
2001-07-04 21:27:38 -04:00
|
|
|
}
|
|
|
|
|
2003-07-26 13:34:12 -04:00
|
|
|
int MyListCtrl::OnGetItemImage(long WXUNUSED(item)) const
|
2001-07-04 21:27:38 -04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-07-11 12:22:12 -04:00
|
|
|
wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const
|
|
|
|
{
|
|
|
|
return item % 2 ? NULL : (wxListItemAttr *)&m_attr;
|
|
|
|
}
|
|
|
|
|
2001-07-09 11:58:24 -04:00
|
|
|
void MyListCtrl::InsertItemInReportView(int i)
|
|
|
|
{
|
|
|
|
wxString buf;
|
|
|
|
buf.Printf(_T("This is item %d"), i);
|
|
|
|
long tmp = InsertItem(i, buf, 0);
|
|
|
|
SetItemData(tmp, i);
|
|
|
|
|
|
|
|
buf.Printf(_T("Col 1, item %d"), i);
|
|
|
|
SetItem(i, 1, buf);
|
|
|
|
|
|
|
|
buf.Printf(_T("Item %d in column 2"), i);
|
|
|
|
SetItem(i, 2, buf);
|
|
|
|
}
|