2 #----------------------------------------------------------------------------
4 # Purpose: Testing lots of stuff, controls, window types, etc.
6 # Author: Robin Dunn & Gary Dumer
10 # Copyright: (c) 1998 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------------
14 from wxPython
.wx
import *
16 #---------------------------------------------------------------------------
18 class TestListCtrlPanel(wxPanel
):
19 def __init__(self
, parent
, log
):
20 wxPanel
.__init
__(self
, parent
, -1)
25 self
.il
= wxImageList(16, 16)
26 idx1
= self
.il
.Add(wxNoRefBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP
))
28 self
.list = wxListCtrl(self
, tID
, wxDefaultPosition
, wxDefaultSize
,
29 wxLC_REPORT|wxSUNKEN_BORDER
)
30 self
.list.SetImageList(self
.il
, wxIMAGE_LIST_SMALL
)
32 self
.list.SetToolTip(wxToolTip("This is a ToolTip!"))
33 wxToolTip_Enable(true
)
35 self
.list.InsertColumn(0, "Column 0")
36 self
.list.InsertColumn(1, "Column 1")
37 self
.list.InsertColumn(2, "One More Column (2)")
39 self
.list.InsertImageStringItem(x
, "This is item %d" % x
, idx1
)
40 self
.list.SetStringItem(x
, 1, "Col 1, item %d" % x
)
41 self
.list.SetStringItem(x
, 2, "item %d in column 2" % x
)
43 self
.list.SetColumnWidth(0, wxLIST_AUTOSIZE
)
44 self
.list.SetColumnWidth(1, wxLIST_AUTOSIZE
)
45 self
.list.SetColumnWidth(2, wxLIST_AUTOSIZE
)
47 self
.list.SetItemState(5, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
)
50 EVT_LIST_ITEM_SELECTED(self
, tID
, self
.OnItemSelected
)
51 EVT_LEFT_DCLICK(self
.list, self
.OnDoubleClick
)
52 EVT_RIGHT_DOWN(self
.list, self
.OnRightDown
)
55 EVT_COMMAND_RIGHT_CLICK(self
.list, tID
, self
.OnRightClick
)
58 EVT_RIGHT_UP(self
.list, self
.OnRightClick
)
61 def OnRightDown(self
, event
):
64 self
.log
.WriteText("x, y = %s\n" % str((self
.x
, self
.y
)))
67 def OnItemSelected(self
, event
):
68 self
.currentItem
= event
.m_itemIndex
69 self
.log
.WriteText("OnItemSelected: %s\n" % self
.list.GetItemText(self
.currentItem
))
71 def OnDoubleClick(self
, event
):
72 self
.log
.WriteText("OnDoubleClick item %s\n" % self
.list.GetItemText(self
.currentItem
))
75 def OnRightClick(self
, event
):
76 self
.log
.WriteText("OnRightClick %s\n" % self
.list.GetItemText(self
.currentItem
))
81 self
.menu
.Append(tPopupID1
, "One")
82 self
.menu
.Append(tPopupID2
, "Two")
83 self
.menu
.Append(tPopupID3
, "Three")
84 EVT_MENU(self
, tPopupID1
, self
.OnPopupOne
)
85 EVT_MENU(self
, tPopupID2
, self
.OnPopupTwo
)
86 EVT_MENU(self
, tPopupID3
, self
.OnPopupThree
)
87 self
.PopupMenu(self
.menu
, self
.x
, self
.y
)
89 def OnPopupOne(self
, event
):
90 self
.log
.WriteText("Popup one\n")
92 def OnPopupTwo(self
, event
):
93 self
.log
.WriteText("Popup two\n")
95 def OnPopupThree(self
, event
):
96 self
.log
.WriteText("Popup three\n")
98 def OnSize(self
, event
):
99 w
,h
= self
.GetClientSizeTuple()
100 self
.list.SetDimensions(0, 0, w
, h
)
107 #---------------------------------------------------------------------------
109 def runTest(frame
, nb
, log
):
110 win
= TestListCtrlPanel(nb
, log
)
113 #---------------------------------------------------------------------------
131 A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
134 ------------------------
138 wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
140 Constructor, creating and showing a list control.
145 parent = Parent window. Must not be NULL.
147 id = Window identifier. A value of -1 indicates a default value.
149 pos = Window position.
151 size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
153 style = Window style. See wxListCtrl.
155 validator = Window validator.