wxDataViewListCtrl - IconTextColumn, how to centre align column data? Topic is solved
wxDataViewListCtrl - IconTextColumn, how to centre align column data?
I have a IconTextColumn in wxDataViewListCtrl, in which I show a greyscale icon, and clicking on it changes the image from greyscale to coloured, acting like a ToggleColumn. Everything works fine, just want to know how can I center align the column data instead of left aligned, I can set the position of column header but not the blocks below it. Here is a example image,
As you can see, the column header shows in middle, but the blocks below it are left aligned, I want that they also show center aligned. I have tried using SetAlignment(wxALIGN_CENTER) but it does not seem to do anything, or perhaps it is for column header only.
As you can see, the column header shows in middle, but the blocks below it are left aligned, I want that they also show center aligned. I have tried using SetAlignment(wxALIGN_CENTER) but it does not seem to do anything, or perhaps it is for column header only.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Can you check the "dataview" sample?
On the second tab, "MyListModel", the first column is an icon+text column. Under Windows it is center aligned.
On the second tab, "MyListModel", the first column is an icon+text column. Under Windows it is center aligned.
Use the source, Luke!
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
I just checked the dataview sample, it does not look like center aligned in the sample either, so is it not possible on Linux/GTK?
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Hi,
Can you try and see if its possible to set the right alignment?
Also - what is your GTK+ version, theme and WM?
Thank you.
Can you try and see if its possible to set the right alignment?
Also - what is your GTK+ version, theme and WM?
Thank you.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Your sample looks different than mine. You're still on wx 3.0.5?
Use the source, Luke!
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
I tried using SetAlignment(wxALIGN_RIGHT), looks like it only aligns the column header right, not the block below.
My GTK and wx version,
Theme I'm using currently is the default GTK theme used, i.e Adwaita, I'm using dark version of it, I have multiple WM installed, in the screenshot above, I'm using a standalone WM called DWM. But I don't think WM should affect anything here.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Yes, the Git branch I'm currently working on, I'm still on wx 3.0.5, I will switch to wx 3.1.x, in a different branch, because this branch is temporary. I will try the sample for wx3.1.x, and see if that sample shows in center.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Yes on the sample for wx3.1.x source, the column items appear center aligned.
I guess I got another reason to switch to wx3.1.x.
I also noticed widgets looked a bit different, the over feel, visually looked a bit different, more polished and cleaner. Is there some difference?
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
I'm pretty sure there are many differences, 3.0.5 is over a year old. Maybe the improved dark mode support is what you're seeing.Is there some difference?
Use the source, Luke!
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Okay, I built the application with wx3.1.5,
But it still does not show center aligned,
Here is the code, where I append the columns,
Code: Select all
m_SampleListView->AppendIconTextColumn((wchar_t)U'🟊', wxDATAVIEW_CELL_ACTIVATABLE, 30, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE);
m_SampleListView->AppendTextColumn("Filename", wxDATAVIEW_CELL_INERT, 320, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->AppendTextColumn("Sample Pack", wxDATAVIEW_CELL_INERT, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->AppendTextColumn("Type", wxDATAVIEW_CELL_INERT, 120, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->AppendTextColumn("Channels", wxDATAVIEW_CELL_INERT, 100, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->AppendTextColumn("Length", wxDATAVIEW_CELL_INERT, 100, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->AppendTextColumn("Sample Rate", wxDATAVIEW_CELL_INERT, 140, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->AppendTextColumn("Bitrate", wxDATAVIEW_CELL_INERT, 100, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
m_SampleListView->GetColumn(0)->SetAlignment(wxALIGN_CENTER);
Code: Select all
wxVariant icon;
icon << wxDataViewIconText(wxEmptyString, wxIcon(ICON_GREYSCALE));
if (tags.IsFileValid())
{
data.clear();
data.push_back(icon);
data.push_back(filename);
.
.
.
I also noticed quite a few things, that was not working before started working now, like before wxLogInfo() and wxLogWarning() was not working, i.e nothing shows up, only wxLogDebug() worked, now wxLogInfo(0 and wxLogWarning() are showing up as well.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Hi,
So what do you do differently from the sample?
Can you isolate it, i.e. make the sample work like your application?
Thank you.
So what do you do differently from the sample?
Can you isolate it, i.e. make the sample work like your application?
Thank you.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Looking at the code for the dataview sample, it looks like it is using a custom column that uses CheckIconTextRenderer instead of IconTextRenderer,
Code: Select all
wxDataViewColumn* const colCheckIconText = new wxDataViewColumn
(
L"\u2714 + icon + text",
new wxDataViewCheckIconTextRenderer(),
MyListModel::Col_ToggleIconText,
wxCOL_WIDTH_AUTOSIZE
);
m_ctrl[Page_List]->AppendColumn(colCheckIconText);
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Hi,
Then all you meed to do is use it, right?
Thank you.
Then all you meed to do is use it, right?
Thank you.
Re: wxDataViewListCtrl - IconTextColumn, how to centre align column data?
Hi,
Yes, But you can override the renderer and use the icon instead.
Thank you.
Yes, But you can override the renderer and use the icon instead.
Thank you.