]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/listctrl.cpp
Added missing not operator that was preventing the drawing of the
[wxWidgets.git] / src / msw / listctrl.cpp
... / ...
Content-type: text/html ]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/listctrl.cpp


500 - Internal Server Error

Malformed UTF-8 character (fatal) at /usr/lib/x86_64-linux-gnu/perl5/5.40/HTML/Entities.pm line 485, <$fd> line 312.
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/listctrl.cpp
3// Purpose: wxListCtrl
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#if wxUSE_LISTCTRL
28
29#ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #include "wx/intl.h"
32 #include "wx/log.h"
33 #include "wx/settings.h"
34#endif
35
36#include "wx/textctrl.h"
37#include "wx/imaglist.h"
38#include "wx/listctrl.h"
39#include "wx/dcclient.h"
40
41#include "wx/msw/private.h"
42
43#if defined(__WXWINCE__) && !defined(__HANDHELDPC__)
44 #include <ole2.h>
45 #include <shellapi.h>
46 #if _WIN32_WCE < 400
47 #include <aygshell.h>
48 #endif
49#endif
50
51// include <commctrl.h> "properly"
52#include "wx/msw/wrapcctl.h"
53
54// Currently gcc and watcom don't define NMLVFINDITEM, and DMC only defines
55// it by its old name NM_FINDTIEM.
56//
57#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(NMLVFINDITEM)
58 #define HAVE_NMLVFINDITEM 1
59#elif defined(__DMC__) || defined(NM_FINDITEM)
60 #define HAVE_NMLVFINDITEM 1
61 #define NMLVFINDITEM NM_FINDITEM
62#endif
63
64// ----------------------------------------------------------------------------
65// private functions
66// ----------------------------------------------------------------------------
67
68// convert our state and mask flags to LV_ITEM constants
69static void wxConvertToMSWFlags(long state, long mask, LV_ITEM& lvItem);
70
71// convert wxListItem to LV_ITEM
72static void wxConvertToMSWListItem(const wxListCtrl *ctrl,
73 const wxListItem& info, LV_ITEM& lvItem);
74
75// convert LV_ITEM to wxListItem
76static void wxConvertFromMSWListItem(HWND hwndListCtrl,
77 wxListItem& info,
78 /* const */ LV_ITEM& lvItem);
79
80// convert our wxListItem to LV_COLUMN
81static void wxConvertToMSWListCol(HWND hwndList,
82 int col,
83 const wxListItem& item,
84 LV_COLUMN& lvCol);
85
86// ----------------------------------------------------------------------------
87// private helper classes
88// ----------------------------------------------------------------------------
89
90// We have to handle both fooW and fooA notifications in several cases
91// because of broken comctl32.dll and/or unicows.dll. This class is used to
92// convert LV_ITEMA and LV_ITEMW to LV_ITEM (which is either LV_ITEMA or
93// LV_ITEMW depending on wxUSE_UNICODE setting), so that it can be processed
94// by wxConvertToMSWListItem().
95#if wxUSE_UNICODE
96 #define LV_ITEM_NATIVE LV_ITEMW
97 #define LV_ITEM_OTHER LV_ITEMA
98
99 #define LV_CONV_TO_WX cMB2WX
100 #define LV_CONV_BUF wxMB2WXbuf
101#else // ANSI
102 #define LV_ITEM_NATIVE LV_ITEMA
103 #define LV_ITEM_OTHER LV_ITEMW
104
105 #define LV_CONV_TO_WX cWC2WX
106 #define LV_CONV_BUF wxWC2WXbuf
107#endif // Unicode/ANSI
108
109class wxLV_ITEM
110{
111public:
112 // default ctor, use Init() later
113 wxLV_ITEM() { m_buf = NULL; m_pItem = NULL; }
114
115 // init without conversion
116 void Init(LV_ITEM_NATIVE& item)
117 {
118 wxASSERT_MSG( !m_pItem, _T("Init() called twice?") );
119
120 m_pItem = &item;
121 }
122
123 // init with conversion
124 void Init(const LV_ITEM_OTHER& item)
125 {
126 // avoid unnecessary dynamic memory allocation, jjust make m_pItem
127 // point to our own m_item
128
129 // memcpy() can't work if the struct sizes are different
130 wxCOMPILE_TIME_ASSERT( sizeof(LV_ITEM_OTHER) == sizeof(LV_ITEM_NATIVE),
131 CodeCantWorkIfDiffSizes);
132
133 memcpy(&m_item, &item, sizeof(LV_ITEM_NATIVE));
134
135 // convert text from ANSI to Unicod if necessary
136 if ( (item.mask & LVIF_TEXT) && item.pszText )
137 {
138 m_buf = new LV_CONV_BUF(wxConvLocal.LV_CONV_TO_WX(item.pszText));
139 m_item.pszText = (wxChar *)m_buf->data();
140 }
141 }
142
143 // ctor without conversion
144 wxLV_ITEM(LV_ITEM_NATIVE& item) : m_buf(NULL), m_pItem(&item) { }
145
146 // ctor with conversion
147 wxLV_ITEM(LV_ITEM_OTHER& item) : m_buf(NULL)
148 {
149 Init(item);
150 }
151
152 ~wxLV_ITEM() { delete m_buf; }
153
154 // conversion to the real LV_ITEM
155 operator LV_ITEM_NATIVE&() const { return *m_pItem; }
156
157private:
158 LV_CONV_BUF *m_buf;
159
160 LV_ITEM_NATIVE *m_pItem;
161 LV_ITEM_NATIVE m_item;
162
163 DECLARE_NO_COPY_CLASS(wxLV_ITEM)
164};
165
166///////////////////////////////////////////////////////
167// Problem:
168// The MSW version had problems with SetTextColour() et
169// al as the wxListItemAttr's were stored keyed on the
170// item index. If a item was inserted anywhere but the end
171// of the list the the text attributes (colour etc) for
172// the following items were out of sync.
173//
174// Solution:
175// Under MSW the only way to associate data with a List
176// item independent of its position in the list is to
177// store a pointer to it in its lParam attribute. However
178// user programs are already using this (via the
179// SetItemData() GetItemData() calls).
180//
181// However what we can do is store a pointer to a
182// structure which contains the attributes we want *and*
183// a lParam for the users data, e.g.
184//
185// class wxListItemInternalData
186// {
187// public:
188// wxListItemAttr *attr;
189// long lParam; // user data
190// };
191//
192// To conserve memory, a wxListItemInternalData is
193// only allocated for a LV_ITEM if text attributes or
194// user data(lparam) are being set.
195
196
197// class wxListItemInternalData
198class wxListItemInternalData
199{
200public:
201 wxListItemAttr *attr;
202 LPARAM lParam; // user data
203
204 wxListItemInternalData() : attr(NULL), lParam(0) {}
205 ~wxListItemInternalData()
206 {
207 if (attr)
208 delete attr;
209 };
210
211 DECLARE_NO_COPY_CLASS(wxListItemInternalData)
212};
213
214// Get the internal data structure
215static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId);
216static wxListItemInternalData *wxGetInternalData(const wxListCtrl *ctl, long itemId);
217static wxListItemAttr *wxGetInternalDataAttr(const wxListCtrl *ctl, long itemId);
218static void wxDeleteInternalData(wxListCtrl* ctl, long itemId);
219
220
221// ----------------------------------------------------------------------------
222// events
223// ----------------------------------------------------------------------------
224
225DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
226DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
227DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
228DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
229DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
230DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
231#if WXWIN_COMPATIBILITY_2_4
232DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
233DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
234#endif
235DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
236DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
237DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
238DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
239DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
240DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
241DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
242DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
243DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
244DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
245DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
246DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
247DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
248DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
249
250#if wxUSE_EXTENDED_RTTI
251WX_DEFINE_FLAGS( wxListCtrlStyle )
252
253wxBEGIN_FLAGS( wxListCtrlStyle )
254 // new style border flags, we put them first to
255 // use them for streaming out
256 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
257 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
258 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
259 wxFLAGS_MEMBER(wxBORDER_RAISED)
260 wxFLAGS_MEMBER(wxBORDER_STATIC)
261 wxFLAGS_MEMBER(wxBORDER_NONE)
262
263 // old style border flags
264 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
265 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
266 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
267 wxFLAGS_MEMBER(wxRAISED_BORDER)
268 wxFLAGS_MEMBER(wxSTATIC_BORDER)
269 wxFLAGS_MEMBER(wxBORDER)
270
271 // standard window styles
272 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
273 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
274 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
275 wxFLAGS_MEMBER(wxWANTS_CHARS)
276 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
277 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
278 wxFLAGS_MEMBER(wxVSCROLL)
279 wxFLAGS_MEMBER(wxHSCROLL)
280
281 wxFLAGS_MEMBER(wxLC_LIST)
282 wxFLAGS_MEMBER(wxLC_REPORT)
283 wxFLAGS_MEMBER(wxLC_ICON)
284 wxFLAGS_MEMBER(wxLC_SMALL_ICON)
285 wxFLAGS_MEMBER(wxLC_ALIGN_TOP)
286 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT)
287 wxFLAGS_MEMBER(wxLC_AUTOARRANGE)
288 wxFLAGS_MEMBER(wxLC_USER_TEXT)
289 wxFLAGS_MEMBER(wxLC_EDIT_LABELS)
290 wxFLAGS_MEMBER(wxLC_NO_HEADER)
291 wxFLAGS_MEMBER(wxLC_SINGLE_SEL)
292 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING)
293 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING)
294 wxFLAGS_MEMBER(wxLC_VIRTUAL)
295
296wxEND_FLAGS( wxListCtrlStyle )
297
298IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl, wxControl,"wx/listctrl.h")
299
300wxBEGIN_PROPERTIES_TABLE(wxListCtrl)
301 wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
302
303 wxPROPERTY_FLAGS( WindowStyle , wxListCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
304wxEND_PROPERTIES_TABLE()
305
306wxBEGIN_HANDLERS_TABLE(wxListCtrl)
307wxEND_HANDLERS_TABLE()
308
309wxCONSTRUCTOR_5( wxListCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle )
310
311/*
312