//This method allows the user to quickly and easily create new windows. It
// returns a pointer to the newly added window, to allow for easy manipulation.
Window* Container::InstantiateWindow(float x, float y, float width, float height, std::string windowText) {
	
	//Create the base window
	this->AddChild(new Window(x, y, width, height, this, rendering, bottomLeft));
	Element* currentWindow = this->children[childCount - 1];
	currentWindow->draggable = false;

	//Add a close button
	currentWindow->AddChild(new Button(0, 0, 30, 30,
		currentWindow,
		rendering, 1, this, topRight));
	currentWindow->children[0]->draggable = false;

	//Add a title bar
	if (windowText != "") {
		currentWindow->AddChild(new Textbox(-1.0f, -1.0f, 2.0f, 30, 
											currentWindow, 
											windowText, 
											rendering,
											titleFont,
											topLeft));
		currentWindow->children[1]->draggable = true;
	}
	else
	{
		currentWindow->AddChild(new Window(-1.0f, 1.0f, 2.0f, 30, currentWindow,
			rendering, topLeft));
		currentWindow->children[1]->draggable = true;
	}

	return (Window*)currentWindow;
}
Exemplo n.º 2
0
TEST(DomTreeTest, DomTreeInitTest)
{
    LOG_INFO << "pid = " << getpid() << " begin to run";
    EXPECT_FALSE(false);

    Node* head = new Text("html");
    Element* p = new Element("a");
    p->AddAttr("href", "http://abc/");
    p->AddAttr("color", "yellow");
    Node* txt = new Text("def");
    Node* txt2 = new Text("Head");

    head->AddChild(p);
    p->AddChild(txt);
    head->AddChild(txt2);

    ostringstream oss;
    head->ToString(oss, 0);
    LOG_INFO << "\n" << oss.str();
    string out(
            "html\n"
            "--Tagname is a Key colorValue yellow Key hrefValue http://abc/\n"
            "----def\n"
            "--Head\n");
    ASSERT_EQ(out, oss.str());

    delete head;
    delete p;
    delete txt;
    delete txt2;

}