applied heavily modified patch 1116702: support for specifying disabled toolbar images and modified the sample to show how it works (badly, background of tools for which disabled bitmap is not specified is wrong)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33102 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_TBAR95_H_
|
#ifndef _WX_MSW_TBAR95_H_
|
||||||
#define _WX_TBAR95_H_
|
#define _WX_MSW_TBAR95_H_
|
||||||
|
|
||||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||||
#pragma interface "tbar95.h"
|
#pragma interface "tbar95.h"
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
|
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
|
#include "wx/imaglist.h"
|
||||||
|
|
||||||
class WXDLLEXPORT wxToolBar : public wxToolBarBase
|
class WXDLLEXPORT wxToolBar : public wxToolBarBase
|
||||||
{
|
{
|
||||||
@@ -116,9 +117,18 @@ protected:
|
|||||||
// should be called whenever the toolbar size changes
|
// should be called whenever the toolbar size changes
|
||||||
void UpdateSize();
|
void UpdateSize();
|
||||||
|
|
||||||
|
// create m_disabledImgList (but doesn't fill it), set it to NULL if it is
|
||||||
|
// unneeded
|
||||||
|
void CreateDisabledImageList();
|
||||||
|
|
||||||
|
|
||||||
// the big bitmap containing all bitmaps of the toolbar buttons
|
// the big bitmap containing all bitmaps of the toolbar buttons
|
||||||
WXHBITMAP m_hBitmap;
|
WXHBITMAP m_hBitmap;
|
||||||
|
|
||||||
|
// the image list with disabled images, may be NULL if we use
|
||||||
|
// system-provided versions of them
|
||||||
|
wxImageList *m_disabledImgList;
|
||||||
|
|
||||||
// the total number of toolbar elements
|
// the total number of toolbar elements
|
||||||
size_t m_nButtons;
|
size_t m_nButtons;
|
||||||
|
|
||||||
@@ -133,5 +143,5 @@ private:
|
|||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
|
||||||
#endif
|
#endif // _WX_MSW_TBAR95_H_
|
||||||
// _WX_TBAR95_H_
|
|
||||||
|
@@ -108,6 +108,7 @@ public:
|
|||||||
void OnToggleToolbarSize(wxCommandEvent& event);
|
void OnToggleToolbarSize(wxCommandEvent& event);
|
||||||
void OnToggleToolbarOrient(wxCommandEvent& event);
|
void OnToggleToolbarOrient(wxCommandEvent& event);
|
||||||
void OnToggleToolbarRows(wxCommandEvent& event);
|
void OnToggleToolbarRows(wxCommandEvent& event);
|
||||||
|
void OnToggleCustomDisabled(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
|
void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
|
||||||
void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); }
|
void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); }
|
||||||
@@ -144,7 +145,8 @@ private:
|
|||||||
|
|
||||||
bool m_smallToolbar,
|
bool m_smallToolbar,
|
||||||
m_horzToolbar,
|
m_horzToolbar,
|
||||||
m_horzText;
|
m_horzText,
|
||||||
|
m_useCustomDisabled;
|
||||||
size_t m_rows; // 1 or 2 only
|
size_t m_rows; // 1 or 2 only
|
||||||
|
|
||||||
// the number of print buttons we have (they're added/removed dynamically)
|
// the number of print buttons we have (they're added/removed dynamically)
|
||||||
@@ -170,6 +172,7 @@ enum
|
|||||||
IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
|
IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
|
||||||
IDM_TOOLBAR_TOGGLETOOLBARORIENT,
|
IDM_TOOLBAR_TOGGLETOOLBARORIENT,
|
||||||
IDM_TOOLBAR_TOGGLETOOLBARROWS,
|
IDM_TOOLBAR_TOGGLETOOLBARROWS,
|
||||||
|
IDM_TOOLBAR_TOGGLECUSTOMDISABLED,
|
||||||
IDM_TOOLBAR_ENABLEPRINT,
|
IDM_TOOLBAR_ENABLEPRINT,
|
||||||
IDM_TOOLBAR_DELETEPRINT,
|
IDM_TOOLBAR_DELETEPRINT,
|
||||||
IDM_TOOLBAR_INSERTPRINT,
|
IDM_TOOLBAR_INSERTPRINT,
|
||||||
@@ -212,6 +215,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
|
||||||
|
EVT_MENU(IDM_TOOLBAR_TOGGLECUSTOMDISABLED, MyFrame::OnToggleCustomDisabled)
|
||||||
|
|
||||||
EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
|
EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
|
||||||
EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint)
|
EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint)
|
||||||
@@ -302,33 +306,47 @@ void MyFrame::RecreateToolbar()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set up toolbar
|
// Set up toolbar
|
||||||
wxBitmap toolBarBitmaps[8];
|
enum
|
||||||
|
{
|
||||||
|
Tool_new,
|
||||||
|
Tool_open,
|
||||||
|
Tool_save,
|
||||||
|
Tool_copy,
|
||||||
|
Tool_cut,
|
||||||
|
Tool_paste,
|
||||||
|
Tool_print,
|
||||||
|
Tool_help,
|
||||||
|
Tool_Max
|
||||||
|
};
|
||||||
|
|
||||||
|
wxBitmap toolBarBitmaps[Tool_Max];
|
||||||
|
|
||||||
#if USE_XPM_BITMAPS
|
#if USE_XPM_BITMAPS
|
||||||
toolBarBitmaps[0] = wxBitmap(new_xpm);
|
#define INIT_TOOL_BMP(bmp) \
|
||||||
toolBarBitmaps[1] = wxBitmap(open_xpm);
|
toolBarBitmaps[Tool_##bmp] = wxBitmap(bmp##_xpm)
|
||||||
toolBarBitmaps[2] = wxBitmap(save_xpm);
|
|
||||||
toolBarBitmaps[3] = wxBitmap(copy_xpm);
|
|
||||||
toolBarBitmaps[4] = wxBitmap(cut_xpm);
|
|
||||||
toolBarBitmaps[5] = wxBitmap(paste_xpm);
|
|
||||||
toolBarBitmaps[6] = wxBitmap(print_xpm);
|
|
||||||
toolBarBitmaps[7] = wxBitmap(help_xpm);
|
|
||||||
#else // !USE_XPM_BITMAPS
|
#else // !USE_XPM_BITMAPS
|
||||||
toolBarBitmaps[0] = wxBITMAP(new);
|
#define INIT_TOOL_BMP(bmp) \
|
||||||
toolBarBitmaps[1] = wxBITMAP(open);
|
toolBarBitmaps[Tool_##bmp] = wxBITMAP(bmp)
|
||||||
toolBarBitmaps[2] = wxBITMAP(save);
|
|
||||||
toolBarBitmaps[3] = wxBITMAP(copy);
|
|
||||||
toolBarBitmaps[4] = wxBITMAP(cut);
|
|
||||||
toolBarBitmaps[5] = wxBITMAP(paste);
|
|
||||||
toolBarBitmaps[6] = wxBITMAP(print);
|
|
||||||
toolBarBitmaps[7] = wxBITMAP(help);
|
|
||||||
#endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
|
#endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
|
||||||
|
|
||||||
|
INIT_TOOL_BMP(new);
|
||||||
|
INIT_TOOL_BMP(open);
|
||||||
|
INIT_TOOL_BMP(save);
|
||||||
|
INIT_TOOL_BMP(copy);
|
||||||
|
INIT_TOOL_BMP(cut);
|
||||||
|
INIT_TOOL_BMP(paste);
|
||||||
|
INIT_TOOL_BMP(print);
|
||||||
|
INIT_TOOL_BMP(help);
|
||||||
|
|
||||||
|
int w = toolBarBitmaps[Tool_new].GetWidth(),
|
||||||
|
h = toolBarBitmaps[Tool_new].GetHeight();
|
||||||
|
|
||||||
if ( !m_smallToolbar )
|
if ( !m_smallToolbar )
|
||||||
{
|
{
|
||||||
int w = 2*toolBarBitmaps[0].GetWidth(),
|
w *= 2;
|
||||||
h = 2*toolBarBitmaps[0].GetHeight();
|
h *= 2;
|
||||||
for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ )
|
|
||||||
|
for ( size_t n = Tool_new; n < WXSIZEOF(toolBarBitmaps); n++ )
|
||||||
{
|
{
|
||||||
toolBarBitmaps[n] =
|
toolBarBitmaps[n] =
|
||||||
wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h));
|
wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h));
|
||||||
@@ -337,8 +355,8 @@ void MyFrame::RecreateToolbar()
|
|||||||
toolBar->SetToolBitmapSize(wxSize(w, h));
|
toolBar->SetToolBitmapSize(wxSize(w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[0], _T("New file"));
|
toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[Tool_new], _T("New file"));
|
||||||
toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[1], _T("Open file"));
|
toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[Tool_open], _T("Open file"));
|
||||||
|
|
||||||
// the generic toolbar doesn't really support this
|
// the generic toolbar doesn't really support this
|
||||||
#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
|
#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
|
||||||
@@ -355,13 +373,35 @@ void MyFrame::RecreateToolbar()
|
|||||||
}
|
}
|
||||||
#endif // toolbars which don't support controls
|
#endif // toolbars which don't support controls
|
||||||
|
|
||||||
toolBar->AddTool(wxID_SAVE, _T("Save"), toolBarBitmaps[2], _T("Toggle button 1"), wxITEM_CHECK);
|
toolBar->AddTool(wxID_SAVE, _T("Save"), toolBarBitmaps[Tool_save], _T("Toggle button 1"), wxITEM_CHECK);
|
||||||
toolBar->AddTool(wxID_COPY, _T("Copy"), toolBarBitmaps[3], _T("Toggle button 2"), wxITEM_CHECK);
|
toolBar->AddTool(wxID_COPY, _T("Copy"), toolBarBitmaps[Tool_copy], _T("Toggle button 2"), wxITEM_CHECK);
|
||||||
toolBar->AddTool(wxID_CUT, _T("Cut"), toolBarBitmaps[4], _T("Toggle/Untoggle help button"));
|
toolBar->AddTool(wxID_CUT, _T("Cut"), toolBarBitmaps[Tool_cut], _T("Toggle/Untoggle help button"));
|
||||||
toolBar->AddTool(wxID_PASTE, _T("Paste"), toolBarBitmaps[5], _T("Paste"));
|
toolBar->AddTool(wxID_PASTE, _T("Paste"), toolBarBitmaps[Tool_paste], _T("Paste"));
|
||||||
toolBar->AddTool(wxID_PRINT, _T("Print"), toolBarBitmaps[6], _T("Delete this tool. This is a very long tooltip to test whether it does the right thing when the tooltip is more than Windows can cope with."));
|
|
||||||
|
if ( m_useCustomDisabled )
|
||||||
|
{
|
||||||
|
wxBitmap bmpDisabled(w, h);
|
||||||
|
{
|
||||||
|
wxMemoryDC dc;
|
||||||
|
dc.SelectObject(bmpDisabled);
|
||||||
|
dc.DrawBitmap(toolBarBitmaps[Tool_print], 0, 0);
|
||||||
|
|
||||||
|
wxPen pen(*wxRED, 5);
|
||||||
|
dc.SetPen(pen);
|
||||||
|
dc.DrawLine(0, 0, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
toolBar->AddTool(wxID_PRINT, _T("Print"), toolBarBitmaps[Tool_print],
|
||||||
|
bmpDisabled);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolBar->AddTool(wxID_PRINT, _T("Print"), toolBarBitmaps[Tool_print],
|
||||||
|
_T("Delete this tool. This is a very long tooltip to test whether it does the right thing when the tooltip is more than Windows can cope with."));
|
||||||
|
}
|
||||||
|
|
||||||
toolBar->AddSeparator();
|
toolBar->AddSeparator();
|
||||||
toolBar->AddTool(wxID_HELP, _T("Help"), toolBarBitmaps[7], _T("Help button"), wxITEM_CHECK);
|
toolBar->AddTool(wxID_HELP, _T("Help"), toolBarBitmaps[Tool_help], _T("Help button"), wxITEM_CHECK);
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to reflect
|
// after adding the buttons to the toolbar, must call Realize() to reflect
|
||||||
// the changes
|
// the changes
|
||||||
@@ -388,6 +428,7 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
m_smallToolbar = true;
|
m_smallToolbar = true;
|
||||||
m_horzToolbar = true;
|
m_horzToolbar = true;
|
||||||
m_horzText = false;
|
m_horzText = false;
|
||||||
|
m_useCustomDisabled = false;
|
||||||
m_rows = 1;
|
m_rows = 1;
|
||||||
m_nPrint = 1;
|
m_nPrint = 1;
|
||||||
|
|
||||||
@@ -425,6 +466,11 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
_T("Toggle number of &rows\tCtrl-R"),
|
_T("Toggle number of &rows\tCtrl-R"),
|
||||||
_T("Toggle number of toolbar rows between 1 and 2"));
|
_T("Toggle number of toolbar rows between 1 and 2"));
|
||||||
|
|
||||||
|
tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLECUSTOMDISABLED,
|
||||||
|
_T("Use c&ustom disabled images\tCtrl-U"),
|
||||||
|
_T("Switch between using system-generated and custom disabled images"));
|
||||||
|
|
||||||
|
|
||||||
tbarMenu->AppendSeparator();
|
tbarMenu->AppendSeparator();
|
||||||
|
|
||||||
tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, _T("&Enable print button\tCtrl-E"), _T(""));
|
tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, _T("&Enable print button\tCtrl-E"), _T(""));
|
||||||
@@ -581,6 +627,13 @@ void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event))
|
|||||||
//RecreateToolbar(); -- this is unneeded
|
//RecreateToolbar(); -- this is unneeded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnToggleCustomDisabled(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
m_useCustomDisabled = !m_useCustomDisabled;
|
||||||
|
|
||||||
|
RecreateToolbar();
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
m_horzToolbar = !m_horzToolbar;
|
m_horzToolbar = !m_horzToolbar;
|
||||||
|
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
#include "wx/toolbar.h"
|
#include "wx/toolbar.h"
|
||||||
#include "wx/sysopt.h"
|
#include "wx/sysopt.h"
|
||||||
|
#include "wx/image.h"
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
@@ -213,6 +214,7 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
|
|||||||
void wxToolBar::Init()
|
void wxToolBar::Init()
|
||||||
{
|
{
|
||||||
m_hBitmap = 0;
|
m_hBitmap = 0;
|
||||||
|
m_disabledImgList = NULL;
|
||||||
|
|
||||||
m_nButtons = 0;
|
m_nButtons = 0;
|
||||||
|
|
||||||
@@ -321,6 +323,12 @@ void wxToolBar::Recreate()
|
|||||||
m_hBitmap = 0;
|
m_hBitmap = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_disabledImgList )
|
||||||
|
{
|
||||||
|
delete m_disabledImgList;
|
||||||
|
m_disabledImgList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Realize();
|
Realize();
|
||||||
UpdateSize();
|
UpdateSize();
|
||||||
}
|
}
|
||||||
@@ -339,6 +347,8 @@ wxToolBar::~wxToolBar()
|
|||||||
{
|
{
|
||||||
::DeleteObject((HBITMAP) m_hBitmap);
|
::DeleteObject((HBITMAP) m_hBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete m_disabledImgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxToolBar::DoGetBestSize() const
|
wxSize wxToolBar::DoGetBestSize() const
|
||||||
@@ -508,6 +518,37 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxToolBar::CreateDisabledImageList()
|
||||||
|
{
|
||||||
|
// as we can't use disabled image list with older versions of comctl32.dll,
|
||||||
|
// don't even bother creating it
|
||||||
|
if ( wxTheApp->GetComCtl32Version() >= 470 )
|
||||||
|
{
|
||||||
|
// search for the first disabled button img in the toolbar, if any
|
||||||
|
for ( wxToolBarToolsList::compatibility_iterator
|
||||||
|
node = m_tools.GetFirst(); node; node = node->GetNext() )
|
||||||
|
{
|
||||||
|
wxToolBarToolBase *tool = node->GetData();
|
||||||
|
wxBitmap bmpDisabled = tool->GetDisabledBitmap();
|
||||||
|
if ( bmpDisabled.Ok() )
|
||||||
|
{
|
||||||
|
m_disabledImgList = new wxImageList
|
||||||
|
(
|
||||||
|
m_defaultWidth,
|
||||||
|
m_defaultHeight,
|
||||||
|
bmpDisabled.GetMask() != NULL,
|
||||||
|
GetToolsCount()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we don't have any disabled bitmaps
|
||||||
|
}
|
||||||
|
|
||||||
|
m_disabledImgList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxToolBar::Realize()
|
bool wxToolBar::Realize()
|
||||||
{
|
{
|
||||||
const size_t nTools = GetToolsCount();
|
const size_t nTools = GetToolsCount();
|
||||||
@@ -600,8 +641,10 @@ bool wxToolBar::Realize()
|
|||||||
totalBitmapWidth, totalBitmapHeight);
|
totalBitmapWidth, totalBitmapHeight);
|
||||||
|
|
||||||
dcAllButtons.SelectObject(bitmap);
|
dcAllButtons.SelectObject(bitmap);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif // !__WXWINCE__
|
||||||
|
|
||||||
// the button position
|
// the button position
|
||||||
wxCoord x = 0;
|
wxCoord x = 0;
|
||||||
@@ -609,6 +652,7 @@ bool wxToolBar::Realize()
|
|||||||
// the number of buttons (not separators)
|
// the number of buttons (not separators)
|
||||||
int nButtons = 0;
|
int nButtons = 0;
|
||||||
|
|
||||||
|
CreateDisabledImageList();
|
||||||
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
|
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
wxToolBarToolBase *tool = node->GetData();
|
wxToolBarToolBase *tool = node->GetData();
|
||||||
@@ -627,6 +671,39 @@ bool wxToolBar::Realize()
|
|||||||
wxFAIL_MSG( _T("invalid tool button bitmap") );
|
wxFAIL_MSG( _T("invalid tool button bitmap") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// also deal with disabled bitmap if we want to use them
|
||||||
|
if ( m_disabledImgList )
|
||||||
|
{
|
||||||
|
wxBitmap bmpDisabled = tool->GetDisabledBitmap();
|
||||||
|
if ( !bmpDisabled.Ok() )
|
||||||
|
{
|
||||||
|
#if wxUSE_IMAGE
|
||||||
|
// no disabled bitmap specified but we still need to
|
||||||
|
// fill the space in the image list with something, so
|
||||||
|
// we grey out the normal bitmap
|
||||||
|
wxImage img = bmp.ConvertToImage();
|
||||||
|
#if 0
|
||||||
|
img.SetMaskColour(wxLIGHT_GREY->Red(),
|
||||||
|
wxLIGHT_GREY->Green(),
|
||||||
|
wxLIGHT_GREY->Blue());
|
||||||
|
#endif
|
||||||
|
wxImage imgGreyed;
|
||||||
|
wxCreateGreyedImage(img, imgGreyed);
|
||||||
|
|
||||||
|
bmpDisabled = wxBitmap(imgGreyed);
|
||||||
|
#if 0
|
||||||
|
bmpDisabled.SetMask(new wxMask(bmpDisabled, *wxLIGHT_GREY));
|
||||||
|
|
||||||
|
MapBitmap(bmpDisabled.GetHBITMAP(),
|
||||||
|
bmpDisabled.GetWidth(),
|
||||||
|
bmpDisabled.GetHeight());
|
||||||
|
#endif // 0
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
m_disabledImgList->Add(bmpDisabled);
|
||||||
|
}
|
||||||
|
|
||||||
// still inc width and number of buttons because otherwise the
|
// still inc width and number of buttons because otherwise the
|
||||||
// subsequent buttons will all be shifted which is rather confusing
|
// subsequent buttons will all be shifted which is rather confusing
|
||||||
// (and like this you'd see immediately which bitmap was bad)
|
// (and like this you'd see immediately which bitmap was bad)
|
||||||
@@ -645,6 +722,8 @@ bool wxToolBar::Realize()
|
|||||||
// Map to system colours
|
// Map to system colours
|
||||||
hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap,
|
hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap,
|
||||||
totalBitmapWidth, totalBitmapHeight);
|
totalBitmapWidth, totalBitmapHeight);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addBitmap = true;
|
bool addBitmap = true;
|
||||||
@@ -694,6 +773,19 @@ bool wxToolBar::Realize()
|
|||||||
wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
|
wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_disabledImgList )
|
||||||
|
{
|
||||||
|
HIMAGELIST oldImageList = (HIMAGELIST)
|
||||||
|
::SendMessage(GetHwnd(),
|
||||||
|
TB_SETDISABLEDIMAGELIST,
|
||||||
|
0,
|
||||||
|
(LPARAM)GetHimagelistOf(m_disabledImgList));
|
||||||
|
|
||||||
|
// delete previous image list if any
|
||||||
|
if ( oldImageList )
|
||||||
|
::DeleteObject( oldImageList );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't call SetToolBitmapSize() as we don't want to change the values of
|
// don't call SetToolBitmapSize() as we don't want to change the values of
|
||||||
|
Reference in New Issue
Block a user