// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#endif
#if !defined(__WXMSW__) && !defined(__WXPM__)
- #include "mondrian.xpm"
+ #include "../sample.xpm"
#endif
#ifndef __WXMSW__
static const int NUM_ICONS = 9;
int wxCALLBACK
-MyCompareFunction(long item1, long item2, wxIntPtr WXUNUSED(sortData))
+MyCompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr WXUNUSED(sortData))
{
// inverse the order
if (item1 < item2)
- return -1;
- if (item1 > item2)
return 1;
+ if (item1 > item2)
+ return -1;
return 0;
}
// Show the frame
frame->Show(true);
- SetTopWindow(frame);
-
return true;
}
EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
+ EVT_MENU(LIST_TOGGLE_HEADER, MyFrame::OnToggleHeader)
#ifdef __WXOSX__
EVT_MENU(LIST_MAC_USE_GENERIC, MyFrame::OnToggleMacUseGeneric)
#endif // __WXOSX__
EVT_MENU(LIST_FIND, MyFrame::OnFind)
- EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
+ EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateUIEnableInReport)
+ EVT_UPDATE_UI(LIST_TOGGLE_HEADER, MyFrame::OnUpdateUIEnableInReport)
+
EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
+ EVT_UPDATE_UI(LIST_TOGGLE_HEADER, MyFrame::OnUpdateToggleHeader)
END_EVENT_TABLE()
// My frame constructor
m_numListItems = 10;
// Give it an icon
- SetIcon( wxICON(mondrian) );
+ SetIcon(wxICON(sample));
// Make an image list containing large icons
m_imageListNormal = new wxImageList(32, 32, true);
menuList->Append(LIST_THAW, wxT("Tha&w\tCtrl-W"));
menuList->AppendSeparator();
menuList->AppendCheckItem(LIST_TOGGLE_LINES, wxT("Toggle &lines\tCtrl-I"));
- menuList->Append(LIST_TOGGLE_MULTI_SEL, wxT("&Multiple selection\tCtrl-M"),
- wxT("Toggle multiple selection"), true);
+ menuList->AppendCheckItem(LIST_TOGGLE_MULTI_SEL,
+ wxT("&Multiple selection\tCtrl-M"));
+ menuList->Check(LIST_TOGGLE_MULTI_SEL, true);
+ menuList->AppendCheckItem(LIST_TOGGLE_HEADER, "Toggle &header\tCtrl-H");
+ menuList->Check(LIST_TOGGLE_HEADER, true);
wxMenu *menuCol = new wxMenu;
menuCol->Append(LIST_SET_FG_COL, wxT("&Foreground colour..."));
#ifdef __WXMSW__
// this is useful to know specially when debugging :)
- wxLogMessage("Your version of comctl32.dll is: %d",
+ wxLogMessage("Your version of comctl32.dll is: %d",
wxApp::GetComCtl32Version());
#endif
m_listCtrl->SetSingleStyle(wxLC_HRULES | wxLC_VRULES, event.IsChecked());
}
+void MyFrame::OnToggleHeader(wxCommandEvent& event)
+{
+ wxLogMessage("%s the header", event.IsChecked() ? "Showing" : "Hiding");
+
+ m_listCtrl->ToggleWindowStyle(wxLC_NO_HEADER);
+}
+
#ifdef __WXOSX__
void MyFrame::OnToggleMacUseGeneric(wxCommandEvent& event)
}
}
-void MyFrame::OnUpdateShowColInfo(wxUpdateUIEvent& event)
+void MyFrame::OnUpdateUIEnableInReport(wxUpdateUIEvent& event)
{
event.Enable( (m_listCtrl->GetWindowStyleFlag() & wxLC_REPORT) != 0 );
}
void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent& event)
{
- event.Check((m_listCtrl->GetWindowStyleFlag() & wxLC_SINGLE_SEL) == 0);
+ event.Check(!m_listCtrl->HasFlag(wxLC_SINGLE_SEL));
+}
+
+void MyFrame::OnUpdateToggleHeader(wxUpdateUIEvent& event)
+{
+ event.Check(!m_listCtrl->HasFlag(wxLC_NO_HEADER));
}
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnEdit(wxCommandEvent& WXUNUSED(event))
{
- long itemCur = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
- wxLIST_STATE_FOCUSED);
-
- if ( itemCur != -1 )
+ // demonstrate cancelling editing: this currently is wxMSW-only
+#ifdef __WXMSW__
+ if ( m_listCtrl->GetEditControl() )
{
- m_listCtrl->EditLabel(itemCur);
+ m_listCtrl->EndEditLabel(true);
}
- else
+ else // start editing
+#endif // __WXMSW__
{
- m_logWindow->WriteText(wxT("No item to edit"));
+ long itemCur = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
+ wxLIST_STATE_FOCUSED);
+
+ if ( itemCur != -1 )
+ {
+ m_listCtrl->EditLabel(itemCur);
+ }
+ else
+ {
+ m_logWindow->WriteText(wxT("No item to edit"));
+ }
}
}