From a9fdf82418221608fca0259a586a7a6c13d133c8 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 17 Feb 2007 11:35:58 +0000 Subject: [PATCH] Minor parts from FM's wxDataViewCtrl patch. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44522 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 85 ++++++++++++++++++++++++-------------------- src/msw/renderer.cpp | 40 +++++++++++++++++++++ 2 files changed, 87 insertions(+), 38 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 9870353bca..78c3fb1150 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1769,6 +1769,50 @@ bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id) return false; } +// utility used by wxListCtrl::MSWOnNotify and by wxDataViewHeaderWindowMSW::MSWOnNotify +unsigned int wxMSWGetColumnClicked(NMHDR *nmhdr, POINT *ptClick) +{ + wxASSERT(nmhdr && ptClick); + + // find the column clicked: we have to search for it + // ourselves as the notification message doesn't provide + // this info + + // where did the click occur? +#if defined(__WXWINCE__) && !defined(__HANDHELDPC__) && _WIN32_WCE < 400 + if (nmhdr->code == GN_CONTEXTMENU) + { + *ptClick = ((NMRGINFO*)nmhdr)->ptAction; + } + else +#endif //__WXWINCE__ + if ( !::GetCursorPos(ptClick) ) + { + wxLogLastError(_T("GetCursorPos")); + } + + if ( !::ScreenToClient(nmhdr->hwndFrom, ptClick) ) + { + wxLogLastError(_T("ScreenToClient(header)")); + } + + int colCount = Header_GetItemCount(nmhdr->hwndFrom); + + RECT rect; + for ( int col = 0; col < colCount; col++ ) + { + if ( Header_GetItemRect(nmhdr->hwndFrom, col, &rect) ) + { + if ( ::PtInRect(&rect, *ptClick) ) + { + return col; + } + } + } + + return wxNOT_FOUND; +} + bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { @@ -1836,47 +1880,12 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) #endif //__WXWINCE__ case NM_RCLICK: { - eventType = wxEVT_COMMAND_LIST_COL_RIGHT_CLICK; - event.m_col = -1; - - // find the column clicked: we have to search for it - // ourselves as the notification message doesn't provide - // this info - - // where did the click occur? POINT ptClick; -#if defined(__WXWINCE__) && !defined(__HANDHELDPC__) && _WIN32_WCE < 400 - if(nmhdr->code == GN_CONTEXTMENU) { - ptClick = ((NMRGINFO*)nmhdr)->ptAction; - } else -#endif //__WXWINCE__ - if ( !::GetCursorPos(&ptClick) ) - { - wxLogLastError(_T("GetCursorPos")); - } - - if ( !::ScreenToClient(GetHwnd(), &ptClick) ) - { - wxLogLastError(_T("ScreenToClient(listctrl header)")); - } + eventType = wxEVT_COMMAND_LIST_COL_RIGHT_CLICK; + event.m_col = wxMSWGetColumnClicked(nmhdr, &ptClick); event.m_pointDrag.x = ptClick.x; event.m_pointDrag.y = ptClick.y; - - int colCount = Header_GetItemCount(hwndHdr); - - RECT rect; - for ( int col = 0; col < colCount; col++ ) - { - if ( Header_GetItemRect(hwndHdr, col, &rect) ) - { - if ( ::PtInRect(&rect, ptClick) ) - { - event.m_col = col; - break; - } - } - } } break; @@ -1886,7 +1895,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // parameters // // I have no idea what is the real cause of the bug (which is, - // just to make things interesting, is impossible to reproduce + // just to make things interesting, impossible to reproduce // reliably) but ignoring all these messages does fix it and // doesn't seem to have any negative consequences return true; diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index 27c7cb7e6c..637639ccc4 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -154,6 +154,12 @@ public: const wxRect& rect, int flags = 0); + virtual void DrawItemSelectionRect(wxWindow *win, + wxDC& dc, + const wxRect& rect, + int flags = 0 ); + + virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); private: DECLARE_NO_COPY_CLASS(wxRendererXP) @@ -469,6 +475,40 @@ wxRendererXP::DrawPushButton(wxWindow * win, } +void +wxRendererXP::DrawItemSelectionRect(wxWindow * WXUNUSED(win), + wxDC& dc, + const wxRect& rect, + int flags) +{ + wxBrush brush; + if ( flags & wxCONTROL_SELECTED ) + { + if ( flags & wxCONTROL_FOCUSED ) + { + brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + } + else // !focused + { + brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)); + } + } + else // !selected + { + brush = *wxTRANSPARENT_BRUSH; + } + + dc.SetBrush(brush); + + // unlike for wxRendererGeneric, on windows we _never_ want to draw + // the outline of the rectangle: + dc.SetPen(*wxTRANSPARENT_PEN); + + dc.DrawRectangle( rect ); +} + + + // ---------------------------------------------------------------------------- // splitter drawing // ---------------------------------------------------------------------------- -- 2.45.2