#include "wx/msw/private.h"
+#if wxUSE_UXTHEME
+#include "wx/msw/uxtheme.h"
+#endif
+
// include <commctrl.h> "properly"
#include "wx/msw/wrapcctl.h"
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
/*
- TOOLBAR PROPERTIES
- tool
- bitmap
- bitmap2
- tooltip
- longhelp
- radio (bool)
- toggle (bool)
- separator
- style ( wxNO_BORDER | wxTB_HORIZONTAL)
- bitmapsize
- margins
- packing
- separation
-
- dontattachtoframe
+ TOOLBAR PROPERTIES
+ tool
+ bitmap
+ bitmap2
+ tooltip
+ longhelp
+ radio (bool)
+ toggle (bool)
+ separator
+ style ( wxNO_BORDER | wxTB_HORIZONTAL)
+ bitmapsize
+ margins
+ packing
+ separation
+
+ dontattachtoframe
*/
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
{
// common initialisation
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
- return FALSE;
+ return false;
// MSW-specific initialisation
if ( !MSWCreateToolbar(pos, size) )
- return FALSE;
+ return false;
wxSetCCUnicodeFormat(GetHwnd());
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
// workaround for flat toolbar on Windows XP classic style
+#if wxUSE_UXTHEME
if ( style & wxTB_FLAT )
{
- DWORD dwToolbarStyle;
-
- dwToolbarStyle = (DWORD)::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L );
-
- if ((dwToolbarStyle & TBSTYLE_FLAT) == 0)
+ wxUxThemeEngine *p = wxUxThemeEngine::Get();
+ if ( !p || !p->IsThemeActive() )
{
- dwToolbarStyle |= TBSTYLE_FLAT;
- ::SendMessage(GetHwnd(), TB_SETSTYLE, 0, (LPARAM)dwToolbarStyle );
+ DWORD dwToolbarStyle;
+
+ dwToolbarStyle = (DWORD)::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L );
+
+ if ((dwToolbarStyle & TBSTYLE_FLAT) == 0)
+ {
+ dwToolbarStyle |= TBSTYLE_FLAT;
+ ::SendMessage(GetHwnd(), TB_SETSTYLE, 0, (LPARAM)dwToolbarStyle );
+ }
}
}
- return TRUE;
+#endif
+
+ return true;
}
bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size)
{
if ( !MSWCreateControl(TOOLBARCLASSNAME, wxEmptyString, pos, size) )
- return FALSE;
+ return false;
// toolbar-specific post initialisation
::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
-
- return TRUE;
+
+ return true;
}
void wxToolBar::Recreate()
tool->Attach(this);
InvalidateBestSize();
- return TRUE;
+ return true;
}
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
{
wxLogLastError(wxT("TB_DELETEBUTTON"));
- return FALSE;
+ return false;
}
}
int x;
wxControl *control = tool2->GetControl();
control->GetPosition(&x, NULL);
- control->Move(x - width, -1);
+ control->Move(x - width, wxDefaultCoord);
}
}
InvalidateBestSize();
- return TRUE;
+ return true;
}
bool wxToolBar::Realize()
if ( nTools == 0 )
{
// nothing to do
- return TRUE;
+ return true;
}
const bool isVertical = HasFlag(wxTB_VERTICAL);
if (wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 2)
{
doRemapBg = doRemap = false;
- doTransparent = true;
+ doTransparent = true;
}
else
{ doRemap = !wxSystemOptions::HasOption(wxT("msw.remap"))
{
wxLogLastError(_T("CreateCompatibleBitmap"));
- return FALSE;
+ return false;
}
m_hBitmap = (WXHBITMAP)hBitmap;
int yOffset = wxMax(0, (m_defaultHeight - bmp.GetHeight())/2);
#if USE_BITMAP_MASKS
// notice the last parameter: do use mask
- dcAllButtons.DrawBitmap(bmp, x+xOffset, yOffset, TRUE);
+ dcAllButtons.DrawBitmap(bmp, x+xOffset, yOffset, true);
#else // !USE_BITMAP_MASKS
SelectInHDC hdcSelector2(memoryDC2, GetHbitmapOf(bmp));
if ( !BitBlt(memoryDC,
totalBitmapWidth, totalBitmapHeight);
}
- bool addBitmap = TRUE;
+ bool addBitmap = true;
if ( oldToolBarBitmap )
{
::DeleteObject(oldToolBarBitmap);
// already done
- addBitmap = FALSE;
+ 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;
+ addBitmap = true;
bitmapId = m_nButtons;
}
// this array will hold the indices of all controls in the toolbar
wxArrayInt controlIds;
- bool lastWasRadio = FALSE;
+ bool lastWasRadio = false;
int i = 0;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxZeroMemory(button);
- bool isRadio = FALSE;
+ bool isRadio = false;
switch ( tool->GetStyle() )
{
case wxTOOL_STYLE_CONTROL:
// radio items
button.fsState |= TBSTATE_CHECKED;
- tool->Toggle(TRUE);
+ tool->Toggle(true);
}
- isRadio = TRUE;
+ isRadio = true;
break;
case wxITEM_CHECK:
// note that we use TB_GETITEMRECT and not TB_GETRECT because the
// latter only appeared in v4.70 of comctl32.dll
RECT r;
- if ( !SendMessage(GetHwnd(), TB_GETITEMRECT,
- index, (LPARAM)(LPRECT)&r) )
+ if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT,
+ index, (LPARAM)(LPRECT)&r) )
{
wxLogLastError(wxT("TB_GETITEMRECT"));
}
wxSize size = control->GetSize();
// the position of the leftmost controls corner
- int left = -1;
+ int left = wxDefaultCoord;
// TB_SETBUTTONINFO message is only supported by comctl32.dll 4.71+
#ifdef TB_SETBUTTONINFO
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_SIZE;
tbbi.cx = size.x;
- if ( !SendMessage(GetHwnd(), TB_SETBUTTONINFO,
- tool->GetId(), (LPARAM)&tbbi) )
+ if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO,
+ tool->GetId(), (LPARAM)&tbbi) )
{
// the id is probably invalid?
wxLogLastError(wxT("TB_SETBUTTONINFO"));
size_t nSeparators = size.x / widthSep;
for ( size_t nSep = 0; nSep < nSeparators; nSep++ )
{
- if ( !SendMessage(GetHwnd(), TB_INSERTBUTTON,
- index, (LPARAM)&tbb) )
+ if ( !::SendMessage(GetHwnd(), TB_INSERTBUTTON,
+ index, (LPARAM)&tbb) )
{
wxLogLastError(wxT("TB_INSERTBUTTON"));
}
((wxToolBarTool *)tool)->SetSeparatorsCount(nSeparators);
// adjust the controls width to exactly cover the separators
- control->SetSize((nSeparators + 1)*widthSep, -1);
+ control->SetSize((nSeparators + 1)*widthSep, wxDefaultCoord);
}
// position the control itself correctly vertically
if ( diff < 0 )
{
// the control is too high, resize to fit
- control->SetSize(-1, height - 2);
+ control->SetSize(wxDefaultCoord, height - 2);
diff = 2;
}
}
else // horizontal toolbar
{
- if ( left == -1 )
+ if ( left == wxDefaultCoord )
left = r.left;
top = r.top;
}
InvalidateBestSize();
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
{
wxToolBarToolBase *tool = FindById((int)id);
if ( !tool )
- return FALSE;
+ return false;
bool toggled = false; // just to suppress warnings
// ignore the event when a radio button is released, as this doesn't seem to
// happen at all, and is handled otherwise
if ( tool->GetKind() == wxITEM_RADIO && !toggled )
- return TRUE;
+ return true;
tool->Toggle(toggled);
UnToggleRadioGroup(tool);
::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0));
}
- return TRUE;
+ return true;
}
bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl),
// in an ANSI application - this seems to be a bug in comctl32.dll v5
UINT code = hdr->code;
if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) )
- return FALSE;
+ return false;
HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
if ( toolTipWnd != hdr->hwndFrom )
- return FALSE;
+ return false;
LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
int id = (int)ttText->hdr.idFrom;
wxToolBarToolBase *tool = FindById(id);
if ( !tool )
- return FALSE;
+ return false;
return HandleTooltipNotify(code, lParam, tool->GetShortHelp());
#else
- return FALSE;
+ return false;
#endif
}
void wxToolBar::UpdateSize()
{
// the toolbar size changed
- SendMessage(GetHwnd(), TB_AUTOSIZE, 0, 0);
+ ::SendMessage(GetHwnd(), TB_AUTOSIZE, 0, 0);
// we must also refresh the frame after the toolbar size (possibly) changed
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
}
// message processed
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam)
if ( !node )
{
// no controls, nothing to erase
- return FALSE;
+ return false;
}
// prepare the DC on which we'll be drawing
dc.SetPen(*wxTRANSPARENT_PEN);
RECT r;
- if ( !GetUpdateRect(GetHwnd(), &r, FALSE) )
+ if ( !::GetUpdateRect(GetHwnd(), &r, FALSE) )
{
// nothing to redraw anyhow
- return FALSE;
+ return false;
}
wxRect rectUpdate;
{
// yes, do erase it!
dc.DrawRectangle(rectItem);
-
+
// Necessary in case we use a no-paint-on-size
// style in the parent: the controls can disappear
- control->Refresh(FALSE);
+ control->Refresh(false);
}
}
}
}
- return TRUE;
+ return true;
}
void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)