I inserted the custom control. But instead of setting the "Class name" property to wxStaticBitmap I set it to wxGenericStaticBitmap as the use of this class is the reason for the custom control. The "Var name" property was set to img_Schem_Cascode_Boost, and the Identifier property was set to ID_IMG_SCHEM_CASCODE_BOOST.
In the Code::Blocks generated code the compiler indicated an error line 91:
TIAFrame::TIAFrame(wxWindow* parent,wxWindowID id)
{
...
img_Schem_Cascode_Boost = new wxGenericStaticBitmap(Panel1,ID_IMG_SCHEM_CASCODE_BOOST,wxPoint(0,0),wxDefaultSize,0,wxDefaultValidator,_T("ID_IMG_SCHEM_CASCODE_BOOST")); // Line 91
...
}
The errors:
||=== Build: Debug in TIA (compiler: GNU GCC Compiler) ===|
C:\Engineering Software\TIA\TIAMain.cpp||In constructor 'TIAFrame::TIAFrame(wxWindow*, wxWindowID)':|
C:\Engineering Software\TIA\TIAMain.cpp|91|error: no matching function for call to 'wxGenericStaticBitmap::wxGenericStaticBitmap(wxPanel*&, const long int&, wxPoint, const wxSize&, int, const wxValidator&, const wchar_t [27])'|
C:\Engineering Software\TIA\TIAMain.cpp|91|note: candidates are:|
C:\wxWidgets-3.0.3\include\wx\generic\statbmpg.h|19|note: wxGenericStaticBitmap::wxGenericStaticBitmap(wxWindow*, wxWindowID, const wxBitmap&, const wxPoint&, const wxSize&, long int, const wxString&)|
C:\wxWidgets-3.0.3\include\wx\generic\statbmpg.h|19|note: no known conversion for argument 3 from 'wxPoint' to 'const wxBitmap&'|
C:\wxWidgets-3.0.3\include\wx\generic\statbmpg.h|18|note: wxGenericStaticBitmap::wxGenericStaticBitmap()|
C:\wxWidgets-3.0.3\include\wx\generic\statbmpg.h|18|note: candidate expects 0 arguments, 7 provided|
C:\wxWidgets-3.0.3\include\wx\generic\statbmpg.h|15|note: wxGenericStaticBitmap::wxGenericStaticBitmap(const wxGenericStaticBitmap&)|
C:\wxWidgets-3.0.3\include\wx\generic\statbmpg.h|15|note: candidate expects 1 argument, 7 provided|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Missing in the Code::Blocks created constructor call in that line 91's instantiation is a parameter of type wxBitmap. Is this a bug in Code::Blocks? What can be done get this working?
I know how to create a wxBitmap type object and I have written the code to create it to pass to wxGenericStaticBitmap::SetBitmap() .
It appears that in my circumstance default "Creating code" property for the custom element cannot be counted on to be correct. I changed this element to the string:
$(THIS) = new $(CLASS)($(PARENT),$(ID),SchematicCascodeBoostBitmap,$(POS),$(SIZE),$(STYLE),$(NAME));
Then I defined and insantiated SchematicCascodeBoostBitmap in the constructor as shown in this excerpt:
TIAFrame::TIAFrame(wxWindow* parent,wxWindowID id)
{
const wxString Filename("Images//TIA Cascode & Bootstrap cropped.sch.png");
const wxBitmap SchematicCascodeBoostBitmap( Filename, wxBITMAP_TYPE_PNG );
//(*Initialize(TIAFrame)
...
img_Schem_Cascode_Boost = new wxGenericStaticBitmap(Panel1,ID_IMG_SCHEM_CASCODE_BOOST,SchematicCascodeBoostBitmap,wxPoint(0,0),wxDefaultSize,,_T("ID_IMG_SCHEM_CASCODE_BOOST"));
...
//*)
}
The code compiles but the image does not show in the sizer. I know I have defined and instantiated SchematicCascodeBoostBitmap correctly because before I used the Custom element I used SchematicCascodeBoostBitma to add the image in the form in code I created outside of what Code::Blocks creates. I used the code automatically generated code as an example. The image displayed, but not inside the sizer.
What is missing here regarding the use of the Custom element?
as you have found out, the "generic" control is generic. It uses the most common constructor of window classes in wxWidgets but they do not fit all needs.
The code compiles but the image does not show in the sizer
From here on it is no codeblocks problem anymore, and you will need to search for help in a wx forum. We can not support this kind of questions.
const wxString Filename("Images//TIA Cascode & Bootstrap cropped.sch.png");
const wxBitmap SchematicCascodeBoostBitmap( Filename, wxBITMAP_TYPE_PNG );
you do not make any sanity check if the bitmap is loaded. This seems to be a bad idea for me. Here it can fail.
You can try to debug...
The image displayed, but not inside the sizer
So the image gets displayed but is not inside the sizer, or does not scale properly? Have you checked if the generated code is correct? Is the custom control added to your sizer? Have you set the expand flag? This is all wild guessing without code, image or video...
you have completrly messed up your project file...
Do you have moved and or renamed source files?
wxSmith can not find the source and header files it has to work with. To fix this open the TIADesigner.cbp file with a text editor (notepad++ for example). Search for the part
<wxsmith version="1">
<gui name="wxWidgets" src="TIAApp.cpp" main="TIAFrame" init_handlers="necessary" language="CPP" />
<resources>
<wxFrame wxs="wxsmith/TIAframe.wxs" src="TIAMain.cpp" hdr="TIAMain.h" fwddecl="0" i18n="1" name="TIAFrame" language="CPP" />
</resources>
</wxsmith>
here you have to set all src and hdr attributes to valid source files. The attributes in the gui node is you application and the attributes in the wxFrame node is your frame. Save the file and open it in codeblocks. Add a button to the frame and remove it again, so that the code gets re generated...