Is wxListCtrl crossplatform? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Is wxListCtrl crossplatform?

Post by Ronald »

Code: Select all

class WXDLLIMPEXP_CORE wxListCtrl: public wxListCtrlBase
wxListCtrlBase in include\wx\listbase.h
wxListCtrl in include\wx\msw\listctrl.h

When programming under windows, wxListCtrl is used.
Does it mean wxListCtrl is not crossplatform?

BTW, no listctrl.h in
  • include/gtk
  • include/gtk1
  • include/motif
  • include/osx
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Is wxListCtrl crossplatform?

Post by doublemax »

Code: Select all

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    #include "wx/msw/listctrl.h"
#elif defined(__WXQT__) && !defined(__WXUNIVERSAL__)
    #include "wx/qt/listctrl.h"
#else
    #include "wx/generic/listctrl.h"
#endif
A generic implementation is used on platforms where no native control is available.
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

doublemax wrote: Mon Oct 14, 2019 11:26 am

Code: Select all

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    #include "wx/msw/listctrl.h"
#elif defined(__WXQT__) && !defined(__WXUNIVERSAL__)
    #include "wx/qt/listctrl.h"
#else
    #include "wx/generic/listctrl.h"
#endif
A generic implementation is used on platforms where no native control is available.
So to be crossplatform, wxListCtrl should not be used?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Is wxListCtrl crossplatform?

Post by doublemax »

So to be crossplatform, wxListCtrl should not be used?
That's not what i said. wxListCtrl is available and usable on all platforms, but only under Windows a native control will be used for it.
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

doublemax wrote: Mon Oct 14, 2019 12:27 pm wxListCtrl is available and usable on all platforms, but only under Windows a native control will be used for it.
While each wxListctrl derived from wxListCtrlBase, they have their own public functions, non virtual, like:

Code: Select all

bool GetItem( wxListItem& info ) const;
bool SetItem( wxListItem& info ) ;
bool SetItem( long index, int col, const wxString& label, int imageId = -1 );
int  GetItemState( long item, long stateMask ) const;
bool SetItemState( long item, long state, long stateMask);
bool SetItemImage( long item, int image, int selImage = -1 );
bool SetItemColumnImage( long item, long column, int image );
What's the standard to keep wxListCtrl crossplatform? The doc?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Is wxListCtrl crossplatform?

Post by ONEEYEMAN »

Hi,
All controls inside wxWidgets are cross-platform. The difference is that some controls on some platform are native, while the control on a different platform is generic.
What generic means is that it implemented by wxWidgets itself, but using the same public API as a native one.

But all this shouldn't concern you - it is implementation detail.
Unless you working on the wxWidgets itself.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Is wxListCtrl crossplatform?

Post by doublemax »

Ronald wrote: Mon Oct 14, 2019 12:49 pm What's the standard to keep wxListCtrl crossplatform? The doc?
Yes
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

ONEEYEMAN wrote: Mon Oct 14, 2019 2:37 pm But all this shouldn't concern you - it is implementation detail.
Unless you working on the wxWidgets itself.
I'm considering to do some pulll request.
wxListCtrl/wxListView currently not support sort header indicator in virtual mode,
so I'd like to add the feature.
BTW, SetColumnImage can add an indicator, but it is always to the right of the label,
instead of aligning to the right of the header rect.
Last edited by Ronald on Mon Oct 14, 2019 4:48 pm, edited 2 times in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Is wxListCtrl crossplatform?

Post by ONEEYEMAN »

Hi,
OK, so you are looking to create a new event and basically modify msw/listctrl.{cpp,h} and generic/listctrl{cpp,h}.

Thank you.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

doublemax wrote: Mon Oct 14, 2019 3:33 pm
Ronald wrote: Mon Oct 14, 2019 12:49 pm What's the standard to keep wxListCtrl crossplatform? The doc?
Yes
It's clear, flexible.

Thanks
Last edited by Ronald on Mon Oct 14, 2019 4:52 pm, edited 2 times in total.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

ONEEYEMAN wrote: Mon Oct 14, 2019 4:40 pm Hi,
OK, so you are looking to create a new event and basically modify msw/listctrl.{cpp,h} and generic/listctrl{cpp,h}.

Thank you.
According to

Code: Select all

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    #include "wx/msw/listctrl.h"
#elif defined(__WXQT__) && !defined(__WXUNIVERSAL__)
    #include "wx/qt/listctrl.h"
#else
    #include "wx/generic/listctrl.h"
