Kirix Support Forums

Why not more public members? Why not more virtual functions

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

Why not more public members? Why not more virtual functions

Postby jeff.daily on Fri Mar 21, 2008 11:55 am

We're trying to use wxAUI but we're wrestling with a few things:
1) We want to add three or more custom buttons to the pane caption and those buttons must also be available when the pane is floated.
2) We want to add an open/close toggle to the pane caption that leaves the caption in place but hides the rest of the pane.

This is what we're tried:
As a first attempt, we used the buttonCustom[1-3] wxAuiPaneState members of wxAuiPaneInfo and a custom art provider to get our buttons to show up in the docked pane. That feature is not documented but is in the source code. Unfortunately, when floated, our buttons have no place to go since the native window manager's window decorations cannot be modified. If there was a way to forgo using the window manager decorations in the floated windows and instead always use the standard AUI caption, we would have been fine. We couldn't find a way to draw and interact with the AUI caption in the floated window, so we resorted to creating our own caption area.

One downside to creating our caption area was that dragging-to-float was not easily supported. wxAUI otherwise ignores clicking on our custom caption area because it is technically part of the Pane contents rather than a gripper/caption part.

The upside to creating our own caption area was that it could be part of the floated pane such that our custom buttons appear when floated. By turning off the AUI caption via CaptionVisible(false), the floated frame's window decorations were gone which not only looked better but minimized screen real estate. In addition, we could customize the order of the buttons and add custom buttons more easily. For instance, we have two buttons, then the panel name, then the remaining buttons.

As far as (2) above is concerned, one of our custom buttons toggles a pane opened and closed vs the standard pane dismissal using the Close button. This proved to be tricky since Load/SavePerspective serializes the pane sizes as well as their docked positions and also because the sizes of the pane windows were changing between layouts. Worse yet, a "closed" pane was considered Fixed and an "open" pane could be either Fixed or Resizable depending on its content. So, if all panes were "closed", the Dock would consider itself a Fixed Dock and use fixed pixel layout, causing unnecessary space between panes when toggling between open/closed states. We worked around this by tricking the AUI layout function, first making one of the panes Resizable and calling Update, then making it Fixed again and calling Update a second time.

So far we have developed all of our code without touching or altering the wxAUI code. We now have a mess of spaghetti code and no longer a separation of concerns (wxAUI layout hacks all over the place, custom caption code all over the place, etc.)

Our next step is to subclass various wxAUI classes in order to get the functionality that we want. In reality, it would only take altering a few functions such as LayoutAll, getting access to some of the protected members in wxAuiManager, and adding our caption customizations. Unfortunately, practically nothing in wxAuiManager is marked virtual. We would have to do a complete re-write/copy and thus lose the ability to upgrade wxWidgets/wxAUI independent of our changes. Strangely, a select few members and functions are labeled public, while others are protected, with seemingly no design behind those decisions.

Why not just make everything public while you were at it?
Why not more/all virtual functions?

Registered User
Posts: 1
Joined: Fri Mar 21, 2008 11:25 am

Re: Why not more public members? Why not more virtual functions

Postby Ben on Mon Mar 24, 2008 8:16 am


Certainly we could have made everything public and virtual. Our goal was a stable, sustainable public API, and I think that to a large extent, this has been achieved. That said, you are right that it would be convenient if some functions, notably the Layout functions, were virtual.

We can make more functions virtual this in the trunk branch of wxWidgets, but the 2.8 branch is under ABI freeze, so this will not be possible under wxWidgets 2.8.

Thanks much for your thoughts.

Ben Williams
Kirix Support Team
User avatar
Kirix Support Team
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Return to wxAUI Questions, Thoughts & Feedback