wxRibbon richtooltips

16 views
Skip to first unread message

John Roberts

unread,
Feb 7, 2012, 9:15:49 AM2/7/12
to wx-...@googlegroups.com
Vadim
Before I do any more on this, is this an acceptable api?
John
 
{{{
virtual void SetToolRichTipParams( wxRibbonToolBarToolBase* toolBase,
                                   const wxString& tipTitle,
                                   const wxString& tipMessage,
                                   int wxiconId = wxICON_INFORMATION );
 
virtual void SetToolRichTipParams( int tool_id,
                                   const wxString& tipTitle,
                                   const wxString& tipMessage,
                                   int wxiconId = wxICON_INFORMATION );
 
virtual void SetToolRichTipIcon( wxRibbonToolBarToolBase* toolBase,
                                 const wxIcon& icon );
 
virtual void SetToolRichTipIcon( int tool_id,
                                 const wxIcon& icon );
}}}

Vadim Zeitlin

unread,
Feb 7, 2012, 9:29:20 AM2/7/12
to wx-...@googlegroups.com
On Tue, 7 Feb 2012 22:15:49 +0800 John Roberts <jo...@iinet.net.au> wrote:

JR> Before I do any more on this, is this an acceptable api?
JR>
JR> {{{
JR> virtual void SetToolRichTipParams( wxRibbonToolBarToolBase* toolBase,
JR> const wxString& tipTitle,
JR> const wxString& tipMessage,
JR> int wxiconId = wxICON_INFORMATION );
JR>
JR> virtual void SetToolRichTipParams( int tool_id,
JR> const wxString& tipTitle,
JR> const wxString& tipMessage,
JR> int wxiconId = wxICON_INFORMATION );
JR>
JR> virtual void SetToolRichTipIcon( wxRibbonToolBarToolBase* toolBase,
JR> const wxIcon& icon );
JR>
JR> virtual void SetToolRichTipIcon( int tool_id,
JR> const wxIcon& icon );
JR> }}}

Do we really need to distinguish between "params" and "icon"? I.e. why not
have a single overloaded method:

void SetToolTip(wxRibbonToolBarToolBase* tool,
const wxString& title,
const wxString& message,
int icon = wxICON_INFORMATION);

void SetToolTip(wxRibbonToolBarToolBase* tool,
const wxString& title,
const wxString& message,
const wxIcon& icon);

? Notice that I removed "Rich" from the names as I don't think it adds
anything.

I also think that perhaps I was wrong to not introduce a separate
wxRichToolTipInfo struct, as I initially planned to. If we had such struct
containing all of the information about the tool tip (similar to
wxAboutDialogInfo one), then we could simply have a single

void SetToolTip(wxRibbonToolBarToolBase* tool,
const wxRichToolTipInfo& tipInfo);

and use it like this:

wxRichToolTipInfo tipInfo("Title", "Message");
tipInfo.SetIcon(whatever);
tipInfo.SetBackgroundColour(*wxWHITE, *wxBLACK);
...
ribbonBar->SetToolTip(tool, tipInfo);

Regards,
VZ

John Roberts

unread,
Feb 7, 2012, 9:41:52 AM2/7/12
to wx-...@googlegroups.com
-----Original Message-----
From: Vadim Zeitlin
Sent: Tuesday, February 07, 2012 10:29 PM
To: wx-...@googlegroups.com
Subject: Re: [wx-dev] wxRibbon richtooltips

Do we really need to distinguish between "params" and "icon"? I.e. why not
have a single overloaded method:

? Notice that I removed "Rich" from the names as I don't think it adds
anything.

I also think that perhaps I was wrong to not introduce a separate
wxRichToolTipInfo struct, as I initially planned to. If we had such struct
containing all of the information about the tool tip (similar to
wxAboutDialogInfo one), then we could simply have a single

void SetToolTip(wxRibbonToolBarToolBase* tool,
const wxRichToolTipInfo& tipInfo);

Regards,
VZ

All points are good. The latter can be added later if not done now.
Regards, John

John Roberts

unread,
Feb 8, 2012, 2:39:26 AM2/8/12
to wx-...@googlegroups.com
-----Original Message-----
From: Vadim Zeitlin
Sent: Tuesday, February 07, 2012 10:29 PM
To: wx-...@googlegroups.com
Subject: Re: [wx-dev] wxRibbon richtooltips

If we had such struct containing all of the information about the tool tip

