summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8f79ece)
Don't fail loudly if the image file is not found (which can happen under Unix
if the image sample wasn't built yet or if we're not running the sample from
its own directory) but just don't create the bitmap.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62770
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#include "wx/textctrl.h"
#endif
#include "wx/textctrl.h"
#endif
+#include "wx/filename.h"
+
#include "wx/generic/statbmpg.h"
#include "wx/sizer.h"
#include "wx/filepicker.h"
#include "wx/generic/statbmpg.h"
#include "wx/sizer.h"
#include "wx/filepicker.h"
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices), choices);
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices), choices);
- m_filepicker = new wxFilePickerCtrl(this, wxID_ANY, "../image/toucan.png");
+ wxString testImage;
+#if wxUSE_LIBPNG
+ wxFileName fn("../image/toucan.png");
+ if ( fn.FileExists() )
+ testImage = fn.GetFullPath();
+#endif // wxUSE_LIBPNG
+ m_filepicker = new wxFilePickerCtrl(this, wxID_ANY, testImage);
m_sbsizer = new wxStaticBoxSizer(wxVERTICAL, this, "wxStaticBitmap inside");
m_sbsizer = new wxStaticBoxSizer(wxVERTICAL, this, "wxStaticBitmap inside");
wxInitAllImageHandlers();
wxInitAllImageHandlers();
- Connect(wxEVT_COMMAND_FILEPICKER_CHANGED,
+ Connect(wxEVT_COMMAND_FILEPICKER_CHANGED,
wxFileDirPickerEventHandler(StatBmpWidgetsPage::OnFileChange));
wxFileDirPickerEventHandler(StatBmpWidgetsPage::OnFileChange));
- Connect(wxEVT_COMMAND_RADIOBOX_SELECTED,
+ Connect(wxEVT_COMMAND_RADIOBOX_SELECTED,
wxCommandEventHandler(StatBmpWidgetsPage::OnRadioChange));
m_statbmp = NULL;
wxCommandEventHandler(StatBmpWidgetsPage::OnRadioChange));
m_statbmp = NULL;
void StatBmpWidgetsPage::RecreateWidget()
{
delete m_statbmp;
void StatBmpWidgetsPage::RecreateWidget()
{
delete m_statbmp;
wxString filepath = m_filepicker->GetPath();
wxString filepath = m_filepicker->GetPath();
+ if ( filepath.empty() )
+ return;
+
wxImage image(filepath);
if (! image.Ok() )
{
wxLogMessage("Reading image from file '%s' failed.", filepath.c_str());
wxImage image(filepath);
if (! image.Ok() )
{
wxLogMessage("Reading image from file '%s' failed.", filepath.c_str());
return;
}
if (m_radio->GetSelection() == 0)
return;
}
if (m_radio->GetSelection() == 0)
m_statbmp = new wxGenericStaticBitmap(this, wxID_ANY, wxBitmap(image));
m_sbsizer->Add(m_statbmp, wxSizerFlags(1).Expand());
GetSizer()->Layout();
m_statbmp = new wxGenericStaticBitmap(this, wxID_ANY, wxBitmap(image));
m_sbsizer->Add(m_statbmp, wxSizerFlags(1).Expand());
GetSizer()->Layout();
- m_statbmp->Connect(wxEVT_LEFT_DOWN,
+ m_statbmp->Connect(wxEVT_LEFT_DOWN,
wxMouseEventHandler(StatBmpWidgetsPage::OnMouseEvent),
NULL, this);
wxMouseEventHandler(StatBmpWidgetsPage::OnMouseEvent),
NULL, this);
- // When switching from generic to native control on wxMSW under Wine,
+ // When switching from generic to native control on wxMSW under Wine,
// the explicit Refresh() is necessary
// the explicit Refresh() is necessary