Ejemplo n.º 1
0
bool GUI::removeComponent (string name)
{
    Component *toDelete = searchByName (name, this->root);
    if (toDelete)
    {
        Component *temp = toDelete->getParent();
        for (unsigned int i = 0; i < temp->getChildren().size(); i++)
        {
            if (temp->getChildren()[i] == toDelete)
            {
                temp->getChildren().erase(temp->getChildren().begin() + i);
                subtractArea (temp, toDelete->getAreaUsage());
                return true;
            }
        }
    }
    else
    {
        return false;
    }
}
Ejemplo n.º 2
0
int main(int argc, const char *argv[])
{
    Component* cpn = new Composite();
    cpn->add(new Leaf1);
    cpn->add(new Leaf2);

    Component* c = new Composite();
    c->add(new Leaf2);
    c->add(new Leaf2);

    cpn->add(c);
    cpn->draw();
    return 0;
}
Ejemplo n.º 3
0
void pokeLoc(Layer& layer, int l, int x, int y, bool charge, char dir)
{
    Component* c = &layer.get(l)->get(x, y);
    if (c->getID() == "WIRE")
        invokeWire(layer, l, x, y, charge);
    else if (c->getID() == "LIGHT")
        invokeLight(layer, l, x, y, charge);
    else if (c->getID() == "VERT")
        invokeVert(layer, l, x, y, charge);
    else if (c->getID() == "NOT" && dir == 'l')
        invokeNot(layer, l, x, y, charge);
    else if ((dir == 'd' || dir == 'u') && isGate(c->getID()))
        invokeGate(layer, l, x, y, charge, dir);
}
Ejemplo n.º 4
0
string ERModel::searchForeignKey( int foreignKeyEntityID )
{
	Component* foreignKeyEntity = searchComponent(foreignKeyEntityID);
	vector<Component*> attributeSet = searchSpecificTypeComponentSet(PARAMETER_ATTRIBUTE, foreignKeyEntity->getConnections());
	string isFKString;

	for(int i = 0; i < attributeSet.size(); i++)
	{
		if (static_cast<NodeAttribute*>(attributeSet[i])->getIsPrimaryKey())
			isFKString += attributeSet[i]->getText() + TEXT_COMMASPACE;
	}

	// 刪除最後一個", "並將格式放入string中
	if (isFKString != PARAMETER_NULL)
	{
		isFKString = isFKString.substr(PARAMETER_STRINGBEGIN, isFKString.size() - PARAMETER_ADJUSTSTRINGSIZE);
		isFKString = TEXT_GETERDIAGRAM_FK + isFKString + TEXT_GETERDIAGRAM_ENDKEY;
	}
	return isFKString;
}
Ejemplo n.º 5
0
void ASI::RemoveFromLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if (pComponent->m_pData->inLayout &&
                    IsParent(pLayoutComponent, pComponent))
                {
                    /*
                     * Tell the layout component to remove
                     * the item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 2, dref, true);

                    DisconnectFromReceiver(pLayoutComponent, emitter, cref);
                    DisconnectFromReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout);

                    pComponent->m_pData->inLayout = false;

                    CRef invalidCRef;
                    pComponent->SetParent(invalidCRef);
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
Ejemplo n.º 6
0
static void createFileCreationOptionComboBox (Component& setupComp,
                                              OwnedArray<Component>& itemsCreated,
                                              const char** types)
{
    ComboBox* c = new ComboBox();
    itemsCreated.add (c);
    setupComp.addChildAndSetID (c, "filesToCreate");

    const char* fileOptions[] = { "Create a Main.cpp file",
                                  "Create a Main.cpp file and a basic window",
                                  "Don't create any files", 0 };

    c->addItemList (StringArray (fileOptions), 1);
    c->setSelectedId (1, false);

    Label* l = new Label (String::empty, "Files to Auto-Generate:");
    l->attachToComponent (c, true);
    itemsCreated.add (l);

    c->setBounds ("parent.width / 2 + 160, 10, parent.width - 10, top + 22");
}
Ejemplo n.º 7
0
void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bool /*wasResized*/)
{
    const Font f (getLookAndFeel().getLabelFont (*this));

    if (leftOfOwnerComp)
    {
        setSize (jmin (f.getStringWidth (textValue.toString()) + 8, component.getX()),
                 component.getHeight());

        setTopRightPosition (component.getX(), component.getY());
    }
    else
    {
        setSize (component.getWidth(),
                 8 + roundToInt (f.getHeight()));

        setTopLeftPosition (component.getX(), component.getY() - getHeight());
    }
}
Ejemplo n.º 8
0
Node* Node::CloneRecursive(Node* parent, SceneResolver& resolver, CreateMode mode)
{
    // Create clone node
    Node* cloneNode = parent->CreateChild(0, (mode == REPLICATED && id_ < FIRST_LOCAL_ID) ? REPLICATED : LOCAL);
    resolver.AddNode(id_, cloneNode);

    // Copy attributes
    unsigned numAttributes = GetNumAttributes();
    for (unsigned j = 0; j < numAttributes; ++j)
        cloneNode->SetAttribute(j, GetAttribute(j));

    // Clone components
    for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
    {
        Component* component = *i;
        Component* cloneComponent = cloneNode->CreateComponent(component->GetType(), (mode == REPLICATED && component->GetID() <
            FIRST_LOCAL_ID) ? REPLICATED : LOCAL);
        if (!cloneComponent)
        {
            LOGERROR("Could not clone component " + component->GetTypeName());
            continue;
        }
        resolver.AddComponent(component->GetID(), cloneComponent);

        numAttributes = component->GetNumAttributes();
        for (unsigned j = 0; j < numAttributes; ++j)
            cloneComponent->SetAttribute(j, component->GetAttribute(j));
    }

    // Clone child nodes recursively
    for (Vector<SharedPtr<Node> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
    {
        Node* node = *i;
        node->CloneRecursive(cloneNode, resolver, mode);
    }

    return cloneNode;
}
Ejemplo n.º 9
0
void ASI::AddToLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if ((!pComponent->m_pData->inLayout) &&
                    (pComponent != pLayoutComponent))
                {
                    pComponent->SetParent(layout);

                    /*
                     * Tell the layout component to add
                     * a new item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 1, dref, true);

                    ConnectToReceiver(pLayoutComponent, emitter, cref, BOI_STD_R(SetPosition));
                    ConnectToReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout, receiver);

                    pComponent->m_pData->inLayout = true;
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
bool CompositionObj::hasChild(Component child)
{
    std::cout << this->getName() << "<->" << child->getName() << std::endl;
    Component c = child;
//    auto spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c);
    //while ((std::shared_ptr<SpecializedComponentObjBase> spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c)) && spec.get()) {
    SpecializedComponentBase spec;

    //TODO try this
    //for(auto spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c); spec.get(); c=spec->getOrginal());
    while ((spec = std::dynamic_pointer_cast<SpecializedComponentObjBase>(c)) && spec.get()) {
        c = spec->getOrginal();
    }

    for (auto ch : getChildren()) {
        std::cout << "\t Child: " << ch.second->getName() << std::endl;
        if (ch.second == c || (ch.second == child)) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 11
0
        bool call_optional_or_variant(Component const& component, mpl::true_) const
        {
            // If Attribute is an optional, then create an attribute for the Component
            // with the type optional::value_type. If the expected attribute is unused type,
            // use it instead.
            typedef typename
                traits::attribute_of<Component, Context, Iterator>::type
            expected_type;

            typename mpl::if_<
                is_same<expected_type, unused_type>,
                unused_type,
                typename Attribute::value_type>::type
            val;

            if (component.parse(first, last, context, skipper, val))
            {
                traits::assign_to(val, attr);
                return true;
            }
            return false;
        }
Ejemplo n.º 12
0
bool DataModel::addComponent(QString _id, QString _name, double _value, QString _unit, QString _des) {
    if(!isLoad) {
        logger.reportError(tr("Attempt to modify before load"));
        return false;
    }

    if(checkComponentId(_id)+1) {
        logger.reportError(tr("Component Id ")+_id+tr(" has existed"));
        return false;
    }
    Component *c = new Component();
    c->setId(_id); c->setName(_name); c->setValue(_value); c->setUnit(_unit); c->setDescription(_des);
    dat->addComponent(c);

    isModified = true;
    return true;
}
Ejemplo n.º 13
0
int  FormSegmentator::neighbourPos(const SquarePos &pos, int diagramNum) const
{
	int num = -1;
	for (int i = 0; i < mAllComponents.size(); i ++) {
		Component diagram = mAllComponents.at(i);
		if ((i != diagramNum && (num >= 0 &&
								 (pos.dist(diagram.at(0)) <= neighbourhoodRad ||
								  pos.dist(diagram.back()) <= neighbourhoodRad))) ||
				(pos.dist(diagram.at(0)) <= neighbourhoodRad &&
				 pos.dist(diagram.back()) <= neighbourhoodRad))
		{
			return -1;
		}
		if (diagramNum != i && (pos.dist(diagram.at(0)) <= neighbourhoodRad ||
								pos.dist(diagram.back()) <= neighbourhoodRad))
		{
			num = i;
		}
	}
	return num;
}
 ConfiguredComponent(Component underlaying_component, std::map<std::string, Gecode::FloatVar> f, std::map<std::string, Gecode::BoolVar> b, std::map<std::string, Gecode::IntVar> i,
                     std::map<std::string, Gecode::IntVar> s, std::shared_ptr<std::map<std::string, int>> sh)
     : underlaying_name(underlaying_component->getName())
 {
     component = underlaying_component;
     // std::cout << "Debug for " << underlaying_component->getName() << std::endl;
     // string_name << component->toString() << std::endl;
     for (auto j : i) {
         // std::cout << "\t-" << j.first << j.second << std::endl;
         int_config.push_back(Config<int>{j.second.min(), j.second.max(), j.first});
     }
     for (auto j : f) {
         double_config.push_back(Config<double>{j.second.min(), j.second.max(), j.first});
     }
     for (auto j : b) {
         bool_config.push_back(Config<bool>{(bool)j.second.min(), (bool)j.second.max(), j.first});
     }
     for (auto e : s) {
         std::string config_value = "ERR (FATAL)";
         bool valid = false;
         if (e.second.assigned()) {
             auto id = e.second.val();
             for (auto v : *sh) {
                 if (v.second == id) {
                     config_value = v.first;
                     valid = true;
                     break;
                 }
             }
         } else {
             valid = true;
             config_value = "<unassigned>";
         }
         assert(valid);
         string_config.push_back({e.first, config_value});
     }
 }
Ejemplo n.º 15
0
TEST(EntityTests, OverridesDuplicateSpatials) {
    Entity entity;

    Component* componentA = new Component();
    componentA->setAttr("type", "spatial");
    componentA->setAttr("x", 1);
    entity.addComponent(componentA);

    Component* componentB = new Component();
    componentB->setAttr("type", "spatial");
    componentB->setAttr("x", 2);
    entity.addComponent(componentB);

    entity.prefabOverride();

    ASSERT_EQ(entity.components().count(), 1);
    ASSERT_EQ(entity.components().first()->attr("x").intValue(), 1);
}
Ejemplo n.º 16
0
int main()
{
	// 创建一个树形结构
	// 创建根节点
	Component *pRoot = new Composite("江湖公司(任我行)");

	// 创建分支
	Component *pDepart1 = new Composite("日月神教(东方不败)");
	pDepart1->Add(new Leaf("光明左使(向问天)"));
	pDepart1->Add(new Leaf("光明右使(曲洋)"));
	pRoot->Add(pDepart1);

	Component *pDepart2 = new Composite("五岳剑派(左冷蝉)");
	pDepart2->Add(new Leaf("嵩山(左冷蝉)"));
	pDepart2->Add(new Leaf("衡山(莫大)"));
	pDepart2->Add(new Leaf("华山(岳不群)"));
	pDepart2->Add(new Leaf("泰山(天门道长)"));
	pDepart2->Add(new Leaf("恒山(定闲师太)"));
	pRoot->Add(pDepart2);

	// 添加和删除叶子
	pRoot->Add(new Leaf("少林(方证大师)"));
	pRoot->Add(new Leaf("武当(冲虚道长)"));
	Component *pLeaf = new Leaf("青城(余沧海)");
	pRoot->Add(pLeaf);

	// 小丑,直接裁掉
	pRoot->Remove(pLeaf);

	// 递归地显示组织架构
	pRoot->Operation(1);

	// 删除分配的内存
	SAFE_DELETE(pRoot);

	getchar();

	return 0;
}
Ejemplo n.º 17
0
void ContactListener::registerHit(b2Fixture* source, b2Fixture* target, b2Contact* contact) {
  // things like the floor are int he physics world but arent entities so dont have components or labels
  int sourceLabel = -1;

  if (source->GetBody()->GetUserData()) {
    Component* sourceSpatial = (Component*)source->GetBody()->GetUserData();
    sourceLabel = sourceSpatial->label();
  }
  
  int targetLabel = -1;
  String targetMaterial;
  
  if (target->GetBody()->GetUserData()) {
    Component* targetSpatial = (Component*)target->GetBody()->GetUserData();
    
    Component* targetPhysical = level_->component("physical", targetSpatial->label());
    targetMaterial = targetPhysical->attr("material").string();
    targetLabel = targetSpatial->label();
  }
  
  eventSystem_->postEvent("collision", sourceLabel, targetLabel, targetMaterial);
}
Ejemplo n.º 18
0
 // Please note that this function might be executed from ANY thread context, which is
 // most likely not the same as used by the application thus appropriate mechanisms to ensure
 // correct execution must be implemented by an application(e.g. GUI applications might send an
 // event to the main thread instead of directly accessing GUI elements).
 virtual void execute( Component& c, void* pUserData )
 {
     // get access to the user data previously associated with the component that just executes the callback
     RecordStack* pRecordStack = reinterpret_cast<RecordStack*>( pUserData );
     // do some work with the user data object
     const RecordStack::size_type recordCount = pRecordStack->size();
     cout << "Component '" << c.name() << "' did just cause a callback. It's the " << ++hitCount_ << " time this function got called." << endl
          << "This callback carries " << recordCount << " good old vinyl records with it." << endl;
     RecordStack::const_iterator it = pRecordStack->begin();
     const RecordStack::const_iterator itEND = pRecordStack->end();
     unsigned int i = 0;
     while( it != itEND )
     {
         cout << "  There is a record called '" << ( *it )->getAlbum() << "'";
         if( hitCount_ % recordCount == i )
         {
             cout << ", which I will play now";
             ( *it )->play();
         }
         cout << endl;
         ++it;
         ++i;
     }
 }
Ejemplo n.º 19
0
void DataModel::updateComponents() {
    if(!isLoad) {
        logger.reportWarning(tr("Attempt to show data before load"));
        return;
    }

    components.cleanAll();
    components.setHeader(QString("Id,Name,Value,Unit,Description").split(','));
    for(int i=0;i<dat->componentsLength();i++) {
        Component *c = dat->componentsAt(i);
        QStringList r;
        r.append(c->Id());
        r.append(c->Name());
        r.append(QString::number(c->Value()));
        r.append(c->Unit());
        r.append(c->Description());
        components.addRow(r);
    }
}
Ejemplo n.º 20
0
void Select::redo()
{
	if (!Move)
	{
		Component * pC = pManager->GetComponent(GFXInfo.x1, GFXInfo.y1);
		if (!pC->isSelected())
			pManager->HighlightComponent(pC);
		else
			pManager->UnhighlightComponent(pC);
	}
	else {
		for (unsigned int i = 0; i < InitialPositions.size(); i++)
		{
			Component* pG = pManager->GetComponent(InitialPositions[i].first.x1, InitialPositions[i].first.y1);
			pG->EraseComponent(pManager);
			pG->get_GraphicInfo() = FinalPositions[i].first;
			pG->AddComponent(pManager);
		}
	}
}
Ejemplo n.º 21
0
void MindMapModel::saveMindMap()
{
	list <Component *> tempList = root->getNodeList();
	list <Component *> resultList;
	list <Component *> childList;
	list <Component *>::iterator i;//iteration i use on resultList
	list <Component *>::iterator j;//iteration j use on childList

	resultList.push_back(root);
	getNodeList(tempList, resultList);
	resultList.sort(compare);

	fstream fp;

	//ios::app : input file's end
	fp.open("MindMap.txt", ios::out);
	if (!fp)
		cout << "file open failed" << endl;
	else
	{
		for (i = resultList.begin(); i != resultList.end(); ++i)//print node's ID
		{
			Component *temp = *i;
			childList = temp->getNodeList();
			fp << temp->getID() << " \"" + temp->getDescription() + "\" ";
			if (!childList.empty())
			{
				for (j = childList.begin(); j != childList.end(); ++j)
				{
					Component *child = *j;
					fp << child->getID() << " ";
				}
			}
			fp << "\n";
		}
	}
	fp.close();
}
Ejemplo n.º 22
0
int
Component::compare(const Component& other) const
{
  if (this->hasWire() && other.hasWire()) {
    // In the common case where both components have wire encoding,
    // it's more efficient to simply compare the wire encoding.
    // This works because lexical order of TLV encoding happens to be
    // the same as canonical order of the value.
    return std::memcmp(wire(), other.wire(), std::min(size(), other.size()));
  }

  int cmpType = type() - other.type();
  if (cmpType != 0)
    return cmpType;

  int cmpSize = value_size() - other.value_size();
  if (cmpSize != 0)
    return cmpSize;

  if (empty())
    return 0;

  return std::memcmp(value(), other.value(), value_size());
}
Ejemplo n.º 23
0
void GameObject::ReadXMLInfo(const XMLNode *xmlInfo)
{
    IFileable::ReadXMLInfo(xmlInfo);

    SetEnabled( xmlInfo->GetBool("enabled") );
    SetName( xmlInfo->GetString("name") );  //Read GameObject name

    for ( XMLNode *xmlChild : xmlInfo->GetChildren() )
    {
        String tagName = xmlChild->GetTagName();
        if (tagName == "GameObject") // It's a child
        {
            GameObject *child = new GameObject();
            // Important: this line must be before the ReadXMLInfo, because
            // it will avoid Behaviour to be compiled if it's not in the scene,
            // and it only can really know if its in scene when executing the Read if
            // we set it before the Read, not after. Wtf I don't know how to write this xds
            child->SetParent(this);
            child->ReadXMLInfo(xmlChild);
        }
        else // It's a Component
        {
            Component *c = nullptr;
            if (tagName == "Transform")
            {
                c = transform;
            }
            else if (tagName == "MeshRenderer")
            {
                c = AddComponent<MeshRenderer>();
            }
            else if (tagName == "Camera")
            {
                c = AddComponent<Camera>();
            }
            else if (tagName == "BehaviourHolder")
            {
                c = AddComponent<BehaviourHolder>();
            }
            else if (tagName == "DirectionalLight")
            {
                c = AddComponent<DirectionalLight>();
            }
            else if (tagName == "PointLight")
            {
                c = AddComponent<PointLight>();
            }
            else if (tagName == "Canvas")
            {
                Canvas *cv = AddComponent<Canvas>();
                cv->ReadXMLInfo(xmlChild);
                c = cv;
            }
            else if (tagName == "UIImage")
            {
                c = AddComponent<UIImage>();
            }
            else if (tagName == "UIText")
            {
                c = AddComponent<UIText>();
            }

            if (c)
            {
                c->ReadXMLInfo(xmlChild);
            }
        }
    }
}
Ejemplo n.º 24
0
 bool operator()(Component const& component) const
 {
     // return true if the parser fails
     return !component.parse(first, last, context, skipper, unused);
 }
Ejemplo n.º 25
0
 bool operator()(Component const& component, Attribute& attr) const
 {
     // return true if the parser fails
     return !component.parse(first, last, context, skipper, attr);
 }
Ejemplo n.º 26
0
void AlertWindow::updateLayout (const bool onlyIncreaseSize)
{
    const int titleH = 24;
    const int iconWidth = 80;

    const Font font (getLookAndFeel().getAlertWindowMessageFont());

    const int wid = jmax (font.getStringWidth (text),
                          font.getStringWidth (getName()));

    const int sw = (int) std::sqrt (font.getHeight() * wid);
    int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f));
    const int edgeGap = 10;
    const int labelHeight = 18;
    int iconSpace = 0;

    AttributedString attributedText;
    attributedText.append (getName(), font.withHeight (font.getHeight() * 1.1f).boldened());

    if (text.isNotEmpty())
        attributedText.append ("\n\n" + text, font);

    attributedText.setColour (findColour (textColourId));

    if (alertIconType == NoIcon)
    {
        attributedText.setJustification (Justification::centredTop);
        textLayout.createLayoutWithBalancedLineLengths (attributedText, (float) w);
    }
    else
    {
        attributedText.setJustification (Justification::topLeft);
        textLayout.createLayoutWithBalancedLineLengths (attributedText, (float) w);
        iconSpace = iconWidth;
    }

    w = jmax (350, (int) textLayout.getWidth() + iconSpace + edgeGap * 4);
    w = jmin (w, (int) (getParentWidth() * 0.7f));

    const int textLayoutH = (int) textLayout.getHeight();
    const int textBottom = 16 + titleH + textLayoutH;
    int h = textBottom;

    int buttonW = 40;
    int i;
    for (i = 0; i < buttons.size(); ++i)
        buttonW += 16 + buttons.getUnchecked(i)->getWidth();

    w = jmax (buttonW, w);

    h += (textBoxes.size() + comboBoxes.size() + progressBars.size()) * 50;

    if (buttons.size() > 0)
        h += 20 + buttons.getUnchecked(0)->getHeight();

    for (i = customComps.size(); --i >= 0;)
    {
        Component* c = customComps.getUnchecked(i);
        w = jmax (w, (c->getWidth() * 100) / 80);
        h += 10 + c->getHeight();

        if (c->getName().isNotEmpty())
            h += labelHeight;
    }

    for (i = textBlocks.size(); --i >= 0;)
    {
        const AlertTextComp* const ac = static_cast <const AlertTextComp*> (textBlocks.getUnchecked(i));
        w = jmax (w, ac->getPreferredWidth());
    }

    w = jmin (w, (int) (getParentWidth() * 0.7f));

    for (i = textBlocks.size(); --i >= 0;)
    {
        AlertTextComp* const ac = static_cast <AlertTextComp*> (textBlocks.getUnchecked(i));
        ac->updateLayout ((int) (w * 0.8f));
        h += ac->getHeight() + 10;
    }

    h = jmin (getParentHeight() - 50, h);

    if (onlyIncreaseSize)
    {
        w = jmax (w, getWidth());
        h = jmax (h, getHeight());
    }

    if (! isVisible())
    {
        centreAroundComponent (associatedComponent, w, h);
    }
    else
    {
        const int cx = getX() + getWidth() / 2;
        const int cy = getY() + getHeight() / 2;

        setBounds (cx - w / 2,
                   cy - h / 2,
                   w, h);
    }

    textArea.setBounds (edgeGap, edgeGap, w - (edgeGap * 2), h - edgeGap);

    const int spacer = 16;
    int totalWidth = -spacer;

    for (i = buttons.size(); --i >= 0;)
        totalWidth += buttons.getUnchecked(i)->getWidth() + spacer;

    int x = (w - totalWidth) / 2;
    int y = (int) (getHeight() * 0.95f);

    for (i = 0; i < buttons.size(); ++i)
    {
        TextButton* const c = buttons.getUnchecked(i);
        int ny = proportionOfHeight (0.95f) - c->getHeight();
        c->setTopLeftPosition (x, ny);
        if (ny < y)
            y = ny;

        x += c->getWidth() + spacer;

        c->toFront (false);
    }

    y = textBottom;

    for (i = 0; i < allComps.size(); ++i)
    {
        Component* const c = allComps.getUnchecked(i);
        h = 22;

        const int comboIndex = comboBoxes.indexOf (dynamic_cast <ComboBox*> (c));
        if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty())
            y += labelHeight;

        const int tbIndex = textBoxes.indexOf (dynamic_cast <TextEditor*> (c));
        if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty())
            y += labelHeight;

        if (customComps.contains (c))
        {
            if (c->getName().isNotEmpty())
                y += labelHeight;

            c->setTopLeftPosition (proportionOfWidth (0.1f), y);
            h = c->getHeight();
        }
        else if (textBlocks.contains (c))
        {
            c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y);
            h = c->getHeight();
        }
        else
        {
            c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h);
        }

        y += h + 10;
    }

    setWantsKeyboardFocus (getNumChildComponents() == 0);
}
Ejemplo n.º 27
0
 bool call(Component const& component, mpl::true_) const
 {
     // if Attribute is not a variant, then pass it as-is
     return component.parse(first, last, context, skipper, attr);
 }
Ejemplo n.º 28
0
void Label::componentParentHierarchyChanged (Component& component)
{
    if (component.getParentComponent() != nullptr)
        component.getParentComponent()->addChildComponent (this);
}
Ejemplo n.º 29
0
void Label::componentVisibilityChanged (Component& component)
{
    setVisible (component.isVisible());
}
Ejemplo n.º 30
0
 bool call_unused(Component const& component, mpl::false_) const
 {
     return component.parse(first, last, context, skipper, unused);
 }