Merge branch 'rename-listctrl-checkbox-methods' of https://github.com/discnl/wxWidgets

Use consistent case for wxListCtrl::{Has,Enable}CheckBoxes() methods.

Closes https://github.com/wxWidgets/wxWidgets/pull/275
This commit is contained in:
Vadim Zeitlin
2016-04-23 18:52:47 +02:00
10 changed files with 52 additions and 45 deletions

View File

@@ -55,6 +55,13 @@ Changes in behaviour which may result in build errors
3.1.1: (not released yet) 3.1.1: (not released yet)
---------------------------- ----------------------------
INCOMPATIBLE CHANGES SINCE 3.1.0:
- wxListCtrl::HasCheckboxes() and EnableCheckboxes(), which were added in
3.1.0, have been renamed to HasCheckBoxes and EnableCheckBoxes respectively
for consistency with wxCheckBox naming.
All: All:
- Add support for the micro version (third component) to OS and toolkit version - Add support for the micro version (third component) to OS and toolkit version

View File

@@ -101,8 +101,8 @@ public:
void SetTextColour(const wxColour& col); void SetTextColour(const wxColour& col);
long GetTopItem() const; long GetTopItem() const;
virtual bool HasCheckboxes() const wxOVERRIDE; virtual bool HasCheckBoxes() const wxOVERRIDE;
virtual bool EnableCheckboxes(bool enable = true) wxOVERRIDE; virtual bool EnableCheckBoxes(bool enable = true) wxOVERRIDE;
virtual bool IsItemChecked(long item) const wxOVERRIDE; virtual bool IsItemChecked(long item) const wxOVERRIDE;
virtual void CheckItem(long item, bool check) wxOVERRIDE; virtual void CheckItem(long item, bool check) wxOVERRIDE;

View File

@@ -641,8 +641,8 @@ public:
bool GetItemPosition( long item, wxPoint& pos ) const; bool GetItemPosition( long item, wxPoint& pos ) const;
int GetSelectedItemCount() const; int GetSelectedItemCount() const;
bool HasCheckboxes() const; bool HasCheckBoxes() const;
bool EnableCheckboxes(bool enable = true); bool EnableCheckBoxes(bool enable = true);
bool IsItemChecked(long item) const; bool IsItemChecked(long item) const;
void CheckItem(long item, bool check); void CheckItem(long item, bool check);
@@ -789,7 +789,7 @@ protected:
m_lineBeforeLastClicked, m_lineBeforeLastClicked,
m_lineSelectSingleOnUp; m_lineSelectSingleOnUp;
bool m_hasCheckboxes; bool m_hasCheckBoxes;
protected: protected:
wxWindow *GetMainWindowOfCompositeControl() wxOVERRIDE { return GetParent(); } wxWindow *GetMainWindowOfCompositeControl() wxOVERRIDE { return GetParent(); }
@@ -853,7 +853,7 @@ private:
// Check if the given point is inside the checkbox of this item. // Check if the given point is inside the checkbox of this item.
// //
// Always returns false if there are no checkboxes. // Always returns false if there are no checkboxes.
bool IsInsideCheckbox(long item, int x, int y); bool IsInsideCheckBox(long item, int x, int y);
// the height of one line using the current font // the height of one line using the current font
wxCoord m_lineHeight; wxCoord m_lineHeight;

View File

@@ -415,8 +415,8 @@ public:
virtual bool SetHeaderAttr(const wxItemAttr& WXUNUSED(attr)) { return false; } virtual bool SetHeaderAttr(const wxItemAttr& WXUNUSED(attr)) { return false; }
// Checkboxes support: only implemented in wxMSW currently. // Checkboxes support: only implemented in wxMSW currently.
virtual bool HasCheckboxes() const { return false; } virtual bool HasCheckBoxes() const { return false; }
virtual bool EnableCheckboxes(bool WXUNUSED(enable) = true) { return false; } virtual bool EnableCheckBoxes(bool WXUNUSED(enable) = true) { return false; }
virtual bool IsItemChecked(long WXUNUSED(item)) const { return false; } virtual bool IsItemChecked(long WXUNUSED(item)) const { return false; }
virtual void CheckItem(long WXUNUSED(item), bool WXUNUSED(check)) { } virtual void CheckItem(long WXUNUSED(item), bool WXUNUSED(check)) { }

View File

