OSX toolbar adaptations to wxBitmapBundle
This commit is contained in:
committed by
Vadim Zeitlin
parent
95aa8e40fd
commit
edc95443a3
@@ -58,8 +58,9 @@ public:
|
||||
|
||||
virtual void SetRows(int nRows) wxOVERRIDE;
|
||||
|
||||
virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE;
|
||||
virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE;
|
||||
|
||||
virtual void SetToolNormalBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE;
|
||||
virtual void SetToolDisabledBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE;
|
||||
|
||||
#ifndef __WXOSX_IPHONE__
|
||||
// Add all the buttons
|
||||
@@ -83,8 +84,8 @@ public:
|
||||
|
||||
virtual wxToolBarToolBase *CreateTool(int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled = wxNullBitmap,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled = wxNullBitmap,
|
||||
wxItemKind kind = wxITEM_NORMAL,
|
||||
wxObject *clientData = NULL,
|
||||
const wxString& shortHelp = wxEmptyString,
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "wx/app.h"
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/private/available.h"
|
||||
#include "wx/private/bmpbndl.h"
|
||||
#include "wx/geometry.h"
|
||||
#include "wx/sysopt.h"
|
||||
|
||||
@@ -77,8 +78,8 @@ public:
|
||||
wxToolBar *tbar,
|
||||
int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
@@ -591,14 +592,14 @@ void wxToolBarTool::SetPosition( const wxPoint& position )
|
||||
|
||||
void wxToolBarTool::UpdateImages()
|
||||
{
|
||||
[(NSButton*) m_controlHandle setImage:m_bmpNormal.GetNSImage()];
|
||||
[(NSButton*) m_controlHandle setImage:wxOSXGetImageFromBundle(m_bmpNormal)];
|
||||
|
||||
if ( CanBeToggled() )
|
||||
{
|
||||
int w = m_bmpNormal.GetScaledWidth();
|
||||
int h = m_bmpNormal.GetScaledHeight();
|
||||
// TODO CS this should use the best current representation, or optionally iterate through all
|
||||
wxSize sz = m_bmpNormal.GetDefaultSize();
|
||||
m_alternateBitmap = wxBitmap();
|
||||
m_alternateBitmap.CreateScaled(w, h, -1, m_bmpNormal.GetScaleFactor());
|
||||
m_alternateBitmap.Create(sz.x, sz.y, -1); // TODO CS m_alternateBitmap.CreateScaled(sz.x, sz.y, -1, m_bmpNormal.GetScaleFactor());
|
||||
m_alternateBitmap.UseAlpha();
|
||||
wxMemoryDC dc;
|
||||
|
||||
@@ -610,8 +611,8 @@ void wxToolBarTool::UpdateImages()
|
||||
dc.Clear();
|
||||
dc.SetPen(grey);
|
||||
dc.SetBrush(grey);
|
||||
dc.DrawRoundedRectangle( 0, 0, w, h, 3 );
|
||||
dc.DrawBitmap( m_bmpNormal, 0, 0, true );
|
||||
dc.DrawRoundedRectangle( 0, 0, sz.x, sz.y, 3 );
|
||||
dc.DrawBitmap( m_bmpNormal.GetBitmap(sz), 0, 0, true );
|
||||
dc.SelectObject( wxNullBitmap );
|
||||
|
||||
[(NSButton*) m_controlHandle setAlternateImage:m_alternateBitmap.GetNSImage()];
|
||||
@@ -633,7 +634,7 @@ void wxToolBarTool::UpdateToggleImage( bool toggle )
|
||||
if ( CanBeToggled() && toggle )
|
||||
[m_toolbarItem setImage:m_alternateBitmap.GetNSImage()];
|
||||
else
|
||||
[m_toolbarItem setImage:m_bmpNormal.GetNSImage()];
|
||||
[m_toolbarItem setImage:wxOSXGetImageFromBundle(m_bmpNormal)];
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -645,8 +646,8 @@ wxToolBarTool::wxToolBarTool(
|
||||
wxToolBar *tbar,
|
||||
int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
@@ -665,8 +666,8 @@ wxToolBarTool::wxToolBarTool(
|
||||
wxToolBarToolBase *wxToolBar::CreateTool(
|
||||
int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
@@ -1380,7 +1381,7 @@ void wxToolBar::MacSuperChangedPosition()
|
||||
*/
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
|
||||
if ( tool )
|
||||
@@ -1394,7 +1395,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
}
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
|
||||
if ( tool )
|
||||
|
@@ -19,10 +19,13 @@
|
||||
#endif
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/geometry.h"
|
||||
#include "wx/sysopt.h"
|
||||
|
||||
#include "wx/private/bmpbndl.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Tool Implementation
|
||||
|
||||
@@ -58,8 +61,8 @@ public:
|
||||
wxToolBar *tbar,
|
||||
int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
@@ -104,8 +107,8 @@ wxToolBarTool::wxToolBarTool(
|
||||
wxToolBar *tbar,
|
||||
int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
@@ -127,7 +130,7 @@ wxToolBarToolBase(
|
||||
}
|
||||
else if ( bmpNormal.IsOk() )
|
||||
{
|
||||
bui = [bui initWithImage:bmpNormal.GetUIImage() style:UIBarButtonItemStylePlain target:toolbar
|
||||
bui = [bui initWithImage:wxOSXGetImageFromBundle(bmpNormal) style:UIBarButtonItemStylePlain target:toolbar
|
||||
action:@selector(clickedAction:)];
|
||||
}
|
||||
else
|
||||
@@ -180,8 +183,8 @@ wxToolBarTool::~wxToolBarTool()
|
||||
wxToolBarToolBase *wxToolBar::CreateTool(
|
||||
int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
const wxBitmapBundle& bmpNormal,
|
||||
const wxBitmapBundle& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
@@ -296,7 +299,7 @@ void wxToolBar::SetRows(int nRows)
|
||||
m_maxRows = nRows;
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
|
||||
if ( tool )
|
||||
@@ -307,7 +310,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
|
||||
}
|
||||
}
|
||||
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
|
||||
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap )
|
||||
{
|
||||
wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
|
||||
if ( tool )
|
||||
|
Reference in New Issue
Block a user