Simplify API for extending wxListCtrl background display

Replace SetListRulesAlternateColourOnBlank() taking 2 arguments, with
the second of them being used only when the first one is true, with a
simpler but still sufficient ExtendRulesAndAlternateColour(bool).

Make the new method virtual and define it as doing nothing in
wxListCtrlBase class, so that it's still available, even if currently
not implemented, in wxMSW.

Also simplify the implementation, fix style problems and other minor
improvements.
This commit is contained in:
Vadim Zeitlin
2020-11-09 00:37:55 +01:00
parent 584d1ae47d
commit 5ae2a8ebb8
7 changed files with 80 additions and 96 deletions

View File

@@ -740,6 +740,12 @@ public:
return true;
}
void ExtendRulesAndAlternateColour(bool extend)
{
m_extendRulesAndAlternateColour = extend;
}
// these are for wxListLineData usage only
// get the backpointer to the list ctrl
@@ -779,13 +785,6 @@ public:
const wxRect& rect,
int lineNumber );
void SetListRulesAlternateColourOnBlank( const bool state,
const wxColour& colour)
{
m_listRulesAlternateColourOnBlank = state;
m_alternateColourOnBlank = colour;
}
protected:
// the array of all line objects for a non virtual list control (for the
// virtual list control we only ever use m_lines[0])
@@ -947,18 +946,14 @@ private:
// NULL if no item is being edited
wxListTextCtrlWrapper *m_textctrlWrapper;
// tells whether or not to paint empty rows with alternate colour and draw
// rulers on empty rows
bool m_extendRulesAndAlternateColour;
wxDECLARE_EVENT_TABLE();
friend class wxGenericListCtrl;
friend class wxListCtrlMaxWidthCalculator;
// tells whether or not to paint empty rows with alternate colour and draw
// rulers on empty rows
bool m_listRulesAlternateColourOnBlank;
// colour to paint empty rows (zebra effect)
wxColour m_alternateColourOnBlank;
};
#endif // wxUSE_LISTCTRL