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