]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/listctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl. See also Robert's generic wxListCtrl
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/listctrl.h"
22 #include "wx/os2/private.h"
24 // TODO: not sure if we will need these
26 static void wxConvertToOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem);
27 static void wxConvertFromOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem, HWND getFullInfo = 0);
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
32 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
35 wxListCtrl::wxListCtrl()
37 m_imageListNormal
= NULL
;
38 m_imageListSmall
= NULL
;
39 m_imageListState
= NULL
;
45 bool wxListCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
46 long style
, const wxValidator
& validator
, const wxString
& name
)
48 m_imageListNormal
= NULL
;
49 m_imageListSmall
= NULL
;
50 m_imageListState
= NULL
;
53 SetValidator(validator
);
61 m_windowStyle
= style
;
65 m_windowId
= (id
== -1) ? NewControlId() : id
;
67 if (parent
) parent
->AddChild(this);
69 // TODO create list control
70 // DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP |
71 // LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS;
72 // if ( wxStyleHasBorder(m_windowStyle) )
73 // wstyle |= WS_BORDER;
74 // m_baseStyle = wstyle;
76 // if ( !DoCreateControl(x, y, width, height) )
80 // parent->AddChild(this);
84 bool wxListCtrl::DoCreateControl(int x
, int y
, int w
, int h
)
86 DWORD wstyle
= m_baseStyle
;
90 // WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
92 // Even with extended styles, need to combine with WS_BORDER
93 // for them to look right.
95 // wstyle |= WS_BORDER;
97 // long oldStyle = 0; // Dummy
98 // wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);
100 // Create the ListView control.
101 // m_hWnd = (WXHWND)CreateWindowEx(exStyle,
106 // GetWinHwnd(GetParent()),
107 // (HMENU)m_windowId,
113 // wxLogError(wxT("Can't create list control window."));
118 // for comctl32.dll v 4.70+ we want to have this attribute because it's
119 // prettier (and also because wxGTK does it like this)
120 #ifdef ListView_SetExtendedListViewStyle
121 // if ( wstyle & LVS_REPORT )
123 // ListView_SetExtendedListViewStyle(GetHwnd(),
124 // LVS_EX_FULLROWSELECT);
126 #endif // ListView_SetExtendedListViewStyle
128 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
));
129 SetForegroundColour(GetParent()->GetForegroundColour());
131 // SubclassWin(m_hWnd);
136 void wxListCtrl::UpdateStyle()
141 // The new window view style
143 DWORD dwStyleNew = ConvertToMSWStyle(dummy, m_windowStyle);
144 dwStyleNew |= m_baseStyle;
146 // Get the current window style.
147 DWORD dwStyleOld = ::GetWindowLong(GetHwnd(), GWL_STYLE);
149 // Only set the window style if the view bits have changed.
150 if ( dwStyleOld != dwStyleNew )
152 ::SetWindowLong(GetHwnd(), GWL_STYLE, dwStyleNew);
157 wxListCtrl::~wxListCtrl()
161 m_textCtrl
->UnsubclassWin();
162 m_textCtrl
->SetHWND(0);
168 // Add or remove a single window style
169 void wxListCtrl::SetSingleStyle(long style
, bool add
)
171 long flag
= GetWindowStyleFlag();
173 // Get rid of conflicting styles
176 if ( style
& wxLC_MASK_TYPE
)
177 flag
= flag
& ~wxLC_MASK_TYPE
;
178 if ( style
& wxLC_MASK_ALIGN
)
179 flag
= flag
& ~wxLC_MASK_ALIGN
;
180 if ( style
& wxLC_MASK_SORT
)
181 flag
= flag
& ~wxLC_MASK_SORT
;
197 m_windowStyle
= flag
;
202 // Set the whole window style
203 void wxListCtrl::SetWindowStyleFlag(long flag
)
205 m_windowStyle
= flag
;
210 // Can be just a single style, or a bitlist
211 long wxListCtrl::ConvertToOS2Style(long& oldStyle
, long style
) const
215 if ( style & wxLC_ICON )
217 if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
218 oldStyle -= LVS_SMALLICON;
219 if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
220 oldStyle -= LVS_REPORT;
221 if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
222 oldStyle -= LVS_LIST;
226 if ( style & wxLC_SMALL_ICON )
228 if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
229 oldStyle -= LVS_ICON;
230 if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
231 oldStyle -= LVS_REPORT;
232 if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
233 oldStyle -= LVS_LIST;
234 wstyle |= LVS_SMALLICON;
237 if ( style & wxLC_LIST )
239 if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
240 oldStyle -= LVS_ICON;
241 if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
242 oldStyle -= LVS_REPORT;
243 if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
244 oldStyle -= LVS_SMALLICON;
248 if ( style & wxLC_REPORT )
250 if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
251 oldStyle -= LVS_ICON;
252 if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
253 oldStyle -= LVS_LIST;
254 if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
255 oldStyle -= LVS_SMALLICON;
257 wstyle |= LVS_REPORT;
260 if ( style & wxLC_ALIGN_LEFT )
262 if ( oldStyle & LVS_ALIGNTOP )
263 oldStyle -= LVS_ALIGNTOP;
264 wstyle |= LVS_ALIGNLEFT;
267 if ( style & wxLC_ALIGN_TOP )
269 if ( oldStyle & LVS_ALIGNLEFT )
270 oldStyle -= LVS_ALIGNLEFT;
271 wstyle |= LVS_ALIGNTOP;
274 if ( style & wxLC_AUTOARRANGE )
275 wstyle |= LVS_AUTOARRANGE;
277 // Apparently, no such style (documentation wrong?)
278 // if ( style & wxLC_BUTTON )
279 // wstyle |= LVS_BUTTON;
281 if ( style & wxLC_NO_SORT_HEADER )
282 wstyle |= LVS_NOSORTHEADER;
284 if ( style & wxLC_NO_HEADER )
285 wstyle |= LVS_NOCOLUMNHEADER;
287 if ( style & wxLC_EDIT_LABELS )
288 wstyle |= LVS_EDITLABELS;
290 if ( style & wxLC_SINGLE_SEL )
291 wstyle |= LVS_SINGLESEL;
293 if ( style & wxLC_SORT_ASCENDING )
295 if ( oldStyle & LVS_SORTDESCENDING )
296 oldStyle -= LVS_SORTDESCENDING;
297 wstyle |= LVS_SORTASCENDING;
300 if ( style & wxLC_SORT_DESCENDING )
302 if ( oldStyle & LVS_SORTASCENDING )
303 oldStyle -= LVS_SORTASCENDING;
304 wstyle |= LVS_SORTDESCENDING;
310 // Sets the background colour (GetBackgroundColour already implicit in
312 bool wxListCtrl::SetBackgroundColour(const wxColour
& col
)
314 if ( !wxWindow::SetBackgroundColour(col
) )
317 // ListView_SetBkColor(GetHwnd(), PALETTERGB(col.Red(), col.Green(), col.Blue()));
322 // Gets information about this column
323 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
329 // Sets information about this column
330 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
336 // Gets the column width
337 int wxListCtrl::GetColumnWidth(int col
) const
343 // Sets the column width
344 bool wxListCtrl::SetColumnWidth(int col
, int width
)
350 // Gets the number of items that can fit vertically in the
351 // visible area of the list control (list or report view)
352 // or the total number of items in the list control (icon
353 // or small icon view)
354 int wxListCtrl::GetCountPerPage() const
360 // Gets the edit control for editing labels.
361 wxTextCtrl
* wxListCtrl::GetEditControl() const
366 // Gets information about the item
367 bool wxListCtrl::GetItem(wxListItem
& info
) const
373 // Sets information about the item
374 bool wxListCtrl::SetItem(wxListItem
& info
)
380 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
384 info
.m_mask
= wxLIST_MASK_TEXT
;
385 info
.m_itemId
= index
;
389 info
.m_image
= imageId
;
390 info
.m_mask
|= wxLIST_MASK_IMAGE
;
392 return SetItem(info
);
396 // Gets the item state
397 int wxListCtrl::GetItemState(long item
, long stateMask
) const
401 info
.m_mask
= wxLIST_MASK_STATE
;
402 info
.m_stateMask
= stateMask
;
403 info
.m_itemId
= item
;
411 // Sets the item state
412 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
416 info
.m_mask
= wxLIST_MASK_STATE
;
417 info
.m_state
= state
;
418 info
.m_stateMask
= stateMask
;
419 info
.m_itemId
= item
;
421 return SetItem(info
);
424 // Sets the item image
425 bool wxListCtrl::SetItemImage(long item
, int image
, int selImage
)
429 info
.m_mask
= wxLIST_MASK_IMAGE
;
430 info
.m_image
= image
;
431 info
.m_itemId
= item
;
433 return SetItem(info
);
436 // Gets the item text
437 wxString
wxListCtrl::GetItemText(long item
) const
441 info
.m_mask
= wxLIST_MASK_TEXT
;
442 info
.m_itemId
= item
;
449 // Sets the item text
450 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
454 info
.m_mask
= wxLIST_MASK_TEXT
;
455 info
.m_itemId
= item
;
461 // Gets the item data
462 long wxListCtrl::GetItemData(long item
) const
466 info
.m_mask
= wxLIST_MASK_DATA
;
467 info
.m_itemId
= item
;
474 // Sets the item data
475 bool wxListCtrl::SetItemData(long item
, long data
)
479 info
.m_mask
= wxLIST_MASK_DATA
;
480 info
.m_itemId
= item
;
483 return SetItem(info
);
486 // Gets the item rectangle
487 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
493 // Gets the item position
494 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
500 // Sets the item position.
501 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
507 // Gets the number of items in the list control
508 int wxListCtrl::GetItemCount() const
514 // Retrieves the spacing between icons in pixels.
515 // If small is TRUE, gets the spacing for the small icon
516 // view, otherwise the large icon view.
517 int wxListCtrl::GetItemSpacing(bool isSmall
) const
523 // Gets the number of selected items in the list control
524 int wxListCtrl::GetSelectedItemCount() const
530 // Gets the text colour of the listview
531 wxColour
wxListCtrl::GetTextColour() const
537 // Sets the text colour of the listview
538 void wxListCtrl::SetTextColour(const wxColour
& col
)
543 // Gets the index of the topmost visible item when in
544 // list or report view
545 long wxListCtrl::GetTopItem() const
551 // Searches for an item, starting from 'item'.
552 // 'geometry' is one of
553 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
554 // 'state' is a state bit flag, one or more of
555 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
556 // item can be -1 to find the first item that matches the
558 // Returns the item or -1 if unsuccessful.
559 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
565 wxImageList
*wxListCtrl::GetImageList(int which
) const
567 if ( which
== wxIMAGE_LIST_NORMAL
)
569 return m_imageListNormal
;
571 else if ( which
== wxIMAGE_LIST_SMALL
)
573 return m_imageListSmall
;
575 else if ( which
== wxIMAGE_LIST_STATE
)
577 return m_imageListState
;
582 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
585 if ( which
== wxIMAGE_LIST_NORMAL
)
587 m_imageListNormal
= imageList
;
589 else if ( which
== wxIMAGE_LIST_SMALL
)
591 m_imageListSmall
= imageList
;
593 else if ( which
== wxIMAGE_LIST_STATE
)
595 m_imageListState
= imageList
;
597 // TODO set image list
601 ////////////////////////////////////////////////////////////////////////////
603 // Arranges the items
604 bool wxListCtrl::Arrange(int flag
)
611 bool wxListCtrl::DeleteItem(long item
)
618 bool wxListCtrl::DeleteAllItems()
625 bool wxListCtrl::DeleteAllColumns()
632 bool wxListCtrl::DeleteColumn(int col
)
638 // Clears items, and columns if there are any.
639 void wxListCtrl::ClearAll()
642 if ( m_colCount
> 0 )
647 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
653 // End label editing, optionally cancelling the edit
654 bool wxListCtrl::EndEditLabel(bool cancel
)
660 // Ensures this item is visible
661 bool wxListCtrl::EnsureVisible(long item
)
667 // Find an item whose label matches this string, starting from the item after 'start'
668 // or the beginning if 'start' is -1.
669 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
675 // Find an item whose data matches this data, starting from the item after 'start'
676 // or the beginning if 'start' is -1.
677 long wxListCtrl::FindItem(long start
, long data
)
683 // Find an item nearest this position in the specified direction, starting from
684 // the item after 'start' or the beginning if 'start' is -1.
685 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
691 // Determines which item (if any) is at the specified point,
692 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
693 long wxListCtrl::HitTest(const wxPoint
& point
, int& flags
)
699 // Inserts an item, returning the index of the new item if successful,
701 long wxListCtrl::InsertItem(wxListItem
& info
)
707 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
711 info
.m_mask
= wxLIST_MASK_TEXT
;
712 info
.m_itemId
= index
;
713 return InsertItem(info
);
716 // Inserts an image item
717 long wxListCtrl::InsertItem(long index
, int imageIndex
)
720 info
.m_image
= imageIndex
;
721 info
.m_mask
= wxLIST_MASK_IMAGE
;
722 info
.m_itemId
= index
;
723 return InsertItem(info
);
726 // Inserts an image/string item
727 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
730 info
.m_image
= imageIndex
;
732 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
733 info
.m_itemId
= index
;
734 return InsertItem(info
);
737 // For list view mode (only), inserts a column.
738 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
744 long wxListCtrl::InsertColumn(long col
, const wxString
& heading
, int format
,
748 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
749 item
.m_text
= heading
;
752 item
.m_mask
|= wxLIST_MASK_WIDTH
;
753 item
.m_width
= width
;
755 item
.m_format
= format
;
757 return InsertColumn(col
, item
);
760 // Scrolls the list control. If in icon, small icon or report view mode,
761 // x specifies the number of pixels to scroll. If in list view mode, x
762 // specifies the number of columns to scroll.
763 // If in icon, small icon or list view mode, y specifies the number of pixels
764 // to scroll. If in report view mode, y specifies the number of lines to scroll.
765 bool wxListCtrl::ScrollList(int dx
, int dy
)
773 // fn is a function which takes 3 long arguments: item1, item2, data.
774 // item1 is the long data associated with a first item (NOT the index).
775 // item2 is the long data associated with a second item (NOT the index).
776 // data is the same value as passed to SortItems.
777 // The return value is a negative number if the first item should precede the second
778 // item, a positive number of the second item should precede the first,
779 // or zero if the two items are equivalent.
781 // data is arbitrary data to be passed to the sort function.
782 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
788 bool wxListCtrl::OS2Command(WXUINT cmd
, WXWORD id
)
791 if (cmd == EN_UPDATE)
793 wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id);
794 event.SetEventObject( this );
795 ProcessCommand(event);
798 else if (cmd == EN_KILLFOCUS)
800 wxCommandEvent event(wxEVT_KILL_FOCUS, id);
801 event.SetEventObject( this );
802 ProcessCommand(event);
811 bool wxListCtrl::OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
815 wxListEvent event(wxEVT_NULL, m_windowId);
816 wxEventType eventType = wxEVT_NULL;
817 NMHDR *hdr1 = (NMHDR *) lParam;
818 switch ( hdr1->code )
821 eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
825 if ( eventType == wxEVT_NULL )
827 eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
831 NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam;
832 event.m_itemIndex = hdr->iItem;
833 event.m_pointDrag.x = hdr->ptAction.x;
834 event.m_pointDrag.y = hdr->ptAction.y;
838 case LVN_BEGINLABELEDIT:
840 eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
841 LV_DISPINFO *info = (LV_DISPINFO *)lParam;
842 wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
846 case LVN_COLUMNCLICK:
848 eventType = wxEVT_COMMAND_LIST_COL_CLICK;
849 NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
850 event.m_itemIndex = -1;
851 event.m_col = hdr->iSubItem;
855 case LVN_DELETEALLITEMS:
856 // what's the sense of generating a wxWin event for this when
857 // it's absolutely not portable?
859 eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
860 event.m_itemIndex = -1;
863 // return TRUE to suppress all additional LVN_DELETEITEM
864 // notifications - this makes deleting all items from a list ctrl
871 eventType = wxEVT_COMMAND_LIST_DELETE_ITEM;
872 NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
873 event.m_itemIndex = hdr->iItem;
876 case LVN_ENDLABELEDIT:
878 eventType = wxEVT_COMMAND_LIST_END_LABEL_EDIT;
879 LV_DISPINFO *info = (LV_DISPINFO *)lParam;
880 wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
881 if ( info->item.pszText == NULL || info->item.iItem == -1 )
882 event.m_cancelled = TRUE;
885 case LVN_GETDISPINFO:
888 // this provokes stack overflow: indeed, wxConvertFromMSWListItem()
889 // sends us WM_NOTIFY! As it doesn't do anything for now, just leave
893 // TODO: some text buffering here, I think
894 // TODO: API for getting Windows to retrieve values
896 eventType = wxEVT_COMMAND_LIST_GET_INFO;
897 LV_DISPINFO *info = (LV_DISPINFO *)lParam;
898 wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
905 eventType = wxEVT_COMMAND_LIST_INSERT_ITEM;
906 NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
907 event.m_itemIndex = hdr->iItem;
910 case LVN_ITEMCHANGED:
912 // This needs to be sent to wxListCtrl as a rather more
913 // concrete event. For now, just detect a selection
915 NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
916 if ( (hdr->uNewState & LVIS_SELECTED) && !(hdr->uOldState & LVIS_SELECTED) )
918 eventType = wxEVT_COMMAND_LIST_ITEM_SELECTED;
919 event.m_itemIndex = hdr->iItem;
921 else if ( !(hdr->uNewState & LVIS_SELECTED) && (hdr->uOldState & LVIS_SELECTED) )
923 eventType = wxEVT_COMMAND_LIST_ITEM_DESELECTED;
924 event.m_itemIndex = hdr->iItem;
933 LV_KEYDOWN *info = (LV_KEYDOWN *)lParam;
934 WORD wVKey = info->wVKey;
936 // get the current selection
937 long lItem = GetNextItem(-1,
939 wxLIST_STATE_SELECTED);
941 // <Enter> or <Space> activate the selected item if any
942 if ( lItem != -1 && (wVKey == VK_RETURN || wVKey == VK_SPACE) )
944 // TODO this behaviour probably should be optional
945 eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
946 event.m_itemIndex = lItem;
950 eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
951 event.m_code = wxCharCodeMSWToWX(wVKey);
957 // if the user processes it in wxEVT_COMMAND_LEFT_CLICK(), don't do
959 if ( wxControl::MSWOnNotify(idCtrl, lParam, result) )
964 // else translate it into wxEVT_COMMAND_LIST_ITEM_ACTIVATED event
965 eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
968 case LVN_SETDISPINFO:
970 eventType = wxEVT_COMMAND_LIST_SET_INFO;
971 LV_DISPINFO *info = (LV_DISPINFO *)lParam;
972 wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
977 return wxControl::MSWOnNotify(idCtrl, lParam, result);
980 event.SetEventObject( this );
981 event.SetEventType(eventType);
983 if ( !GetEventHandler()->ProcessEvent(event) )
986 if (hdr1->code == LVN_GETDISPINFO)
988 LV_DISPINFO *info = (LV_DISPINFO *)lParam;
989 if ( info->item.mask & LVIF_TEXT )
991 if ( !event.m_item.m_text.IsNull() )
993 info->item.pszText = AddPool(event.m_item.m_text);
994 info->item.cchTextMax = wxStrlen(info->item.pszText) + 1;
997 // wxConvertToMSWListItem(this, event.m_item, info->item);
1000 *result = !event.IsAllowed();
1005 wxChar
*wxListCtrl::AddPool(const wxString
& str
)
1007 // Remove the first element if 3 strings exist
1008 if ( m_stringPool
.Number() == 3 )
1010 wxNode
*node
= m_stringPool
.First();
1011 delete[] (char *)node
->Data();
1014 wxNode
*node
= m_stringPool
.Add(WXSTRINGCAST str
);
1015 return (wxChar
*)node
->Data();
1017 // List item structure
1018 wxListItem::wxListItem()
1028 m_format
= wxLIST_FORMAT_CENTRE
;
1032 // TODO see if we need these
1034 static void wxConvertFromOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& lvItem, HWND getFullInfo)
1036 info.m_data = lvItem.lParam;
1039 info.m_stateMask = 0;
1040 info.m_itemId = lvItem.iItem;
1042 long oldMask = lvItem.mask;
1044 bool needText = FALSE;
1045 if (getFullInfo != 0)
1047 if ( lvItem.mask & LVIF_TEXT )
1054 lvItem.pszText = new wxChar[513];
1055 lvItem.cchTextMax = 512;
1057 // lvItem.mask |= TVIF_HANDLE | TVIF_STATE | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
1058 lvItem.mask |= LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
1059 ::SendMessage(getFullInfo, LVM_GETITEM, 0, (LPARAM)& lvItem);
1062 if ( lvItem.mask & LVIF_STATE )
1064 info.m_mask |= wxLIST_MASK_STATE;
1066 if ( lvItem.stateMask & LVIS_CUT)
1068 info.m_stateMask |= wxLIST_STATE_CUT;
1069 if ( lvItem.state & LVIS_CUT )
1070 info.m_state |= wxLIST_STATE_CUT;
1072 if ( lvItem.stateMask & LVIS_DROPHILITED)
1074 info.m_stateMask |= wxLIST_STATE_DROPHILITED;
1075 if ( lvItem.state & LVIS_DROPHILITED )
1076 info.m_state |= wxLIST_STATE_DROPHILITED;
1078 if ( lvItem.stateMask & LVIS_FOCUSED)
1080 info.m_stateMask |= wxLIST_STATE_FOCUSED;
1081 if ( lvItem.state & LVIS_FOCUSED )
1082 info.m_state |= wxLIST_STATE_FOCUSED;
1084 if ( lvItem.stateMask & LVIS_SELECTED)
1086 info.m_stateMask |= wxLIST_STATE_SELECTED;
1087 if ( lvItem.state & LVIS_SELECTED )
1088 info.m_state |= wxLIST_STATE_SELECTED;
1092 if ( lvItem.mask & LVIF_TEXT )
1094 info.m_mask |= wxLIST_MASK_TEXT;
1095 info.m_text = lvItem.pszText;
1097 if ( lvItem.mask & LVIF_IMAGE )
1099 info.m_mask |= wxLIST_MASK_IMAGE;
1100 info.m_image = lvItem.iImage;
1102 if ( lvItem.mask & LVIF_PARAM )
1103 info.m_mask |= wxLIST_MASK_DATA;
1104 if ( lvItem.mask & LVIF_DI_SETITEM )
1105 info.m_mask |= wxLIST_SET_ITEM;
1106 info.m_col = lvItem.iSubItem;
1111 delete[] lvItem.pszText;
1113 lvItem.mask = oldMask;
1116 static void wxConvertToOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& lvItem)
1118 lvItem.iItem = (int) info.m_itemId;
1120 lvItem.iImage = info.m_image;
1121 lvItem.lParam = info.m_data;
1122 lvItem.stateMask = 0;
1125 lvItem.iSubItem = info.m_col;
1127 if (info.m_mask & wxLIST_MASK_STATE)
1129 lvItem.mask |= LVIF_STATE;
1130 if (info.m_stateMask & wxLIST_STATE_CUT)
1132 lvItem.stateMask |= LVIS_CUT;
1133 if (info.m_state & wxLIST_STATE_CUT)
1134 lvItem.state |= LVIS_CUT;
1136 if (info.m_stateMask & wxLIST_STATE_DROPHILITED)
1138 lvItem.stateMask |= LVIS_DROPHILITED;
1139 if (info.m_state & wxLIST_STATE_DROPHILITED)
1140 lvItem.state |= LVIS_DROPHILITED;
1142 if (info.m_stateMask & wxLIST_STATE_FOCUSED)
1144 lvItem.stateMask |= LVIS_FOCUSED;
1145 if (info.m_state & wxLIST_STATE_FOCUSED)
1146 lvItem.state |= LVIS_FOCUSED;
1148 if (info.m_stateMask & wxLIST_STATE_SELECTED)
1150 lvItem.stateMask |= LVIS_SELECTED;
1151 if (info.m_state & wxLIST_STATE_SELECTED)
1152 lvItem.state |= LVIS_SELECTED;
1156 if (info.m_mask & wxLIST_MASK_TEXT)
1158 lvItem.mask |= LVIF_TEXT;
1159 if ( ctrl->GetWindowStyleFlag() & wxLC_USER_TEXT )
1161 lvItem.pszText = LPSTR_TEXTCALLBACK;
1165 lvItem.pszText = WXSTRINGCAST info.m_text;
1166 if ( lvItem.pszText )
1167 lvItem.cchTextMax = info.m_text.Length();
1169 lvItem.cchTextMax = 0;
1172 if (info.m_mask & wxLIST_MASK_IMAGE)
1173 lvItem.mask |= LVIF_IMAGE;
1174 if (info.m_mask & wxLIST_MASK_DATA)
1175 lvItem.mask |= LVIF_PARAM;
1180 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxCommandEvent
)
1182 wxListEvent::wxListEvent(wxEventType commandType
, int id
)
1183 : wxNotifyEvent(commandType
, id
)
1188 m_cancelled
= FALSE
;