예제 #1
0
boolean Editor::DependsOn (Component* parent) {
    Component* child = GetComponent();

    while (child != nil) {
        if (parent == child) {
            return true;
        }
        child = child->GetParent();
    }
    return false;
}
예제 #2
0
파일: menuitem.cpp 프로젝트: CodeMason/Vox
void MenuItem::MouseReleased(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	Menu* lpParentMenu = (Menu* )GetParent();
	
	// Make sure that we are inside the bounds of the parent menu
	if(lpParentMenu->GetPullDownMenuParent() != NULL)
	{
		int lTextHeight = m_pRenderer->GetFreeTypeTextHeight(lpParentMenu->GetPullDownMenuParent()->GetGUIFont(), "%s", lpParentMenu->GetMenuTitle().c_str());
		int lMenuHeight = lTextHeight + (lpParentMenu->GetMenuItemSpacer() * 2);
		int lFullMenuDisplayHeight = lpParentMenu->GetPullDownMenuParent()->GetMaxNumItemsDisplayed() * lMenuHeight;

		Point location = lpParentMenu->GetPullDownMenuParent()->GetLocation();
		for(Component* parent = lpParentMenu->GetPullDownMenuParent()->GetParent(); parent != 0;)
		{
			Point parentLocation = parent->GetLocation();

			location.m_x += parentLocation.m_x;
			location.m_y += parentLocation.m_y;

			parent = parent->GetParent();
		}
		int lMenuX = location.m_x;
		int lMenuY = location.m_y - lFullMenuDisplayHeight;
		int lMenuWidth = lpParentMenu->GetBiggestWidth()+ (lpParentMenu->GetMenuItemSpacer() * 2);

		if(lEvent.GetX() > lMenuX && lEvent.GetX() <= lMenuX+lMenuWidth && lEvent.GetY() > lMenuY && lEvent.GetY() <= lMenuY+lFullMenuDisplayHeight)
		{
			// Close the menu, since we have clicked this menu item
			lpParentMenu->CloseMenu();

			SetHover(false);
			SetSelected(false);

			// Signal that we have pressed this menu item
			MenuItemPressed();
		}
	}


	FocusManager::GetInstance()->SetFocusOwner(0);

	OnMouseReleased();
}
예제 #3
0
파일: menuitem.cpp 프로젝트: CodeMason/Vox
void MenuItem::MouseEntered(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	Menu* lpParentMenu = (Menu* )GetParent();

	// Make sure that we are inside the bounds of the parent menu
	if(lpParentMenu->GetPullDownMenuParent() != NULL)
	{
		int lTextHeight = m_pRenderer->GetFreeTypeTextHeight(lpParentMenu->GetPullDownMenuParent()->GetGUIFont(), "%s", lpParentMenu->GetMenuTitle().c_str());
		int lMenuHeight = lTextHeight + (lpParentMenu->GetMenuItemSpacer() * 2);
		int lFullMenuDisplayHeight = lpParentMenu->GetPullDownMenuParent()->GetMaxNumItemsDisplayed() * lMenuHeight;

		Point location = lpParentMenu->GetPullDownMenuParent()->GetLocation();
		for(Component* parent = lpParentMenu->GetPullDownMenuParent()->GetParent(); parent != 0;)
		{
			Point parentLocation = parent->GetLocation();

			location.m_x += parentLocation.m_x;
			location.m_y += parentLocation.m_y;

			parent = parent->GetParent();
		}
		int lMenuX = location.m_x;
		int lMenuY = location.m_y - lFullMenuDisplayHeight;
		int lMenuWidth = lpParentMenu->GetBiggestWidth()+ (lpParentMenu->GetMenuItemSpacer() * 2);

		if(lEvent.GetX() > lMenuX && lEvent.GetX() <= lMenuX+lMenuWidth && lEvent.GetY() > lMenuY && lEvent.GetY() <= lMenuY+lFullMenuDisplayHeight)
		{
			SetHover(true);

			OnMouseEnter();
		}
	}
}
예제 #4
0
boolean TextScript::Definition (ostream& out) {
    TextOvComp* comp = (TextOvComp*) GetSubject();
    TextGraphic* g = comp->GetText();
    const char* text = g->GetOriginal();

    int h = g->GetLineHeight();
    out << "text(";
    out << h << ",";
    int indent_level = 0;
    Component* parent = comp;
    do {
	parent = parent->GetParent();
	indent_level++;
    } while (parent != nil);
    ParamList::output_text(out, text, indent_level);

    float sep = g->GetLineHeight() - 1;         // correct for vert shift
    Transformer corrected, *t = g->GetTransformer();
    corrected.Translate(0., sep);
    if (t == nil) {
        g->SetTransformer(&corrected);
        TextGS(out);
        g->SetTransformer(t);

    } else {
        t->Reference();
        corrected.Postmultiply(t);
        g->SetTransformer(&corrected);
        TextGS(out);
        g->SetTransformer(t);
        Unref(t);
    }
    Annotation(out);
    Attributes(out);
    out << ")";

    return out.good();
}