toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file");
currentX += width + 5;
toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file");
+ currentX += width + 5;
+ toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1");
+
toolBar->AddSeparator();
wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO);
if ( !smallicons )
{
- toolBar->AddSeparator();
currentX += width + 5;
- toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1");
- currentX += width + 5;
- toolBar->AddSeparator();
toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 2");
currentX += width + 5;
toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Toggle/Untoggle help button");
toolBar->Realize();
// Can delete the bitmaps since they're reference counted
- int i, max = smallicons ? 2 : WXSIZEOF(toolBarBitmaps);
+ int i, max = smallicons ? 3 : WXSIZEOF(toolBarBitmaps);
for (i = 0; i < max; i++)
delete toolBarBitmaps[i];
{
m_toolStyle = wxTOOL_STYLE_CONTROL;
m_control = control;
+ m_index = control->GetId();
}
wxToolBarTool::~wxToolBarTool()
if ( !CreateControl(parent, id, pos, size, style, name) )
return FALSE;
- // set up the colors and fonts
-#if 0
- wxRGBToColour(m_backgroundColour, GetSysColor(COLOR_BTNFACE));
- m_foregroundColour = *wxBLACK;
-
- SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-#endif
-
// prepare flags
DWORD msflags = 0; // WS_VISIBLE | WS_CHILD always included
if (style & wxBORDER)
if (style & wxTB_FLAT)
{
if (wxTheApp->GetComCtl32Version() > 400)
- msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT;
+ msflags |= TBSTYLE_FLAT;
}
// MSW-specific initialisation
if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) )
return FALSE;
- // Toolbar-specific initialisation
+ // toolbar-specific post initialisation
::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
+ // set up the colors and fonts
+ wxRGBToColour(m_backgroundColour, GetSysColor(COLOR_BTNFACE));
+ m_foregroundColour = *wxBLACK;
+
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+
// position it
int x = pos.x;
int y = pos.y;
// and position the control itself correctly vertically
RECT r;
- SendMessage(GetHwnd(), TB_GETRECT, 0, (LPARAM)(LPRECT)&r);
+ if ( !SendMessage(GetHwnd(), TB_GETRECT,
+ tool->m_index, (LPARAM)(LPRECT)&r) )
+ {
+ wxLogLastError("TB_GETRECT");
+ }
int height = r.bottom - r.top;
int diff = height - size.y;