Opened 5 years ago

Closed 4 years ago

#15110 closed enhancement (fixed)

wxInfoBar should get methods to get the added buttons

Reported by: Hanmac Owned by: VZ
Priority: low Milestone:
Component: GUI-all Version: stable-latest
Keywords: work-needed Cc:
Blocked By: Blocking:
Patch: yes


i made a Patch that adds

    virtual bool HasButtonId(wxWindowID btnid) = 0;
    virtual wxWindowID GetButtonId(size_t idx) = 0;
    virtual size_t GetButtonCount() = 0;

to wxInfoBarBase so the user could look that buttons are in there.

i wish i could add this functions too but i dont get it working with the GTK port

    virtual void SetButtonLabel(wxWindowID btnid, const wxString& label) = 0;
    virtual wxString GetButtonLabel(wxWindowID btnid) = 0;

Attachments (1)

infobar.patch download (7.3 KB) - added by Hanmac 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by vadz

  • Keywords work-needed added
  • Priority changed from normal to low
  • Status changed from new to confirmed
  • Summary changed from wxInfoBar should get methods to get the added Buttons to wxInfoBar should get methods to get the added buttons

Thanks for the patch! It's a good start but unfortunately can't be quite applied in the current state because of the following points:

  1. We absolutely require documentation for any new features, please update source:wxWidgets/trunk/interface/wx/infobar.h with the descriptions of the new functions. Please don't forget to use "@since 2.9.5" in their documentation.
  2. All the new methods should be "const", as they don't modify the object itself.
  3. The comments in wxInfoBarGeneric::GetButtonCount() don't seem to make sense for this method, they probably were copied from another method. Its code is also rather strange, why do we return 0 "if we found our button"?
  4. The interpretation of idx argument of wxInfoBarGeneric::GetButtonId() is unclear (the documentation would have helped here...): do we count the buttons from left to right or in order of their addition? In any case it looks like the code here is too complicated and could be simplified.
  5. Which bring me to the next point: it's hard to be sure that the code works correctly. It would be great to add tests/controls/infobar.cpp with some tests verifying that this is indeed the case. Or at least add the calls to these methods to the infobar sample to allow testing them interactively.
  6. Minor: please don't leave commented out methods in include/wx/infobar.h.

Could you please update the patch to address these points? TIA!

comment:2 Changed 5 years ago by Hanmac

  1. go from the back and look for the spacer, if you find it, go forward again and count the buttons, if the button with the wanted idx is found return that id

it may complicated but i dont know a better way

the others will me fixed instantly

PS: there is a difference between the eventobject when you bind the EVT_COMMAND_BUTTON_CLICKED event,
with gtk the eventobject is the infobar itself but in the generic one, its the clicked button ... i dont know if we should mention that

Changed 5 years ago by Hanmac

comment:3 Changed 5 years ago by Hanmac

i added a Patch that should fix most of your requests

"The interpretation of idx argument of wxInfoBarGeneric::GetButtonId()" this is not fixed yet, because i currently dont know how to write it better, and yah its counted from the left, but first it needs to find the rightest spacer

and i currently dont have an idea how to write an Test for it

comment:4 Changed 4 years ago by vadz

Sorry for the long delay, I'm finally going to apply this.

For the future patches I'd really like to ask you to use our coding conventions, it's annoying to have to reformat the code before applying. TIA!

comment:5 Changed 4 years ago by VZ

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

In 76651:

Allow access to the currently shown wxInfoBar buttons.

Add wxInfoBar::GetButtonCount(), GetButtonId() and HasButtonId() methods.

Closes #15110.

Note: See TracTickets for help on using tickets.