1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/tbar95.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && !defined(__SMARTPHONE__)
29 #include "wx/toolbar.h"
32 #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
33 #include "wx/dynarray.h"
37 #include "wx/settings.h"
38 #include "wx/bitmap.h"
39 #include "wx/dcmemory.h"
40 #include "wx/control.h"
41 #include "wx/app.h" // for GetComCtl32Version
43 #include "wx/stattext.h"
46 #include "wx/sysopt.h"
48 #include "wx/msw/private.h"
51 #include "wx/msw/uxtheme.h"
54 // this define controls whether the code for button colours remapping (only
55 // useful for 16 or 256 colour images) is active at all, it's always turned off
56 // for CE where it doesn't compile (and is probably not needed anyhow) and may
57 // also be turned off for other systems if you always use 24bpp images and so
60 #define wxREMAP_BUTTON_COLOURS
61 #endif // !__WXWINCE__
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
67 // these standard constants are not always defined in compilers headers
71 #define TBSTYLE_LIST 0x1000
72 #define TBSTYLE_FLAT 0x0800
75 #ifndef TBSTYLE_TRANSPARENT
76 #define TBSTYLE_TRANSPARENT 0x8000
79 #ifndef TBSTYLE_TOOLTIPS
80 #define TBSTYLE_TOOLTIPS 0x0100
85 #define TB_SETSTYLE (WM_USER + 56)
86 #define TB_GETSTYLE (WM_USER + 57)
90 #define TB_HITTEST (WM_USER + 69)
94 #define TB_GETMAXSIZE (WM_USER + 83)
97 // these values correspond to those used by comctl32.dll
98 #define DEFAULTBITMAPX 16
99 #define DEFAULTBITMAPY 15
101 // ----------------------------------------------------------------------------
103 // ----------------------------------------------------------------------------
105 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
117 style ( wxNO_BORDER | wxTB_HORIZONTAL)
126 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
127 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
128 EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged
)
129 EVT_ERASE_BACKGROUND(wxToolBar::OnEraseBackground
)
132 // ----------------------------------------------------------------------------
134 // ----------------------------------------------------------------------------
136 class wxToolBarTool
: public wxToolBarToolBase
139 wxToolBarTool(wxToolBar
*tbar
,
141 const wxString
& label
,
142 const wxBitmap
& bmpNormal
,
143 const wxBitmap
& bmpDisabled
,
145 wxObject
*clientData
,
146 const wxString
& shortHelp
,
147 const wxString
& longHelp
)
148 : wxToolBarToolBase(tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
149 clientData
, shortHelp
, longHelp
)
155 wxToolBarTool(wxToolBar
*tbar
, wxControl
*control
, const wxString
& label
)
156 : wxToolBarToolBase(tbar
, control
, label
)
158 if ( IsControl() && !m_label
.empty() )
160 // create a control to render the control's label
161 m_staticText
= new wxStaticText
168 wxALIGN_CENTRE
| wxST_NO_AUTORESIZE
179 virtual ~wxToolBarTool()
184 virtual void SetLabel(const wxString
& label
)
186 if ( label
== m_label
)
189 wxToolBarToolBase::SetLabel(label
);
192 m_staticText
->SetLabel(label
);
194 // we need to update the label shown in the toolbar because it has a
195 // pointer to the internal buffer of the old label
197 // TODO: use TB_SETBUTTONINFO
200 wxStaticText
* GetStaticText()
202 wxASSERT_MSG( IsControl(),
203 _T("only makes sense for embedded control tools") );
208 // set/get the number of separators which we use to cover the space used by
209 // a control in the toolbar
210 void SetSeparatorsCount(size_t count
) { m_nSepCount
= count
; }
211 size_t GetSeparatorsCount() const { return m_nSepCount
; }
215 wxStaticText
*m_staticText
;
217 DECLARE_NO_COPY_CLASS(wxToolBarTool
)
220 // ============================================================================
222 // ============================================================================
224 // ----------------------------------------------------------------------------
226 // ----------------------------------------------------------------------------
228 wxToolBarToolBase
*wxToolBar::CreateTool(int id
,
229 const wxString
& label
,
230 const wxBitmap
& bmpNormal
,
231 const wxBitmap
& bmpDisabled
,
233 wxObject
*clientData
,
234 const wxString
& shortHelp
,
235 const wxString
& longHelp
)
237 return new wxToolBarTool(this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
238 clientData
, shortHelp
, longHelp
);
242 wxToolBar::CreateTool(wxControl
*control
, const wxString
& label
)
244 return new wxToolBarTool(this, control
, label
);
247 // ----------------------------------------------------------------------------
248 // wxToolBar construction
249 // ----------------------------------------------------------------------------
251 void wxToolBar::Init()
254 m_disabledImgList
= NULL
;
258 m_defaultWidth
= DEFAULTBITMAPX
;
259 m_defaultHeight
= DEFAULTBITMAPY
;
264 bool wxToolBar::Create(wxWindow
*parent
,
269 const wxString
& name
)
271 // common initialisation
272 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
277 // MSW-specific initialisation
278 if ( !MSWCreateToolbar(pos
, size
) )
281 wxSetCCUnicodeFormat(GetHwnd());
283 // workaround for flat toolbar on Windows XP classic style: we have to set
284 // the style after creating the control; doing it at creation time doesn't work
286 if ( style
& wxTB_FLAT
)
288 LRESULT style
= GetMSWToolbarStyle();
290 if ( !(style
& TBSTYLE_FLAT
) )
291 ::SendMessage(GetHwnd(), TB_SETSTYLE
, 0, style
| TBSTYLE_FLAT
);
293 #endif // wxUSE_UXTHEME
298 bool wxToolBar::MSWCreateToolbar(const wxPoint
& pos
, const wxSize
& size
)
300 if ( !MSWCreateControl(TOOLBARCLASSNAME
, wxEmptyString
, pos
, size
) )
303 // toolbar-specific post initialisation
304 ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE
, sizeof(TBBUTTON
), 0);
309 void wxToolBar::Recreate()
311 const HWND hwndOld
= GetHwnd();
314 // we haven't been created yet, no need to recreate
318 // get the position and size before unsubclassing the old toolbar
319 const wxPoint pos
= GetPosition();
320 const wxSize size
= GetSize();
324 if ( !MSWCreateToolbar(pos
, size
) )
327 wxFAIL_MSG( _T("recreating the toolbar failed") );
332 // reparent all our children under the new toolbar
333 for ( wxWindowList::compatibility_iterator node
= m_children
.GetFirst();
335 node
= node
->GetNext() )
337 wxWindow
*win
= node
->GetData();
338 if ( !win
->IsTopLevel() )
339 ::SetParent(GetHwndOf(win
), GetHwnd());
342 // only destroy the old toolbar now --
343 // after all the children had been reparented
344 ::DestroyWindow(hwndOld
);
346 // it is for the old bitmap control and can't be used with the new one
349 ::DeleteObject((HBITMAP
) m_hBitmap
);
353 if ( m_disabledImgList
)
355 delete m_disabledImgList
;
356 m_disabledImgList
= NULL
;
362 wxToolBar::~wxToolBar()
364 // we must refresh the frame size when the toolbar is deleted but the frame
365 // is not - otherwise toolbar leaves a hole in the place it used to occupy
366 wxFrame
*frame
= wxDynamicCast(GetParent(), wxFrame
);
367 if ( frame
&& !frame
->IsBeingDeleted() )
368 frame
->SendSizeEvent();
371 ::DeleteObject((HBITMAP
) m_hBitmap
);
373 delete m_disabledImgList
;
376 wxSize
wxToolBar::DoGetBestSize() const
381 if ( !::SendMessage(GetHwnd(), TB_GETMAXSIZE
, 0, (LPARAM
)&size
) )
383 // maybe an old (< 0x400) Windows version? try to approximate the
384 // toolbar size ourselves
385 sizeBest
= GetToolSize();
386 sizeBest
.y
+= 2 * ::GetSystemMetrics(SM_CYBORDER
); // Add borders
387 sizeBest
.x
*= GetToolsCount();
389 // reverse horz and vertical components if necessary
393 sizeBest
.x
= sizeBest
.y
;
399 sizeBest
.x
= size
.cx
;
400 sizeBest
.y
= size
.cy
;
403 CacheBestSize(sizeBest
);
408 WXDWORD
wxToolBar::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
410 // toolbars never have border, giving one to them results in broken
412 WXDWORD msStyle
= wxControl::MSWGetStyle
414 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exstyle
417 if ( !(style
& wxTB_NO_TOOLTIPS
) )
418 msStyle
|= TBSTYLE_TOOLTIPS
;
420 if ( style
& (wxTB_FLAT
| wxTB_HORZ_LAYOUT
) )
422 // static as it doesn't change during the program lifetime
423 static const int s_verComCtl
= wxApp::GetComCtl32Version();
425 // comctl32.dll 4.00 doesn't support the flat toolbars and using this
426 // style with 6.00 (part of Windows XP) leads to the toolbar with
427 // incorrect background colour - and not using it still results in the
428 // correct (flat) toolbar, so don't use it there
429 if ( s_verComCtl
> 400 && s_verComCtl
< 600 )
430 msStyle
|= TBSTYLE_FLAT
| TBSTYLE_TRANSPARENT
;
432 if ( s_verComCtl
>= 470 && style
& wxTB_HORZ_LAYOUT
)
433 msStyle
|= TBSTYLE_LIST
;
436 if ( style
& wxTB_NODIVIDER
)
437 msStyle
|= CCS_NODIVIDER
;
439 if ( style
& wxTB_NOALIGN
)
440 msStyle
|= CCS_NOPARENTALIGN
;
442 if ( style
& wxTB_VERTICAL
)
445 if( style
& wxTB_BOTTOM
)
446 msStyle
|= CCS_BOTTOM
;
448 if ( style
& wxTB_RIGHT
)
449 msStyle
|= CCS_RIGHT
;
454 // ----------------------------------------------------------------------------
455 // adding/removing tools
456 // ----------------------------------------------------------------------------
458 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*tool
)
460 // nothing special to do here - we really create the toolbar buttons in
464 InvalidateBestSize();
468 bool wxToolBar::DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
)
470 // the main difficulty we have here is with the controls in the toolbars:
471 // as we (sometimes) use several separators to cover up the space used by
472 // them, the indices are not the same for us and the toolbar
474 // first determine the position of the first button to delete: it may be
475 // different from pos if we use several separators to cover the space used
477 wxToolBarToolsList::compatibility_iterator node
;
478 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
480 wxToolBarToolBase
*tool2
= node
->GetData();
483 // let node point to the next node in the list
484 node
= node
->GetNext();
489 if ( tool2
->IsControl() )
490 pos
+= ((wxToolBarTool
*)tool2
)->GetSeparatorsCount() - 1;
493 // now determine the number of buttons to delete and the area taken by them
494 size_t nButtonsToDelete
= 1;
496 // get the size of the button we're going to delete
498 if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT
, pos
, (LPARAM
)&r
) )
500 wxLogLastError(_T("TB_GETITEMRECT"));
503 int width
= r
.right
- r
.left
;
505 if ( tool
->IsControl() )
507 nButtonsToDelete
= ((wxToolBarTool
*)tool
)->GetSeparatorsCount();
508 width
*= nButtonsToDelete
;
509 tool
->GetControl()->Destroy();
512 // do delete all buttons
513 m_nButtons
-= nButtonsToDelete
;
514 while ( nButtonsToDelete
-- > 0 )
516 if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON
, pos
, 0) )
518 wxLogLastError(wxT("TB_DELETEBUTTON"));
526 // and finally reposition all the controls after this button (the toolbar
527 // takes care of all normal items)
528 for ( /* node -> first after deleted */ ; node
; node
= node
->GetNext() )
530 wxToolBarTool
*tool2
= (wxToolBarTool
*)node
->GetData();
531 if ( tool2
->IsControl() )
534 wxControl
*control
= tool2
->GetControl();
535 control
->GetPosition(&x
, NULL
);
536 control
->Move(x
- width
, wxDefaultCoord
);
538 wxStaticText
* staticText
= tool2
->GetStaticText();
539 staticText
->Move(x
- width
, wxDefaultCoord
);
543 InvalidateBestSize();
548 void wxToolBar::CreateDisabledImageList()
550 if (m_disabledImgList
!= NULL
)
552 delete m_disabledImgList
;
553 m_disabledImgList
= NULL
;
556 // as we can't use disabled image list with older versions of comctl32.dll,
557 // don't even bother creating it
558 if ( wxApp::GetComCtl32Version() >= 470 )
560 // search for the first disabled button img in the toolbar, if any
561 for ( wxToolBarToolsList::compatibility_iterator
562 node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
564 wxToolBarToolBase
*tool
= node
->GetData();
565 wxBitmap bmpDisabled
= tool
->GetDisabledBitmap();
566 if ( bmpDisabled
.Ok() )
568 m_disabledImgList
= new wxImageList
572 bmpDisabled
.GetMask() != NULL
,
579 // we don't have any disabled bitmaps
583 bool wxToolBar::Realize()
585 const size_t nTools
= GetToolsCount();
590 #ifdef wxREMAP_BUTTON_COLOURS
591 // don't change the values of these constants, they can be set from the
592 // user code via wxSystemOptions
601 // the user-specified option overrides anything, but if it wasn't set, only
602 // remap the buttons on 8bpp displays as otherwise the bitmaps usually look
603 // much worse after remapping
604 static const wxChar
*remapOption
= wxT("msw.remap");
605 const int remapValue
= wxSystemOptions::HasOption(remapOption
)
606 ? wxSystemOptions::GetOptionInt(remapOption
)
607 : wxDisplayDepth() <= 8 ? Remap_Buttons
610 #endif // wxREMAP_BUTTON_COLOURS
612 // delete all old buttons, if any
613 for ( size_t pos
= 0; pos
< m_nButtons
; pos
++ )
615 if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON
, 0, 0) )
617 wxLogDebug(wxT("TB_DELETEBUTTON failed"));
621 // First, add the bitmap: we use one bitmap for all toolbar buttons
622 // ----------------------------------------------------------------
624 wxToolBarToolsList::compatibility_iterator node
;
628 if ( HasFlag(wxTB_NOICONS
) )
630 // no icons, don't leave space for them
634 else // do show icons
636 // if we already have a bitmap, we'll replace the existing one --
637 // otherwise we'll install a new one
638 HBITMAP oldToolBarBitmap
= (HBITMAP
)m_hBitmap
;
640 sizeBmp
.x
= m_defaultWidth
;
641 sizeBmp
.y
= m_defaultHeight
;
643 const wxCoord totalBitmapWidth
= m_defaultWidth
*
644 wx_truncate_cast(wxCoord
, nTools
),
645 totalBitmapHeight
= m_defaultHeight
;
647 // Create a bitmap and copy all the tool bitmaps into it
648 wxMemoryDC dcAllButtons
;
649 wxBitmap
bitmap(totalBitmapWidth
, totalBitmapHeight
);
650 dcAllButtons
.SelectObject(bitmap
);
652 #ifdef wxREMAP_BUTTON_COLOURS
653 if ( remapValue
!= Remap_TransparentBg
)
654 #endif // wxREMAP_BUTTON_COLOURS
656 // VZ: why do we hardcode grey colour for CE?
657 dcAllButtons
.SetBackground(wxBrush(
659 wxColour(0xc0, 0xc0, 0xc0)
660 #else // !__WXWINCE__
661 GetBackgroundColour()
662 #endif // __WXWINCE__/!__WXWINCE__
664 dcAllButtons
.Clear();
667 m_hBitmap
= bitmap
.GetHBITMAP();
668 HBITMAP hBitmap
= (HBITMAP
)m_hBitmap
;
670 #ifdef wxREMAP_BUTTON_COLOURS
671 if ( remapValue
== Remap_Bg
)
673 dcAllButtons
.SelectObject(wxNullBitmap
);
675 // Even if we're not remapping the bitmap
676 // content, we still have to remap the background.
677 hBitmap
= (HBITMAP
)MapBitmap((WXHBITMAP
) hBitmap
,
678 totalBitmapWidth
, totalBitmapHeight
);
680 dcAllButtons
.SelectObject(bitmap
);
682 #endif // wxREMAP_BUTTON_COLOURS
684 // the button position
687 // the number of buttons (not separators)
690 CreateDisabledImageList();
691 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
693 wxToolBarToolBase
*tool
= node
->GetData();
694 if ( tool
->IsButton() )
696 const wxBitmap
& bmp
= tool
->GetNormalBitmap();
698 const int w
= bmp
.GetWidth();
699 const int h
= bmp
.GetHeight();
703 int xOffset
= wxMax(0, (m_defaultWidth
- w
)/2);
704 int yOffset
= wxMax(0, (m_defaultHeight
- h
)/2);
706 // notice the last parameter: do use mask
707 dcAllButtons
.DrawBitmap(bmp
, x
+ xOffset
, yOffset
, true);
711 wxFAIL_MSG( _T("invalid tool button bitmap") );
714 // also deal with disabled bitmap if we want to use them
715 if ( m_disabledImgList
)
717 wxBitmap bmpDisabled
= tool
->GetDisabledBitmap();
718 #if wxUSE_IMAGE && wxUSE_WXDIB
719 if ( !bmpDisabled
.Ok() )
721 // no disabled bitmap specified but we still need to
722 // fill the space in the image list with something, so
723 // we grey out the normal bitmap
725 imgGreyed
= bmp
.ConvertToImage().ConvertToGreyscale();
727 #ifdef wxREMAP_BUTTON_COLOURS
728 if ( remapValue
== Remap_Buttons
)
730 // we need to have light grey background colour for
731 // MapBitmap() to work correctly
732 for ( int y
= 0; y
< h
; y
++ )
734 for ( int x
= 0; x
< w
; x
++ )
736 if ( imgGreyed
.IsTransparent(x
, y
) )
737 imgGreyed
.SetRGB(x
, y
,
739 wxLIGHT_GREY
->Green(),
740 wxLIGHT_GREY
->Blue());
744 #endif // wxREMAP_BUTTON_COLOURS
746 bmpDisabled
= wxBitmap(imgGreyed
);
748 #endif // wxUSE_IMAGE
750 #ifdef wxREMAP_BUTTON_COLOURS
751 if ( remapValue
== Remap_Buttons
)
752 MapBitmap(bmpDisabled
.GetHBITMAP(), w
, h
);
753 #endif // wxREMAP_BUTTON_COLOURS
755 m_disabledImgList
->Add(bmpDisabled
);
758 // still inc width and number of buttons because otherwise the
759 // subsequent buttons will all be shifted which is rather confusing
760 // (and like this you'd see immediately which bitmap was bad)
766 dcAllButtons
.SelectObject(wxNullBitmap
);
768 // don't delete this HBITMAP!
769 bitmap
.SetHBITMAP(0);
771 #ifdef wxREMAP_BUTTON_COLOURS
772 if ( remapValue
== Remap_Buttons
)
774 // Map to system colours
775 hBitmap
= (HBITMAP
)MapBitmap((WXHBITMAP
) hBitmap
,
776 totalBitmapWidth
, totalBitmapHeight
);
778 #endif // wxREMAP_BUTTON_COLOURS
780 bool addBitmap
= true;
782 if ( oldToolBarBitmap
)
784 #ifdef TB_REPLACEBITMAP
785 if ( wxApp::GetComCtl32Version() >= 400 )
787 TBREPLACEBITMAP replaceBitmap
;
788 replaceBitmap
.hInstOld
= NULL
;
789 replaceBitmap
.hInstNew
= NULL
;
790 replaceBitmap
.nIDOld
= (UINT
) oldToolBarBitmap
;
791 replaceBitmap
.nIDNew
= (UINT
) hBitmap
;
792 replaceBitmap
.nButtons
= nButtons
;
793 if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP
,
794 0, (LPARAM
) &replaceBitmap
) )
796 wxFAIL_MSG(wxT("Could not replace the old bitmap"));
799 ::DeleteObject(oldToolBarBitmap
);
805 #endif // TB_REPLACEBITMAP
807 // we can't replace the old bitmap, so we will add another one
808 // (awfully inefficient, but what else to do?) and shift the bitmap
809 // indices accordingly
812 bitmapId
= m_nButtons
;
816 if ( addBitmap
) // no old bitmap or we can't replace it
818 TBADDBITMAP addBitmap
;
820 addBitmap
.nID
= (UINT
) hBitmap
;
821 if ( ::SendMessage(GetHwnd(), TB_ADDBITMAP
,
822 (WPARAM
) nButtons
, (LPARAM
)&addBitmap
) == -1 )
824 wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
828 // disable image lists are only supported in comctl32.dll 4.70+
829 if ( wxApp::GetComCtl32Version() >= 470 )
831 HIMAGELIST hil
= m_disabledImgList
832 ? GetHimagelistOf(m_disabledImgList
)
835 // notice that we set the image list even if don't have one right
836 // now as we could have it before and need to reset it in this case
837 HIMAGELIST oldImageList
= (HIMAGELIST
)
838 ::SendMessage(GetHwnd(), TB_SETDISABLEDIMAGELIST
, 0, (LPARAM
)hil
);
840 // delete previous image list if any
842 ::DeleteObject(oldImageList
);
846 // don't call SetToolBitmapSize() as we don't want to change the values of
847 // m_defaultWidth/Height
848 if ( !::SendMessage(GetHwnd(), TB_SETBITMAPSIZE
, 0,
849 MAKELONG(sizeBmp
.x
, sizeBmp
.y
)) )
851 wxLogLastError(_T("TB_SETBITMAPSIZE"));
854 // Next add the buttons and separators
855 // -----------------------------------
857 TBBUTTON
*buttons
= new TBBUTTON
[nTools
];
859 // this array will hold the indices of all controls in the toolbar
860 wxArrayInt controlIds
;
862 bool lastWasRadio
= false;
864 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
866 wxToolBarToolBase
*tool
= node
->GetData();
868 // don't add separators to the vertical toolbar with old comctl32.dll
869 // versions as they didn't handle this properly
870 if ( IsVertical() && tool
->IsSeparator() &&
871 wxApp::GetComCtl32Version() <= 472 )
876 TBBUTTON
& button
= buttons
[i
];
878 wxZeroMemory(button
);
880 bool isRadio
= false;
881 switch ( tool
->GetStyle() )
883 case wxTOOL_STYLE_CONTROL
:
884 button
.idCommand
= tool
->GetId();
885 // fall through: create just a separator too
887 case wxTOOL_STYLE_SEPARATOR
:
888 button
.fsState
= TBSTATE_ENABLED
;
889 button
.fsStyle
= TBSTYLE_SEP
;
892 case wxTOOL_STYLE_BUTTON
:
893 if ( !HasFlag(wxTB_NOICONS
) )
894 button
.iBitmap
= bitmapId
;
896 if ( HasFlag(wxTB_TEXT
) )
898 const wxString
& label
= tool
->GetLabel();
899 if ( !label
.empty() )
900 button
.iString
= (int)label
.wx_str();
903 button
.idCommand
= tool
->GetId();
905 if ( tool
->IsEnabled() )
906 button
.fsState
|= TBSTATE_ENABLED
;
907 if ( tool
->IsToggled() )
908 button
.fsState
|= TBSTATE_CHECKED
;
910 switch ( tool
->GetKind() )
913 button
.fsStyle
= TBSTYLE_CHECKGROUP
;
917 // the first item in the radio group is checked by
918 // default to be consistent with wxGTK and the menu
920 button
.fsState
|= TBSTATE_CHECKED
;
922 if (tool
->Toggle(true))
924 DoToggleTool(tool
, true);
927 else if (tool
->IsToggled())
929 wxToolBarToolsList::compatibility_iterator nodePrev
= node
->GetPrevious();
930 int prevIndex
= i
- 1;
933 TBBUTTON
& prevButton
= buttons
[prevIndex
];
934 wxToolBarToolBase
*tool
= nodePrev
->GetData();
935 if ( !tool
->IsButton() || tool
->GetKind() != wxITEM_RADIO
)
938 if ( tool
->Toggle(false) )
939 DoToggleTool(tool
, false);
941 prevButton
.fsState
= TBSTATE_ENABLED
;
942 nodePrev
= nodePrev
->GetPrevious();
951 button
.fsStyle
= TBSTYLE_CHECK
;
955 button
.fsStyle
= TBSTYLE_BUTTON
;
959 wxFAIL_MSG( _T("unexpected toolbar button kind") );
960 button
.fsStyle
= TBSTYLE_BUTTON
;
968 lastWasRadio
= isRadio
;
973 if ( !::SendMessage(GetHwnd(), TB_ADDBUTTONS
, (WPARAM
)i
, (LPARAM
)buttons
) )
975 wxLogLastError(wxT("TB_ADDBUTTONS"));
980 // Deal with the controls finally
981 // ------------------------------
983 // adjust the controls size to fit nicely in the toolbar
986 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext(), index
++ )
988 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->GetData();
990 // we calculate the running y coord for vertical toolbars so we need to
991 // get the items size for all items but for the horizontal ones we
992 // don't need to deal with the non controls
993 bool isControl
= tool
->IsControl();
994 if ( !isControl
&& !IsVertical() )
997 // note that we use TB_GETITEMRECT and not TB_GETRECT because the
998 // latter only appeared in v4.70 of comctl32.dll
1000 if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT
,
1001 index
, (LPARAM
)(LPRECT
)&r
) )
1003 wxLogLastError(wxT("TB_GETITEMRECT"));
1008 // can only be control if isVertical
1009 y
+= r
.bottom
- r
.top
;
1014 wxControl
*control
= tool
->GetControl();
1015 wxStaticText
* const staticText
= tool
->GetStaticText();
1017 wxSize size
= control
->GetSize();
1018 wxSize staticTextSize
;
1021 staticTextSize
= staticText
->GetSize();
1022 staticTextSize
.y
+= 3; // margin between control and its label
1025 // the position of the leftmost controls corner
1026 int left
= wxDefaultCoord
;
1028 // TB_SETBUTTONINFO message is only supported by comctl32.dll 4.71+
1029 #ifdef TB_SETBUTTONINFO
1030 // available in headers, now check whether it is available now
1031 // (during run-time)
1032 if ( wxApp::GetComCtl32Version() >= 471 )
1034 // set the (underlying) separators width to be that of the
1037 tbbi
.cbSize
= sizeof(tbbi
);
1038 tbbi
.dwMask
= TBIF_SIZE
;
1039 tbbi
.cx
= (WORD
)size
.x
;
1040 if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO
,
1041 tool
->GetId(), (LPARAM
)&tbbi
) )
1043 // the id is probably invalid?
1044 wxLogLastError(wxT("TB_SETBUTTONINFO"));
1048 #endif // comctl32.dll 4.71
1049 // TB_SETBUTTONINFO unavailable
1051 // try adding several separators to fit the controls width
1052 int widthSep
= r
.right
- r
.left
;
1058 tbb
.fsState
= TBSTATE_ENABLED
;
1059 tbb
.fsStyle
= TBSTYLE_SEP
;
1061 size_t nSeparators
= size
.x
/ widthSep
;
1062 for ( size_t nSep
= 0; nSep
< nSeparators
; nSep
++ )
1064 if ( !::SendMessage(GetHwnd(), TB_INSERTBUTTON
,
1065 index
, (LPARAM
)&tbb
) )
1067 wxLogLastError(wxT("TB_INSERTBUTTON"));
1073 // remember the number of separators we used - we'd have to
1074 // delete all of them later
1075 ((wxToolBarTool
*)tool
)->SetSeparatorsCount(nSeparators
);
1077 // adjust the controls width to exactly cover the separators
1078 size
.x
= (nSeparators
+ 1)*widthSep
;
1079 control
->SetSize(size
.x
, wxDefaultCoord
);
1082 // position the control itself correctly vertically centering it on the
1083 // icon area of the toolbar
1084 int height
= r
.bottom
- r
.top
- staticTextSize
.y
;
1086 int diff
= height
- size
.y
;
1087 if ( diff
< 0 || !HasFlag(wxTB_TEXT
) )
1089 // not enough room for the static text
1093 // recalculate height & diff without the staticText control
1094 height
= r
.bottom
- r
.top
;
1095 diff
= height
- size
.y
;
1098 // the control is too high, resize to fit
1099 control
->SetSize(wxDefaultCoord
, height
- 2);
1104 else // enough space for both the control and the label
1116 y
+= height
+ 2 * GetMargins().y
;
1118 else // horizontal toolbar
1120 if ( left
== wxDefaultCoord
)
1126 control
->Move(left
, top
+ (diff
+ 1) / 2);
1129 staticText
->Move(left
+ (size
.x
- staticTextSize
.x
)/2,
1130 r
.bottom
- staticTextSize
.y
);
1134 // the max index is the "real" number of buttons - i.e. counting even the
1135 // separators which we added just for aligning the controls
1138 if ( !IsVertical() )
1140 if ( m_maxRows
== 0 )
1141 // if not set yet, only one row
1144 else if ( m_nButtons
> 0 ) // vertical non empty toolbar
1146 // if not set yet, have one column
1148 SetRows(m_nButtons
);
1151 InvalidateBestSize();
1157 // ----------------------------------------------------------------------------
1159 // ----------------------------------------------------------------------------
1161 bool wxToolBar::MSWCommand(WXUINT
WXUNUSED(cmd
), WXWORD id
)
1163 wxToolBarToolBase
*tool
= FindById((int)id
);
1167 bool toggled
= false; // just to suppress warnings
1169 if ( tool
->CanBeToggled() )
1171 LRESULT state
= ::SendMessage(GetHwnd(), TB_GETSTATE
, id
, 0);
1172 toggled
= (state
& TBSTATE_CHECKED
) != 0;
1174 // ignore the event when a radio button is released, as this doesn't
1175 // seem to happen at all, and is handled otherwise
1176 if ( tool
->GetKind() == wxITEM_RADIO
&& !toggled
)
1179 tool
->Toggle(toggled
);
1180 UnToggleRadioGroup(tool
);
1183 // OnLeftClick() can veto the button state change - for buttons which
1184 // may be toggled only, of couse
1185 if ( !OnLeftClick((int)id
, toggled
) && tool
->CanBeToggled() )
1188 tool
->Toggle(!toggled
);
1190 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
, id
, MAKELONG(!toggled
, 0));
1196 bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl
),
1198 WXLPARAM
*WXUNUSED(result
))
1200 if( !HasFlag(wxTB_NO_TOOLTIPS
) )
1203 // First check if this applies to us
1204 NMHDR
*hdr
= (NMHDR
*)lParam
;
1206 // the tooltips control created by the toolbar is sometimes Unicode, even
1207 // in an ANSI application - this seems to be a bug in comctl32.dll v5
1208 UINT code
= hdr
->code
;
1209 if ( (code
!= (UINT
) TTN_NEEDTEXTA
) && (code
!= (UINT
) TTN_NEEDTEXTW
) )
1212 HWND toolTipWnd
= (HWND
)::SendMessage(GetHwnd(), TB_GETTOOLTIPS
, 0, 0);
1213 if ( toolTipWnd
!= hdr
->hwndFrom
)
1216 LPTOOLTIPTEXT ttText
= (LPTOOLTIPTEXT
)lParam
;
1217 int id
= (int)ttText
->hdr
.idFrom
;
1219 wxToolBarToolBase
*tool
= FindById(id
);
1221 return HandleTooltipNotify(code
, lParam
, tool
->GetShortHelp());
1223 wxUnusedVar(lParam
);
1230 // ----------------------------------------------------------------------------
1232 // ----------------------------------------------------------------------------
1234 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
1236 wxToolBarBase::SetToolBitmapSize(size
);
1238 ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE
, 0, MAKELONG(size
.x
, size
.y
));
1241 void wxToolBar::SetRows(int nRows
)
1243 if ( nRows
== m_maxRows
)
1245 // avoid resizing the frame uselessly
1249 // TRUE in wParam means to create at least as many rows, FALSE -
1252 ::SendMessage(GetHwnd(), TB_SETROWS
,
1253 MAKEWPARAM(nRows
, !(GetWindowStyle() & wxTB_VERTICAL
)),
1261 // The button size is bigger than the bitmap size
1262 wxSize
wxToolBar::GetToolSize() const
1264 // TB_GETBUTTONSIZE is supported from version 4.70
1265 #if defined(_WIN32_IE) && (_WIN32_IE >= 0x300 ) \
1266 && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) ) \
1267 && !defined (__DIGITALMARS__)
1268 if ( wxApp::GetComCtl32Version() >= 470 )
1270 DWORD dw
= ::SendMessage(GetHwnd(), TB_GETBUTTONSIZE
, 0, 0);
1272 return wxSize(LOWORD(dw
), HIWORD(dw
));
1275 #endif // comctl32.dll 4.70+
1278 return wxSize(m_defaultWidth
+ 8, m_defaultHeight
+ 7);
1283 wxToolBarToolBase
*GetItemSkippingDummySpacers(const wxToolBarToolsList
& tools
,
1286 wxToolBarToolsList::compatibility_iterator current
= tools
.GetFirst();
1288 for ( ; current
; current
= current
->GetNext() )
1291 return current
->GetData();
1293 wxToolBarTool
*tool
= (wxToolBarTool
*)current
->GetData();
1294 size_t separators
= tool
->GetSeparatorsCount();
1296 // if it is a normal button, sepcount == 0, so skip 1 item (the button)
1297 // otherwise, skip as many items as the separator count, plus the
1299 index
-= separators
? separators
+ 1 : 1;
1305 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
1310 int index
= (int)::SendMessage(GetHwnd(), TB_HITTEST
, 0, (LPARAM
)&pt
);
1312 // MBN: when the point ( x, y ) is close to the toolbar border
1313 // TB_HITTEST returns m_nButtons ( not -1 )
1314 if ( index
< 0 || (size_t)index
>= m_nButtons
)
1315 // it's a separator or there is no tool at all there
1316 return (wxToolBarToolBase
*)NULL
;
1318 // when TB_SETBUTTONINFO is available (both during compile- and run-time),
1319 // we don't use the dummy separators hack
1320 #ifdef TB_SETBUTTONINFO
1321 if ( wxApp::GetComCtl32Version() >= 471 )
1323 return m_tools
.Item((size_t)index
)->GetData();
1326 #endif // TB_SETBUTTONINFO
1328 return GetItemSkippingDummySpacers( m_tools
, (size_t) index
);
1332 void wxToolBar::UpdateSize()
1334 wxPoint pos
= GetPosition();
1335 ::SendMessage(GetHwnd(), TB_AUTOSIZE
, 0, 0);
1336 if (pos
!= GetPosition())
1339 // In case Realize is called after the initial display (IOW the programmer
1340 // may have rebuilt the toolbar) give the frame the option of resizing the
1341 // toolbar to full width again, but only if the parent is a frame and the
1342 // toolbar is managed by the frame. Otherwise assume that some other
1343 // layout mechanism is controlling the toolbar size and leave it alone.
1344 wxFrame
*frame
= wxDynamicCast(GetParent(), wxFrame
);
1345 if ( frame
&& frame
->GetToolBar() == this )
1347 frame
->SendSizeEvent();
1351 // ----------------------------------------------------------------------------
1353 // ---------------------------------------------------------------------------
1355 // get the TBSTYLE of the given toolbar window
1356 long wxToolBar::GetMSWToolbarStyle() const
1358 return ::SendMessage(GetHwnd(), TB_GETSTYLE
, 0, 0L);
1361 void wxToolBar::SetWindowStyleFlag(long style
)
1363 // the style bits whose changes force us to recreate the toolbar
1364 static const long MASK_NEEDS_RECREATE
= wxTB_TEXT
| wxTB_NOICONS
;
1366 const long styleOld
= GetWindowStyle();
1368 wxToolBarBase::SetWindowStyleFlag(style
);
1370 // don't recreate an empty toolbar: not only this is unnecessary, but it is
1371 // also fatal as we'd then try to recreate the toolbar when it's just being
1373 if ( GetToolsCount() &&
1374 (style
& MASK_NEEDS_RECREATE
) != (styleOld
& MASK_NEEDS_RECREATE
) )
1376 // to remove the text labels, simply re-realizing the toolbar is enough
1377 // but I don't know of any way to add the text to an existing toolbar
1378 // other than by recreating it entirely
1383 // ----------------------------------------------------------------------------
1385 // ----------------------------------------------------------------------------
1387 void wxToolBar::DoEnableTool(wxToolBarToolBase
*tool
, bool enable
)
1389 ::SendMessage(GetHwnd(), TB_ENABLEBUTTON
,
1390 (WPARAM
)tool
->GetId(), (LPARAM
)MAKELONG(enable
, 0));
1393 void wxToolBar::DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
)
1395 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
,
1396 (WPARAM
)tool
->GetId(), (LPARAM
)MAKELONG(toggle
, 0));
1399 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
1401 // VZ: AFAIK, the button has to be created either with TBSTYLE_CHECK or
1402 // without, so we really need to delete the button and recreate it here
1403 wxFAIL_MSG( _T("not implemented") );
1406 void wxToolBar::SetToolNormalBitmap( int id
, const wxBitmap
& bitmap
)
1408 wxToolBarTool
* tool
= wx_static_cast(wxToolBarTool
*, FindById(id
));
1411 wxCHECK_RET( tool
->IsButton(), wxT("Can only set bitmap on button tools."));
1413 tool
->SetNormalBitmap(bitmap
);
1418 void wxToolBar::SetToolDisabledBitmap( int id
, const wxBitmap
& bitmap
)
1420 wxToolBarTool
* tool
= wx_static_cast(wxToolBarTool
*, FindById(id
));
1423 wxCHECK_RET( tool
->IsButton(), wxT("Can only set bitmap on button tools."));
1425 tool
->SetDisabledBitmap(bitmap
);
1430 // ----------------------------------------------------------------------------
1432 // ----------------------------------------------------------------------------
1434 // Responds to colour changes, and passes event on to children.
1435 void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1437 wxRGBToColour(m_backgroundColour
, ::GetSysColor(COLOR_BTNFACE
));
1439 // Remap the buttons
1442 // Relayout the toolbar
1443 int nrows
= m_maxRows
;
1444 m_maxRows
= 0; // otherwise SetRows() wouldn't do anything
1449 // let the event propagate further
1453 void wxToolBar::OnMouseEvent(wxMouseEvent
& event
)
1455 if (event
.Leaving() && m_pInTool
)
1462 if ( event
.RightDown() )
1464 // find the tool under the mouse
1465 wxCoord x
= 0, y
= 0;
1466 event
.GetPosition(&x
, &y
);
1468 wxToolBarToolBase
*tool
= FindToolForPosition(x
, y
);
1469 OnRightClick(tool
? tool
->GetId() : -1, x
, y
);
1477 // This handler is required to allow the toolbar to be set to a non-default
1478 // colour: for example, when it must blend in with a notebook page.
1479 void wxToolBar::OnEraseBackground(wxEraseEvent
& event
)
1481 RECT rect
= wxGetClientRect(GetHwnd());
1482 HDC hdc
= GetHdcOf((*event
.GetDC()));
1485 // we may need to draw themed colour so that we appear correctly on
1486 // e.g. notebook page under XP with themes but only do it if the parent
1487 // draws themed background itself
1488 if ( !UseBgCol() && !GetParent()->UseBgCol() )
1490 wxUxThemeEngine
*theme
= wxUxThemeEngine::GetIfActive();
1494 hr
= theme
->DrawThemeParentBackground(GetHwnd(), hdc
, &rect
);
1498 // it can also return S_FALSE which seems to simply say that it
1499 // didn't draw anything but no error really occurred
1501 wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr
);
1504 #endif // wxUSE_UXTHEME
1506 if ( UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT
) )
1508 // do draw our background
1510 // notice that this 'dumb' implementation may cause flicker for some of
1511 // the controls in which case they should intercept wxEraseEvent and
1512 // process it themselves somehow
1513 AutoHBRUSH
hBrush(wxColourToRGB(GetBackgroundColour()));
1515 wxCHANGE_HDC_MAP_MODE(hdc
, MM_TEXT
);
1516 ::FillRect(hdc
, &rect
, hBrush
);
1518 else // we have no non default background colour
1520 // let the system do it for us
1525 bool wxToolBar::HandleSize(WXWPARAM
WXUNUSED(wParam
), WXLPARAM lParam
)
1527 // calculate our minor dimension ourselves - we're confusing the standard
1528 // logic (TB_AUTOSIZE) with our horizontal toolbars and other hacks
1530 if ( ::SendMessage(GetHwnd(), TB_GETITEMRECT
, 0, (LPARAM
)&r
) )
1536 w
= r
.right
- r
.left
;
1539 w
*= (m_nButtons
+ m_maxRows
- 1)/m_maxRows
;
1546 if (HasFlag( wxTB_FLAT
))
1547 h
= r
.bottom
- r
.top
- 3;
1549 h
= r
.bottom
- r
.top
;
1552 // FIXME: hardcoded separator line height...
1553 h
+= HasFlag(wxTB_NODIVIDER
) ? 4 : 6;
1558 if ( MAKELPARAM(w
, h
) != lParam
)
1560 // size really changed
1564 // message processed
1571 bool wxToolBar::HandlePaint(WXWPARAM wParam
, WXLPARAM lParam
)
1573 // erase any dummy separators which were used
1574 // for aligning the controls if any here
1576 // first of all, are there any controls at all?
1577 wxToolBarToolsList::compatibility_iterator node
;
1578 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
1580 if ( node
->GetData()->IsControl() )
1585 // no controls, nothing to erase
1588 // prepare the DC on which we'll be drawing
1589 wxClientDC
dc(this);
1590 dc
.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID
));
1591 dc
.SetPen(*wxTRANSPARENT_PEN
);
1594 if ( !::GetUpdateRect(GetHwnd(), &r
, FALSE
) )
1595 // nothing to redraw anyhow
1599 wxCopyRECTToRect(r
, rectUpdate
);
1601 dc
.SetClippingRegion(rectUpdate
);
1603 // draw the toolbar tools, separators &c normally
1604 wxControl::MSWWindowProc(WM_PAINT
, wParam
, lParam
);
1606 // for each control in the toolbar find all the separators intersecting it
1609 // NB: this is really the only way to do it as we don't know if a separator
1610 // corresponds to a control (i.e. is a dummy one) or a real one
1612 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
1614 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->GetData();
1615 if ( tool
->IsControl() )
1617 // get the control rect in our client coords
1618 wxControl
*control
= tool
->GetControl();
1619 wxStaticText
*staticText
= tool
->GetStaticText();
1620 wxRect rectCtrl
= control
->GetRect();
1621 wxRect
rectStaticText(0,0,0,0);
1624 rectStaticText
= staticText
->GetRect();
1627 // iterate over all buttons
1629 int count
= ::SendMessage(GetHwnd(), TB_BUTTONCOUNT
, 0, 0);
1630 for ( int n
= 0; n
< count
; n
++ )
1632 // is it a separator?
1633 if ( !::SendMessage(GetHwnd(), TB_GETBUTTON
,
1636 wxLogDebug(_T("TB_GETBUTTON failed?"));
1641 if ( tbb
.fsStyle
!= TBSTYLE_SEP
)
1644 // get the bounding rect of the separator
1646 if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT
,
1649 wxLogDebug(_T("TB_GETITEMRECT failed?"));
1654 // does it intersect the control?
1656 wxCopyRECTToRect(r
, rectItem
);
1657 if ( rectCtrl
.Intersects(rectItem
) )
1659 // yes, do erase it!
1660 dc
.DrawRectangle(rectItem
);
1662 // Necessary in case we use a no-paint-on-size
1663 // style in the parent: the controls can disappear
1664 control
->Refresh(false);
1666 if ( staticText
&& rectStaticText
.Intersects(rectItem
) )
1668 // yes, do erase it!
1669 dc
.DrawRectangle(rectItem
);
1671 // Necessary in case we use a no-paint-on-size
1672 // style in the parent: the controls can disappear
1673 staticText
->Refresh(false);
1682 void wxToolBar::HandleMouseMove(WXWPARAM
WXUNUSED(wParam
), WXLPARAM lParam
)
1684 wxCoord x
= GET_X_LPARAM(lParam
),
1685 y
= GET_Y_LPARAM(lParam
);
1686 wxToolBarToolBase
* tool
= FindToolForPosition( x
, y
);
1688 // cursor left current tool
1689 if ( tool
!= m_pInTool
&& !tool
)
1695 // cursor entered a tool
1696 if ( tool
!= m_pInTool
&& tool
)
1699 OnMouseEnter( tool
->GetId() );
1703 WXLRESULT
wxToolBar::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1708 // we don't handle mouse moves, so always pass the message to
1709 // wxControl::MSWWindowProc (HandleMouseMove just calls OnMouseEnter)
1710 HandleMouseMove(wParam
, lParam
);
1714 if ( HandleSize(wParam
, lParam
) )
1720 if ( HandlePaint(wParam
, lParam
) )
1728 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);
1731 // ----------------------------------------------------------------------------
1732 // private functions
1733 // ----------------------------------------------------------------------------
1735 #ifdef wxREMAP_BUTTON_COLOURS
1737 WXHBITMAP
wxToolBar::MapBitmap(WXHBITMAP bitmap
, int width
, int height
)
1743 wxLogLastError(_T("CreateCompatibleDC"));
1748 SelectInHDC
bmpInHDC(hdcMem
, (HBITMAP
)bitmap
);
1752 wxLogLastError(_T("SelectObject"));
1757 wxCOLORMAP
*cmap
= wxGetStdColourMap();
1759 for ( int i
= 0; i
< width
; i
++ )
1761 for ( int j
= 0; j
< height
; j
++ )
1763 COLORREF pixel
= ::GetPixel(hdcMem
, i
, j
);
1765 for ( size_t k
= 0; k
< wxSTD_COL_MAX
; k
++ )
1767 COLORREF col
= cmap
[k
].from
;
1768 if ( abs(GetRValue(pixel
) - GetRValue(col
)) < 10 &&
1769 abs(GetGValue(pixel
) - GetGValue(col
)) < 10 &&
1770 abs(GetBValue(pixel
) - GetBValue(col
)) < 10 )
1772 if ( cmap
[k
].to
!= pixel
)
1773 ::SetPixel(hdcMem
, i
, j
, cmap
[k
].to
);
1783 #endif // wxREMAP_BUTTON_COLOURS
1785 #endif // wxUSE_TOOLBAR