XmlColorizer()
 {
     text::ColorEntry entry=GetCurrentTheme()->GetDefaultTextBoxColorEntry();
     SetDefaultColor(entry);
     
     entry.normal.text=Color(0, 128, 0);
     AddToken(L"/<!--([^/-]|-[^/-]|--[^>])*--/>", entry);
     
     entry.normal.text=Color(128, 0, 255);
     AddToken(L"/<!/[CDATA/[([^/]]|/][^/]]|/]/][^>])*/]/]/>", entry);
     
     entry.normal.text=Color(0, 0, 0);
     AddToken(L"\"[^\"]*\"", entry);
     
     entry.normal.text=Color(0, 0, 255);
     AddToken(L"[<>=]", entry);
     
     entry.normal.text=Color(255, 0, 0);
     AddToken(L"[a-zA-Z0-9_/-:]+", entry);
     
     entry.normal.text=Color(163, 21, 21);
     AddExtraToken(entry);
     
     Setup();
 }
 TextBoxPageWindow()
 :GuiWindow(GetCurrentTheme()->CreateWindowStyle())
 {
     this->SetText(L"Controls.Tab.TextBoxPage");
     this->GetBoundsComposition()->SetPreferredMinSize(Size(640, 480));
     
     // create a tab control
     tabControl=g::NewTab();
     tabControl->GetBoundsComposition()->SetAlignmentToParent(Margin(2, 2, 2, 2));
     this->AddChild(tabControl);
     
     // the first page is a control panel
     controlPanelPage=tabControl->CreatePage();
     controlPanelPage->SetText(L"Control Panel");
     
     // add a button to the control panel
     buttonAddPage=g::NewButton();
     buttonAddPage->SetText(L"Add a tab page");
     buttonAddPage->Clicked.AttachMethod(this, &TextBoxPageWindow::buttonAddPage_Clicked);
     controlPanelPage->GetContainerComposition()->SetInternalMargin(Margin(2, 2, 2, 2));
     controlPanelPage->GetContainerComposition()->AddChild(buttonAddPage->GetBoundsComposition());
     
     this->ForceCalculateSizeImmediately();
     this->MoveToScreenCenter();
 }
 ViewSwitchingWindow()
 :GuiWindow(GetCurrentTheme()->CreateWindowStyle())
 {
     this->SetText(L"Controls.ListView.ViewSwitching");
     
     GuiTableComposition* table=new GuiTableComposition;
     table->SetCellPadding(4);
     table->SetAlignmentToParent(Margin(0, 0, 0, 0));
     table->SetRowsAndColumns(2, 1);
     table->SetRowOption(0, GuiCellOption::MinSizeOption());
     table->SetRowOption(1, GuiCellOption::PercentageOption(1.0));
     table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0));
     {
         GuiCellComposition* cell=new GuiCellComposition;
         table->AddChild(cell);
         cell->SetSite(0, 0, 1, 1);
         
         GuiTextList* comboSource=g::NewTextList();
         comboSource->GetItems().Add(new list::TextItem(L"Big Icon"));
         comboSource->GetItems().Add(new list::TextItem(L"Small Icon"));
         comboSource->GetItems().Add(new list::TextItem(L"List"));
         comboSource->GetItems().Add(new list::TextItem(L"Detail"));
         comboSource->GetItems().Add(new list::TextItem(L"Tile"));
         comboSource->GetItems().Add(new list::TextItem(L"Information"));
         comboSource->SetHorizontalAlwaysVisible(false);
         
         comboView=g::NewComboBox(comboSource);
         comboView->SetSelectedIndex(0);
         comboView->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, -1, 0));
         comboView->GetBoundsComposition()->SetPreferredMinSize(Size(160, 0));
         comboView->SelectedIndexChanged.AttachMethod(this, &ViewSwitchingWindow::comboView_SelectedIndexChanged);
         cell->AddChild(comboView->GetBoundsComposition());
     }
     {
         GuiCellComposition* cell=new GuiCellComposition;
         table->AddChild(cell);
         cell->SetSite(1, 0, 1, 1);
         
         listView=g::NewListViewBigIcon();
         listView->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
         listView->SetHorizontalAlwaysVisible(false);
         listView->SetVerticalAlwaysVisible(false);
         listView->SetMultiSelect(true);
         cell->AddChild(listView->GetBoundsComposition());
     }
     this->GetBoundsComposition()->AddChild(table);
     FillData(listView);
     
     // set the preferred minimum client size
     this->GetBoundsComposition()->SetPreferredMinSize(Size(640, 480));
     // call this to calculate the size immediately if any indirect content in the table changes
     // so that the window can calcaulte its correct size before calling the MoveToScreenCenter()
     this->ForceCalculateSizeImmediately();
     // move to the screen center
     this->MoveToScreenCenter();
 }
