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