Add render-related options to dataview sample

To more easily expose problems add options to the dataview sample
related to rendering of items (applying mostly to the MyListModel page
only):

* Use left/centre/right alignment (Ctrl+1/2/3)
* Use top/centre/bottom alignment (Ctrl+4/5/6)
* Toggle tall row usage (Ctrl+7)
* Toggle keep on using small wx logo, regardless of row size (Ctrl+8)
* Toggle multi-line text usage (Ctrl+9)
This commit is contained in:
Dimitri Schoolwerth
2021-02-02 00:01:25 +01:00
parent 771ebfa9a9
commit d04dfd6f22
3 changed files with 155 additions and 12 deletions

View File

@@ -339,9 +339,12 @@ static int my_sort( int *v1, int *v2 )
#define INITIAL_NUMBER_OF_ITEMS 10000
MyListModel::MyListModel() :
MyListModel::MyListModel(int modelFlags) :
wxDataViewVirtualListModel( INITIAL_NUMBER_OF_ITEMS )
{
const wxString multiLineText = L"top (\u1ED6)\ncentre\nbottom (g)";
const bool useMultiLine = (modelFlags & MODEL_USE_MULTI_LINE_TEXT) != 0;
// the first 100 items are really stored in this model;
// all the others are synthesized on request
static const unsigned NUMBER_REAL_ITEMS = 100;
@@ -349,17 +352,32 @@ MyListModel::MyListModel() :
m_toggleColValues.reserve(NUMBER_REAL_ITEMS);
m_textColValues.reserve(NUMBER_REAL_ITEMS);
m_toggleColValues.push_back(false);
m_textColValues.push_back("first row with long label to test ellipsization");
m_textColValues.push_back(useMultiLine
? multiLineText
: wxString("first row with long label to test ellipsization"));
for (unsigned int i = 1; i < NUMBER_REAL_ITEMS; i++)
{
m_toggleColValues.push_back(false);
m_textColValues.push_back(wxString::Format("real row %d", i));
}
m_iconColValues.assign(NUMBER_REAL_ITEMS, "test");
m_iconColValues.assign(NUMBER_REAL_ITEMS,
useMultiLine ? multiLineText : wxString("test"));
m_icon[0] = wxIcon( null_xpm );
m_icon[1] = wxIcon( wx_small_xpm );
const int newSize = m_icon[0].GetWidth() * 2;
const bool useTallRows = (modelFlags & MODEL_USE_TALL_ROWS) != 0;
if ( useTallRows )
m_icon[0].CopyFromBitmap(
wxImage(null_xpm).Rescale(newSize, newSize));
if ( !useTallRows || (modelFlags & MODEL_KEEP_LOGO_SMALL) )
m_icon[1] = wxIcon( wx_small_xpm );
else
m_icon[1].CopyFromBitmap(
wxImage(wx_small_xpm).Rescale(newSize, newSize));
}
void MyListModel::Prepend( const wxString &text )