예제 #1
0
Packet_v1::Packet_v1(field_t componentId, field_t requestId)
  :Packet()
{
  setProtoVersion(PROTOV1);
  setLen(PROTOV1_START_OF_DATA);
  setComponentId(componentId);
  setRequestId(requestId);
}
//==============================================================================
int64 ComponentTypeHandler::getComponentId (Component* comp)
{
    if (comp == 0)
        return 0;

    int64 compId = comp->getProperties() ["jucerCompId"].toString().getHexValue64();

    if (compId == 0)
    {
        compId = Random::getSystemRandom().nextInt64();
        setComponentId (comp, compId);
    }

    return compId;
}
bool ComponentTypeHandler::restoreFromXml (const XmlElement& xml,
        Component* comp,
        const ComponentLayout* layout)
{
    jassert (xml.hasTagName (getXmlTagName()));

    if (! xml.hasTagName (getXmlTagName()))
        return false;

    comp->setName (xml.getStringAttribute ("name", comp->getName()));
    setComponentId (comp, xml.getStringAttribute ("id").getHexValue64());
    comp->getProperties().set ("memberName", xml.getStringAttribute ("memberName"));
    comp->getProperties().set ("virtualName", xml.getStringAttribute ("virtualName"));
    comp->setExplicitFocusOrder (xml.getIntAttribute ("explicitFocusOrder"));

    RelativePositionedRectangle currentPos (getComponentPosition (comp));
    currentPos.updateFromComponent (*comp, layout);

    RelativePositionedRectangle rpr;
    rpr.restoreFromXml (xml, currentPos);

    jassert (layout != 0);
    setComponentPosition (comp, rpr, layout);

    SettableTooltipClient* const ttc = dynamic_cast <SettableTooltipClient*> (comp);
    if (ttc != 0)
        ttc->setTooltip (xml.getStringAttribute ("tooltip"));

    for (int i = 0; i < colours.size(); ++i)
    {
        const String col (xml.getStringAttribute (colours[i]->xmlTagName, String::empty));

        if (col.isNotEmpty())
        {
            comp->setColour (colours[i]->colourId,
                             Colour (col.getHexValue32()));
        }
    }

    return true;
}