Commit wxComboCtrl clipping patch from J. Salli

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-09-03 13:21:29 +00:00
parent 70476471b7
commit 118f5fbd06
5 changed files with 34 additions and 11 deletions

View File

@@ -305,7 +305,9 @@ public:
// key handler).
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const = 0;
// Draws focus background (on combo control) in a way typical on platform.
// Prepare background of combo control or an item in a dropdown list
// in a way typical on platform. This includes painting the focus/disabled
// background and setting the clipping region.
// Unless you plan to paint your own focus indicator, you should always call this
// in your wxComboPopup::PaintComboControl implementation.
// In addition, it sets pen and text colour to what looks good and proper
@@ -313,7 +315,7 @@ public:
// flags: wxRendererNative flags: wxCONTROL_ISSUBMENU: is drawing a list item instead of combo control
// wxCONTROL_SELECTED: list item is selected
// wxCONTROL_DISABLED: control/item is disabled
virtual void DrawFocusBackground( wxDC& dc, const wxRect& rect, int flags ) const;
virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
// Returns true if focus indicator should be drawn in the control.
bool ShouldDrawFocus() const

View File

@@ -59,7 +59,7 @@ public:
virtual ~wxComboCtrl();
virtual void DrawFocusBackground( wxDC& dc, const wxRect& rect, int flags ) const;
virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const;
static int GetFeatures() { return wxComboCtrlFeatures::All; }

View File

@@ -386,7 +386,7 @@ void wxComboPopup::DefaultPaintComboControl( wxComboCtrlBase* combo,
{
if ( combo->GetWindowStyle() & wxCB_READONLY ) // ie. no textctrl
{
combo->DrawFocusBackground(dc,rect,0);
combo->PrepareBackground(dc,rect,0);
dc.DrawText( combo->GetValue(),
rect.x + combo->GetTextIndent(),
@@ -1036,8 +1036,9 @@ void wxComboCtrlBase::DoSetToolTip(wxToolTip *tooltip)
// painting
// ----------------------------------------------------------------------------
// draw focus background on area in a way typical on platform
void wxComboCtrlBase::DrawFocusBackground( wxDC& dc, const wxRect& rect, int flags ) const
#if (!defined(__WXMSW__)) || defined(__WXUNIVERSAL__)
// prepare combo box background on area in a way typical on platform
void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const
{
wxSize sz = GetClientSize();
bool isEnabled;
@@ -1106,7 +1107,19 @@ void wxComboCtrlBase::DrawFocusBackground( wxDC& dc, const wxRect& rect, int fla
dc.SetBrush( bgCol );
dc.SetPen( bgCol );
dc.DrawRectangle( selRect );
// Don't clip exactly to the selection rectangle so we can draw
// to the non-selected area in front of it.
wxRect clipRect(rect.x,rect.y,
(selRect.x+selRect.width)-rect.x,rect.height);
dc.SetClippingRegion(clipRect);
}
#else
// Save the library size a bit for platforms that re-implement this.
void wxComboCtrlBase::PrepareBackground( wxDC&, const wxRect&, int ) const
{
}
#endif
void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, bool paintBg )
{

View File

@@ -1059,12 +1059,15 @@ void wxOwnerDrawnComboBox::OnDrawBackground(wxDC& dc, const wxRect& rect, int it
if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) ||
(flags & wxODCB_PAINTING_CONTROL) )
{
int focusFlag = wxCONTROL_SELECTED;
int bgFlags = wxCONTROL_SELECTED;
if ( (flags & wxODCB_PAINTING_CONTROL) != wxODCB_PAINTING_CONTROL )
focusFlag |= wxCONTROL_ISSUBMENU;
DrawFocusBackground(dc, rect, focusFlag );
{
bgFlags |= wxCONTROL_ISSUBMENU;
PrepareBackground(dc, rect, bgFlags);
}
else if ( HasFlag(wxCB_READONLY) )
PrepareBackground(dc, rect, bgFlags);
}
//else: do nothing for the normal items
}

View File

@@ -239,7 +239,7 @@ static void wxMSWDrawFocusRect( wxDC& dc, const wxRect& rect )
}
// draw focus background on area in a way typical on platform
void wxComboCtrl::DrawFocusBackground( wxDC& dc, const wxRect& rect, int flags ) const
void wxComboCtrl::PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const
{
wxUxThemeEngine* theme = (wxUxThemeEngine*) NULL;
@@ -376,6 +376,11 @@ void wxComboCtrl::DrawFocusBackground( wxDC& dc, const wxRect& rect, int flags )
if ( drawDottedEdge )
wxMSWDrawFocusRect(dc,selRect);
// Don't clip exactly to the selection rectangle so we can draw
// to the non-selected area in front of it.
wxRect clipRect(rect.x,rect.y,
(selRect.x+selRect.width)-rect.x-1,rect.height);
dc.SetClippingRegion(clipRect);
}
void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )