// 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".
#include "wx/wx.h"
#endif
-#if !defined(__WXMSW__) && !defined(__WXPM__)
- #include "mondrian.xpm"
+#ifndef wxHAS_IMAGES_IN_RESOURCES
+ #include "../sample.xpm"
#endif
-#ifndef __WXMSW__
+#ifndef wxHAS_IMAGES_IN_RESOURCES
#include "bitmaps/toolbrai.xpm"
#include "bitmaps/toolchar.xpm"
#include "bitmaps/tooldata.xpm"
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;
}
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);
m_imageListSmall = new wxImageList(16, 16, true);
-#ifdef __WXMSW__
+#ifdef wxHAS_IMAGES_IN_RESOURCES
m_imageListNormal->Add( wxIcon(wxT("icon1"), wxBITMAP_TYPE_ICO_RESOURCE) );
m_imageListNormal->Add( wxIcon(wxT("icon2"), wxBITMAP_TYPE_ICO_RESOURCE) );
m_imageListNormal->Add( wxIcon(wxT("icon3"), wxBITMAP_TYPE_ICO_RESOURCE) );
#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
if ( withText )
{
- m_listCtrl->InsertItem(i, wxString::Format(wxT("Label %d"), i),
- image);
+ // Make labels of different widths to test the layout.
+ wxString label;
+ if ( !(i % 5) )
+ label.Printf("Longer label %d", i);
+ else
+ label.Printf("Label %d", i);
+
+ m_listCtrl->InsertItem(i, label, image);
}
else
{
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
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
+ 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"));
+ }
}
}