table serialization

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1132 dfc29bdd-3216-0410-991c-e03cc46cb475
master
bitplane 2007-12-23 02:48:02 +00:00
parent 3bba1695e6
commit 0dffdd46a6
4 changed files with 78 additions and 9 deletions

View File

@ -27,7 +27,7 @@ Changes in version 1.5 (... 2008)
Nodes are now solid or transparent. ( but still more states are needed )
- GUI:
Finally added table control and TabControl additions from StarSonata team.
Finally added StarSonata/Acki patch with table element and TabControl additions.
-------------------------------------------

View File

@ -55,10 +55,10 @@ namespace gui
//! Returns the ordering used by the currently active column
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;
//! set a column width
//! Set the width of a column
virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
//! This tells the table control wether is should send a EGET_TABLE_HEADER_CHANGED message or not when
//! This tells the table control whether is should send a EGET_TABLE_HEADER_CHANGED message or not when
//! a column header is clicked. If set to false, the table control will use a default alphabetical ordering scheme.
/** \param columnIndex: The index of the column header.
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/

View File

@ -39,14 +39,15 @@ CGUITable::CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
IGUISkin* skin = Environment->getSkin();
s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
ScrollBar = new CGUIScrollBar(false, Environment, this, -1,
ScrollBar = Environment->addScrollBar(false,
core::rect<s32>(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()),
!clip);
this, -1);
if (ScrollBar)
{
ScrollBar->setPos(0);
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
ScrollBar->setNotClipped(clip);
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
ScrollBar->setSubElement(true);
ScrollBar->grab();
}
@ -304,12 +305,11 @@ bool CGUITable::OnEvent(const SEvent& event)
return true;
}
break;
/*case gui::EGET_ELEMENT_FOCUS_LOST:
case gui::EGET_ELEMENT_FOCUS_LOST:
{
Selecting = false;
return true;
}
break;*/
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
@ -710,6 +710,64 @@ void CGUITable::breakText(core::stringw &text, u32 cellWidth )
text = line;
}
//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
void CGUITable::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
IGUIElement::serializeAttributes(out, options);
core::stringc tmp, tmp2;
out->addInt("Columns", Columns.size());
for (u32 i=0; i < Columns.size(); ++i)
{
tmp = "Column"; tmp += i; tmp += ".";
tmp2 = tmp + "Name";
out->addString(tmp2.c_str(), Columns[i].name.c_str());
tmp2 = tmp + "Width";
out->addInt(tmp2.c_str(), Columns[i].width);
tmp2 = tmp + "CustomOrdering";
out->addBool(tmp2.c_str(), Columns[i].useCustomOrdering);
}
}
//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
void CGUITable::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{
// clear everything
clear();
IGUIElement::deserializeAttributes(in , options);
// add columns
core::stringc tmp, tmp2;
u32 count = in->getAttributeAsInt("Columns");
for (u32 i=0; i < count; ++i)
{
tmp = "Column"; tmp += i; tmp += ".";
tmp2 = tmp + "Name";
addColumn(in->getAttributeAsStringW(tmp2.c_str()).c_str());
tmp2 = tmp + "Width";
setColumnWidth(i, in->getAttributeAsInt(tmp2.c_str()));
tmp2 = tmp + "CustomOrdering";
setColumnCustomOrdering(i, in->getAttributeAsBool(tmp2.c_str()));
}
}
} // end namespace gui
} // end namespace irr

View File

@ -117,6 +117,17 @@ namespace gui
//! draws the element and its children
virtual void draw();
//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
private:
struct Cell