I'm writing a new component : a checkbox list into a combo box, based on wxOwnerDrawnComboBox.
It will be used into personnal log windows that able to select or unselect TraceMasks listed into this combobox.
The initialisation of this special combo looks like :
// Init mask choice
wxArrayString arrAllTraceMasks = wxLog::GetTraceMasks();
for (size_t stBlc=0;stBlc<arrAllTraceMasks.GetCount();++stBlc)
{
m_pChoiceMask->Append(arrAllTraceMasks[stBlc],true,(void *) stBlc);
}
It's not very easy to make this combo work with wxSmith because I must create wxETKCheckBoxListComboBoxXmlHandler to be able to correctly create the component.
This is working right now (the OnDrawItem / OnDrawBackground functions are not done but it is simple to do it). To be able to let user initialize items list directly into wxSmith interface, I thought I could use the Xml Data field into wxSmith and decode it into my combo handler.
Unfortunally the Xml Data is not save, I wrote <item>Label1</item> into it, save all, qui Code::Blocks and reopen : this field is empty. Editing wxs and xrc with text editor : no Label1 is written.
My question : What this field (Xml Data) is doing for ? How to be able to write some specific data into xrc file to fill content of custom components ?
I give you my source code (not yet finished) that can help some peaple like me to create custom component that are not supported by wxSmith.
The source code is too big, cannot post here, I let a link to be able to download the zip with header and source code :
Source code wxETKCheckBoxListComboBox (http://ti1ca.com/Album-wxETKCheckBoxListComboBox-n7m1gcxj)
(http://mk1.ti1ca.com/n7m1gcxj.jpg) (http://ti1ca.com/n7m1gcxj-wxETKCheckBoxListComboBox-wxETKCheckBoxListComboBox.zip.html) (http://mk5.ti1ca.com/7b5avtr.jpg) (http://ti1ca.com/7b5avtr-wxETKCheckBoxListComboBox-wxETKCheckBoxListComboBox.cpp.html) (http://mk6.ti1ca.com/tgaqchpu.jpg) (http://ti1ca.com/tgaqchpu-wxETKCheckBoxListComboBox-wxETKCheckBoxListComboBox.h.html)
If someone is interested I'll could post the finished component when it'll be done.
I Hope I post in the good forum because it's not really a specific wxWidgets problem (so I don't post on wxWidgets forum) and it's wxSmith problem, there is no specific topic for wxSmith (really very cool component of Code::Blocs)
Best regards,
Stéphane Château
This file is only to set define EXPORT_IMPORT to be able to export / import (dll mode) on nothing (static mode).
You can remove it and define EXPORT_IMPORT with nothing.
This source code is extracted from personnal dll.
To make it work, don't forget to add :
// Add XmlResource Handler to be able to load wxETKCheckBoxListComboBox as custom control
// into xrc file
wxXmlResource::Get()->AddHandler(new wxETKCheckBoxListComboBoxXmlHandler());
to be able to read custom objet as checkbox list combo.
Don't catch select notification for this control, it ha no sens, but catch new one :
BEGIN_EVENT_TABLE(MyPanell,wxPanel)
//(*EventTable(MyPanel)
//*)
// Mask selection has changed
EVT_COMBOBOX_CHECKED(wxID_ANY,MyPanel::OnMaskCheckBoxChanged)
END_EVENT_TABLE()
void MyPanel::OnMaskCheckBoxChanged(wxCommandEvent& _rEvent)
{
if (m_pCheckBoxListComboBox->GetItemCheck((int) _rEvent.GetClientData()))
{ // Just checked
// Add you own code here
}
else
{ // Just unchecked
// Add you own code here
}
}
You can modify message and appearance (ombo or wxchoice)
m_pCheckBoxListComboBox->SetwxChoiceAppearance(true); // <-- wxChoice appearance
m_pChoiceMask->SetComboMessage(_("My message I want to display..."));
Left bug to fix : clipping text to don't write on arrow
manage disable state
add tooltip to show selected elements