コード例 #1
0
ファイル: Main.cpp プロジェクト: DaZhu/gac
	void AddBorderCell(int row, int column, int rowSpan, int columnSpan, INativeWindowListener::HitTestResult hitTestResult)
	{
		GuiCellComposition* cell=new GuiCellComposition;
		boundsComposition->AddChild(cell);
		cell->SetSite(row, column, rowSpan, columnSpan);
		cell->SetAssociatedHitTestResult(hitTestResult);
	}
コード例 #2
0
ファイル: Main.cpp プロジェクト: DaZhu/gac
	GuiButton* AddTitleButton(int column, Color titleBackgroundColor, Color titleForegroundColor)
	{
		GuiCellComposition* cell=new GuiCellComposition;
		boundsComposition->AddChild(cell);
		cell->SetSite(1, column, 1, 1);

		GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create();
		element->SetColor(titleBackgroundColor);
		cell->SetOwnedElement(element);

		GuiButton* button=new GuiButton(new CustomTemplateWindowButtonStyle(titleForegroundColor));
		button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3));
		cell->AddChild(button->GetBoundsComposition());
		return button;
	}
コード例 #3
0
ファイル: Main.cpp プロジェクト: DaZhu/gac
	GuiBoundsComposition* AddTitleCell(int column, INativeWindowListener::HitTestResult hitTestResult, Color titleBackgroundColor)
	{
		GuiCellComposition* cell=new GuiCellComposition;
		boundsComposition->AddChild(cell);
		cell->SetSite(1, column, 1, 1);

		GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create();
		element->SetColor(titleBackgroundColor);
		cell->SetOwnedElement(element);

		GuiBoundsComposition* composition=new GuiBoundsComposition;
		composition->SetAlignmentToParent(Margin(0, 0, 0, 0));
		composition->SetPreferredMinSize(Size(SystemIconSize, SystemIconSize));
		composition->SetAssociatedHitTestResult(hitTestResult);
		cell->AddChild(composition);

		return composition;
	}
コード例 #4
0
ファイル: Main.cpp プロジェクト: DaZhu/gac
	void SetText(const WString& value)override
	{
		titleElement->SetText(value);
		boundsComposition->ForceCalculateSizeImmediately();
	}
コード例 #5
0
ファイル: Main.cpp プロジェクト: DaZhu/gac
	CustomTemplateWindowStyle()
		:window(0)
	{
		Color borderColor(0, 122, 204);
		Color titleBackgroundColor(45, 45, 48);
		Color backgroundColor(30, 30, 30);
		Color titleColor(153, 153, 153);

		boundsComposition=new GuiTableComposition;
		boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		boundsComposition->SetRowsAndColumns(4, 7);
		boundsComposition->SetRowOption(0, GuiCellOption::AbsoluteOption(5));
		boundsComposition->SetRowOption(1, GuiCellOption::MinSizeOption());
		boundsComposition->SetRowOption(2, GuiCellOption::PercentageOption(1.0));
		boundsComposition->SetRowOption(3, GuiCellOption::AbsoluteOption(5));
		boundsComposition->SetColumnOption(0, GuiCellOption::AbsoluteOption(5));
		boundsComposition->SetColumnOption(1, GuiCellOption::MinSizeOption());
		boundsComposition->SetColumnOption(2, GuiCellOption::PercentageOption(1.0));
		boundsComposition->SetColumnOption(3, GuiCellOption::MinSizeOption());
		boundsComposition->SetColumnOption(4, GuiCellOption::MinSizeOption());
		boundsComposition->SetColumnOption(5, GuiCellOption::MinSizeOption());
		boundsComposition->SetColumnOption(6, GuiCellOption::AbsoluteOption(5));
		{
			GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create();
			element->SetColor(borderColor);
			boundsComposition->SetOwnedElement(element);
		}
		AddBorderCell(0, 0, 1, 1, INativeWindowListener::BorderLeftTop);
		AddBorderCell(0, 6, 1, 1, INativeWindowListener::BorderRightTop);
		AddBorderCell(3, 0, 1, 1, INativeWindowListener::BorderLeftBottom);
		AddBorderCell(3, 6, 1, 1, INativeWindowListener::BorderRightBottom);
		AddBorderCell(1, 0, 2, 1, INativeWindowListener::BorderLeft);
		AddBorderCell(1, 6, 2, 1, INativeWindowListener::BorderRight);
		AddBorderCell(0, 1, 1, 5, INativeWindowListener::BorderTop);
		AddBorderCell(3, 1, 1, 5, INativeWindowListener::BorderBottom);
		{
			{
				iconComposition=AddTitleCell(1, INativeWindowListener::Icon, titleBackgroundColor);
				iconComposition->SetAlignmentToParent(Margin(3, 3, 3, 3));

				Ptr<INativeImage> icon=GetCurrentController()->ImageService()->CreateImageFromFile(GetApplication()->GetExecutableFolder()+L"..\\Resources\\BigDoc.png");
				iconElement=GuiImageFrameElement::Create();
				iconElement->SetImage(icon, 0);
				iconElement->SetStretch(true);
				iconComposition->SetOwnedElement(iconElement);
			}
			{
				titleComposition=AddTitleCell(2, INativeWindowListener::Title, titleBackgroundColor);
				titleComposition->SetAlignmentToParent(Margin(0, 3, 3, 3));

				titleElement=GuiSolidLabelElement::Create();
				titleElement->SetColor(titleColor);
				titleElement->SetAlignments(Alignment::Left, Alignment::Center);
				titleComposition->SetOwnedElement(titleElement);
			}
			{
				minimumButton=AddTitleButton(3, titleBackgroundColor, titleColor);
				minimumButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3));
				minimumButton->Clicked.AttachMethod(this, &CustomTemplateWindowStyle::minimumButton_Clicked);
			}
			{
				maximumButton=AddTitleButton(4, titleBackgroundColor, titleColor);
				maximumButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3));
				maximumButton->Clicked.AttachMethod(this, &CustomTemplateWindowStyle::maximumButton_Clicked);
			}
			{
				closeButton=AddTitleButton(5, titleBackgroundColor, titleColor);
				closeButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3));
				closeButton->Clicked.AttachMethod(this, &CustomTemplateWindowStyle::closeButton_Clicked);
			}
		}
		{
			GuiCellComposition* cell=new GuiCellComposition;
			boundsComposition->AddChild(cell);
			cell->SetSite(2, 1, 1, 5);
			cell->SetAssociatedHitTestResult(INativeWindowListener::Client);

			containerComposition=new GuiBoundsComposition;
			containerComposition->SetAlignmentToParent(Margin(0, 0, 0, 0));
			cell->AddChild(containerComposition);

			GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create();
			element->SetColor(backgroundColor);
			containerComposition->SetOwnedElement(element);
		}
	}
