Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#15125 closed enhancement (fixed)

Allow to select a page in wxBookCtrlBase more conveniently

Reported by: troelsk Owned by:
Priority: low Milestone:
Component: GUI-all Version: stable-latest
Keywords: wxBookCtrlBase wxNotebook Cc:
Blocked By: Blocking:
Patch: yes

Description

So a notebook page can request itself to become selected (without dealing with the page numbers)

void MyNotebookPage::Raise()
{
    wxStaticCast(GetParent(), wxNotebook)->SetSelection(this);
}

Attachments (2)

setselection.patch download (2.5 KB) - added by troelsk 19 months ago.
Trunk
findpage.patch download (2.0 KB) - added by troelsk 19 months ago.
FindPage()

Download all attachments as: .zip

Change History (6)

Changed 19 months ago by troelsk

Trunk

comment:1 Changed 19 months ago by vadz

  • Patch unset
  • Priority changed from normal to low
  • Status changed from new to confirmed
  • Summary changed from wxBookCtrlBase::SetSelection(const wxWindow*) convenience method to Allow to select a page in wxBookCtrlBase more conveniently

I don't like this for 2 reasons:

  1. Overriding virtual SetSelection() will result in virtual function hiding warnings when using g++. Moreover, these warnings are not harmless: you won't be able to call the newly added method on, say, wxNotebook*, only on wxBookCtrl*.
  2. If we have SetSelection(), we need ChangeSelection() too but I'd rather not duplicate this code, even if it's trivial.

So it looks like we need

class wxBookCtrlBase {
...
   int FindPage(wxWindow* page) const;
};

and use this instead.

Changed 19 months ago by troelsk

FindPage()

comment:2 Changed 19 months ago by troelsk

  • Patch set

Indeed. New patch added implementing FindPage(). In aui the name is GetIdxFromWindow().

comment:3 Changed 19 months ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [73734]) Added wxBookCtrlBase::FindPage().

Add helper function to find the index of the given page.

Closes #15125.

comment:4 Changed 19 months ago by VZ

(In [73735]) Minor documentation corrections in wxBookCtrlBase.

Use the correct preposition in "set selection to the given page".

See #15125.

Note: See TracTickets for help on using tickets.