(similar to wxAboutDialogInfo one...

Regards,
VZ

The more I thought about this the more attractive it became. It could hold
all the fruit for an easier uniform app customisation and save revisiting
code if done now.
It would also replace wxRichToolTip members with a single info member?
I have done a quick copy/paste version below and added a few things
excluding getters of which there are none in wxRichToolTip but will be
necessary here.

One problem is that the tip point is set to the centre of the supplied
window/rect. I guess it is easier to position above and below the rect that
way. However, using 'wxTipKind_None' the tip window covers half the parent
rect unless I fudge when using ShowFor. This is also a problem for Hybrid 2
part buttons where the bottom (or top) part becomes covered.

Regards, John

class WXDLLIMPEXP_ADV wxRichToolTipInfo
{
public:
wxRichToolTipInfo();
wxRichToolTipInfo( wxRichToolTipInfo& info );

wxRichToolTipInfo( const wxString& title,


const wxString& message,
int icon = wxICON_INFORMATION );

void SetBackgroundColour( const wxColour &col, const wxColour
&colEnd=wxColour() );
void SetTimes( unsigned millisecondsDelay, unsigned
millisecondsTimeout );
void SetTipKind( wxTipKind tipKind );
void SetTitleFont( const wxFont &font );
void ShowFor( wxWindow *win );
void SetIcon( int icon=wxICON_INFORMATION );
void SetIcon( const wxIcon &icon);

private:
void Init();

wxString m_title,
m_message;

unsigned m_iconId,
m_timeDelay,
m_timeOut

wxIcon m_icon;

wxColour m_backcolourStart,
m_forecolourEnd;

wxFont m_font;

wxTipKind m_tipKind;
};

Vadim Zeitlin

unread,
Feb 8, 2012, 7:50:38 AM2/8/12
to wx-...@googlegroups.com
On Wed, 8 Feb 2012 15:39:26 +0800 John Roberts <jo...@iinet.net.au> wrote:

JR> -----Original Message-----
JR> From: Vadim Zeitlin
JR> Sent: Tuesday, February 07, 2012 10:29 PM
JR> To: wx-...@googlegroups.com
JR> Subject: Re: [wx-dev] wxRibbon richtooltips
JR>
JR> If we had such struct containing all of the information about the tool tip
JR> (similar to wxAboutDialogInfo one...
JR>
JR> Regards,
JR> VZ
JR>
JR> The more I thought about this the more attractive it became. It could hold
JR> all the fruit for an easier uniform app customisation and save revisiting
JR> code if done now.
JR> It would also replace wxRichToolTip members with a single info member?

Yes, it could be used in wxRichToolTipGenericImpl too.

JR> class WXDLLIMPEXP_ADV wxRichToolTipInfo
JR> {
JR> public:
JR> wxRichToolTipInfo();

I don't think we should have a default ctor, the title and the message
must always be specified.

JR> wxRichToolTipInfo( wxRichToolTipInfo& info );

The copy ctor doesn't seem to be necessary, the default one should be just
fine AFAICS.

Regards,
VZ

John Roberts

unread,
Nov 16, 2012, 8:56:35 PM11/16/12
to wx-...@googlegroups.com


On Wednesday, 8 February 2012 20:50:38 UTC+8, VZ wrote:
On Wed, 8 Feb 2012 15:39:26 +0800 John Roberts <jo...@iinet.net.au> wrote:

JR> -----Original Message-----
JR> From: Vadim Zeitlin
JR> Sent: Tuesday, February 07, 2012 10:29 PM
JR> To: wx-...@googlegroups.com
JR> Subject: Re: [wx-dev] wxRibbon richtooltips

JR> class WXDLLIMPEXP_ADV wxRichToolTipInfo


JR> {
JR> public:
JR>     wxRichToolTipInfo();

 I don't think we should have a default ctor, the title and the message
must always be specified.

Don't we need one to use wxRichToolTipInfo as a non-pointer class member?
wxRichToolTipInfo m_richToolTipInfo;
I had in mind using it as an app member to use as an app wide rich tip settings storage and as a member in wxRibbonButton/ToolBarBase.

Also I assume the declaration should go in "\include\wx/richtooltip.h"
and definition in "\src\common\richtooltipcmn.cpp" with no need for an impl based construction?

Regards, John

Regards, John
 

Vadim Zeitlin

unread,
Nov 17, 2012, 5:56:20 PM11/17/12
to wx-...@googlegroups.com
On Fri, 16 Nov 2012 17:56:35 -0800 (PST) John Roberts wrote:

JR> > JR> class WXDLLIMPEXP_ADV wxRichToolTipInfo
JR> > JR> {
JR> > JR> public:
JR> > JR> wxRichToolTipInfo();
JR> >
JR> > I don't think we should have a default ctor, the title and the message
JR> > must always be specified.
JR> >
JR> Don't we need one to use wxRichToolTipInfo as a non-pointer class member?
JR> wxRichToolTipInfo m_richToolTipInfo;

I didn't think anybody would want to use it like this, i.e. store it
permanently. Still not sure if this is really that useful in practice to be
honest.

JR> Also I assume the declaration should go in "\include\wx/richtooltip.h"
JR> and definition in "\src\common\richtooltipcmn.cpp" with no need for an impl
JR> based construction?

If we want to add this, we'd need to change wxRichToolTipImpl::Create() to
no take any parameters (which would in turn involve changing the ctors of
the various impl classes) and add wxRichToolTipImpl::SetTitleAndMessage().

Regards,
VZ

John Roberts

unread,
Nov 17, 2012, 6:51:28 PM11/17/12
to wx-...@googlegroups.com
On 18/11/2012 06:56, Vadim Zeitlin wrote:
> On Fri, 16 Nov 2012 17:56:35 -0800 (PST) John Roberts wrote:

> I didn't think anybody would want to use it like this, i.e. store it
> permanently. Still not sure if this is really that useful in practice to be
> honest.

Honesty is always best. If it is not useful generally I am glad I held
off writing help docs and submitted a rough draft :)

How did you envisage its usage?

Regards, John

Vadim Zeitlin

unread,
Nov 17, 2012, 7:00:51 PM11/17/12
to wx-...@googlegroups.com
On Sun, 18 Nov 2012 07:51:28 +0800 John Roberts wrote:

JR> On 18/11/2012 06:56, Vadim Zeitlin wrote:
JR> > On Fri, 16 Nov 2012 17:56:35 -0800 (PST) John Roberts wrote:
JR>
JR> > I didn't think anybody would want to use it like this, i.e. store it
JR> > permanently. Still not sure if this is really that useful in practice to be
JR> > honest.
JR>
JR> Honesty is always best. If it is not useful generally I am glad I held
JR> off writing help docs and submitted a rough draft :)
JR>
JR> How did you envisage its usage?

Well, I mostly thought that it would be used for passing information about
the tooltip to show from one place to another. But thinking more about it,
I think that you're right and that it could be natural to want to store it
permanently too. I still don't know if it's important enough to justify
doing the changes that I mentioned in the previous reply when you can
always just use a shared_ptr<wxRichToolTipInfo> for uninitialized info
object instead, but I agree that for wxRichToolTipInfo -- unlike
wxRichToolTip itself -- it probably would make more sense to have this
default ctor.

Sorry for the about-face,
VZ

John Roberts

unread,
Nov 17, 2012, 7:14:20 PM11/17/12
to wx-...@googlegroups.com
On 18/11/2012 08:00, Vadim Zeitlin wrote:
> On Sun, 18 Nov 2012 07:51:28 +0800 John Roberts wrote:
>
> JR> On 18/11/2012 06:56, Vadim Zeitlin wrote:
> JR> > On Fri, 16 Nov 2012 17:56:35 -0800 (PST) John Roberts wrote:
> JR> How did you envisage its usage?
> snip
> when you can
> always just use a shared_ptr<wxRichToolTipInfo> for uninitialized info
> object instead,
> VZ

My head is a little worse for wear this morning. Could you spell this
out a little more for me please?
Thanks, John

Vadim Zeitlin

unread,
Nov 17, 2012, 7:20:43 PM11/17/12
to wx-...@googlegroups.com
On Sun, 18 Nov 2012 08:14:20 +0800 John Roberts wrote:

JR> > when you can always just use a shared_ptr<wxRichToolTipInfo> for
JR> > uninitialized info object instead,
JR>
JR> My head is a little worse for wear this morning. Could you spell this
JR> out a little more for me please?

I meant that instead of using default-initialized wxRichToolTipInfo object
you could use a NULL pointer instead. I.e. right now you can do

shared_ptr<wxRichToolTipInfo> info;
... info is invalid in the meanwhile ...
info = make_shared<wxRichToolTipInfo>("Title", "Message");
info->SetTimeout(10000);
wxRichToolTip tip(*info);

which is not quite as efficient (extra heap allocation) nor simple as

wxRichToolTipInfo info;
... info is invalid in the meanwhile ...
info.SetTitleAndMessage("Title", "Message");
info.SetTimeout(10000);
wxRichToolTip tip(info);

but not that different, really.

Regards,
VZ
Reply all
Reply to author
Forward
0 new messages