added demo for bitmaps of different size
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5431 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <wx/toolbar.h>
|
#include <wx/toolbar.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
#include <wx/image.h>
|
||||||
|
|
||||||
// define this to 1 to use wxToolBarSimple instead of the native one
|
// define this to 1 to use wxToolBarSimple instead of the native one
|
||||||
#define USE_GENERIC_TBAR 0
|
#define USE_GENERIC_TBAR 0
|
||||||
@@ -218,14 +219,24 @@ void MyFrame::RecreateToolbar()
|
|||||||
|
|
||||||
toolBarBitmaps[0] = wxBITMAP(new);
|
toolBarBitmaps[0] = wxBITMAP(new);
|
||||||
toolBarBitmaps[1] = wxBITMAP(open);
|
toolBarBitmaps[1] = wxBITMAP(open);
|
||||||
if ( !m_smallToolbar )
|
|
||||||
{
|
|
||||||
toolBarBitmaps[2] = wxBITMAP(save);
|
toolBarBitmaps[2] = wxBITMAP(save);
|
||||||
toolBarBitmaps[3] = wxBITMAP(copy);
|
toolBarBitmaps[3] = wxBITMAP(copy);
|
||||||
toolBarBitmaps[4] = wxBITMAP(cut);
|
toolBarBitmaps[4] = wxBITMAP(cut);
|
||||||
toolBarBitmaps[5] = wxBITMAP(paste);
|
toolBarBitmaps[5] = wxBITMAP(paste);
|
||||||
toolBarBitmaps[6] = wxBITMAP(print);
|
toolBarBitmaps[6] = wxBITMAP(print);
|
||||||
toolBarBitmaps[7] = wxBITMAP(help);
|
toolBarBitmaps[7] = wxBITMAP(help);
|
||||||
|
|
||||||
|
if ( !m_smallToolbar )
|
||||||
|
{
|
||||||
|
int w = 2*toolBarBitmaps[0].GetWidth(),
|
||||||
|
h = 2*toolBarBitmaps[0].GetHeight();
|
||||||
|
for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ )
|
||||||
|
{
|
||||||
|
toolBarBitmaps[n] =
|
||||||
|
wxImage(toolBarBitmaps[n]).Scale(w, h).ConvertToBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
toolBar->SetToolBitmapSize(wxSize(w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
@@ -255,8 +266,6 @@ void MyFrame::RecreateToolbar()
|
|||||||
}
|
}
|
||||||
#endif // toolbars which don't support controls
|
#endif // toolbars which don't support controls
|
||||||
|
|
||||||
if ( !m_smallToolbar )
|
|
||||||
{
|
|
||||||
currentX += width + 5;
|
currentX += width + 5;
|
||||||
toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1");
|
toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1");
|
||||||
currentX += width + 5;
|
currentX += width + 5;
|
||||||
@@ -270,7 +279,6 @@ void MyFrame::RecreateToolbar()
|
|||||||
currentX += width + 5;
|
currentX += width + 5;
|
||||||
toolBar->AddSeparator();
|
toolBar->AddSeparator();
|
||||||
toolBar->AddTool(wxID_HELP, toolBarBitmaps[7], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help button");
|
toolBar->AddTool(wxID_HELP, toolBarBitmaps[7], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help button");
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
||||||
@@ -294,7 +302,7 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
{
|
{
|
||||||
m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
|
m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
|
||||||
|
|
||||||
m_smallToolbar = FALSE;
|
m_smallToolbar = TRUE;
|
||||||
m_horzToolbar = TRUE;
|
m_horzToolbar = TRUE;
|
||||||
m_rows = 1;
|
m_rows = 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user