wxShapeFramework : serialize Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
bcteh
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Nov 27, 2006 9:56 am

wxShapeFramework : serialize

Post by bcteh »

Hi
I am testing for make an query builder by using wxShapeFramework.
Image
Everything work fine. Now face the problem to serialize the list items.

The table and field name , is used "class QBListBox : public wxSFRectShape" to draw it as wxCheckListBox.
Now, I need to serialize the list items (m_items), it store in array of QBlistItem.
How can i make it ?
Thank

Code: Select all

class QBListItem: public wxObject
{
    DECLARE_CLASS(QBListItem)
public:
// Constructors
    QBListItem(const wxString& fieldname, bool check = false)
    { m_fieldname = fieldname; m_check = check; m_selected = false; }
// Accessors
	void SetCheck(bool check) { m_check = check; }
    bool IsCheck() const { return m_check; }
	bool IsSelected() const { return m_selected; }
	void SetSelected(bool select) { m_selected = select;}
	/// Draw the item
    virtual bool Draw(wxDC& dc,const wxRect& rect, int style) ;
    /// Draw the background
    virtual bool DrawBackground(wxDC& dc,const wxRect& rect,int style, int index) ;
	wxString GetText() const { return m_fieldname;}
protected:
	wxString m_fieldname;
	bool m_check;
	bool m_selected;
};
/* 
 * Class : QBListBox
 * 
 */
 WX_DECLARE_OBJARRAY( QBListItem,  QBListItemArray);
 
class QBListBox : public wxSFRectShape
{
public:
	XS_DECLARE_CLONABLE_CLASS(QBListBox);
	QBListBox();
	QBListBox(const wxRealPoint& pos, const wxRealPoint& size, wxSFDiagramManager* manager);
	
	QBListBox(const QBListBox& obj);
	virtual ~QBListBox();
private:
         QBListItemArray    m_items;

};
Jessy V
Earned a small fee
Earned a small fee
Posts: 17
Joined: Sat Feb 18, 2012 9:12 pm

Re: wxShapeFramework : serialize

Post by Jessy V »

Which library are you using for these classes ?
It looks like none of the classes you are talking about is part of wxWidgets...
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: wxShapeFramework : serialize

Post by Auria »

Serialize to what format? In any case I'm not sure I understand what is the question. Simply iterate over the list and serialize each item of the list to your favorite serialization format
"Keyboard not detected. Press F1 to continue"
-- Windows
bcteh
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Nov 27, 2006 9:56 am

Re: wxShapeFramework : serialize

Post by bcteh »

The wxShapeFramework have existing functionality to serialize the Shape properties.
For example:
To serialize the table name:
XS_SERIALIZE_STRING(m_tablename,wxT("tablename");
When i save the diagram, All the properties of the shape is save automatically into xml file.

I would like to use existing framework to save the diagrams into xml file
and open the xml file. The diagrams will draw as previous saved state.

The is a lot of macro to used:
/*! \brief Macro creates new serialized property (type 'string hash map (StringMap)') */
#define XS_SERIALIZE_MAPSTRING(x, name) XS_SERIALIZE_PROPERTY(x, wxT("mapstring"), name);

/*! \brief Macro creates new serialized property encapsulating a dynamic serializable object */
#define XS_SERIALIZE_DYNAMIC_OBJECT(x, name) XS_SERIALIZE_PROPERTY(x, wxT("serializabledynamic"), name);
....
...
#define XS_SERIALIZE_ARRAYINT(x, name) XS_SERIALIZE_PROPERTY(x, wxT("arrayint"), name);

But that is not array of objects. The closely, i can find is the XS_SERIALIZE_DYNAMIC_OBJECT.

XML file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<canvas>
  <settings>
    <object type="wxSFCanvasSettings">
      <property name="id" type="long">-1</property>
      <property name="scale" type="double">1.000000</property>
      <property name="style" type="long">2559</property>
      <property name="accepted_shapes" type="arraystring">
        <item>QBListBox</item>
        <item>wxSFLineShape</item>
        <item>All</item>
      </property>
    </object>
  </settings>
  <chart>
    <object type="QBListBox">
      <property name="id" type="long">1001</property>
      <property name="accepted_connections" type="arraystring">
        <item>QBLineElement</item>
        <item>All</item>
      </property>
      <property name="accepted_src_neighbours" type="arraystring">
        <item>All</item>
      </property>
      <property name="accepted_trg_neighbours" type="arraystring">
        <item>All</item>
      </property>
      <property name="relative_position" type="realpoint">130.000000,80.000000</property>
      <property name="size" type="realpoint">138.000000,89.000000</property>
    </object>
wxShapeFramework is not a standard wxWidget framework.
http://sourceforge.net/projects/wxsf/

Solve: refer to wxXmlSerializer document
Thank
Post Reply