@@ -221,8 +221,8 @@ public:
wxFont GetItemFont( long item ) const; wxFont GetItemFont( long item ) const;
// Checkbox state of an item // Checkbox state of an item
virtual bool HasCheckboxes() const wxOVERRIDE; virtual bool HasCheckBoxes() const wxOVERRIDE;
virtual bool EnableCheckboxes(bool enable = true) wxOVERRIDE; virtual bool EnableCheckBoxes(bool enable = true) wxOVERRIDE;
virtual bool IsItemChecked(long item) const wxOVERRIDE; virtual bool IsItemChecked(long item) const wxOVERRIDE;
virtual void CheckItem(long item, bool check) wxOVERRIDE; virtual void CheckItem(long item, bool check) wxOVERRIDE;

View File

@@ -1249,11 +1249,11 @@ public:
/** /**
Returns true if checkboxes are enabled for list items. Returns true if checkboxes are enabled for list items.
@see EnableCheckboxes() @see EnableCheckBoxes()
@since 3.1.0 @since 3.1.0
*/ */
bool HasCheckboxes() const; bool HasCheckBoxes() const;
/** /**
Enable or disable checkboxes for list items. Enable or disable checkboxes for list items.
@@ -1263,7 +1263,7 @@ public:
@since 3.1.0 @since 3.1.0
*/ */
bool EnableCheckboxes(bool enable = true); bool EnableCheckBoxes(bool enable = true);
/** /**
Return true if the checkbox for the given wxListItem is checked. Return true if the checkbox for the given wxListItem is checked.
@@ -1280,7 +1280,7 @@ public:
Check or uncheck a wxListItem in a control using checkboxes. Check or uncheck a wxListItem in a control using checkboxes.
This method only works if checkboxes support had been successfully This method only works if checkboxes support had been successfully
enabled using EnableCheckboxes(). enabled using EnableCheckBoxes().
@param item Item (zero-based) index. @param item Item (zero-based) index.
@param check If @true, check the item, otherwise uncheck. @param check If @true, check the item, otherwise uncheck.

View File

@@ -155,16 +155,16 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(LIST_MAC_USE_GENERIC, MyFrame::OnToggleMacUseGeneric) EVT_MENU(LIST_MAC_USE_GENERIC, MyFrame::OnToggleMacUseGeneric)
#endif // __WXOSX__ #endif // __WXOSX__
EVT_MENU(LIST_FIND, MyFrame::OnFind) EVT_MENU(LIST_FIND, MyFrame::OnFind)
EVT_MENU(LIST_TOGGLE_CHECKBOX, MyFrame::OnToggleItemCheckbox) EVT_MENU(LIST_TOGGLE_CHECKBOX, MyFrame::OnToggleItemCheckBox)
EVT_MENU(LIST_GET_CHECKBOX, MyFrame::OnGetItemCheckbox) EVT_MENU(LIST_GET_CHECKBOX, MyFrame::OnGetItemCheckBox)
EVT_MENU(LIST_TOGGLE_CHECKBOXES, MyFrame::OnToggleCheckboxes) EVT_MENU(LIST_TOGGLE_CHECKBOXES, MyFrame::OnToggleCheckBoxes)
EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateUIEnableInReport) EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateUIEnableInReport)
EVT_UPDATE_UI(LIST_TOGGLE_HEADER, MyFrame::OnUpdateUIEnableInReport) EVT_UPDATE_UI(LIST_TOGGLE_HEADER, MyFrame::OnUpdateUIEnableInReport)
EVT_UPDATE_UI(LIST_CUSTOM_HEADER_ATTR, MyFrame::OnUpdateUIEnableInReport) EVT_UPDATE_UI(LIST_CUSTOM_HEADER_ATTR, MyFrame::OnUpdateUIEnableInReport)
EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel) EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
EVT_UPDATE_UI(LIST_TOGGLE_CHECKBOXES, MyFrame::OnUpdateToggleCheckboxes) EVT_UPDATE_UI(LIST_TOGGLE_CHECKBOXES, MyFrame::OnUpdateToggleCheckBoxes)
EVT_UPDATE_UI(LIST_TOGGLE_HEADER, MyFrame::OnUpdateToggleHeader) EVT_UPDATE_UI(LIST_TOGGLE_HEADER, MyFrame::OnUpdateToggleHeader)
EVT_UPDATE_UI(LIST_ROW_LINES, MyFrame::OnUpdateRowLines) EVT_UPDATE_UI(LIST_ROW_LINES, MyFrame::OnUpdateRowLines)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
@@ -848,22 +848,22 @@ void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent& event)
event.Check(!m_listCtrl->HasFlag(wxLC_SINGLE_SEL)); event.Check(!m_listCtrl->HasFlag(wxLC_SINGLE_SEL));
} }
void MyFrame::OnToggleCheckboxes(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToggleCheckBoxes(wxCommandEvent& WXUNUSED(event))
{ {
if ( !m_listCtrl->EnableCheckboxes(!m_listCtrl->HasCheckboxes()) ) if ( !m_listCtrl->EnableCheckBoxes(!m_listCtrl->HasCheckBoxes()) )
{ {
wxLogMessage("Failed to toggle checkboxes (not supported?)"); wxLogMessage("Failed to toggle checkboxes (not supported?)");
} }
else else
{ {
wxLogMessage("Checkboxes are now %s", wxLogMessage("Checkboxes are now %s",
m_listCtrl->HasCheckboxes() ? "enabled" : "disabled"); m_listCtrl->HasCheckBoxes() ? "enabled" : "disabled");
} }
} }
void MyFrame::OnUpdateToggleCheckboxes(wxUpdateUIEvent& event) void MyFrame::OnUpdateToggleCheckBoxes(wxUpdateUIEvent& event)
{ {
bool cbEnabled = m_listCtrl->HasCheckboxes(); bool cbEnabled = m_listCtrl->HasCheckBoxes();
event.Check(cbEnabled); event.Check(cbEnabled);
GetMenuBar()->Enable(LIST_TOGGLE_CHECKBOX, cbEnabled); GetMenuBar()->Enable(LIST_TOGGLE_CHECKBOX, cbEnabled);
GetMenuBar()->Enable(LIST_GET_CHECKBOX, cbEnabled); GetMenuBar()->Enable(LIST_GET_CHECKBOX, cbEnabled);
@@ -941,7 +941,7 @@ void MyFrame::OnEdit(wxCommandEvent& WXUNUSED(event))
} }
} }
void MyFrame::OnToggleItemCheckbox(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToggleItemCheckBox(wxCommandEvent& WXUNUSED(event))
{ {
long item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while (item != -1) while (item != -1)
@@ -954,7 +954,7 @@ void MyFrame::OnToggleItemCheckbox(wxCommandEvent& WXUNUSED(event))
} }
} }
void MyFrame::OnGetItemCheckbox(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnGetItemCheckBox(wxCommandEvent& WXUNUSED(event))
{ {
long item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while (item != -1) while (item != -1)

View File

@@ -150,13 +150,13 @@ protected:
void OnToggleMacUseGeneric(wxCommandEvent& event); void OnToggleMacUseGeneric(wxCommandEvent& event);
#endif // __WXOSX__ #endif // __WXOSX__
void OnFind(wxCommandEvent& event); void OnFind(wxCommandEvent& event);
void OnToggleItemCheckbox(wxCommandEvent& event); void OnToggleItemCheckBox(wxCommandEvent& event);
void OnGetItemCheckbox(wxCommandEvent& event); void OnGetItemCheckBox(wxCommandEvent& event);
void OnToggleCheckboxes(wxCommandEvent& event); void OnToggleCheckBoxes(wxCommandEvent& event);
void OnUpdateUIEnableInReport(wxUpdateUIEvent& event); void OnUpdateUIEnableInReport(wxUpdateUIEvent& event);
void OnUpdateToggleMultiSel(wxUpdateUIEvent& event); void OnUpdateToggleMultiSel(wxUpdateUIEvent& event);
void OnUpdateToggleCheckboxes(wxUpdateUIEvent& event); void OnUpdateToggleCheckBoxes(wxUpdateUIEvent& event);
void OnUpdateToggleHeader(wxUpdateUIEvent& event); void OnUpdateToggleHeader(wxUpdateUIEvent& event);
void OnUpdateRowLines(wxUpdateUIEvent& event); void OnUpdateRowLines(wxUpdateUIEvent& event);

View File

@@ -797,7 +797,7 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
x += 2; x += 2;
#endif #endif
if ( m_owner->HasCheckboxes() ) if ( m_owner->HasCheckBoxes() )
{ {
wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(m_owner); wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(m_owner);
int yOffset = (rect.height - cbSize.GetHeight()) / 2; int yOffset = (rect.height - cbSize.GetHeight()) / 2;
@@ -820,7 +820,7 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
wxListItemData *item = node->GetData(); wxListItemData *item = node->GetData();
int width = m_owner->GetColumnWidth(col); int width = m_owner->GetColumnWidth(col);
if (col == 0 && m_owner->HasCheckboxes()) if (col == 0 && m_owner->HasCheckBoxes())
width -= x; width -= x;
int xOld = x; int xOld = x;
x += width; x += width;
@@ -1609,7 +1609,7 @@ void wxListMainWindow::Init()
m_lineSelectSingleOnUp = m_lineSelectSingleOnUp =
m_lineBeforeLastClicked = (size_t)-1; m_lineBeforeLastClicked = (size_t)-1;
m_hasCheckboxes = false; m_hasCheckBoxes = false;
} }
wxListMainWindow::wxListMainWindow() wxListMainWindow::wxListMainWindow()
@@ -2579,7 +2579,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
bool cmdModifierDown = event.CmdDown(); bool cmdModifierDown = event.CmdDown();
if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) ) if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) )
{ {
if (IsInsideCheckbox(current, x, y)) if (IsInsideCheckBox(current, x, y))
{ {
CheckItem(current, !IsItemChecked(current)); CheckItem(current, !IsItemChecked(current));
} }
@@ -3703,14 +3703,14 @@ bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) const
// checkboxes // checkboxes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxListMainWindow::HasCheckboxes() const bool wxListMainWindow::HasCheckBoxes() const
{ {
return m_hasCheckboxes; return m_hasCheckBoxes;
} }
bool wxListMainWindow::EnableCheckboxes(bool enable) bool wxListMainWindow::EnableCheckBoxes(bool enable)
{ {
m_hasCheckboxes = enable; m_hasCheckBoxes = enable;
m_dirty = true; m_dirty = true;
m_headerWidth = 0; m_headerWidth = 0;
@@ -3736,9 +3736,9 @@ bool wxListMainWindow::IsItemChecked(long item) const
return line->IsChecked(); return line->IsChecked();
} }
bool wxListMainWindow::IsInsideCheckbox(long item, int x, int y) bool wxListMainWindow::IsInsideCheckBox(long item, int x, int y)
{ {
if ( HasCheckboxes() ) if ( HasCheckBoxes() )
{ {
wxRect lineRect = GetLineRect(item); wxRect lineRect = GetLineRect(item);
wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(this); wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(this);
@@ -4769,20 +4769,20 @@ void wxGenericListCtrl::OnScroll(wxScrollWinEvent& event)
event.Skip(); event.Skip();
} }
bool wxGenericListCtrl::HasCheckboxes() const bool wxGenericListCtrl::HasCheckBoxes() const
{ {
if (!InReportView()) if (!InReportView())
return false; return false;
return m_mainWin->HasCheckboxes(); return m_mainWin->HasCheckBoxes();
} }
bool wxGenericListCtrl::EnableCheckboxes(bool enable) bool wxGenericListCtrl::EnableCheckBoxes(bool enable)
{ {
if (!InReportView()) if (!InReportView())
return false; return false;
return m_mainWin->EnableCheckboxes(enable); return m_mainWin->EnableCheckBoxes(enable);
} }
void wxGenericListCtrl::CheckItem(long item, bool state) void wxGenericListCtrl::CheckItem(long item, bool state)

View File

@@ -1306,13 +1306,13 @@ wxFont wxListCtrl::GetItemFont( long item ) const
return f; return f;
} }
bool wxListCtrl::HasCheckboxes() const bool wxListCtrl::HasCheckBoxes() const
{ {
const DWORD currStyle = ListView_GetExtendedListViewStyle(GetHwnd()); const DWORD currStyle = ListView_GetExtendedListViewStyle(GetHwnd());
return (currStyle & LVS_EX_CHECKBOXES) != 0; return (currStyle & LVS_EX_CHECKBOXES) != 0;
} }
bool wxListCtrl::EnableCheckboxes(bool enable) bool wxListCtrl::EnableCheckBoxes(bool enable)
{ {
(void)ListView_SetExtendedListViewStyleEx(GetHwnd(), LVS_EX_CHECKBOXES, (void)ListView_SetExtendedListViewStyleEx(GetHwnd(), LVS_EX_CHECKBOXES,
enable ? LVS_EX_CHECKBOXES : 0); enable ? LVS_EX_CHECKBOXES : 0);