Example #4
0
	CheckAndRadioWindow()
		:GuiWindow(GetCurrentTheme()->CreateWindowStyle())
	{
		this->SetText(L"Controls.Button.CheckAndRadio");
		// limit the size that the window should always show the whole content without cliping it
		this->GetContainerComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);

		// create a table to layout the 2 group boxes
		GuiTableComposition* table=new GuiTableComposition;
		// make the table to have 2 rows
		table->SetRowsAndColumns(1, 2);
		table->SetRowOption(0, GuiCellOption::MinSizeOption());
		table->SetColumnOption(0, GuiCellOption::PercentageOption(0.5));
		table->SetColumnOption(1, GuiCellOption::PercentageOption(0.5));
		// dock the table to fill the window
		table->SetAlignmentToParent(Margin(4, 4, 4, 4));
		table->SetCellPadding(6);
		// add the table to the window;
		this->GetContainerComposition()->AddChild(table);

		// add group box for check boxes
		{
			GuiCellComposition* cell=CreateButtons(L"Check Boxes", L"This is a check box ", true, 0);
			table->AddChild(cell);
			// this cell is the left cell
			cell->SetSite(0, 0, 1, 1);
		}

		// add group box for radio buttons
		{
			// create a group controller to group those radio buttons together
			// so that select a radio button will unselect the previous one automatically
			GuiSelectableButton::GroupController* groupController=new GuiSelectableButton::MutexGroupController;
			this->AddComponent(groupController);

			GuiCellComposition* cell=CreateButtons(L"Radio buttons", L"This is a radio button ", false, groupController);
			table->AddChild(cell);
			// this cell is the right cell
			cell->SetSite(0, 1, 1, 1);
		}

		// call this to calculate the size immediately if any indirect content in the table changes
		// so that the window can calcaulte its correct size before calling the MoveToScreenCenter()
		this->ForceCalculateSizeImmediately();
		// move to the screen center
		this->MoveToScreenCenter();
	}
