From 8468c5bd934c861316287ddbf52109ff791a6e26 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Thu, 30 Apr 2020 21:11:43 +0200 Subject: [PATCH] Fix #9: Don't use wxWidgets' best size calculation for card and keyword lists. --- src/gui/control/item_list.cpp | 8 ++++++++ src/gui/control/item_list.hpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/control/item_list.cpp b/src/gui/control/item_list.cpp index eec1acb7..555d2e69 100644 --- a/src/gui/control/item_list.cpp +++ b/src/gui/control/item_list.cpp @@ -226,6 +226,14 @@ void ItemList::SetColumnImage(int col, int image) { // ----------------------------------------------------------------------------- : ItemList : Window events +wxSize ItemList::DoGetBestClientSize() const { + // wxWidgets decided to be 'smart', and calculate the best size of a list view based on the column header width. + // But this also sets the minimum window size, so the window can't be made any smaller than that, even on small screens. + // See issue #9 + // So, return some small size instead. + return wxSize(10,10); +} + void ItemList::onColumnClick(wxListEvent& ev) { long new_sort_by_column = ev.GetColumn(); if (sort_by_column == new_sort_by_column) { diff --git a/src/gui/control/item_list.hpp b/src/gui/control/item_list.hpp index 4291667c..01b4f982 100644 --- a/src/gui/control/item_list.hpp +++ b/src/gui/control/item_list.hpp @@ -92,7 +92,11 @@ class ItemList : public wxListView { void focusItem(const VoidP& item, bool focus = true); /// Count the number of focused items long focusCount() const; - + + // --------------------------------------------------- : Fixing wx issues + + wxSize DoGetBestClientSize() const; + // --------------------------------------------------- : Data VoidP selected_item; ///< The currently selected item long selected_item_pos; ///< Position of the selected item in the sorted_list, or -1 if no card is selected