#endif
and qt/listctrl.{cpp,h}

I'm only hot for msw now.
Leaving the other 2 with invalid implementations, it seems that the PR is hard to be accepted, because it's not complete, right?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Is wxListCtrl crossplatform?

Post by doublemax »

Ronald wrote: Mon Oct 14, 2019 4:47 pm Leaving the other 2 with invalid implementations, it seems that the PR is hard to be accepted, because it's not complete, right?
What kind of API extension are you suggesting? Implementing it for MSW and the generic version would cover all major platforms.

But this kind of things should be discussed on the mailing list, and i think you've already talked with Vadim about this. But i didn't follow the details.
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

doublemax wrote: Mon Oct 14, 2019 4:59 pm What kind of API extension are you suggesting? Implementing it for MSW and the generic version would cover all major platforms.

Code: Select all

void  ShowSortIndicator(unsigned int idx, bool sortOrder = true)
{
    HWND hLC = GetHWND();
    HWND hLCH = (HWND)ListView_GetHeader(hLC);

    HDITEMW hdiOld = { 0 };
    {
        hdiOld.mask = HDI_FORMAT;
        Header_GetItem(hLCH, idx, &hdiOld);
    }

    HDITEMW hdi = { 0 };
    hdi.mask = HDI_FORMAT;
    hdi.fmt = hdiOld.fmt;
    if (sortOrder)
    {
        hdi.fmt |= HDF_SORTUP;
        hdi.fmt &= ~HDF_SORTDOWN;
    }
    else
    {
        hdi.fmt &= ~HDF_SORTUP;
        hdi.fmt |= HDF_SORTDOWN;
    }

    Header_SetItem(hLCH, idx, &hdi);
}

void  RemoveSortIndicator(unsigned int idx)
{
    HWND hLC = GetHWND();
    HWND hLCH = (HWND)ListView_GetHeader(hLC);

    HDITEMW hdiOld = { 0 };
    {
        hdiOld.mask = HDI_FORMAT;
        Header_GetItem(hLCH, idx, &hdiOld);
    }

    HDITEMW hdi = { 0 };
    hdi.mask = HDI_FORMAT;
    hdi.fmt = hdiOld.fmt & ~(HDF_SORTUP | HDF_SORTDOWN);

    Header_SetItem(hLCH, idx, &hdi);
}
doublemax wrote: Mon Oct 14, 2019 4:59 pm But this kind of things should be discussed on the mailing list, and i think you've already talked with Vadim about this. But i didn't follow the details.
He ignore me :lol:
https://trac.wxwidgets.org/ticket/18527

zzz now
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Is wxListCtrl crossplatform?

Post by PB »

I do not think he is ignoring you. Vadim is just extremely busy.

Additionally, adding a new feature for all platforms may not be easy. Can you test it on MSW, OSX, and Linux (and Qt)?

I have added only a bit here and there for MSW only and even that was often surprisingly difficult, just making sure the code builds with all supported compilers was quite a challenge, usually due to a lack of up-to-date MiNGW headers...

I would also make sure to read Coding Guidelines (e.g, with regard to bool arguments of functions). For example, even if the code you posted worked, in many regards, it is quite different from the code which can be reasonably expected to merge. OTOH, the community is friendly and can help with the small things.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: Is wxListCtrl crossplatform?

Post by Ronald »

PB wrote: Mon Oct 14, 2019 7:39 pm I do not think he is ignoring you. Vadim is just extremely busy.
When I filed a bug, he responded much more quickly.
However I don't think he is intended to ingore me.
When I found he committed code step by step, I thought he was strict and for quality.
I appreciate the way.
So a new but related issue should be in a new ticket, better with a patch for testing.
PB wrote: Mon Oct 14, 2019 7:39 pm Additionally, adding a new feature for all platforms may not be easy. Can you test it on MSW, OSX, and Linux (and Qt)?

I have added only a bit here and there for MSW only and even that was often surprisingly difficult, just making sure the code builds with all supported compilers was quite a challenge, usually due to a lack of up-to-date MiNGW headers...

I would also make sure to read Coding Guidelines (e.g, with regard to bool arguments of functions). For example, even if the code you posted worked, in many regards, it is quite different from the code which can be reasonably expected to merge.
OK, it depends on the value of contributed code and time.
PB wrote: Mon Oct 14, 2019 7:39 pm OTOH, the community is friendly and can help with the small things.
Yes, thanks.
Post Reply