Added SetToolNormalBitmap and SetToolDisabledBitmap
(ported from 2.8 branch) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44388 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0daf5e6be2
commit
bbd321ffc2
@ -761,6 +761,17 @@ and not the eventual size of the tool button.
|
||||
Sets the client data associated with the tool.
|
||||
|
||||
|
||||
\membersection{wxToolBar::SetToolDisabledBitmap}\label{wxtoolbarsettooldisabledbitmap}
|
||||
|
||||
\func{void}{SetToolDisabledBitmap}{\param{int }{id}, \param{const wxBitmap\& }{bitmap}}
|
||||
|
||||
Sets the bitmap to be used by the tool with the given ID when the tool
|
||||
is in a disabled state. This can only be used on Button tools, not
|
||||
controls. NOTE: The native toolbar classes on the main platforms all
|
||||
synthesize the disabled bitmap from the normal bitmap, so this
|
||||
function will have no effect on those platforms.
|
||||
|
||||
|
||||
\membersection{wxToolBar::SetToolLongHelp}\label{wxtoolbarsettoollonghelp}
|
||||
|
||||
\func{void}{SetToolLongHelp}{\param{int }{toolId}, \param{const wxString\& }{helpString}}
|
||||
@ -824,6 +835,15 @@ An application might use short help for identifying the tool purpose in a toolti
|
||||
\helpref{wxToolBar::GetToolShortHelp}{wxtoolbargettoolshorthelp}, \helpref{wxToolBar::SetToolLongHelp}{wxtoolbarsettoollonghelp}
|
||||
|
||||
|
||||
\membersection{wxToolBar::SetToolNormalBitmap}\label{wxtoolbarsettoolnormalbitmap}
|
||||
|
||||
\func{void}{SetToolNormalBitmap}{\param{int }{id}, \param{const wxBitmap\& }{bitmap}}
|
||||
|
||||
Sets the bitmap to be used by the tool with the given ID. This can
|
||||
only be used on Button tools, not controls.
|
||||
|
||||
|
||||
|
||||
\membersection{wxToolBar::SetToolSeparation}\label{wxtoolbarsettoolseparation}
|
||||
|
||||
\func{void}{SetToolSeparation}{\param{int}{ separation}}
|
||||
|
@ -52,6 +52,9 @@ public:
|
||||
|
||||
virtual void SetWindowStyleFlag( long style );
|
||||
|
||||
virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
|
||||
virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
|
||||
|
||||
static wxVisualAttributes
|
||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||
|
||||
|
@ -57,6 +57,9 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase
|
||||
|
||||
virtual void SetRows(int nRows);
|
||||
|
||||
virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
|
||||
virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
|
||||
|
||||
// Add all the buttons
|
||||
|
||||
virtual wxString MacGetToolTipString( wxPoint &where ) ;
|
||||
|
@ -54,6 +54,9 @@ public:
|
||||
|
||||
virtual void SetRows(int nRows);
|
||||
|
||||
virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
|
||||
virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
|
@ -372,6 +372,9 @@ public:
|
||||
virtual void SetToolLongHelp(int toolid, const wxString& helpString);
|
||||
virtual wxString GetToolLongHelp(int toolid) const;
|
||||
|
||||
virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) {}
|
||||
virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) {}
|
||||
|
||||
// margins/packing/separation
|
||||
// --------------------------
|
||||
|
||||
|
@ -597,6 +597,30 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
|
||||
}
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
|
||||
if ( tool )
|
||||
{
|
||||
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
|
||||
|
||||
tool->SetNormalBitmap(bitmap);
|
||||
tool->SetImage(tool->GetBitmap());
|
||||
}
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
|
||||
if ( tool )
|
||||
{
|
||||
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
|
||||
|
||||
tool->SetDisabledBitmap(bitmap);
|
||||
tool->SetImage(tool->GetBitmap());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxToolBar idle handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -168,10 +168,19 @@ public:
|
||||
m_toolbarItemRef = ref;
|
||||
if ( m_toolbarItemRef )
|
||||
{
|
||||
wxFont f;
|
||||
wxFontEncoding enc;
|
||||
if ( GetToolBar() )
|
||||
f = GetToolBar()->GetFont();
|
||||
if ( f.IsOk() )
|
||||
enc = f.GetEncoding();
|
||||
else
|
||||
enc = wxFont::GetDefaultEncoding();
|
||||
|
||||
HIToolbarItemSetHelpText(
|
||||
m_toolbarItemRef,
|
||||
wxMacCFStringHolder( GetShortHelp(), GetToolBar()->GetFont().GetEncoding() ),
|
||||
wxMacCFStringHolder( GetLongHelp(), GetToolBar()->GetFont().GetEncoding() ) );
|
||||
wxMacCFStringHolder( GetShortHelp(), enc ),
|
||||
wxMacCFStringHolder( GetLongHelp(), enc ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1312,6 +1321,33 @@ void wxToolBar::MacSuperChangedPosition()
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
|
||||
if ( tool )
|
||||
{
|
||||
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
|
||||
|
||||
tool->SetNormalBitmap(bitmap);
|
||||
|
||||
// a side-effect of the UpdateToggleImage function is that it always changes the bitmap used on the button.
|
||||
tool->UpdateToggleImage( tool->CanBeToggled() && tool->IsToggled() );
|
||||
}
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
|
||||
if ( tool )
|
||||
{
|
||||
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
|
||||
|
||||
tool->SetDisabledBitmap(bitmap);
|
||||
|
||||
// TODO: what to do for this one?
|
||||
}
|
||||
}
|
||||
|
||||
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
|
||||
{
|
||||
wxToolBarTool *tool;
|
||||
@ -1365,6 +1401,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
|
||||
Rect toolrect = { 0, 0, toolSize.y, toolSize.x };
|
||||
ControlRef controlHandle = NULL;
|
||||
OSStatus err = 0;
|
||||
tool->Attach( this );
|
||||
|
||||
switch (tool->GetStyle())
|
||||
{
|
||||
@ -1494,7 +1531,6 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
|
||||
tool->UpdateToggleImage( true );
|
||||
|
||||
// nothing special to do here - we relayout in Realize() later
|
||||
tool->Attach( this );
|
||||
InvalidateBestSize();
|
||||
}
|
||||
else
|
||||
|
@ -1331,6 +1331,30 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(tog
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
|
||||
if ( tool )
|
||||
{
|
||||
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
|
||||
|
||||
tool->SetNormalBitmap(bitmap);
|
||||
Realize();
|
||||
}
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
|
||||
if ( tool )
|
||||
{
|
||||
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
|
||||
|
||||
tool->SetDisabledBitmap(bitmap);
|
||||
Realize();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user