In the file:
\src\plugins\contrib\wxSmith\wxwidgets\defitems\wxsimage.h
I see it has some code snippet:
/*! \brief Class for the wxsImage tool.
* \note For reasons unknown, GCC emits a warning that the image is declared but not used when "Use Include File" is set.
*/
class wxsImage : public wxsTool
{
public:
wxsImage(wxsItemResData* Data);
wxBitmap GetPreview(void);
void DoBuild(void);
So, it report the GCC will report a warning. I also see this build warning of the generated code.
But what I see is that the generated code has some issues:
1, I first add a wxImage tool by click the wxImage toolbar button in the wxSmith Tools panel. (see below image)
2, then I add an image by select an png file in the wxImage's property list, also I have select the image from disk (see image below)
3, select the "Image1" in the wxImagePanel control, see image below:
4, then I build the project, I see such warning:
-------------- Build: Debug in test-wxImagePanel (compiler: GNU GCC Compiler)---------------
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -DTEST -IE:\wxWidgets-3.1.1-rc\include -IE:\wxWidgets-3.1.1-rc\lib\gcc_dll\mswu -c E:\code\test-wxImagePanel\test_wxImagePanelApp.cpp -o obj\Debug\test_wxImagePanelApp.o
In file included from E:\code\test-wxImagePanel\test_wxImagePanelMain.h:14:0,
from E:\code\test-wxImagePanel\test_wxImagePanelApp.cpp:14:
E:/code/test-wxImagePanel/wximages/test_wxImagePanelMain_Image1_XPM.xpm:1:20: warning: 'Image1_XPM' defined but not used [-Wunused-variable]
static const char *Image1_XPM[] = {
^~~~~~~~~~
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -DTEST -IE:\wxWidgets-3.1.1-rc\include -IE:\wxWidgets-3.1.1-rc\lib\gcc_dll\mswu -c E:\code\test-wxImagePanel\test_wxImagePanelMain.cpp -o obj\Debug\test_wxImagePanelMain.o
g++.exe -LE:\wxWidgets-3.1.1-rc\lib\gcc_dll -o bin\Debug\test-wxImagePanel.exe obj\Debug\test_wxImagePanelApp.o obj\Debug\test_wxImagePanelMain.o obj\Debug\wximagepanel.o obj\Debug\resource.res -mthreads -lwxmsw31u -mwindows
Output file is bin\Debug\test-wxImagePanel.exe with size 1.28 MB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 1 warning(s) (0 minute(s), 2 second(s))
I see the variable is used in such generated code:
test_wxImagePanelFrame::test_wxImagePanelFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(test_wxImagePanelFrame)
...
Image1 = new wxImage(Image1_XPM);
Image1_BMP = new wxBitmap(Image1_XPM);
// Set the bitmap for ImagePanel1.
ImagePanel1->SetBitmap(*Image1_BMP);
...
//*)
}
But as you can see, "Image1_XPM" is used here. But I don't see Image1 is used in some place.
Question: does GCC deduced that Image1_XPM is not used?Image1 = new wxImage(Image1_XPM);
If you look at the wxs file, you will see some code snippet:
<object class="wxImage" variable="Image1" member="yes">
<image>
<Item>static const char *xpm_data[] = {</Item>
<Item>"225 225 48 1",</Item>
<Item>", c #FFD6D6",</Item>
<Item>"x c #FF2E2E",</Item>
<Item>"$ c #FF9B9B",</Item>
<Item>"O c #FFD0D0",</Item>
<Item>"& c #FF9595",</Item>
<Item>"9 c #FF5A5A",</Item>
<Item>"_ c #FFFFFF",</Item>
<Item>"* c #FF8F8F",</Item>
<Item>"< c #FF8C8C",</Item>
<Item>"l c #FFC1C1",</Item>
<Item>". c #FFF6F6",</Item>
<Item>"X c #FFF0F0",</Item>
......
......
Look, the whole image data was saved in the wxs file(the wxs file has thousands of lines), which make the wxs file hard to read and maintain.
My question is: can we simply save the file path like <image>red-car.png</image> here? From reading the source code(mainly the \src\plugins\contrib\wxSmith\wxwidgets\defitems\wxsimage.h and \src\plugins\contrib\wxSmith\wxwidgets\defitems\wxsimage.cpp, I don't see that "wxImage tool" support such data persistence.