Fix resizing loop when the Windows Classic theme with some large resolutions have been chosen.

This commit is contained in:
tadatada 2014-10-28 12:44:12 +09:00
parent f0d85d7dcc
commit d55aa66751
2 changed files with 26 additions and 2 deletions

View File

@ -30,7 +30,9 @@ END_EVENT_TABLE()
GenericListView::GenericListView(wxWindow* parent, GenericListViewColumn* columns, int columnCount)
: wxListView(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxLC_VIRTUAL|wxLC_REPORT|wxLC_SINGLE_SEL|wxNO_BORDER)
{
insertColumns(columns,columnCount);
m_isInResizeColumn = false;
insertColumns(columns, columnCount);
}
void GenericListView::insertColumns(GenericListViewColumn* columns, int count)
@ -49,11 +51,22 @@ void GenericListView::insertColumns(GenericListViewColumn* columns, int count)
this->columns = columns;
}
void GenericListView::resizeColumn(int col, int width)
{
if (!m_isInResizeColumn) {
m_isInResizeColumn = true;
SetColumnWidth(col, width);
m_isInResizeColumn = false;
}
}
void GenericListView::resizeColumns(int totalWidth)
{
for (int i = 0; i < GetColumnCount(); i++)
{
SetColumnWidth(i,totalWidth*columns[i].size);
resizeColumn(i, totalWidth * columns[i].size);
}
}

View File

@ -47,8 +47,19 @@ protected:
virtual void onDoubleClick(int itemIndex, const wxPoint& point) { };
virtual void onRightClick(int itemIndex, const wxPoint& point) { };
virtual void onKeyDown(int key) { };
// This flag prevents resizing loop in the resizeColumn method of this class
// when the Windows Classic theme with some large resolutions around larger
// than 1024 x 768 have been chosen.
//
// The resizing loop will occur by the ListView_SetColumnWidth macro in the
// Windows SDK called by the wxListCtrl::SetColumnWidth method when the
// conditions above have been chosen.
bool m_isInResizeColumn;
private:
void insertColumns(GenericListViewColumn* columns, int count);
void resizeColumn(int col, int width);
void resizeColumns(int totalWidth);
wxString OnGetItemText(long item, long col) const;