const wxString& name)
{
// common initialisation
- if ( !CreateControl(parent, id, pos, size, style, name) )
+ if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
// prepare flags
DWORD msflags = 0; // WS_VISIBLE | WS_CHILD always included
if (style & wxBORDER)
msflags |= WS_BORDER;
+
+#ifdef TBSTYLE_TOOLTIPS
msflags |= TBSTYLE_TOOLTIPS;
+#endif
if (style & wxTB_FLAT)
{
// Map to system colours
wxMapBitmap(hBitmap, totalBitmapWidth, totalBitmapHeight);
+ int bitmapId = 0;
+
+ bool addBitmap = TRUE;
+
if ( oldToolBarBitmap )
{
- TBREPLACEBITMAP replaceBitmap;
- replaceBitmap.hInstOld = NULL;
- replaceBitmap.hInstNew = NULL;
- replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
- replaceBitmap.nIDNew = (UINT) hBitmap;
- replaceBitmap.nButtons = nButtons;
- if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP,
- 0, (LPARAM) &replaceBitmap) )
+#ifdef TB_REPLACEBITMAP
+ if ( wxTheApp->GetComCtl32Version() >= 400 )
{
- wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
+ TBREPLACEBITMAP replaceBitmap;
+ replaceBitmap.hInstOld = NULL;
+ replaceBitmap.hInstNew = NULL;
+ replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
+ replaceBitmap.nIDNew = (UINT) hBitmap;
+ replaceBitmap.nButtons = nButtons;
+ if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP,
+ 0, (LPARAM) &replaceBitmap) )
+ {
+ wxFAIL_MSG(wxT("Could not replace the old bitmap"));
+ }
+
+ ::DeleteObject(oldToolBarBitmap);
+
+ // already done
+ addBitmap = FALSE;
}
+ else
+#endif // TB_REPLACEBITMAP
+ {
+ // we can't replace the old bitmap, so we will add another one
+ // (awfully inefficient, but what else to do?) and shift the bitmap
+ // indices accordingly
+ addBitmap = TRUE;
- ::DeleteObject(oldToolBarBitmap);
+ bitmapId = m_nButtons;
+ }
// Now delete all the buttons
for ( size_t pos = 0; pos < m_nButtons; pos++ )
wxLogLastError("TB_DELETEBUTTON");
}
}
+
}
- else // no old bitmap
+
+ if ( addBitmap ) // no old bitmap or we can't replace it
{
TBADDBITMAP addBitmap;
addBitmap.hInst = 0;
wxArrayInt controlIds;
int i = 0;
- int bitmapId = 0;
-
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxToolBarToolBase *tool = node->GetData();
// the id is probably invalid?
wxLogLastError("TB_SETBUTTONINFO");
}
-
}
else
#endif // comctl32.dll 4.71
TBBUTTON tbb;
wxZeroMemory(tbb);
tbb.idCommand = 0;
- tbb.fsState = TBSTATE_ENABLED;
+ tbb.fsState = TBSTATE_ENABLED | TBSTATE_HIDDEN;
tbb.fsStyle = TBSTYLE_SEP;
size_t nSeparators = size.x / widthSep;
if ( tool->CanBeToggled() )
{
LRESULT state = ::SendMessage(GetHwnd(), TB_GETSTATE, id, 0);
- tool->SetToggle((state & TBSTATE_CHECKED) != 0);
+ tool->Toggle((state & TBSTATE_CHECKED) != 0);
}
bool toggled = tool->IsToggled();
void wxToolBar::UpdateSize()
{
- // we must refresh the frame after the toolbar size (possibly) changed
+ // the toolbar size changed
+ SendMessage(GetHwnd(), TB_AUTOSIZE, 0, 0);
+
+ // we must also refresh the frame after the toolbar size (possibly) changed
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
if ( frame )
{
(void)::SendMessage(GetHwndOf(frame), WM_SIZE, SIZE_RESTORED,
MAKELPARAM(r.right - r.left, r.bottom - r.top));
}
-
}
// ----------------------------------------------------------------------------
#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
-#define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
+#define BGR_BACKGROUNDSEL (RGB(000,000,255)) // blue
#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
void wxMapBitmap(HBITMAP hBitmap, int width, int height)
{BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
{BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
{BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
- {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
+/* {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue */
{BGR_BACKGROUND, COLOR_WINDOW} // magenta
};