Author Topic: wxSmith : creating wxOwnerDrawnComboBox as Custom  (Read 9403 times)

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
wxSmith : creating wxOwnerDrawnComboBox as Custom
« on: May 28, 2011, 03:39:50 pm »
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 :
Code
    // 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




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
« Last Edit: May 28, 2011, 07:51:58 pm by Feneck91 »

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
Re: wxSmith : creating wxOwnerDrawnComboBox as Custom
« Reply #1 on: May 30, 2011, 12:17:37 am »
I almost finished the control. It can be useful to understand how to make work wxSmith with custom control.
2 display modes : wxComboBox and wxChoice. Display list of check box when opening the combo. Sending new notification so the use is able to know when a check box is modified.
It let : adding tooltip to display list of selected items.
Fill content and/or property by filling xml data (if possible).

Last source code :


Source code wxETKCheckBoxListComboBox



Always waiting answers to my questions... seems to be complex ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxSmith : creating wxOwnerDrawnComboBox as Custom
« Reply #2 on: May 30, 2011, 05:47:19 am »
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 didn't have a deeper look into, but you can see how we handled the XRC stuff in the wxScrolledDialog that was added recently to wxSmith.

Ant btw: You sample won't compile as at least one file (wxETKTypes.h) is missing.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
Re: wxSmith : creating wxOwnerDrawnComboBox as Custom
« Reply #3 on: May 30, 2011, 06:44:10 am »
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 :
Code
    // 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 :
Code
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)
Code
    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
« Last Edit: May 30, 2011, 06:56:54 am by Feneck91 »

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
Re: wxSmith : creating wxOwnerDrawnComboBox as Custom
« Reply #4 on: May 31, 2011, 07:31:56 pm »
I have post my component in wxWidgets forum if it can help some peaple. I upload the last version of this component on the wxWidgets topic here
More explanation about how to use it, screenshot and some initialisation source code.

No reply with this Xml Code not working...
Quote
I didn't have a deeper look into, but you can see how we handled the XRC stuff in the wxScrolledDialog that was added recently to wxSmith.
I don't want to make a plugin into Code::Blocks to support my component but only use the Custom component of wxSmith and use the Xml Data to be able to add elements into combo directly into the wxSmitch GUI.