wxInfoBar - How to show above another widget?

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.
Post Reply
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

wxInfoBar - How to show above another widget?

Post by apoorv569 »

Is it possible to show wxInfoBar on top of another widget, instead of taking its own space, and also auto hides after some timeout? For example,
Image

In this image, I have wxSearchCtrl and below it wxDataViewListCtrl, when the wxInfoBar appears, I have set its position to be below wxSearchCtrl. Just curious if it is possible to show wxInfoBar where the wxSearchCtrl is, not taking its own space?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxInfoBar - How to show above another widget?

Post by doublemax »

I would use wxRichToolTip instead.
https://docs.wxwidgets.org/trunk/classw ... l_tip.html

Check the "dialogs" sample to see it in action.
Use the source, Luke!
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

Re: wxInfoBar - How to show above another widget?

Post by apoorv569 »

doublemax wrote: Sun Jun 27, 2021 10:18 pm I would use wxRichToolTip instead.
https://docs.wxwidgets.org/trunk/classw ... l_tip.html

Check the "dialogs" sample to see it in action.
I tried wxRichToolTip, it appears on center screen, near to where I click (I could be wrong about the position), also it does not look very native GTK control. Here is the relavent code,

Code: Select all

            msg = wxString::Format("Added %s to %s", name, folder_name);

            wxRichToolTip tip("Info", msg);
            tip.SetTipKind(wxTipKind_None);
            tip.SetIcon(wxICON_INFORMATION);
            tip.ShowFor(m_SampleListView);
Here is a screenshot of both InfoBar and RichToolTip inside the application,
Image

Is it possible to show this, where the InfoBar is currently?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxInfoBar - How to show above another widget?

Post by doublemax »

The ShowFor() call takes a wxRect as second parameter which can be used to set the position of the tooltip.
...also it does not look very native GTK control.
Yes, it's not a native control.
Use the source, Luke!
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

Re: wxInfoBar - How to show above another widget?

Post by apoorv569 »

doublemax wrote: Tue Jun 29, 2021 9:50 am The ShowFor() call takes a wxRect as second parameter which can be used to set the position of the tooltip.
I set the the wxRect as,

Code: Select all

            msg = wxString::Format("Added %s to %s", name, folder_name);

            wxRect* rect = new wxRect(m_SearchBox->GetPosition(), m_SearchBox->GetSize());

            wxRichToolTip tip("Info", msg);
            tip.SetTipKind(wxTipKind_None);
            tip.SetIcon(wxICON_INFORMATION);
            tip.ShowFor(m_SampleListView, rect);
But it still shows as this,
Image
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxInfoBar - How to show above another widget?

Post by doublemax »

I think the rect is relative to the window you're passing. Try passing a rect of (0,0,1,1) and check where it opens.
Use the source, Luke!
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

Re: wxInfoBar - How to show above another widget?

Post by apoorv569 »

doublemax wrote: Tue Jun 29, 2021 11:32 am I think the rect is relative to the window you're passing. Try passing a rect of (0,0,1,1) and check where it opens.
Passing (0,0,1,1) for rect, shows it like this, I have hidden the InfoBar,
Image

Not sure, but looks like at 0,0 of wxDVLC the tooltip puts its center.

Also curious, what if I, whenever I want to show InfoBar, I call Hide() for SearchCtrl, then I show the InfoBar() and when the InfoBar is closed, I call Show() for SearchCtrl?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxInfoBar - How to show above another widget?

Post by doublemax »

apoorv569 wrote: Tue Jun 29, 2021 11:56 am Not sure, but looks like at 0,0 of wxDVLC the tooltip puts its center.
Ok. With that information you should be able to place it where ever you want.
apoorv569 wrote: Tue Jun 29, 2021 11:56 am Also curious, what if I, whenever I want to show InfoBar, I call Hide() for SearchCtrl, then I show the InfoBar() and when the InfoBar is closed, I call Show() for SearchCtrl?
You could try, but i think it'll look ugly.
Use the source, Luke!
Post Reply