Example #5
0
	Direct2DWindow()
		:GuiWindow(GetCurrentTheme()->CreateWindowStyle())
	{
		SetText(L"Rendering.RawAPI.Direct2D");
		SetClientSize(Size(640, 480));
		GetBoundsComposition()->SetPreferredMinSize(Size(640, 480));
		MoveToScreenCenter();
		{
			GuiDirect2DElement* element=GuiDirect2DElement::Create();
			element->Rendering.AttachMethod(this, &Direct2DWindow::element_Rendering);
			element->BeforeRenderTargetChanged.AttachMethod(this, &Direct2DWindow::element_BeforeRenderTargetChanged);
			element->AfterRenderTargetChanged.AttachMethod(this, &Direct2DWindow::element_AfterRenderTargetChanged);

			GuiBoundsComposition* composition=new GuiBoundsComposition;
			composition->SetAlignmentToParent(Margin(0, 0, 0, 0));
			composition->SetOwnedElement(element);
			GetContainerComposition()->AddChild(composition);
		}
	}
 CppColorizer()
 {
     text::ColorEntry entry=GetCurrentTheme()->GetDefaultTextBoxColorEntry();
     SetDefaultColor(entry);
     
     entry.normal.text=Color(128, 0, 255);
     AddToken(L"/d+(./d*)?([eE][+/-]?/d+)?", entry);
     
     entry.normal.text=Color(163, 21, 21);
     AddToken(L"\"([^\\\\\"]|\\\\/.)*\"", entry);
     
     entry.normal.text=Color(0, 128, 0);
     AddToken(L"////[^\r\n]*", entry);
     AddToken(L"///*(//|[*]*[^*//])*/*+//", entry);
     // debug this: L"//[*]([^*]|[*]+[^//])*[*]+//"
     
     entry.normal.text=Color(0, 0, 255);
     AddToken(L"#[a-zA-Z0-9_]*", entry);
     AddToken(CppKeywords, entry);
     
     AddToken(L"[a-zA-Z0-9_]+", GetDefaultColor());
     
     Setup();
 }
 IniColorizer()
 {
     text::ColorEntry entry=GetCurrentTheme()->GetDefaultTextBoxColorEntry();
     colors.Resize(5);
     
     // text color
     colors[NORMAL_COLOR]=entry;
     
     // section color
     entry.normal.text=Color(163, 21, 21);
     colors[SECTION_COLOR]=entry;
     
     // attribute color
     entry.normal.text=Color(255, 0, 0);
     colors[ATTRIBUTE_COLOR]=entry;
     
     // operator color
     entry.normal.text=Color(0, 0, 255);
     colors[OPERATOR_COLOR]=entry;
     
     // operator color
     entry.normal.text=Color(24, 128, 24);
     colors[COMMENT_COLOR]=entry;
 }
