Author Topic: [wxSmith] Two suggestions  (Read 6179 times)

Offline Commodore64

  • Multiple posting newcomer
  • *
  • Posts: 35
[wxSmith] Two suggestions
« on: April 09, 2007, 11:45:26 am »
(If you want, I will open two feature requests at Berlios)

Currently, wxToolBar's are created using wxFrame::CreateToolBar.
I suggest to create toolbars using the constructor of wxToolBar, instead; and *optionally* add them to the wxFrame using wxFrame::SetToolBar.
This way, the user is free to use a toolbar created with wxSmith for other purposes. For example, to pass it to wxAUI.

Another suggestion: EVT_CLOSE is missing from wxFrame. May you add it?

Thank you  :D

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] Two suggestions
« Reply #1 on: April 10, 2007, 12:40:50 am »
Hi, I've added EVT_CLOSE for wxDialog and wxFrame (comitted in rev. 3821), I've also switched to new wxToolBar instead of wxFrame::CreateToolBar.

I still have to think about the change to new wxToolBar because it introducess one shortcoming.
Wx docs for wxFrame::CreateToolBar() say:

Quote
Under Pocket PC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create a wxToolBar as usual.

So it may produce wxToolBar in some platform-specific manner, not always through creating wxToolBar. But I've looked into XRC source code and it creates toolbar using new, so probably this is the best solution for now.

But I still don't see how it could be used outside wxFrame (like in wxAUI). Curent implementation is limited to standard toolbars only and it creates toolbar just like it's done in CreateToolbar. I think that there may still be some problems when you want to use it exernally but I may be wrong :)

Regards
  BYO

Offline Commodore64

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: [wxSmith] Two suggestions
« Reply #2 on: April 10, 2007, 10:41:09 am »
Thank you byo: excellent support ;)

I still have to think about the change to new wxToolBar because it introducess one shortcoming.
Wx docs for wxFrame::CreateToolBar() say:

Quote
Under Pocket PC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create a wxToolBar as usual.

So it may produce wxToolBar in some platform-specific manner, not always through creating wxToolBar. But I've looked into XRC source code and it creates toolbar using new, so probably this is the best solution for now.

But I still don't see how it could be used outside wxFrame (like in wxAUI). Curent implementation is limited to standard toolbars only and it creates toolbar just like it's done in CreateToolbar. I think that there may still be some problems when you want to use it exernally but I may be wrong :)

From the wxAUI sample program:
Code
wxToolBar* tb1 = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
                                   wxTB_FLAT | wxTB_NODIVIDER);

[...]
   
m_mgr.AddPane(tb1, wxAuiPaneInfo().
Name(wxT("tb1")).Caption(wxT("Big Toolbar")).
ToolbarPane().Top().
LeftDockable(false).RightDockable(false));

Basically, it creates a wxToolBar using the constructor and it adds it to the wxAuiManager using the AddPane function, without adding the toolbar to the wxFrame directly.

You are right about the issue with Pocket PC. You may let the user choose among two possibilities: adding the toolbar "at the top or left of the frame", as the manual says (in this case wxFrame::CreateToolBar is used), or not (in this case the wxToolBar constructor is used, and it is the user's responsibility to do something useful with the created toolbar, like adding it to the frame using wxFrame::SetToolBar, or adding the toolbar to a wxAuiManager, or whatever).

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] Two suggestions
« Reply #3 on: April 10, 2007, 02:07:43 pm »
Thank you byo: excellent support ;)

Nice to hear that :) Thanks

Quote
Basically, it creates a wxToolBar using the constructor and it adds it to the wxAuiManager using the AddPane function, without adding the toolbar to the wxFrame directly.

You are right about the issue with Pocket PC. You may let the user choose among two possibilities: adding the toolbar "at the top or left of the frame", as the manual says (in this case wxFrame::CreateToolBar is used), or not (in this case the wxToolBar constructor is used, and it is the user's responsibility to do something useful with the created toolbar, like adding it to the frame using wxFrame::SetToolBar, or adding the toolbar to a wxAuiManager, or whatever).

Yup, allowing user to select the "mode" of toolbar creation sounds like the best solution (set to CreateToolbar by default but changable for more advanced users). I'll put this into my TODO list :)

Regards
  BYO