// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "tbar95.h"
#endif
#include "wx/msw/private.h"
-#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
- #include <commctrl.h>
-#else
- #include "wx/msw/gnuwin32/extra.h"
-#endif
+// include <commctrl.h> "properly"
+#include "wx/msw/wrapcctl.h"
#include "wx/app.h" // for GetComCtl32Version
-#if defined(__MWERKS__) && defined(__WXMSW__)
-// including <windef.h> for max definition doesn't seem
-// to work using CodeWarrior 6 Windows. So we define it
-// here. (Otherwise we get a undefined identifier 'max'
-// later on in this file.) (Added by dimitri@shortcut.nl)
-# ifndef max
-# define max(a,b) (((a) > (b)) ? (a) : (b))
-# endif
-
-#endif
-
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
+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
+*/
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent)
private:
size_t m_nSepCount;
+
+ DECLARE_NO_COPY_CLASS(wxToolBarTool)
};
bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size)
{
- if ( !MSWCreateControl(TOOLBARCLASSNAME, _T(""), pos, size) )
+ if ( !MSWCreateControl(TOOLBARCLASSNAME, wxEmptyString, pos, size) )
return FALSE;
// toolbar-specific post initialisation
}
// reparent all our children under the new toolbar
- for ( wxWindowList::Node *node = m_children.GetFirst();
+ for ( wxWindowList::compatibility_iterator node = m_children.GetFirst();
node;
node = node->GetNext() )
{
// do have tooltips wouldn't work
msStyle |= TBSTYLE_TOOLTIPS;
- if ( style & wxTB_FLAT )
+ if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) )
{
// static as it doesn't change during the program lifetime
static int s_verComCtl = wxTheApp->GetComCtl32Version();
{
msStyle |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT;
}
+
+ if ( s_verComCtl >= 470 && style & wxTB_HORZ_LAYOUT )
+ {
+ msStyle |= TBSTYLE_LIST;
+ }
}
if ( style & wxTB_NODIVIDER )
if ( style & wxTB_NOALIGN )
msStyle |= CCS_NOPARENTALIGN;
+ if ( style & wxTB_VERTICAL )
+ msStyle |= CCS_VERT;
+
return msStyle;
}
// first determine the position of the first button to delete: it may be
// different from pos if we use several separators to cover the space used
// by a control
- wxToolBarToolsList::Node *node;
+ wxToolBarToolsList::compatibility_iterator node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxToolBarToolBase *tool2 = node->GetData();
// First, add the bitmap: we use one bitmap for all toolbar buttons
// ----------------------------------------------------------------
- wxToolBarToolsList::Node *node;
+ wxToolBarToolsList::compatibility_iterator node;
int bitmapId = 0;
wxSize sizeBmp;
{
wxToolBarToolBase *tool = node->GetData();
- // don't add separators to the vertical toolbar - looks ugly
- if ( isVertical && tool->IsSeparator() )
+ // don't add separators to the vertical toolbar with old comctl32.dll
+ // versions as they didn't handle this properly
+ if ( isVertical && tool->IsSeparator() &&
+ wxTheApp->GetComCtl32Version() <= 472 )
+ {
continue;
+ }
+
TBBUTTON& button = buttons[i];
int left = -1;
// TB_SETBUTTONINFO message is only supported by comctl32.dll 4.71+
-#if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
+#ifdef TB_SETBUTTONINFO
// available in headers, now check whether it is available now
// (during run-time)
if ( wxTheApp->GetComCtl32Version() >= 471 )
{
// TB_GETBUTTONSIZE is supported from version 4.70
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x300 ) \
- && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
+ && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) ) \
+ && !defined (__DIGITALMARS__)
if ( wxTheApp->GetComCtl32Version() >= 470 )
{
DWORD dw = ::SendMessage(GetHwnd(), TB_GETBUTTONSIZE, 0, 0);
wxToolBarToolBase *GetItemSkippingDummySpacers(const wxToolBarToolsList& tools,
size_t index )
{
- wxToolBarToolsList::Node* current = tools.GetFirst();
+ wxToolBarToolsList::compatibility_iterator current = tools.GetFirst();
for ( ; current != 0; current = current->GetNext() )
{
}
}
-bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam)
+bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
{
- // calculate our minor dimenstion ourselves - we're confusing the standard
+ // calculate our minor dimension ourselves - we're confusing the standard
// logic (TB_AUTOSIZE) with our horizontal toolbars and other hacks
RECT r;
if ( ::SendMessage(GetHwnd(), TB_GETITEMRECT, 0, (LPARAM)&r) )
h = r.bottom - r.top;
if ( m_maxRows )
{
- // FIXME: 6 is hardcoded separator line height...
- //h += 6;
- if (HasFlag(wxTB_NODIVIDER))
- h += 4;
- else
- h += 6;
+ // FIXME: hardcoded separator line height...
+ h += HasFlag(wxTB_NODIVIDER) ? 4 : 6;
h *= m_maxRows;
}
}
// any here
// first of all, do we have any controls at all?
- wxToolBarToolsList::Node *node;
+ wxToolBarToolsList::compatibility_iterator node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
if ( node->GetData()->IsControl() )
{
// 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);
}
}
}
return TRUE;
}
-void wxToolBar::HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam)
+void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
{
wxCoord x = GET_X_LPARAM(lParam),
y = GET_Y_LPARAM(lParam);