Example #8
0
File: Main.cpp Project: copyliu/gac
	TextBoxColorizerWindow()
		:GuiWindow(GetCurrentTheme()->CreateWindowStyle())
	{
		this->SetText(L"Controls.TextBox.Colorizer");
		this->GetContainerComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		this->WindowClosing.AttachMethod(this, &TextBoxColorizerWindow::window_WindowClosing);

		GuiTableComposition* table=new GuiTableComposition;
		table->SetAlignmentToParent(Margin(0, 0, 0, 0));
		table->SetCellPadding(2);
		table->SetRowsAndColumns(2, 3);
		table->SetRowOption(0, GuiCellOption::MinSizeOption());
		table->SetRowOption(1, GuiCellOption::PercentageOption(1.0));
		table->SetColumnOption(0, GuiCellOption::MinSizeOption());
		table->SetColumnOption(1, GuiCellOption::MinSizeOption());
		table->SetColumnOption(2, GuiCellOption::PercentageOption(1.0));
		this->GetContainerComposition()->AddChild(table);
		
		{
			GuiCellComposition* cell=new GuiCellComposition;
			table->AddChild(cell);
			cell->SetSite(0, 0, 1, 1);

			GuiLabel* label=g::NewLabel();
			label->SetText(L"Select a colorizer: ");
			label->GetBoundsComposition()->SetAlignmentToParent(Margin(0, -1, 0, 0));
			cell->AddChild(label->GetBoundsComposition());
		}
		{
			GuiCellComposition* cell=new GuiCellComposition;
			table->AddChild(cell);
			cell->SetSite(0, 1, 1, 1);
			// combo box doesn't have a minimum width, so set it to 150.
			cell->SetPreferredMinSize(Size(150, 0));

			// create a text list control.
			GuiTextList* listContent=g::NewTextList();
			// insert text items.
			listContent->GetItems().Add(L"INI colorizer");
			listContent->GetItems().Add(L"XML colorizer");
			listContent->GetItems().Add(L"C++ colorizer");

			// use the text list control to create a combo box.
			// items in the text list control will be the data source.
			// the text list control will be displayed in the combo box dropdown.
			comboSelector=g::NewComboBox(listContent);
			comboSelector->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
			comboSelector->SelectedIndexChanged.AttachMethod(this, &TextBoxColorizerWindow::comboSelector_SelectedIndexChanged);
			cell->AddChild(comboSelector->GetBoundsComposition());
		}
		{
			GuiCellComposition* cell=new GuiCellComposition;
			table->AddChild(cell);
			cell->SetSite(1, 0, 1, 3);

			textBox=g::NewMultilineTextBox();
			textBox->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
			cell->AddChild(textBox->GetBoundsComposition());
		}

		comboSelector->SetSelectedIndex(0);

		// set the preferred minimum client size
		this->GetBoundsComposition()->SetPreferredMinSize(Size(640, 480));
		// call this to calculate the size immediately if any indirect content in the table changes
		// so that the window can calcaulte its correct size before calling the MoveToScreenCenter()
		this->ForceCalculateSizeImmediately();
		// move to the screen center
		this->MoveToScreenCenter();
	}
 ColorPickerWindow()
 :GuiWindow(GetCurrentTheme()->CreateWindowStyle())
 {
     this->SetText(L"Controls.Scroll.ColorPicker");
     this->GetContainerComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
     
     GuiTableComposition* table=new GuiTableComposition;
     table->SetAlignmentToParent(Margin(0, 0, 0, 0));
     table->SetCellPadding(2);
     table->SetRowsAndColumns(4, 3);
     table->SetRowOption(0, GuiCellOption::PercentageOption(1.0));
     table->SetRowOption(1, GuiCellOption::MinSizeOption());
     table->SetRowOption(2, GuiCellOption::MinSizeOption());
     table->SetRowOption(3, GuiCellOption::MinSizeOption());
     table->SetColumnOption(0, GuiCellOption::MinSizeOption());
     table->SetColumnOption(1, GuiCellOption::AbsoluteOption(32));
     table->SetColumnOption(2, GuiCellOption::PercentageOption(1.0));
     this->GetContainerComposition()->AddChild(table);
     
     {
         colorElement=GuiSolidBackgroundElement::Create();
         
         GuiBoundsComposition* colorComposition=new GuiBoundsComposition;
         colorComposition->SetAlignmentToParent(Margin(0, 0, 0, 0));
         colorComposition->SetOwnedElement(colorElement);
         
         GuiCellComposition* cell=new GuiCellComposition;
         table->AddChild(cell);
         cell->SetSite(0, 0, 1, 3);
         cell->AddChild(colorComposition);
     }
     
     const wchar_t* labels[]={L"R: ", L"G: ", L"B: "};
     for(int i=0;i<3;i++)
     {
         {
             GuiLabel* label=g::NewLabel();
             label->SetText(labels[i]);
             label->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
             
             GuiCellComposition* cell=new GuiCellComposition;
             table->AddChild(cell);
             cell->SetSite(i+1, 0, 1, 1);
             cell->AddChild(label->GetBoundsComposition());
         }
         {
             labelComponents[i]=g::NewLabel();
             labelComponents[i]->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
             
             GuiCellComposition* cell=new GuiCellComposition;
             table->AddChild(cell);
             cell->SetSite(i+1, 1, 1, 1);
             cell->AddChild(labelComponents[i]->GetBoundsComposition());
         }
         {
             trackers[i]=g::NewHTracker();
             trackers[i]->SetTotalSize(255);
             trackers[i]->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
             trackers[i]->PositionChanged.AttachMethod(this, &ColorPickerWindow::Tracker_PositionChanged);
             
             GuiCellComposition* cell=new GuiCellComposition;
             table->AddChild(cell);
             cell->SetSite(i+1, 2, 1, 1);
             cell->AddChild(trackers[i]->GetBoundsComposition());
         }
     }
     
     UpdateColor();
     
     // set the preferred minimum client size
     this->GetBoundsComposition()->SetPreferredMinSize(Size(640, 480));
     // call this to calculate the size immediately if any indirect content in the table changes
     // so that the window can calcaulte its correct size before calling the MoveToScreenCenter()
     this->ForceCalculateSizeImmediately();
     // move to the screen center
     this->MoveToScreenCenter();
 }