コード例 #6
0
ファイル: APlayerWindow.cpp プロジェクト: wyrover/MusicPlayer
void APlayerWindow::initWindows()
{
	const int iRows = 6;
	const int iColumns = 3;
	int cControls = 0;
	// limit the size that the window should always show the whole content without cliping it
	this->GetContainerComposition()->
		SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
	GuiTableComposition* table = new GuiTableComposition;
	table->SetRowsAndColumns(iRows, iColumns);
	for (int i = 0; i < iRows; ++i) {
		table->SetRowOption(i, GuiCellOption::PercentageOption(0.5));
	}
	for (int j = 0; j < iColumns; ++j) {
		table->SetColumnOption(j, GuiCellOption::PercentageOption(0.5));
	}

	table->SetAlignmentToParent(Margin(4, 4, 4, 4));
	table->SetCellPadding(6);

	this->GetContainerComposition()->AddChild(table);

	//add the play button
	{
		GuiCellComposition* cell = new GuiCellComposition;
		table->AddChild(cell);
		//this cell is the top cell
		int _row = cControls % iRows;
		int _col = cControls / iRows;
		cControls++;
		cell->SetSite(_row, _col, 1, 1);

		buttonPlay = g::NewButton();
		buttonPlay->SetText(L"Play");
		buttonPlay->GetBoundsComposition()->
			SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		buttonPlay->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
		buttonPlay->Clicked.AttachMethod(this,
			&APlayerWindow::buttonPlay_OnClick);
		cell->AddChild(buttonPlay->GetBoundsComposition());
	}
	// add the pause button
	{
		GuiCellComposition* cell = new GuiCellComposition;
		table->AddChild(cell);
		//this cell is the top cell
		int _row = cControls % iRows;
		int _col = cControls / iRows;
		cControls++;
		cell->SetSite(_row, _col, 1, 1);

		buttonPause = g::NewButton();
		buttonPause->SetText(L"Pause");
		buttonPause->GetBoundsComposition()->
			SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		buttonPause->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
		buttonPause->Clicked.AttachMethod(this,
			&APlayerWindow::buttonPause_OnClick);
		cell->AddChild(buttonPause->GetBoundsComposition());
	}
	// add the next button
	{
		GuiCellComposition* cell = new GuiCellComposition;
		table->AddChild(cell);
		//this cell is the top cell
		int _row = cControls % iRows;
		int _col = cControls / iRows;
		cControls++;
		cell->SetSite(_row, _col, 1, 1);

		buttonNext = g::NewButton();
		buttonNext->SetText(L"Next");
		buttonNext->GetBoundsComposition()->
			SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		buttonNext->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
		buttonNext->GetBoundsComposition()->SetBounds(Rect(0, 0, 100, 100));
		buttonNext->Clicked.AttachMethod(this,
			&APlayerWindow::buttonNext_OnClick);
		cell->AddChild(buttonNext->GetBoundsComposition());
	}
	// add the addmusic button
	{
		GuiCellComposition* cell = new GuiCellComposition;
		table->AddChild(cell);
		//this cell is the top cell
		int _row = cControls % iRows;
		int _col = cControls / iRows;
		cControls++;
		cell->SetSite(_row, _col, 1, 1);

		buttonAddMusic = g::NewButton();
		buttonAddMusic->SetText(L"Add");
		buttonAddMusic->GetBoundsComposition()->
			SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		buttonAddMusic->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
		buttonAddMusic->GetBoundsComposition()->SetBounds(Rect(0, 0, 100, 100));
		buttonAddMusic->Clicked.AttachMethod(this,
			&APlayerWindow::buttonAddMusic_OnClick);
		cell->AddChild(buttonAddMusic->GetBoundsComposition());
	}
	// add the show lyricform button
	{
		GuiCellComposition* cell = new GuiCellComposition;
		table->AddChild(cell);
		//this cell is the top cell
		int _row = cControls % iRows;
		int _col = cControls / iRows;
		cControls++;
		cell->SetSite(_row, _col, 1, 1);

		buttonLyric = g::NewButton();
		buttonLyric->SetText(L"Lyric");
		buttonLyric->GetBoundsComposition()->
			SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		buttonLyric->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
		buttonLyric->GetBoundsComposition()->SetBounds(Rect(0, 0, 100, 100));
		buttonLyric->Clicked.AttachMethod(this,
			&APlayerWindow::buttonLyric_OnClick);
		cell->AddChild(buttonLyric->GetBoundsComposition());
	}
	//init lyric form
	{
		lyricform = CreateLyricFormController();
	}
	this->ForceCalculateSizeImmediately();
	this->MoveToScreenCenter();
}