Search code examples
c++wxwidgets

How to set the size of a toolbar button


I am trying to make a toolbar with some radio buttons. The Problem is that when I add a button in the toolbar, the button is too big,bigger than the height of the toolbar. I have already tried to set the size of the bitmap with not any result. However there is not any function to set the size of the tool itself. Is there any way to make it?

this->m_ToolBar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT | wxTB_NOICONS);
this->m_ToolBar->AddRadioTool(this->LastToolBarId, Name, wxNullBitmap, wxNullBitmap, toolTip, wxT(""), Data);
this->m_ToolBar->ToggleTool (this->LastToolBarId, true); 
this->m_ToolBar->Realize();

Solution

  • Ok I found it. I didn't know that there is a white bitmap(16x15) over the text of the tool. So the answer is quite simple. I use SetToolBitmapSize with size (1,1)

    this->m_ToolBar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT | wxTB_NOICONS);
    this->m_ToolBar->SetToolBitmapSize(wxSize(1,1)); 
    this->m_ToolBar->AddRadioTool(this->LastToolBarId, Name, wxNullBitmap, wxNullBitmap, toolTip, wxT(""), Data);
    this->m_ToolBar->ToggleTool (this->LastToolBarId, true); 
    this->m_ToolBar->Realize();