X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/edccf4281bc8fbb9d8151240ba5b208339c9ac11..08794f696f254d15841a48b11ddb280849ecbbff:/src/msw/listctrl.cpp diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 6a16a74ff4..d49a287745 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -39,7 +39,7 @@ #include "wx/msw/private.h" -#ifdef __GNUWIN32__ +#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS) #include "wx/msw/gnuwin32/extra.h" #else #include @@ -149,7 +149,7 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h) // Create the ListView control. m_hWnd = (WXHWND)CreateWindowEx(exStyle, WC_LISTVIEW, - _T(""), + wxT(""), wstyle, x, y, w, h, GetWinHwnd(GetParent()), @@ -159,7 +159,7 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h) if ( !m_hWnd ) { - wxLogError(_T("Can't create list control window.")); + wxLogError(wxT("Can't create list control window.")); return FALSE; } @@ -174,8 +174,7 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h) } #endif // ListView_SetExtendedListViewStyle - wxSystemSettings settings; - SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); SetForegroundColour(GetParent()->GetForegroundColour()); SubclassWin(m_hWnd); @@ -192,10 +191,10 @@ void wxListCtrl::UpdateStyle() DWORD dwStyleNew = ConvertToMSWStyle(dummy, m_windowStyle); dwStyleNew |= m_baseStyle; - // Get the current window style. + // Get the current window style. DWORD dwStyleOld = ::GetWindowLong(GetHwnd(), GWL_STYLE); - // Only set the window style if the view bits have changed. + // Only set the window style if the view bits have changed. if ( dwStyleOld != dwStyleNew ) { ::SetWindowLong(GetHwnd(), GWL_STYLE, dwStyleNew); @@ -551,7 +550,14 @@ bool wxListCtrl::SetItem(wxListItem& info) LV_ITEM item; wxConvertToMSWListItem(this, info, item); item.cchTextMax = 0; - return (ListView_SetItem(GetHwnd(), &item) != 0); + bool ok = ListView_SetItem(GetHwnd(), &item) != 0; + if ( ok && (info.m_mask & wxLIST_MASK_IMAGE) ) + { + // make the change visible + ListView_Update(GetHwnd(), item.iItem); + } + + return ok; } long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId) @@ -734,7 +740,7 @@ wxColour wxListCtrl::GetTextColour(void) const // Sets the text colour of the listview void wxListCtrl::SetTextColour(const wxColour& col) { - ListView_SetTextColor(GetHwnd(), PALETTERGB(col.Red(), col.Blue(), col.Green())); + ListView_SetTextColor(GetHwnd(), PALETTERGB(col.Red(), col.Green(), col.Blue())); } // Gets the index of the topmost visible item when in @@ -865,7 +871,7 @@ bool wxListCtrl::DeleteAllColumns() m_colCount--; } - wxASSERT_MSG( m_colCount == 0, _T("no columns should be left") ); + wxASSERT_MSG( m_colCount == 0, wxT("no columns should be left") ); return TRUE; } @@ -1110,7 +1116,7 @@ long wxListCtrl::InsertColumn(long col, wxListItem& item) } else { - wxLogDebug(_T("Failed to insert the column '%s' into listview!"), + wxLogDebug(wxT("Failed to insert the column '%s' into listview!"), lvCol.pszText); } @@ -1191,7 +1197,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) switch ( hdr1->code ) { case LVN_BEGINRDRAG: - eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG; + eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG; // fall through case LVN_BEGINDRAG: @@ -1224,13 +1230,21 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) event.m_col = hdr->iSubItem; break; } + case LVN_DELETEALLITEMS: - { - eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS; - // NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam; - event.m_itemIndex = -1; - break; - } + // what's the sense of generating a wxWin event for this when + // it's absolutely not portable? +#if 0 + eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS; + event.m_itemIndex = -1; +#endif // 0 + + // return TRUE to suppress all additional LVN_DELETEITEM + // notifications - this makes deleting all items from a list ctrl + // much faster + *result = TRUE; + return TRUE; + case LVN_DELETEITEM: { eventType = wxEVT_COMMAND_LIST_DELETE_ITEM; @@ -1330,6 +1344,61 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED; break; + case NM_RCLICK: + /* TECH NOTE: NM_RCLICK isn't really good enough here. We want to + subclass and check for the actual WM_RBUTTONDOWN message, because + NM_RCLICK waits for the WM_RBUTTONUP message as well before firing off. + We want to have notify events for both down -and- up. */ + { + // if the user processes it in wxEVT_COMMAND_RIGHT_CLICK(), don't do + // anything else + if ( wxControl::MSWOnNotify(idCtrl, lParam, result) ) { + return TRUE; + } + + // else translate it into wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event + LV_HITTESTINFO lvhti; +#ifdef __GNUWIN32__ + memset(&lvhti,0,sizeof(LV_HITTESTINFO)); +#else + ZeroMemory(&lvhti, sizeof(LV_HITTESTINFO)); // must set all fields to 0 +#endif + ::GetCursorPos(&(lvhti.pt)); + ::ScreenToClient(GetHwnd(),&(lvhti.pt)); + if ( ListView_HitTest(GetHwnd(),&lvhti) != -1 ) + { + // older headers don't have this symbol +#ifndef LVHT_ONITEM + #define LVHT_ONITEM \ + (LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON) +#endif + if ( lvhti.flags & LVHT_ONITEM ) + { + eventType = wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK; + event.m_itemIndex = lvhti.iItem; + } + } + } + break; + + /* + case NM_MCLICK: // ***** THERE IS NO NM_MCLICK. Subclass anyone? ****** + { + // if the user processes it in wxEVT_COMMAND_MIDDLE_CLICK(), don't do + // anything else + if ( wxControl::MSWOnNotify(idCtrl, lParam, result) ) + { + return TRUE; + } + + // else translate it into wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK event + eventType = wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK; + NMITEMACTIVATE* hdr = (NMITEMACTIVATE*)lParam; + event.m_itemIndex = hdr->iItem; + } + break; + */ + case LVN_SETDISPINFO: { eventType = wxEVT_COMMAND_LIST_SET_INFO; @@ -1348,7 +1417,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) if ( !GetEventHandler()->ProcessEvent(event) ) return FALSE; - if (hdr1->code == LVN_GETDISPINFO) + if ( (int)hdr1->code == LVN_GETDISPINFO) { LV_DISPINFO *info = (LV_DISPINFO *)lParam; if ( info->item.mask & LVIF_TEXT ) @@ -1554,6 +1623,7 @@ wxListEvent::wxListEvent(wxEventType commandType, int id) { m_code = 0; m_itemIndex = 0; + m_oldItemIndex = 0; m_col = 0; m_cancelled = FALSE; }