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