Пример #1
0
LLView* LLViewerTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("text_editor");
	node->getAttributeString("name", name);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	U32 max_text_length = 255;
	node->getAttributeU32("max_length", max_text_length);

	BOOL allow_embedded_items = FALSE;
	node->getAttributeBOOL("embedded_items", allow_embedded_items);

	LLFontGL* font = LLView::selectFont(node);

	// std::string text = node->getValue();
	std::string text = node->getTextContents().substr(0, max_text_length - 1);

	if (text.size() > max_text_length)
	{
		// Erase everything from max_text_length on.
		text.erase(max_text_length);
	}

	LLViewerTextEditor* text_editor = new LLViewerTextEditor(name, 
								rect,
								max_text_length,
								LLStringUtil::null,
								font,
								allow_embedded_items);

	BOOL ignore_tabs = text_editor->tabsToNextField();
	node->getAttributeBOOL("ignore_tab", ignore_tabs);
	text_editor->setTabsToNextField(ignore_tabs);

	text_editor->setTextEditorParameters(node);

	BOOL hide_scrollbar = FALSE;
	node->getAttributeBOOL("hide_scrollbar",hide_scrollbar);
	text_editor->setHideScrollbarForShortDocs(hide_scrollbar);

	BOOL hide_border = !text_editor->isBorderVisible();
	node->getAttributeBOOL("hide_border", hide_border);
	text_editor->setBorderVisible(!hide_border);

	BOOL parse_html = text_editor->mParseHTML;
	node->getAttributeBOOL("allow_html", parse_html);
	text_editor->setParseHTML(parse_html);
	text_editor->setParseHighlights(TRUE);

	text_editor->initFromXML(node, parent);

	// add text after all parameters have been set
	text_editor->appendStyledText(text, FALSE, FALSE);

	return text_editor;
}
Пример #2
0
int Menu::checkClick(const int x, const int y)
{
    for(unsigned int i=0; i < this->buttons.size(); i++)
    {
        if(detectCollision(this->buttons[i]->mouseOverBox, createRect(x, y, 0, 0)))
            return i;
    }
    return -1;
}
Пример #3
0
LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	LLString name("spinner");
	node->getAttributeString("name", name);

	LLString label;
	node->getAttributeString("label", label);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	LLFontGL* font = LLView::selectFont(node);

	F32 initial_value = 0.f;
	node->getAttributeF32("initial_val", initial_value);

	F32 min_value = 0.f;
	node->getAttributeF32("min_val", min_value);

	F32 max_value = 1.f; 
	node->getAttributeF32("max_val", max_value);

	F32 increment = 0.1f;
	node->getAttributeF32("increment", increment);

	U32 precision = 3;
	node->getAttributeU32("decimal_digits", precision);
	
	S32 label_width = llmin(40, rect.getWidth() - 40);
	node->getAttributeS32("label_width", label_width);

	LLUICtrlCallback callback = NULL;

	if(label.empty())
	{
		label.assign( node->getValue() );
	}

	LLSpinCtrl* spinner = new LLSpinCtrl(name,
							rect,
							label,
							font,
							callback,
							NULL,
							initial_value, 
							min_value, 
							max_value, 
							increment,
							"",
							label_width);

	spinner->setPrecision(precision);

	spinner->initFromXML(node, parent);

	return spinner;
}
Пример #4
0
// static
LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("combo_box");
	node->getAttributeString("name", name);

	std::string label("");
	node->getAttributeString("label", label);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	BOOL allow_text_entry = FALSE;
	node->getAttributeBOOL("allow_text_entry", allow_text_entry);

	S32 max_chars = 20;
	node->getAttributeS32("max_chars", max_chars);

	LLUICtrlCallback callback = NULL;

	LLComboBox* combo_box = new LLComboBox(name,
							rect, 
							label,
							callback,
							NULL);
	combo_box->setAllowTextEntry(allow_text_entry, max_chars);

	combo_box->initFromXML(node, parent);

	const std::string& contents = node->getValue();

	if (contents.find_first_not_of(" \n\t") != contents.npos)
	{
		llerrs << "Legacy combo box item format used! Please convert to <combo_item> tags!" << llendl;
	}
	else
	{
		LLXMLNodePtr child;
		for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
		{
			if (child->hasName("combo_item"))
			{
				std::string label = child->getTextContents();

				std::string value = label;
				child->getAttributeString("value", value);

				combo_box->add(label, LLSD(value) );
			}
		}
	}

	combo_box->selectFirstItem();

	return combo_box;
}
Пример #5
0
static void p2_test_overlapping_rects_2(void)
{
	// Square centered on 2,2
	struct PC_vertex_ll * r1 = createRect(2,2,4,4);
	
	// Square centered on 4,4
	struct PC_vertex_ll * r2 = createRectCW(4,4,4,4);
	
	enum PC_op_t op = PC_op_union;
	
	bool result = PC_phase_one(r1, r2); 
	PC_phase_two(r1, r2, op);
	
	// Should be:
	/*
	 *
	 *
	 *           R2_2-------------------R2_3
	 *             |                      |
	 *             |                      |
	 *    R1_5--R1_4/R2_1--R1_3           |
	 *     |       |         |            |
	 *     |       |         |            |
	 *     |     R2_0------R1_2/R2_5----R2_4
	 *     |                 |
	 *     |                 |
	 *    R1_0-------------R1_1
	 *
	 */
	
	
	LT_ASSERT(_I(r1, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 1)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 2)->flag == FLG_EN);
	LT_ASSERT(_I(r1, 3)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 4)->flag == FLG_EX);
	LT_ASSERT(_I(r1, 5)->flag == FLG_NONE);
	
	LT_ASSERT(_I(r2, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 1)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 2)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 3)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 4)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 5)->flag == FLG_EN);
	
	
	LT_ASSERT(no_couples(r1));
	LT_ASSERT(no_couples(r2));
    
    
    PC_free_verticies(r1);
    PC_free_verticies(r2);
}
Пример #6
0
// static
LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
    LLString name("scrolling_panel_list");
    node->getAttributeString("name", name);

    LLRect rect;
    createRect(node, rect, parent, LLRect());

    LLScrollingPanelList* scrolling_panel_list = new LLScrollingPanelList(name, rect);
    scrolling_panel_list->initFromXML(node, parent);
    return scrolling_panel_list;
}
Пример #7
0
Mario::Mario(std::string imageURL) : SDL_Program()
{
  //Initialize animation variables
  status = MARIO_STAND;
  frame = 0;
  
  //Create the Mario surface
  marioSurface = loadImage("tokenImages/RobodogPositions.bmp");

  //Initialize movement variables
    marioRect = createRect(marioSurface, SCREEN_WIDTH - TOKEN_LIB_W, SCREEN_HEIGHT - TOKEN_LIB_H - RUN_BUTTON_H - MARIO_HEIGHT);
}
Пример #8
0
void entity_checkCollisionWithMap(const Entity& entity, sf::Vector2f& movement)
{
	for (auto &obj : level_getCollisions(*entity.level))
	{
		if (obj.GetType() == "solid")
		{
			sf::FloatRect objRect(createRect(OrthogonalToIsometric(obj.GetPosition()), obj.GetSize()));
			if (createRect(OrthogonalToIsometric(entity.objectEntity->GetPosition() + movement), entity.objectEntity->GetSize()).intersects(objRect))
			{
				if (movement.y > 0.f)
					movement.y = 0.f;
				if (movement.y < 0.f)
					movement.y = 0.f;
				if (movement.x > 0)
					movement.x = 0.f;
				if (movement.x < 0)
					movement.x = 0.f;
			}
		}
	}
	for (auto &unit : level_getUnits(*entity.level))
	{
		auto un = unit.GetPropertyString("dead");
		if (unit.GetName() != entity.objectEntity->GetName() && unit.GetPropertyString("dead") == "0")
		{
			sf::FloatRect unitRect(createRect(OrthogonalToIsometric(unit.GetPosition()), unit.GetSize()));
			if (createRect(OrthogonalToIsometric(entity.objectEntity->GetPosition() + movement), entity.objectEntity->GetSize()).intersects(unitRect))
			{
				if (movement.y > 0.f)
					movement.y = 0.f;
				if (movement.y < 0.f)
					movement.y = 0.f;
				if (movement.x > 0)
					movement.x = 0.f;
				if (movement.x < 0)
					movement.x = 0.f;
			}
		}
	}
}
Пример #9
0
LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *factory)
{
	std::string name("panel");
	node->getAttributeString("name", name);

	LLPanel* panelp = factory->createFactoryPanel(name);
	LLFastTimer _(FTM_PANEL_CONSTRUCTION);
	// Fall back on a default panel, if there was no special factory.
	if (!panelp)
	{
		LLRect rect;
		createRect(node, rect, parent, LLRect());
		// create a new panel without a border, by default
		panelp = new LLPanel(name, rect, FALSE);
		// for local registry callbacks; define in constructor, referenced in XUI or postBuild
		panelp->mCommitCallbackRegistrar.pushScope(); 
		panelp->mEnableCallbackRegistrar.pushScope();
		panelp->initPanelXML(node, parent, factory);
		panelp->mCommitCallbackRegistrar.popScope();
		panelp->mEnableCallbackRegistrar.popScope();
		// preserve panel's width and height, but override the location
		const LLRect& panelrect = panelp->getRect();
		S32 w = panelrect.getWidth();
		S32 h = panelrect.getHeight();
		rect.setLeftTopAndSize(rect.mLeft, rect.mTop, w, h);
		panelp->setRect(rect);
	}
	else
	{
		if(!factory->builtPanel(panelp))
		{
			// for local registry callbacks; define in constructor, referenced in XUI or postBuild
			panelp->mCommitCallbackRegistrar.pushScope(); 
			panelp->mEnableCallbackRegistrar.pushScope();
			panelp->initPanelXML(node, parent, factory);
			panelp->mCommitCallbackRegistrar.popScope();
			panelp->mEnableCallbackRegistrar.popScope();
		}
		else
		{
			LLRect new_rect = panelp->getRect();
			// override rectangle with embedding parameters as provided
			panelp->createRect(node, new_rect, parent);
			panelp->setOrigin(new_rect.mLeft, new_rect.mBottom);
			panelp->setShape(new_rect);
			// optionally override follows flags from including nodes
			panelp->parseFollowsFlags(node);
		}
	}

	return panelp;
}
Пример #10
0
//static 
LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name = "flyout_button";
	node->getAttributeString("name", name);

	std::string label("");
	node->getAttributeString("label", label);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	LLUICtrlCallback callback = NULL;

	LLFlyoutButton* flyout_button = new LLFlyoutButton(name,
							rect, 
							label,
							callback,
							NULL);

	std::string list_position;
	node->getAttributeString("list_position", list_position);
	if (list_position == "below")
	{
		flyout_button->mListPosition = BELOW;
	}
	else if (list_position == "above")
	{
		flyout_button->mListPosition = ABOVE;
	}
	

	flyout_button->initFromXML(node, parent);

	LLXMLNodePtr child;
	for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
	{
		if (child->hasName("flyout_button_item"))
		{
			std::string label = child->getTextContents();

			std::string value = label;
			child->getAttributeString("value", value);

			flyout_button->add(label, LLSD(value) );
		}
	}

	flyout_button->updateLayout();

	return flyout_button;
}
Пример #11
0
// static
LLView* LLCheckBoxCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("checkbox");
	node->getAttributeString("name", name);

	std::string label("");
	node->getAttributeString("label", label);

	LLFontGL* font = LLView::selectFont(node);

	BOOL radio_style = FALSE;
	node->getAttributeBOOL("radio_style", radio_style);

	LLUICtrlCallback callback = NULL;

	if (label.empty())
	{
		label.assign(node->getTextContents());
	}

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	LLCheckBoxCtrl* checkbox = new LLCheckboxCtrl(name, 
		rect, 
		label,
		font,
		callback,
		NULL,
		FALSE,
		radio_style); // if true, draw radio button style icons

	BOOL initial_value = checkbox->getValue().asBoolean();
	node->getAttributeBOOL("initial_value", initial_value);

	LLColor4 color;
	color = LLUI::sColorsGroup->getColor( "LabelTextColor" );
	LLUICtrlFactory::getAttributeColor(node,"text_enabled_color", color);
	checkbox->setEnabledColor(color);

	color = LLUI::sColorsGroup->getColor( "LabelDisabledColor" );
	LLUICtrlFactory::getAttributeColor(node,"text_disabled_color", color);
	checkbox->setDisabledColor(color);

	checkbox->setValue(initial_value);

	checkbox->initFromXML(node, parent);

	return checkbox;
}
Пример #12
0
LLView* DOHexEditor::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory)
{
	std::string name("text_editor");
	node->getAttributeString("name", name);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	DOHexEditor* editor = new DOHexEditor(name, rect);

	editor->initFromXML(node, parent);

	return editor;
}
Пример #13
0
void Menu::newToggle(const char* text, TOGGLE toggle_type, bool on)
{
    this->buttons.push_back(new Button);

    if(this->centerText)
    {
        this->buttons[LAST]->normalButton = renderMultiLineText(
            this->font, text, this->hlColor, this->fgColor,
            ALIGN_CENTER | TRANSPARENT_BG | CREATE_SURFACE);

        this->buttons[LAST]->highlightedButton = renderMultiLineText(
            this->font, text, this->fgColor, this->hlColor,
            ALIGN_CENTER | TRANSPARENT_BG | CREATE_SURFACE);

        this->buttons[LAST]->x = ((SCREEN_WIDTH / 2) - 
            (this->buttons[LAST]->normalButton->clip_rect.w / 2));

        this->inbetween = this->buttons[LAST]->normalButton->clip_rect.h;
        this->buttons[LAST]->y = this->y;
        this->y += this->inbetween;
    }
    else
    {
        this->buttons[LAST]->normalButton = renderMultiLineText(
            this->font, (string)text, this->hlColor, this->fgColor,
            TRANSPARENT_BG | CREATE_SURFACE);

        this->buttons[LAST]->highlightedButton = renderMultiLineText(
            this->font, (string)text, this->fgColor, this->hlColor,
            TRANSPARENT_BG | CREATE_SURFACE);

        this->inbetween = this->buttons[LAST]->normalButton->clip_rect.h;
        this->buttons[LAST]->x = this->x;
        this->buttons[LAST]->y = this->y;
        this->y += this->inbetween;
    }

    this->buttons[LAST]->mouseOverBox = createRect(this->buttons[LAST]->x,
        this->buttons[LAST]->y,
        this->buttons[LAST]->normalButton->clip_rect.w,
        this->buttons[LAST]->normalButton->clip_rect.h);

    this->buttons[LAST]->type = TOGGLE_MENU;
    this->buttons[LAST]->button_text = new char[strlen(text) + 1];
    strncpy(this->buttons[LAST]->button_text, text, strlen(text) + 1);
    this->buttons[LAST]->action = NO_ACTION;
    this->buttons[LAST]->toggle = toggle_type;
    this->buttons[LAST]->highlights = true;
    this->buttons[LAST]->switch_status = on;
}
Пример #14
0
static void p2_test_semi2(void)
{
	struct PC_vertex_ll * r1 = createRect(2,2,4,4);
	struct PC_vertex_ll * r2 = createRectCW(4,3,2,2);
	
	enum PC_op_t op = PC_op_union;
	bool result = PC_phase_one(r1, r2); 
	
	
	
	LT_REQUIRE(polySize(r1) == 6); 
	LT_REQUIRE(polySize(r2) == 6);
	
	PC_phase_two(r1, r2, op);
	

	LT_ASSERT(_I(r1, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 1)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 2)->flag == FLG_EN);
	LT_ASSERT(_I(r1, 3)->flag == FLG_EX);
	LT_ASSERT(_I(r1, 4)->flag == FLG_EX);
	LT_ASSERT(_I(r1, 5)->flag == FLG_NONE);
	
	LT_ASSERT(_I(r2, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 1)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 2)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 3)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 4)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 5)->flag == FLG_EN);
	
	
	// Test couple creation
	LT_ASSERT(_I(r1, 0)->couple == NULL);
	LT_ASSERT(_I(r1, 1)->couple == NULL);
	LT_ASSERT(_I(r1, 2)->couple == NULL);
	LT_ASSERT(_I(r1, 3)->couple == _I(r1, 4));
	LT_ASSERT(_I(r1, 4)->couple == _I(r1, 3));
	LT_ASSERT(_I(r1, 5)->couple == NULL);
	
	LT_ASSERT(_I(r2, 0)->couple == NULL);
	LT_ASSERT(_I(r2, 1)->couple == _I(r2, 2));
	LT_ASSERT(_I(r2, 2)->couple == _I(r2, 1));
	LT_ASSERT(_I(r2, 3)->couple == NULL);
	LT_ASSERT(_I(r2, 4)->couple == NULL);
	LT_ASSERT(_I(r2, 5)->couple == NULL);
    
    
    PC_free_verticies(r1);
    PC_free_verticies(r2);
}
LLView* LLMediaCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	LLMediaCtrl::Params p;
	
	BOOL bval;
	LLColor4 color;
	S32 ival;
	LLRect rect;

	std::string sval("web_browser");
	node->getAttributeString("name", sval);
	p.name = sval;
	createRect(node, rect, parent, LLRect());
	p.rect = rect;

	if(node->getAttributeString("start_url", sval ))
		p.start_url = sval;
	if(node->getAttributeString("error_page_url", sval ))
		p.error_page_url = sval;
	if(node->getAttributeString("media_id", sval ))
		p.media_id = sval;
	if(node->getAttributeString("initial_mime_type", sval ))
		p.initial_mime_type = sval;
	if(node->getAttributeBOOL("border_visible", bval))
		p.border_visible = bval;
	if(node->getAttributeBOOL("focus_on_click", bval))
		p.focus_on_click = bval;
	if(node->getAttributeBOOL("decouple_texture_size", bval))
		p.decouple_texture_size = bval;
	if(node->getAttributeBOOL("trusted_content", bval))
		p.trusted_content = bval;
	if(node->getAttributeS32("texture_width", ival))
		p.texture_width = ival;
	if(node->getAttributeBOOL("texture_height", ival))
		p.texture_height = ival;
	if(LLUICtrlFactory::getAttributeColor(node, "caret_color", color))
		p.caret_color = color;

	LLMediaCtrl* web_browser = LLUICtrlFactory::create<LLMediaCtrl>(p,parent);

	web_browser->initFromXML(node, parent);

	if(!p.start_url.getValue().empty())
	{
		web_browser->navigateHome();
	}

	return web_browser;
}
Пример #16
0
//static
LLView* LLMultiSlider::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
    std::string name("multi_slider_bar");
    node->getAttributeString("name", name);

    LLRect rect;
    createRect(node, rect, parent, LLRect());

    F32 initial_value = 0.f;
    node->getAttributeF32("initial_val", initial_value);

    F32 min_value = 0.f;
    node->getAttributeF32("min_val", min_value);

    F32 max_value = 1.f;
    node->getAttributeF32("max_val", max_value);

    F32 increment = 0.1f;
    node->getAttributeF32("increment", increment);

    S32 max_sliders = 1;
    node->getAttributeS32("max_sliders", max_sliders);

    BOOL allow_overlap = FALSE;
    node->getAttributeBOOL("allow_overlap", allow_overlap);

    BOOL draw_track = TRUE;
    node->getAttributeBOOL("draw_track", draw_track);

    BOOL use_triangle = FALSE;
    node->getAttributeBOOL("use_triangle", use_triangle);

    LLMultiSlider* multiSlider = new LLMultiSlider(name,
            rect,
            NULL,
            NULL,
            initial_value,
            min_value,
            max_value,
            increment,
            max_sliders,
            allow_overlap,
            draw_track,
            use_triangle);

    multiSlider->initFromXML(node, parent);

    return multiSlider;
}
Пример #17
0
LLView* LLTextureCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("texture_picker");
	node->getAttributeString("name", name);

	LLRect rect;
	createRect(node, rect, parent);

	std::string label;
	node->getAttributeString("label", label);

	std::string image_id("");
	node->getAttributeString("image", image_id);

	std::string default_image_id("");
	node->getAttributeString("default_image", default_image_id);

	std::string default_image_name("Default");
	node->getAttributeString("default_image_name", default_image_name);

	BOOL allow_no_texture = FALSE;
	node->getAttributeBOOL("allow_no_texture", allow_no_texture);
	
	BOOL allow_invisible_texture = FALSE;
	node->getAttributeBOOL("allow_invisible_texture", allow_invisible_texture);

	BOOL can_apply_immediately = FALSE;
	node->getAttributeBOOL("can_apply_immediately", can_apply_immediately);

	if (label.empty())
	{
		label.assign(node->getValue());
	}

	LLTextureCtrl* texture_picker = new LLTextureCtrl(
									name, 
									rect,
									label,
									LLUUID(image_id),
									LLUUID(default_image_id), 
									default_image_name );
	texture_picker->setAllowNoTexture(allow_no_texture);
	texture_picker->setAllowInvisibleTexture(allow_invisible_texture);
	texture_picker->setCanApplyImmediately(can_apply_immediately);

	texture_picker->initFromXML(node, parent);

	return texture_picker;
}
Пример #18
0
LLView* LLScrollableContainerView::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("scroll_container");
	node->getAttributeString("name", name);

	LLRect rect;
	createRect(node, rect, parent, LLRect());
	
	BOOL opaque = FALSE;
	node->getAttributeBOOL("opaque", opaque);

	LLColor4 color(0,0,0,0);
	LLUICtrlFactory::getAttributeColor(node,"color", color);

	// Create the scroll view
	LLScrollableContainerView *ret = new LLScrollableContainerView(name, rect, (LLPanel*)NULL, opaque, color);

	LLPanel* panelp = NULL;

	// Find a child panel to add
	LLXMLNodePtr child;
	for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
	{
		LLView *control = factory->createCtrlWidget(panelp, child);
		if (control && control->isPanel())
		{
			if (panelp)
			{
				llinfos << "Warning! Attempting to put multiple panels into a scrollable container view!" << llendl;
				delete control;
			}
			else
			{
				panelp = (LLPanel*)control;
			}
		}
	}

	if (panelp == NULL)
	{
		panelp = new LLPanel(std::string("dummy"), LLRect::null, FALSE);
	}

	ret->mScrolledView = panelp;

	ret->initFromXML(node, parent);

	return ret;
}
Пример #19
0
void Menu::checkMouseOver(int mouseX, int mouseY)
{
    for(unsigned int i=0; i < this->buttons.size(); i++)
    {
        if(detectCollision(this->buttons[i]->mouseOverBox, createRect(mouseX, mouseY, 0, 0)) &&
            (this->buttons[i]->highlightedButton != NULL) && this->buttons[i]->highlights)
        {
            this->buttons[i]->displayButton = this->buttons[i]->highlightedButton;
        }
        else
        {
            this->buttons[i]->displayButton = this->buttons[i]->normalButton;
        }
    }
}
Пример #20
0
static void p2_test_onelarger2(void)
{
	// Square centered on 2,2
	struct PC_vertex_ll * r1 = createRect(2,2,4,4);
	
	// Square centered on 3,4
	struct PC_vertex_ll * r2 = createRect(3,3,6,6);
	
	enum PC_op_t op = PC_op_union;
	bool result = PC_phase_one(r1, r2); 
	
	
	LT_REQUIRE(polySize(r1) == 4); 
	LT_REQUIRE(polySize(r2) == 6);
	
	PC_phase_two(r1, r2, op);
	
	LT_ASSERT(_I(r1, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 1)->flag == FLG_EN);
	LT_ASSERT(_I(r1, 2)->flag == FLG_NONE);
	LT_ASSERT(_I(r1, 3)->flag == FLG_EX);
	
	LT_ASSERT(_I(r2, 0)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 1)->flag == FLG_EX);
	LT_ASSERT(_I(r2, 2)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 3)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 4)->flag == FLG_NONE);
	LT_ASSERT(_I(r2, 5)->flag == FLG_EN);
	
	LT_ASSERT(no_couples(r1));
	LT_ASSERT(no_couples(r2));
    
    
    PC_free_verticies(r1);
    PC_free_verticies(r2);
}
Пример #21
0
void Menu::newSubMenu(const char* text, Menu* nextMenu)
{
    this->buttons.push_back(new Button);

    if(this->centerText)
    {
        this->buttons[LAST]->normalButton = renderMultiLineText(
            this->font, text, this->hlColor, this->fgColor,
            ALIGN_CENTER | TRANSPARENT_BG | CREATE_SURFACE);

        this->buttons[LAST]->highlightedButton = renderMultiLineText(
            this->font, text, this->fgColor, this->hlColor,
            ALIGN_CENTER | TRANSPARENT_BG | CREATE_SURFACE);

        this->buttons[LAST]->x = ((SCREEN_WIDTH / 2) - 
            (this->buttons[LAST]->normalButton->clip_rect.w / 2));

        this->inbetween = this->buttons[LAST]->normalButton->clip_rect.h;
        this->buttons[LAST]->y = this->y;
        this->y += this->inbetween;
    }
    else
    {
        this->buttons[LAST]->normalButton = renderMultiLineText(
            this->font, (string)text, this->hlColor, this->fgColor,
            TRANSPARENT_BG | CREATE_SURFACE);

        this->buttons[LAST]->highlightedButton = renderMultiLineText(
            this->font, (string)text, this->fgColor, this->hlColor,
            TRANSPARENT_BG | CREATE_SURFACE);

        this->inbetween = this->buttons[LAST]->normalButton->clip_rect.h;
        this->buttons[LAST]->x = this->x;
        this->buttons[LAST]->y = this->y;
        this->y += this->inbetween;
    }

    this->buttons[LAST]->mouseOverBox = createRect(this->buttons[LAST]->x,
        this->buttons[LAST]->y,
        this->buttons[LAST]->normalButton->clip_rect.w,
        this->buttons[LAST]->normalButton->clip_rect.h);

    this->buttons[LAST]->type = SUB_MENU;
    this->buttons[LAST]->nextMenu = nextMenu;
    this->buttons[LAST]->action = NO_ACTION;
    this->buttons[LAST]->toggle = NO_TOGGLE;
    this->buttons[LAST]->highlights = true;
}
Пример #22
0
void Objrect (double* x         ,
              double* y         ,
              double* width     ,
              double* height    ,
              int    * foreground,
              int    * background,
              BOOL     isfilled  ,
              BOOL     isline    ,
              long   * hdl )
{
    int iNewObjUID = 0;
    int iSubwinUID = 0;
    double rect[6];

    iSubwinUID = getCurrentSubWin();

    /* check if the auto_clear property is on and then erase everything */
    checkRedrawing();

    rect[0] = *x;
    rect[1] = *x + *width;
    rect[2] = *y - *height;
    rect[3] = *y;

    updateXYDataBounds(iSubwinUID, rect);

    /*newObjUID = ConstructRectangle(iSubwinUID , *x, *y, *height, *width,
      foreground, background, isfilled, isline);*/

    iNewObjUID = createRect(iSubwinUID, *x, *y, *height, *width,
                            foreground == NULL ? -1 : *foreground,
                            background == NULL ? -1 : *background,
                            (int)isfilled, (int)isline);

    if (iNewObjUID == 0)
    {
        /* an error occurred */
        *hdl = -1;
        return;
    }

    setCurrentObject(iNewObjUID);
    *hdl = getHandle(iNewObjUID);
}
Пример #23
0
//static
LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory)
{
	std::string label("");
	node->getAttributeString("label", label);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	LLFlyoutButton* flyout_button = new LLFlyoutButton("flyout_button", rect, label);

	std::string list_position;
	node->getAttributeString("list_position", list_position);
	if (list_position == "below")
	{
		flyout_button->mListPosition = BELOW;
	}
	else if (list_position == "above")
	{
		flyout_button->mListPosition = ABOVE;
	}

	if (LLFontGL* font = selectFont(node))
		flyout_button->mActionButton->setFont(font);

	flyout_button->initFromXML(node, parent);

	for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
	{
		if (child->hasName(LL_FLYOUT_BUTTON_ITEM_TAG))
		{
			std::string label(child->getTextContents());
			child->getAttributeString("label", label);
			std::string value(label);
			child->getAttributeString("value", value);

			flyout_button->add(label, LLSD(value));
		}
	}

	flyout_button->updateLayout();

	return flyout_button;
}
void main(){

int i,n;
scanf("%d",&n);
Rect r[n];
for (i=0; i<n; i++){

r[i]=createRect();
r[i]=getData(r[i]);
printRect(r[i]);
printf("\n");
printf("Is this rectange a Square?\n(1 for YES, 0 for NO): %d",isSquare(r[i]));
printf("\narea is %d",computeArea(r[i]));
}

int maxarea;
maxarea=findMaxArea(r,n);
printf("\n the max area is %d\n",maxarea);

}
Пример #25
0
LLView* LLMediaCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("web_browser");
	node->getAttributeString("name", name);

	std::string start_url("");
	node->getAttributeString("start_url", start_url );

	BOOL border_visible = true;
	node->getAttributeBOOL("border_visible", border_visible);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	LLMediaCtrl* web_browser = new LLMediaCtrl( name, rect );

	if(node->hasAttribute("caret_color"))
	{
		LLColor4 color;
		LLUICtrlFactory::getAttributeColor(node, "caret_color", color);
		LLColor4U colorU = LLColor4U(color);
		web_browser->setCaretColor( colorU.mV[0], colorU.mV[1], colorU.mV[2] );
	}

	BOOL ignore_ui_scale = web_browser->getIgnoreUIScale();
	node->getAttributeBOOL("ignore_ui_scale", ignore_ui_scale);
	web_browser->setIgnoreUIScale((bool)ignore_ui_scale);

	web_browser->initFromXML(node, parent);

	web_browser->setHomePageUrl( start_url );

	web_browser->setBorderVisible( border_visible );

	if(! start_url.empty())
	{
		web_browser->navigateHome();
	}

	return web_browser;
}
Пример #26
0
BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name = getName();
	node->getAttributeString("name", name);
	setName(name);

	setPanelParameters(node, parent);

	initChildrenXML(node, factory);

	std::string xml_filename;
	node->getAttributeString("filename", xml_filename);

	BOOL didPost;

	if (!xml_filename.empty())
	{
		didPost = factory->buildPanel(this, xml_filename, NULL);

		LLRect new_rect = getRect();
		// override rectangle with embedding parameters as provided
		createRect(node, new_rect, parent);
		setOrigin(new_rect.mLeft, new_rect.mBottom);
		reshape(new_rect.getWidth(), new_rect.getHeight());
		// optionally override follows flags from including nodes
		parseFollowsFlags(node);
	}
	else
	{
		didPost = FALSE;
	}
	
	if (!didPost)
	{
		postBuild();
		didPost = TRUE;
	}

	return didPost;
}
Пример #27
0
LLView* LLInventoryPanel::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	LLInventoryPanel* panel;

	std::string name("inventory_panel");
	node->getAttributeString("name", name);

	BOOL allow_multi_select = TRUE;
	node->getAttributeBOOL("allow_multi_select", allow_multi_select);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	std::string sort_order(INHERIT_SORT_ORDER);
	node->getAttributeString("sort_order", sort_order);

	std::string start_folder;
	node->getAttributeString("start_folder", start_folder);

	if(name == "Recent Items")
		panel = new LLInventoryRecentItemsPanel(name, sort_order, start_folder,
								 rect, &gInventory,
								 allow_multi_select, parent);
	else if(name == "panel_outbox_inventory")
		panel = new LLOutboxInventoryPanel(name, sort_order, start_folder,
								 rect, &gInventory,
								 allow_multi_select, parent);
	else
		panel = new LLInventoryPanel(name, sort_order, start_folder,
								 rect, &gInventory,
								 allow_multi_select, parent);

	panel->initFromXML(node, parent);

	panel->postBuild();

	return panel;
}
Пример #28
0
//static
LLView* LLSlider::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory)
{
	std::string name("slider_bar");
	node->getAttributeString("name", name);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	F32 initial_value = 0.f;
	node->getAttributeF32("initial_val", initial_value);

	F32 min_value = 0.f;
	node->getAttributeF32("min_val", min_value);

	F32 max_value = 1.f; 
	node->getAttributeF32("max_val", max_value);

	F32 increment = 0.1f;
	node->getAttributeF32("increment", increment);

	BOOL volume = node->hasName("volume_slider") ? TRUE : FALSE;
	node->getAttributeBOOL("volume", volume);

	LLSlider* slider = new LLSlider(name,
							rect,
							NULL,
							NULL,
							initial_value,
							min_value,
							max_value,
							increment,
							volume);

	slider->initFromXML(node, parent);

	return slider;
}
Пример #29
0
LLView* LLColorSwatchCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	std::string name("colorswatch");
	node->getAttributeString("name", name);

	std::string label;
	node->getAttributeString("label", label);

	LLColor4 color(1.f, 1.f, 1.f, 1.f);
	node->getAttributeColor("initial_color", color);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	BOOL can_apply_immediately = FALSE;
	node->getAttributeBOOL("can_apply_immediately", can_apply_immediately);

	LLUICtrlCallback callback = NULL;

	if (label.empty())
	{
		label.assign(node->getValue());
	}

	LLColorSwatchCtrl* color_swatch = new LLColorSwatchCtrl(
		name, 
		rect,
		label,
		color,
		callback,
		NULL );

	color_swatch->setCanApplyImmediately(can_apply_immediately);
	color_swatch->initFromXML(node, parent);

	return color_swatch;
}
Пример #30
0
LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
    std::string name("slider");
    node->getAttributeString("name", name);

    std::string label;
    node->getAttributeString("label", label);

    LLRect rect;
    createRect(node, rect, parent, LLRect());

    LLFontGL* font = LLView::selectFont(node);

    // HACK: Font might not be specified.
    if (!font)
    {
        font = LLFontGL::getFontSansSerifSmall();
    }

    S32 label_width = 0;
    node->getAttributeS32("label_width", label_width);

    BOOL show_text = TRUE;
    node->getAttributeBOOL("show_text", show_text);

    BOOL can_edit_text = FALSE;
    node->getAttributeBOOL("can_edit_text", can_edit_text);

    BOOL volume = FALSE;
    node->getAttributeBOOL("volume", volume);

    F32 initial_value = 0.f;
    node->getAttributeF32("initial_val", initial_value);

    F32 min_value = 0.f;
    node->getAttributeF32("min_val", min_value);

    F32 max_value = 1.f;
    node->getAttributeF32("max_val", max_value);

    F32 increment = 0.1f;
    node->getAttributeF32("increment", increment);

    U32 precision = 3;
    node->getAttributeU32("decimal_digits", precision);

    S32 text_left = 0;
    if (show_text)
    {
        // calculate the size of the text box (log max_value is number of digits - 1 so plus 1)
        if ( max_value )
            text_left = font->getWidth(std::string("0")) * ( static_cast < S32 > ( log10  ( max_value ) ) + precision + 1 );

        if ( increment < 1.0f )
            text_left += font->getWidth(std::string("."));	// (mostly) take account of decimal point in value

        if ( min_value < 0.0f || max_value < 0.0f )
            text_left += font->getWidth(std::string("-"));	// (mostly) take account of minus sign

        // padding to make things look nicer
        text_left += 8;
    }

    LLUICtrlCallback callback = NULL;

    if (label.empty())
    {
        label.assign(node->getTextContents());
    }

    LLSliderCtrl* slider = new LLSliderCtrl(name,
                                            rect,
                                            label,
                                            font,
                                            label_width,
                                            rect.getWidth() - text_left,
                                            show_text,
                                            can_edit_text,
                                            volume,
                                            callback,
                                            NULL,
                                            initial_value,
                                            min_value,
                                            max_value,
                                            increment);

    slider->setPrecision(precision);

    slider->initFromXML(node, parent);

    slider->updateText();

    return slider;
}