X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3bb63e5c806e7ef549673822dc6e4d40aa9dbec9..010024e17ee1c35dfb265c1b054ae88dbf7e1656:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 1379da5ace..304a161756 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "tbar95.h" #endif @@ -49,25 +49,11 @@ #include "wx/msw/private.h" -#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)) - #include -#else - #include "wx/msw/gnuwin32/extra.h" -#endif +// include "properly" +#include "wx/msw/wrapcctl.h" #include "wx/app.h" // for GetComCtl32Version -#if defined(__MWERKS__) && defined(__WXMSW__) -// including 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 // ---------------------------------------------------------------------------- @@ -121,7 +107,26 @@ // 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) @@ -176,6 +181,8 @@ public: private: size_t m_nSepCount; + + DECLARE_NO_COPY_CLASS(wxToolBarTool) }; @@ -245,7 +252,7 @@ bool wxToolBar::Create(wxWindow *parent, 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 @@ -278,7 +285,7 @@ void wxToolBar::Recreate() } // 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() ) { @@ -340,7 +347,7 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const // 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(); @@ -353,6 +360,11 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const { msStyle |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT; } + + if ( s_verComCtl >= 470 && style & wxTB_HORZ_LAYOUT ) + { + msStyle |= TBSTYLE_LIST; + } } if ( style & wxTB_NODIVIDER ) @@ -389,7 +401,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) // 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(); @@ -480,7 +492,7 @@ bool wxToolBar::Realize() // First, add the bitmap: we use one bitmap for all toolbar buttons // ---------------------------------------------------------------- - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; int bitmapId = 0; wxSize sizeBmp; @@ -654,9 +666,14 @@ bool wxToolBar::Realize() { wxToolBarToolBase *tool = node->GetData(); - // don't add separators to the vertical toolbar - looks ugly - //if ( isVertical && tool->IsSeparator() ) - // continue; + // 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]; @@ -782,7 +799,7 @@ bool wxToolBar::Realize() 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 ) @@ -898,28 +915,30 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id) if ( !tool ) return FALSE; + bool toggled = false; // just to suppress warnings + if ( tool->CanBeToggled() ) { LRESULT state = ::SendMessage(GetHwnd(), TB_GETSTATE, id, 0); - tool->Toggle((state & TBSTATE_CHECKED) != 0); - } + toggled = (state & TBSTATE_CHECKED) != 0; - bool toggled = tool->IsToggled(); + // 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; - // avoid sending the event when a radio button is released, this is not - // interesting - if ( !tool->CanBeToggled() || tool->GetKind() != wxITEM_RADIO || toggled ) + tool->Toggle(toggled); + UnToggleRadioGroup(tool); + } + + // OnLeftClick() can veto the button state change - for buttons which + // may be toggled only, of couse + if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() ) { - // OnLeftClick() can veto the button state change - for buttons which - // may be toggled only, of couse - if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() ) - { - // revert back - toggled = !toggled; - tool->SetToggle(toggled); + // revert back + tool->Toggle(!toggled); - ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0)); - } + ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0)); } return TRUE; @@ -992,7 +1011,8 @@ wxSize wxToolBar::GetToolSize() const { // 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); @@ -1011,7 +1031,7 @@ static 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() ) { @@ -1163,7 +1183,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) } } -bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam) +bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) { // calculate our minor dimension ourselves - we're confusing the standard // logic (TB_AUTOSIZE) with our horizontal toolbars and other hacks @@ -1190,12 +1210,8 @@ bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam) 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; } } @@ -1219,7 +1235,7 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) // 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() ) @@ -1301,6 +1317,10 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) { // 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); } } } @@ -1309,7 +1329,7 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) 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);