Merge branch 'qt-listctrl-fixes' of https://github.com/AliKet/wxWidgets

wxListCtrl fixes for wxQt.

See #23029.
This commit is contained in:
Vadim Zeitlin
2022-12-15 01:26:37 +01:00
5 changed files with 497 additions and 65 deletions
+7
View File
@@ -209,6 +209,8 @@ public:
// Ensures this item is visible
bool EnsureVisible(long item);
bool IsVisible(long item) const override;
// Find an item whose label matches this string, starting from the item after 'start'
// or the beginning if 'start' is -1.
long FindItem(long start, const wxString& str, bool partial = false);
@@ -262,6 +264,11 @@ public:
// data is arbitrary data to be passed to the sort function.
bool SortItems(wxListCtrlCompare fn, wxIntPtr data);
// Sort indicator in header.
virtual void ShowSortIndicator(int col, bool ascending = true) override;
virtual int GetSortIndicator() const override;
virtual bool IsAscendingSortIndicator() const override;
virtual QWidget *GetHandle() const override;
protected:
+5 -1
View File
@@ -632,6 +632,10 @@ public:
Gets the number of items that can fit vertically in the visible area of
the list control (list or report view) or the total number of items in
the list control (icon or small icon view).
@note The caller must ensure that there is at least one item in the control
to be able to calculate the count per page under wxQt, otherwise 0 will
be returned.
*/
int GetCountPerPage() const;
@@ -1073,7 +1077,7 @@ public:
@c wxLIST_AUTOSIZE will resize the column to the length of its longest item.
@c wxLIST_AUTOSIZE_USEHEADER will resize the column to the length of the
header (Win32) or 80 pixels (other platforms).
header (wxMSW and wxQt) or 80 pixels (other platforms).
In small or normal icon view, @a col must be -1, and the column width is set
for all columns.
+19
View File
@@ -151,6 +151,8 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(LIST_TOGGLE_HEADER, MyFrame::OnToggleHeader)
EVT_MENU(LIST_TOGGLE_BELL, MyFrame::OnToggleBell)
EVT_MENU(LIST_CHECKVISIBILITY, MyFrame::OnCheckVisibility)
EVT_MENU(LIST_AUTOSIZE, MyFrame::OnAutoResize)
EVT_MENU(LIST_AUTOSIZE_USEHEADER, MyFrame::OnAutoResize)
EVT_MENU(LIST_FIND, MyFrame::OnFind)
EVT_MENU(LIST_TOGGLE_CHECKBOX, MyFrame::OnToggleItemCheckBox)
EVT_MENU(LIST_GET_CHECKBOX, MyFrame::OnGetItemCheckBox)
@@ -260,6 +262,9 @@ MyFrame::MyFrame(const wxString& title)
menuList->AppendCheckItem(LIST_TOGGLE_BELL, "Toggle &bell on no match");
menuList->Append( LIST_CHECKVISIBILITY, "Check if lines 2 and 9 are visible" );
menuList->AppendSeparator();
menuList->Append( LIST_AUTOSIZE, "Auto resize column 2\tCtrl-R" );
menuList->Append( LIST_AUTOSIZE_USEHEADER, "Auto resize column 2 (use header)\tCtrl-Shift-R" );
menuList->AppendSeparator();
menuList->AppendCheckItem(LIST_TOGGLE_CHECKBOXES,
"&Enable Checkboxes");
menuList->Check(LIST_TOGGLE_CHECKBOXES, true);
@@ -379,6 +384,20 @@ void MyFrame::OnCheckVisibility(wxCommandEvent& WXUNUSED(event))
wxLogMessage( "Line 9 is not visible" );
}
void MyFrame::OnAutoResize(wxCommandEvent& event)
{
if ( event.GetId() == LIST_AUTOSIZE )
{
wxLogMessage( "Column 2 resized to content" );
m_listCtrl->SetColumnWidth(1, wxLIST_AUTOSIZE);
}
else
{
wxLogMessage( "Column 2 resized to header" );
m_listCtrl->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
}
}
void MyFrame::OnGoTo(wxCommandEvent& WXUNUSED(event))
{
if ( m_listCtrl->IsEmpty() )
+3
View File
@@ -117,6 +117,7 @@ protected:
void OnVirtualView(wxCommandEvent& event);
void OnSmallVirtualView(wxCommandEvent& event);
void OnCheckVisibility(wxCommandEvent& event);
void OnAutoResize(wxCommandEvent& event);
void OnSetItemsCount(wxCommandEvent& event);
@@ -243,5 +244,7 @@ enum
LIST_THAW,
LIST_TOGGLE_LINES,
LIST_CHECKVISIBILITY,
LIST_AUTOSIZE,
LIST_AUTOSIZE_USEHEADER,
LIST_CTRL = 1000
};
+463 -64
View File
File diff suppressed because it is too large Load Diff