Kirix Support Forums

Controls in toolbar

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

Controls in toolbar

Postby howudodat on Wed May 09, 2007 9:31 am

The toolbar is not being sized correctly if a control is in the bar. It will size the bar at only n*width for the number of buttons. So for example if I have 3 buttons a control (width of 3 buttons) and 3 more buttons, the last 2 buttons will not be visible.

[] [] [] CONTROL [] [] []
------clipped at ----|

Using wxFrame->SetToolBar doesnot manifest the same behaviour, but then I lose the docking toolbar.

Code Below
Peter

Code: Select all
// frame constructor
wxconferenceFrame::wxconferenceFrame(wxWindow* parent, wxWindowID id, const wxString& title,
                                  const wxPoint& pos, const wxSize& size,
                                  long style, const wxString& name)
                                  : wxFrame(parent, id, title, pos, size, style, name)
{
   wxImage::AddHandler(new wxPNGHandler);

   // set the frame icon
   SetIcon(wxICON(conference));

    m_mgr.SetFrame(this);
    m_mgr.SetFlags(wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_TRANSPARENT_HINT);

   CreateMenu();
   CreateToolbars();
   CreateWindows();
}

void wxconferenceFrame::CreateMenu() {
   // create menu bars
   wxMenu *l_fileMenu = new wxMenu(_(""), wxMENU_TEAROFF);
   l_fileMenu->Append(ID_QUIT, _("E&xit\tAlt-X"), _("Quit this program"));
   wxMenu *l_aboutMenu = new wxMenu(_(""), wxMENU_TEAROFF);
   l_aboutMenu->Append(ID_ABOUT, _("&About...\tCtrl-A"), _("Show conference info"));

   // now append the freshly created menu to the menu bar...
   wxMenuBar* l_menuBar = new wxMenuBar();
   l_menuBar->Append(l_fileMenu, _("&File"));
   l_menuBar->Append(l_aboutMenu, _("&Help"));

   // ... and attach this menu bar to the frame
   SetMenuBar(l_menuBar);
}

void wxconferenceFrame::CreateToolbars() {
    // create some toolbars
    wxToolBar* tb1 = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_NODIVIDER);
    tb1->SetToolBitmapSize(wxSize(24,24));

    tb1->AddTool(101, wxT("Help"), wxBitmap(wxImage(_("icons/help.png"))), _("Show Help"));
   tb1->AddControl(new wxComboBox(tb1, 1002));
   tb1->Realize();
//   SetToolBar(tb1);

   m_mgr.AddPane(tb1, wxPaneInfo().
                  Name(wxT("tb1")).Caption(wxT("Big Toolbar")).
                  ToolbarPane().Top().
                  LeftDockable(false).RightDockable(false));
}

void wxconferenceFrame::CreateWindows() {
   wxTextCtrl* text3 = new wxTextCtrl(this, -1, _("Main content window"),
   wxDefaultPosition, wxSize(200,150),
   wxNO_BORDER | wxTE_MULTILINE);


   wxPaneInfo i;
   i.CloseButton(false);
   m_mgr.AddPane(text3, wxCENTER);

   // tell the manager to "commit" all the changes just made
   m_mgr.Update();
}


howudodat
Registered User
 
Posts: 2
Joined: Wed May 09, 2007 9:08 am

Postby Ben on Mon May 14, 2007 2:20 am

Hi there,

This is a known problem with wxToolBar. Try putting your toolbar inside a panel. Things should work better.

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

Postby howudodat on Mon May 14, 2007 3:24 pm

Ben,

Just curious if you have a quick sample code. I assume I can create the panel, create the toolbar with the panel as the parent and add the panel as a control to the AUI toolbar. However I'm not sure I understand correctly. Or do I add the buttons directly to the panel as wxBitmapButtons? Also do I need to set a size for the panel? how will it now how large to make itself when wxToolbar doesn't seem to be sizing itself correctly.

Peter
howudodat
Registered User
 
Posts: 2
Joined: Wed May 09, 2007 9:08 am

Return to wxAUI Questions, Thoughts & Feedback