Use wxBitmapBundle in wxWizard
This commit is contained in:
@@ -29,7 +29,7 @@ public:
|
|||||||
wxWizard(wxWindow *parent,
|
wxWizard(wxWindow *parent,
|
||||||
int id = wxID_ANY,
|
int id = wxID_ANY,
|
||||||
const wxString& title = wxEmptyString,
|
const wxString& title = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE)
|
long style = wxDEFAULT_DIALOG_STYLE)
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
int id = wxID_ANY,
|
int id = wxID_ANY,
|
||||||
const wxString& title = wxEmptyString,
|
const wxString& title = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE);
|
long style = wxDEFAULT_DIALOG_STYLE);
|
||||||
void Init();
|
void Init();
|
||||||
@@ -55,8 +55,8 @@ public:
|
|||||||
virtual void SetBorder(int border) wxOVERRIDE;
|
virtual void SetBorder(int border) wxOVERRIDE;
|
||||||
|
|
||||||
/// set/get bitmap
|
/// set/get bitmap
|
||||||
const wxBitmap& GetBitmap() const { return m_bitmap; }
|
wxBitmap GetBitmap() const { return m_bitmap.GetBitmapFor(this); }
|
||||||
void SetBitmap(const wxBitmap& bitmap);
|
void SetBitmap(const wxBitmapBundle& bitmap);
|
||||||
|
|
||||||
// implementation only from now on
|
// implementation only from now on
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
@@ -116,6 +116,9 @@ protected:
|
|||||||
void AddBackNextPair(wxBoxSizer *buttonRow);
|
void AddBackNextPair(wxBoxSizer *buttonRow);
|
||||||
void AddButtonRow(wxBoxSizer *mainColumn);
|
void AddButtonRow(wxBoxSizer *mainColumn);
|
||||||
|
|
||||||
|
// This function can be used as event handle for wxEVT_DPI_CHANGED event.
|
||||||
|
void WXHandleDPIChanged(wxDPIChangedEvent& event);
|
||||||
|
|
||||||
// the page size requested by user
|
// the page size requested by user
|
||||||
wxSize m_sizePage;
|
wxSize m_sizePage;
|
||||||
|
|
||||||
@@ -125,7 +128,7 @@ protected:
|
|||||||
// wizard state
|
// wizard state
|
||||||
wxWizardPage *m_page; // the current page or NULL
|
wxWizardPage *m_page; // the current page or NULL
|
||||||
wxWizardPage *m_firstpage; // the page RunWizard started on or NULL
|
wxWizardPage *m_firstpage; // the page RunWizard started on or NULL
|
||||||
wxBitmap m_bitmap; // the default bitmap to show
|
wxBitmapBundle m_bitmap; // the default bitmap to show
|
||||||
|
|
||||||
// wizard controls
|
// wizard controls
|
||||||
wxButton *m_btnPrev, // the "<Back" button
|
wxButton *m_btnPrev, // the "<Back" button
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "wx/dialog.h" // the base class
|
#include "wx/dialog.h" // the base class
|
||||||
#include "wx/panel.h" // ditto
|
#include "wx/panel.h" // ditto
|
||||||
#include "wx/event.h" // wxEVT_XXX constants
|
#include "wx/event.h" // wxEVT_XXX constants
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bmpbndl.h"
|
||||||
|
|
||||||
// Extended style to specify a help button
|
// Extended style to specify a help button
|
||||||
#define wxWIZARD_EX_HELPBUTTON 0x00000010
|
#define wxWIZARD_EX_HELPBUTTON 0x00000010
|
||||||
@@ -62,10 +62,10 @@ public:
|
|||||||
// that no other parameters are needed because the wizard will resize and
|
// that no other parameters are needed because the wizard will resize and
|
||||||
// reposition the page anyhow
|
// reposition the page anyhow
|
||||||
wxWizardPage(wxWizard *parent,
|
wxWizardPage(wxWizard *parent,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
bool Create(wxWizard *parent,
|
bool Create(wxWizard *parent,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
// these functions are used by the wizard to show another page when the
|
// these functions are used by the wizard to show another page when the
|
||||||
// user chooses "Back" or "Next" button
|
// user chooses "Back" or "Next" button
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
// cases - override this method if you want to create the bitmap to be used
|
// cases - override this method if you want to create the bitmap to be used
|
||||||
// dynamically or to do something even more fancy. It's ok to return
|
// dynamically or to do something even more fancy. It's ok to return
|
||||||
// wxNullBitmap from here - the default one will be used then.
|
// wxNullBitmap from here - the default one will be used then.
|
||||||
virtual wxBitmap GetBitmap() const { return m_bitmap; }
|
virtual wxBitmap GetBitmap() const { return m_bitmap.GetBitmapFor(this); }
|
||||||
|
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
// Override the base functions to allow a validator to be assigned to this page.
|
// Override the base functions to allow a validator to be assigned to this page.
|
||||||
@@ -103,7 +103,7 @@ protected:
|
|||||||
// common part of ctors:
|
// common part of ctors:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
wxBitmapBundle m_bitmap;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxWizardPage);
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxWizardPage);
|
||||||
@@ -127,7 +127,7 @@ public:
|
|||||||
wxWizardPageSimple(wxWizard *parent,
|
wxWizardPageSimple(wxWizard *parent,
|
||||||
wxWizardPage *prev = NULL,
|
wxWizardPage *prev = NULL,
|
||||||
wxWizardPage *next = NULL,
|
wxWizardPage *next = NULL,
|
||||||
const wxBitmap& bitmap = wxNullBitmap)
|
const wxBitmapBundle& bitmap = wxBitmapBundle())
|
||||||
{
|
{
|
||||||
Create(parent, prev, next, bitmap);
|
Create(parent, prev, next, bitmap);
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
bool Create(wxWizard *parent = NULL, // let it be default ctor too
|
bool Create(wxWizard *parent = NULL, // let it be default ctor too
|
||||||
wxWizardPage *prev = NULL,
|
wxWizardPage *prev = NULL,
|
||||||
wxWizardPage *next = NULL,
|
wxWizardPage *next = NULL,
|
||||||
const wxBitmap& bitmap = wxNullBitmap)
|
const wxBitmapBundle& bitmap = wxBitmapBundle())
|
||||||
{
|
{
|
||||||
m_prev = prev;
|
m_prev = prev;
|
||||||
m_next = next;
|
m_next = next;
|
||||||
@@ -197,7 +197,7 @@ public:
|
|||||||
wxWizard(wxWindow *parent,
|
wxWizard(wxWindow *parent,
|
||||||
int id = wxID_ANY,
|
int id = wxID_ANY,
|
||||||
const wxString& title = wxEmptyString,
|
const wxString& title = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE);
|
long style = wxDEFAULT_DIALOG_STYLE);
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
The page-specific bitmap if different from the global one
|
The page-specific bitmap if different from the global one
|
||||||
*/
|
*/
|
||||||
wxWizardPage(wxWizard* parent,
|
wxWizardPage(wxWizard* parent,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates the wizard page.
|
Creates the wizard page.
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
The page-specific bitmap if different from the global one
|
The page-specific bitmap if different from the global one
|
||||||
*/
|
*/
|
||||||
bool Create(wxWizard *parent,
|
bool Create(wxWizard *parent,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method is called by wxWizard to get the bitmap to display alongside the page.
|
This method is called by wxWizard to get the bitmap to display alongside the page.
|
||||||
@@ -214,7 +214,7 @@ public:
|
|||||||
wxWizardPageSimple(wxWizard* parent,
|
wxWizardPageSimple(wxWizard* parent,
|
||||||
wxWizardPage* prev = NULL,
|
wxWizardPage* prev = NULL,
|
||||||
wxWizardPage* next = NULL,
|
wxWizardPage* next = NULL,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates the wizard page.
|
Creates the wizard page.
|
||||||
@@ -223,7 +223,7 @@ public:
|
|||||||
bool Create(wxWizard *parent = NULL,
|
bool Create(wxWizard *parent = NULL,
|
||||||
wxWizardPage *prev = NULL,
|
wxWizardPage *prev = NULL,
|
||||||
wxWizardPage *next = NULL,
|
wxWizardPage *next = NULL,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A helper chaining this page with the next one.
|
A helper chaining this page with the next one.
|
||||||
@@ -380,7 +380,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxWizard(wxWindow* parent, int id = wxID_ANY,
|
wxWizard(wxWindow* parent, int id = wxID_ANY,
|
||||||
const wxString& title = wxEmptyString,
|
const wxString& title = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE);
|
long style = wxDEFAULT_DIALOG_STYLE);
|
||||||
|
|
||||||
@@ -408,7 +408,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool Create(wxWindow* parent, int id = wxID_ANY,
|
bool Create(wxWindow* parent, int id = wxID_ANY,
|
||||||
const wxString& title = wxEmptyString,
|
const wxString& title = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxPoint& pos = wxDefaultPosition, long style = wxDEFAULT_DIALOG_STYLE);
|
const wxPoint& pos = wxDefaultPosition, long style = wxDEFAULT_DIALOG_STYLE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -523,7 +523,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Sets the bitmap used for the wizard.
|
Sets the bitmap used for the wizard.
|
||||||
*/
|
*/
|
||||||
void SetBitmap(const wxBitmap& bitmap);
|
void SetBitmap(const wxBitmapBundle& bitmap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the colour that should be used to fill the area not taken up by the wizard
|
Sets the colour that should be used to fill the area not taken up by the wizard
|
||||||
|
|||||||
@@ -121,17 +121,17 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxWizardEvent, wxNotifyEvent);
|
|||||||
|
|
||||||
void wxWizardPage::Init()
|
void wxWizardPage::Init()
|
||||||
{
|
{
|
||||||
m_bitmap = wxNullBitmap;
|
m_bitmap = wxBitmapBundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWizardPage::wxWizardPage(wxWizard *parent,
|
wxWizardPage::wxWizardPage(wxWizard *parent,
|
||||||
const wxBitmap& bitmap)
|
const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
Create(parent, bitmap);
|
Create(parent, bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWizardPage::Create(wxWizard *parent,
|
bool wxWizardPage::Create(wxWizard *parent,
|
||||||
const wxBitmap& bitmap)
|
const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
if ( !wxPanel::Create(parent, wxID_ANY) )
|
if ( !wxPanel::Create(parent, wxID_ANY) )
|
||||||
return false;
|
return false;
|
||||||
@@ -280,12 +280,14 @@ void wxWizard::Init()
|
|||||||
m_bitmapBackgroundColour = *wxWHITE;
|
m_bitmapBackgroundColour = *wxWHITE;
|
||||||
m_bitmapPlacement = 0;
|
m_bitmapPlacement = 0;
|
||||||
m_bitmapMinimumWidth = 115;
|
m_bitmapMinimumWidth = 115;
|
||||||
|
|
||||||
|
Bind(wxEVT_DPI_CHANGED, &wxWizard::WXHandleDPIChanged, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWizard::Create(wxWindow *parent,
|
bool wxWizard::Create(wxWindow *parent,
|
||||||
int id,
|
int id,
|
||||||
const wxString& title,
|
const wxString& title,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
long style)
|
long style)
|
||||||
{
|
{
|
||||||
@@ -606,10 +608,10 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
|
|||||||
{
|
{
|
||||||
bmp = m_page->GetBitmap();
|
bmp = m_page->GetBitmap();
|
||||||
if ( !bmp.IsOk() )
|
if ( !bmp.IsOk() )
|
||||||
bmp = m_bitmap;
|
bmp = m_bitmap.GetBitmapFor(this);
|
||||||
|
|
||||||
if ( !bmpPrev.IsOk() )
|
if ( !bmpPrev.IsOk() )
|
||||||
bmpPrev = m_bitmap;
|
bmpPrev = m_bitmap.GetBitmapFor(this);
|
||||||
|
|
||||||
if (!GetBitmapPlacement())
|
if (!GetBitmapPlacement())
|
||||||
{
|
{
|
||||||
@@ -729,7 +731,7 @@ wxSize wxWizard::GetPageSize() const
|
|||||||
if ( m_statbmp )
|
if ( m_statbmp )
|
||||||
{
|
{
|
||||||
// make the page at least as tall as the bitmap
|
// make the page at least as tall as the bitmap
|
||||||
pageSize.IncTo(wxSize(0, m_bitmap.GetLogicalHeight()));
|
pageSize.IncTo(wxSize(0, m_bitmap.GetPreferredLogicalSizeFor(this).GetHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_usingSizer )
|
if ( m_usingSizer )
|
||||||
@@ -862,13 +864,29 @@ void wxWizard::OnWizEvent(wxWizardEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWizard::SetBitmap(const wxBitmap& bitmap)
|
void wxWizard::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
if (m_statbmp)
|
if (m_statbmp)
|
||||||
m_statbmp->SetBitmap(m_bitmap);
|
m_statbmp->SetBitmap(m_bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWizard::WXHandleDPIChanged(wxDPIChangedEvent& event)
|
||||||
|
{
|
||||||
|
wxBitmap bmp;
|
||||||
|
if ( m_statbmp )
|
||||||
|
{
|
||||||
|
bmp = m_page->GetBitmap();
|
||||||
|
if ( !bmp.IsOk() )
|
||||||
|
bmp = m_bitmap.GetBitmapFor(this);
|
||||||
|
|
||||||
|
ResizeBitmap(bmp);
|
||||||
|
m_statbmp->SetBitmap(bmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxWizardEvent
|
// wxWizardEvent
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -948,7 +966,8 @@ bool wxWizard::ResizeBitmap(wxBitmap& bmp)
|
|||||||
|
|
||||||
if (!m_statbmp->GetBitmap().IsOk() || m_statbmp->GetBitmap().GetLogicalHeight() != bitmapHeight)
|
if (!m_statbmp->GetBitmap().IsOk() || m_statbmp->GetBitmap().GetLogicalHeight() != bitmapHeight)
|
||||||
{
|
{
|
||||||
wxBitmap bitmap(bitmapWidth, bitmapHeight);
|
wxBitmap bitmap;
|
||||||
|
bitmap.CreateWithLogicalSize(bitmapWidth, bitmapHeight, bmp.GetScaleFactor(), bmp.GetDepth());
|
||||||
{
|
{
|
||||||
wxMemoryDC dc;
|
wxMemoryDC dc;
|
||||||
dc.SelectObject(bitmap);
|
dc.SelectObject(bitmap);
|
||||||
|
|||||||
Reference in New Issue
Block a user