X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c085e333984dc079a001cd3f581aeb1f51a1f227..1f11220943f14b4bb5190db0dfd0054304f5015c:/src/msw/listctrl.cpp?ds=sidebyside diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 6a0e5dec10..f19fcfb670 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -21,7 +21,7 @@ #endif #ifndef WX_PRECOMP -#include "wx.h" +#include "wx/wx.h" #endif #if defined(__WIN95__) @@ -31,13 +31,15 @@ #include "wx/msw/private.h" -#ifndef __GNUWIN32__ +#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) #include #endif +#ifndef __TWIN32__ #ifdef __GNUWIN32__ #include "wx/msw/gnuwin32/extra.h" #endif +#endif static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem); static void wxConvertFromMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem, HWND getFullInfo = 0); @@ -100,7 +102,7 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con if ( want3D || wxStyleHasBorder(m_windowStyle) ) wstyle |= WS_BORDER; - wstyle |= LVS_SHAREIMAGELISTS; + wstyle |= LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS ; m_baseStyle = wstyle; long oldStyle = 0; // Dummy @@ -463,7 +465,11 @@ wxTextCtrl* wxListCtrl::GetEditControl(void) const bool wxListCtrl::GetItem(wxListItem& info) const { LV_ITEM lvItem; +#ifdef __MINGW32__ + memset(&lvItem, 0, sizeof(lvItem)); +#else ZeroMemory(&lvItem, sizeof(lvItem)); // must set all fields to 0 +#endif lvItem.iItem = info.m_itemId; @@ -478,6 +484,9 @@ bool wxListCtrl::GetItem(wxListItem& info) const lvItem.pszText = NULL; } + if (info.m_mask & wxLIST_MASK_DATA) + lvItem.mask |= LVIF_PARAM ; + if ( info.m_mask & wxLIST_MASK_STATE ) { lvItem.mask |= LVIF_STATE; @@ -618,7 +627,7 @@ bool wxListCtrl::SetItemData(long item, long data) } // Gets the item rectangle -bool wxListCtrl::GetItemRect(long item, wxRectangle& rect, int code) const +bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const { RECT rect2; @@ -1107,22 +1116,31 @@ bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id) else return FALSE; } -bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) +bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result) { wxListEvent event(wxEVT_NULL, m_windowId); wxEventType eventType = wxEVT_NULL; NMHDR *hdr1 = (NMHDR *) lParam; switch ( hdr1->code ) { + case LVN_BEGINRDRAG: + eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG; + // fall through + case LVN_BEGINDRAG: - { - eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG; - NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam; - event.m_itemIndex = hdr->iItem; - event.m_pointDrag.x = hdr->ptAction.x; - event.m_pointDrag.y = hdr->ptAction.y; - break; - } + if ( eventType == wxEVT_NULL ) + { + eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG; + } + + { + NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam; + event.m_itemIndex = hdr->iItem; + event.m_pointDrag.x = hdr->ptAction.x; + event.m_pointDrag.y = hdr->ptAction.y; + } + break; + case LVN_BEGINLABELEDIT: { eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT; @@ -1130,15 +1148,7 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND()); break; } - case LVN_BEGINRDRAG: - { - eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG; - NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam; - event.m_itemIndex = hdr->iItem; - event.m_pointDrag.x = hdr->ptAction.x; - event.m_pointDrag.y = hdr->ptAction.y; - break; - } + case LVN_COLUMNCLICK: { eventType = wxEVT_COMMAND_LIST_COL_CLICK; @@ -1224,8 +1234,7 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) } default : - return wxControl::MSWNotify(wParam, lParam); - break; + return wxControl::MSWNotify(wParam, lParam, result); } event.SetEventObject( this ); @@ -1248,7 +1257,9 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) // wxConvertToMSWListItem(this, event.m_item, info->item); } - return TRUE; + *result = !event.IsAllowed(); + + return TRUE; } char *wxListCtrl::AddPool(const wxString& str) @@ -1424,10 +1435,10 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ } // List event -IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent) -wxListEvent::wxListEvent(wxEventType commandType, int id): - wxCommandEvent(commandType, id) +wxListEvent::wxListEvent(wxEventType commandType, int id) + : wxNotifyEvent(commandType, id) { m_code = 0; m_itemIndex = 0;