added wxGenericStaticBitmap (#9608)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -76,6 +76,7 @@ WIDGETS_OBJECTS = \
|
||||
widgets_slider.o \
|
||||
widgets_spinbtn.o \
|
||||
widgets_static.o \
|
||||
widgets_statbmp.o \
|
||||
widgets_textctrl.o \
|
||||
widgets_toggle.o \
|
||||
widgets_widgets.o \
|
||||
@@ -291,6 +292,9 @@ widgets_spinbtn.o: $(srcdir)/spinbtn.cpp
|
||||
widgets_static.o: $(srcdir)/static.cpp
|
||||
$(CXXC) -c -o $@ $(WIDGETS_CXXFLAGS) $(srcdir)/static.cpp
|
||||
|
||||
widgets_statbmp.o: $(srcdir)/statbmp.cpp
|
||||
$(CXXC) -c -o $@ $(WIDGETS_CXXFLAGS) $(srcdir)/statbmp.cpp
|
||||
|
||||
widgets_textctrl.o: $(srcdir)/textctrl.cpp
|
||||
$(CXXC) -c -o $@ $(WIDGETS_CXXFLAGS) $(srcdir)/textctrl.cpp
|
||||
|
||||
@@ -304,6 +308,15 @@ widgets_sample_rc.o: $(srcdir)/../sample.rc
|
||||
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_2) $(__EXCEPTIONS_DEFINE_p_2) $(__RTTI_DEFINE_p_2) $(__THREAD_DEFINE_p_2) --include-dir $(srcdir) $(__DLLFLAG_p_2) --include-dir $(srcdir)/../../samples $(__RCDEFDIR_p_1) --include-dir $(top_srcdir)/include
|
||||
|
||||
|
||||
$(srcdir)/include/wx/stc/stc.h: \
|
||||
$(srcdir)/src/stc/scintilla/include/Scintilla.iface \
|
||||
$(srcdir)/src/stc/stc.cpp.in \
|
||||
$(srcdir)/src/stc/stc.h.in \
|
||||
$(srcdir)/src/stc/gen_iface.py
|
||||
cd $(srcdir)/src/stc && ./gen_iface.py
|
||||
monolib_stc.o monodll_stc.o stcdll_stc.o stclib_stc.o: \
|
||||
$(srcdir)/include/wx/stc/stc.h
|
||||
|
||||
# Include dependency info, if present:
|
||||
@IF_GNU_MAKE@-include .deps/*.d
|
||||
|
||||
|
40
samples/widgets/icons/statbmp.xpm
Normal file
40
samples/widgets/icons/statbmp.xpm
Normal file
@@ -0,0 +1,40 @@
|
||||
/* XPM */
|
||||
static const char *statbmp_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 2 1",
|
||||
" c Gray0",
|
||||
"# c none",
|
||||
/* pixels */
|
||||
"################################",
|
||||
"################################",
|
||||
"################################",
|
||||
"################################",
|
||||
"################################",
|
||||
"################################",
|
||||
"## ##",
|
||||
"## ########################## ##",
|
||||
"## ########################## ##",
|
||||
"## ######### ########### ##",
|
||||
"## ######## ###### ########## ##",
|
||||
"## ####### ######## ######### ##",
|
||||
"## ######## ######## ######## ##",
|
||||
"## ######### ######## ####### ##",
|
||||
"## ########## ###### ######## ##",
|
||||
"## ########### #### ######### ##",
|
||||
"## ############ ########## ##",
|
||||
"## ########################## ##",
|
||||
"## ### ########### ##",
|
||||
"## ### ########## ########### ##",
|
||||
"## ### ########## ########### ##",
|
||||
"## ### ########## ########### ##",
|
||||
"## ### ########## ########### ##",
|
||||
"## ### ########## ########### ##",
|
||||
"## ### ########### ##",
|
||||
"## ########################## ##",
|
||||
"## ########################## ##",
|
||||
"## ########################## ##",
|
||||
"## ##",
|
||||
"################################",
|
||||
"################################",
|
||||
"################################"
|
||||
};
|
@@ -58,6 +58,7 @@ WIDGETS_OBJECTS = \
|
||||
$(OBJS)\widgets_slider.obj \
|
||||
$(OBJS)\widgets_spinbtn.obj \
|
||||
$(OBJS)\widgets_static.obj \
|
||||
$(OBJS)\widgets_statbmp.obj \
|
||||
$(OBJS)\widgets_textctrl.obj \
|
||||
$(OBJS)\widgets_toggle.obj \
|
||||
$(OBJS)\widgets_widgets.obj
|
||||
@@ -339,6 +340,9 @@ $(OBJS)\widgets_spinbtn.obj: .\spinbtn.cpp
|
||||
$(OBJS)\widgets_static.obj: .\static.cpp
|
||||
$(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) .\static.cpp
|
||||
|
||||
$(OBJS)\widgets_statbmp.obj: .\statbmp.cpp
|
||||
$(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) .\statbmp.cpp
|
||||
|
||||
$(OBJS)\widgets_textctrl.obj: .\textctrl.cpp
|
||||
$(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) .\textctrl.cpp
|
||||
|
||||
|
@@ -51,6 +51,7 @@ WIDGETS_OBJECTS = \
|
||||
$(OBJS)\widgets_slider.o \
|
||||
$(OBJS)\widgets_spinbtn.o \
|
||||
$(OBJS)\widgets_static.o \
|
||||
$(OBJS)\widgets_statbmp.o \
|
||||
$(OBJS)\widgets_textctrl.o \
|
||||
$(OBJS)\widgets_toggle.o \
|
||||
$(OBJS)\widgets_widgets.o \
|
||||
@@ -332,6 +333,9 @@ $(OBJS)\widgets_spinbtn.o: ./spinbtn.cpp
|
||||
$(OBJS)\widgets_static.o: ./static.cpp
|
||||
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\widgets_statbmp.o: ./statbmp.cpp
|
||||
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\widgets_textctrl.o: ./textctrl.cpp
|
||||
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -80,6 +80,7 @@ WIDGETS_OBJECTS = \
|
||||
widgets_slider.o \
|
||||
widgets_spinbtn.o \
|
||||
widgets_static.o \
|
||||
widgets_statbmp.o \
|
||||
widgets_textctrl.o \
|
||||
widgets_toggle.o \
|
||||
widgets_widgets.o
|
||||
@@ -194,6 +195,9 @@ widgets_spinbtn.o: ./spinbtn.cpp
|
||||
widgets_static.o: ./static.cpp
|
||||
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
widgets_statbmp.o: ./statbmp.cpp
|
||||
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
widgets_textctrl.o: ./textctrl.cpp
|
||||
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -52,6 +52,7 @@ WIDGETS_OBJECTS = \
|
||||
$(OBJS)\widgets_slider.obj \
|
||||
$(OBJS)\widgets_spinbtn.obj \
|
||||
$(OBJS)\widgets_static.obj \
|
||||
$(OBJS)\widgets_statbmp.obj \
|
||||
$(OBJS)\widgets_textctrl.obj \
|
||||
$(OBJS)\widgets_toggle.obj \
|
||||
$(OBJS)\widgets_widgets.obj \
|
||||
@@ -415,6 +416,9 @@ $(OBJS)\widgets_spinbtn.obj: .\spinbtn.cpp
|
||||
$(OBJS)\widgets_static.obj: .\static.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) .\static.cpp
|
||||
|
||||
$(OBJS)\widgets_statbmp.obj: .\statbmp.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) .\statbmp.cpp
|
||||
|
||||
$(OBJS)\widgets_textctrl.obj: .\textctrl.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) .\textctrl.cpp
|
||||
|
||||
|
@@ -265,6 +265,7 @@ WIDGETS_OBJECTS = &
|
||||
$(OBJS)\widgets_slider.obj &
|
||||
$(OBJS)\widgets_spinbtn.obj &
|
||||
$(OBJS)\widgets_static.obj &
|
||||
$(OBJS)\widgets_statbmp.obj &
|
||||
$(OBJS)\widgets_textctrl.obj &
|
||||
$(OBJS)\widgets_toggle.obj &
|
||||
$(OBJS)\widgets_widgets.obj
|
||||
@@ -367,6 +368,9 @@ $(OBJS)\widgets_spinbtn.obj : .AUTODEPEND .\spinbtn.cpp
|
||||
$(OBJS)\widgets_static.obj : .AUTODEPEND .\static.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(WIDGETS_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\widgets_statbmp.obj : .AUTODEPEND .\statbmp.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(WIDGETS_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\widgets_textctrl.obj : .AUTODEPEND .\textctrl.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(WIDGETS_CXXFLAGS) $<
|
||||
|
||||
|
131
samples/widgets/statbmp.cpp
Normal file
131
samples/widgets/statbmp.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Program: wxWidgets Widgets Sample
|
||||
// Name: statbmp.cpp
|
||||
// Purpose: Part of the widgets sample showing wxStaticBitmap
|
||||
// Author: Marcin Wojdyr
|
||||
// Created: 2008-06-19
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 2008 Marcin Wojdyr
|
||||
// License: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// for all others, include the necessary headers
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/log.h"
|
||||
|
||||
#include "wx/button.h"
|
||||
#include "wx/radiobox.h"
|
||||
#include "wx/statbmp.h"
|
||||
#include "wx/statbox.h"
|
||||
#include "wx/textctrl.h"
|
||||
#endif
|
||||
|
||||
#include "wx/generic/statbmpg.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/filepicker.h"
|
||||
|
||||
#include "widgets.h"
|
||||
#include "icons/statbmp.xpm"
|
||||
|
||||
|
||||
class StatBmpWidgetsPage : public WidgetsPage
|
||||
{
|
||||
public:
|
||||
StatBmpWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
|
||||
: WidgetsPage(book, imaglist, statbmp_xpm) {}
|
||||
|
||||
virtual void CreateContent();
|
||||
virtual wxControl *GetWidget() const { return m_statbmp; }
|
||||
virtual void RecreateWidget();
|
||||
|
||||
private:
|
||||
void OnFileChange(wxFileDirPickerEvent &WXUNUSED(ev)) { RecreateWidget(); }
|
||||
void OnRadioChange(wxCommandEvent &WXUNUSED(ev)) { RecreateWidget(); }
|
||||
|
||||
void OnMouseEvent(wxMouseEvent& WXUNUSED(event))
|
||||
{
|
||||
wxLogMessage(wxT("wxStaticBitmap clicked."));
|
||||
}
|
||||
|
||||
wxStaticBitmapBase *m_statbmp;
|
||||
wxFilePickerCtrl *m_filepicker;
|
||||
wxRadioBox *m_radio;
|
||||
wxStaticBoxSizer *m_sbsizer;
|
||||
|
||||
DECLARE_WIDGETS_PAGE(StatBmpWidgetsPage)
|
||||
};
|
||||
|
||||
IMPLEMENT_WIDGETS_PAGE(StatBmpWidgetsPage, wxT("StaticBitmap"),
|
||||
ALL_CTRLS);
|
||||
|
||||
void StatBmpWidgetsPage::CreateContent()
|
||||
{
|
||||
|
||||
static const wxString choices[] = { "native", "generic" };
|
||||
m_radio = new wxRadioBox(this, wxID_ANY, "implementation",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
WXSIZEOF(choices), choices);
|
||||
|
||||
m_filepicker = new wxFilePickerCtrl(this, wxID_ANY, "../image/toucan.png");
|
||||
|
||||
m_sbsizer = new wxStaticBoxSizer(wxVERTICAL, this, "wxStaticBitmap inside");
|
||||
|
||||
wxSizer *leftsizer = new wxBoxSizer(wxVERTICAL);
|
||||
leftsizer->Add(m_radio, wxSizerFlags().Expand().Border());
|
||||
leftsizer->Add(m_filepicker, wxSizerFlags().Expand().Border());
|
||||
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(leftsizer, wxSizerFlags().Border());
|
||||
sizer->Add(m_sbsizer, wxSizerFlags().Center());
|
||||
SetSizer(sizer);
|
||||
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
Connect(wxEVT_COMMAND_FILEPICKER_CHANGED,
|
||||
wxFileDirPickerEventHandler(StatBmpWidgetsPage::OnFileChange));
|
||||
Connect(wxEVT_COMMAND_RADIOBOX_SELECTED,
|
||||
wxCommandEventHandler(StatBmpWidgetsPage::OnRadioChange));
|
||||
|
||||
m_statbmp = NULL;
|
||||
RecreateWidget();
|
||||
}
|
||||
|
||||
void StatBmpWidgetsPage::RecreateWidget()
|
||||
{
|
||||
delete m_statbmp;
|
||||
wxString filepath = m_filepicker->GetPath();
|
||||
wxImage image(filepath);
|
||||
if (! image.Ok() )
|
||||
{
|
||||
wxLogMessage("Reading image from file '%s' failed.", filepath.c_str());
|
||||
m_statbmp = NULL;
|
||||
return;
|
||||
}
|
||||
if (m_radio->GetSelection() == 0)
|
||||
m_statbmp = new wxStaticBitmap(this, wxID_ANY, wxBitmap(image));
|
||||
else
|
||||
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,
|
||||
wxMouseEventHandler(StatBmpWidgetsPage::OnMouseEvent),
|
||||
NULL, this);
|
||||
// When switching from generic to native control on wxMSW under Wine,
|
||||
// the explicit Refresh() is necessary
|
||||
m_statbmp->Refresh();
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@
|
||||
slider.cpp
|
||||
spinbtn.cpp
|
||||
static.cpp
|
||||
statbmp.cpp
|
||||
textctrl.cpp
|
||||
toggle.cpp
|
||||
widgets.cpp
|
||||
|
@@ -344,6 +344,10 @@ SOURCE=.\spinbtn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\statbmp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\static.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -669,6 +669,8 @@
|
||||
RelativePath=".\slider.cpp"/>
|
||||
<File
|
||||
RelativePath=".\spinbtn.cpp"/>
|
||||
<File
|
||||
RelativePath=".\statbmp.cpp"/>
|
||||
<File
|
||||
RelativePath=".\static.cpp"/>
|
||||
<File
|
||||
|
@@ -849,6 +849,9 @@
|
||||
<File
|
||||
RelativePath=".\spinbtn.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\statbmp.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\static.cpp"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user