Version: 3.3.1
Loading...
Searching...
No Matches
wxTipWindow::Ref Class Reference

#include <wx/tipwin.h>

Detailed Description

The (weak) reference to wxTipWindow.

wxTipWindow may close itself at any moment, so creating it as usual, with new and using a raw pointer to it is dangerous. Instead, use New() to create it and use the returned Ref which is guaranteed to become invalid when the tip window is closed.

Note that the objects of this type can't be copied, but can be moved.

To test if this object is still valid, it can be compared to nullptr or its explicit bool conversion operator can be used, i.e. either this:

if ( tip != nullptr )
tip->DoSomething();
The (weak) reference to wxTipWindow.
Definition tipwin.h:59
static Ref New(wxWindow *parent, const wxString &text, wxCoord maxLength=100, wxRect *rectBound=nullptr)
Replace the deprecated single-step constructor.

or this:

if ( tip )
tip->DoSomething();

works fine.

Since
3.3.2

Public Member Functions

 Ref ()
 Default constructor.
 
Refoperator= (std::nullptr_t)
 Put object in invalid state.
 
bool operator!= (std::nullptr_t) const
 Returns whether the object is in a valid state.
 
 operator bool () const
 Returns whether the tracked object is valid.
 
wxTipWindowoperator-> () const
 Returns a pointer to the tracked object.
 

Constructor & Destructor Documentation

◆ Ref()

wxTipWindow::Ref::Ref ( )

Default constructor.

The object is created in invalid state.

Member Function Documentation

◆ operator bool()

wxTipWindow::Ref::operator bool ( ) const
explicit

Returns whether the tracked object is valid.

This is equivalent to comparing the object to nullptr.

◆ operator!=()

bool wxTipWindow::Ref::operator!= ( std::nullptr_t ) const

Returns whether the object is in a valid state.

Object is in valid state if it is associated with a still open wxTipWindow.

◆ operator->()

wxTipWindow * wxTipWindow::Ref::operator-> ( ) const

Returns a pointer to the tracked object.

May only be called if the object is valid.

◆ operator=()

Ref & wxTipWindow::Ref::operator= ( std::nullptr_t )

Put object in invalid state.