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();
 }
 void comboView_SelectedIndexChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 {
     switch(comboView->GetSelectedIndex())
     {
         case 0:
             listView->ChangeItemStyle(new list::ListViewBigIconContentProvider);
             break;
         case 1:
             listView->ChangeItemStyle(new list::ListViewSmallIconContentProvider);
             break;
         case 2:
             listView->ChangeItemStyle(new list::ListViewListContentProvider);
             break;
         case 3:
             listView->ChangeItemStyle(new list::ListViewDetailContentProvider);
             break;
         case 4:
             listView->ChangeItemStyle(new list::ListViewTileContentProvider);
             break;
         case 5:
             listView->ChangeItemStyle(new list::ListViewInformationContentProvider);
             break;
     }
 }
Пример #3
0
	void comboSelector_SelectedIndexChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
	{
		comboSelector->SetEnabled(false);
		this->GetBoundsComposition()->SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::LargeWaiting));

		GetApplication()->InvokeAsync(Curry<void(TextBoxColorizerWindow*)>([](TextBoxColorizerWindow* window)
		{
			Ptr<GuiTextBoxColorizerBase> colorizer;
			WString text;

			switch(window->comboSelector->GetSelectedIndex())
			{
			case 0:
				text=
					L";This is a comment\r\n"
					L"[Section1]\r\n"
					L"Name=John Smith\r\n"
					L"ID=008\r\n"
					L"\r\n"
					L"[Section2]\r\n"
					L"Name=Kyon\r\n"
					L"ID=009\r\n"
					;
				break;
			case 1:
				text=
					L"<books>\r\n"
					L"\t<!--Comment-->\r\n"
					L"\t<book name=\"C++Primer\">\r\n"
					L"\t\tContent\r\n"
					L"\t</book>\r\n"
					L"\t<![CDATA[<xml/>]]>\r\n"
					L"</books>\r\n"
					;
				break;
			case 2:
				text=
					L"#include <iostream>\r\n"
					L"using namespace std;\r\n"
					L"\r\n"
					L"int main()\r\n"
					L"{\r\n"
					L"\t//This is a comment\r\n"
					L"\t/**This*is/another\r\n"
					L"\tcomment**/\r\n"
					L"\tcout<<\"Hello, world!\"<<endl;\r\n"
					L"\treturn 0;\r\n"
					L"}\r\n"
					;
				break;
			}

			GetApplication()->InvokeInMainThreadAndWait([text, window]()
			{
				window->textBox->SetColorizer(0);
				window->textBox->SetText(text);
			});

			switch(window->comboSelector->GetSelectedIndex())
			{
			case 0:
				colorizer=new IniColorizer;
				break;
			case 1:
				colorizer=new XmlColorizer;
				break;
			case 2:
				colorizer=new CppColorizer;
				break;
			}

			GetApplication()->InvokeInMainThreadAndWait([colorizer, window]()
			{
				window->textBox->SetColorizer(colorizer);
				window->GetBoundsComposition()->SetAssociatedCursor(GetCurrentController()->ResourceService()->GetDefaultSystemCursor());
				window->comboSelector->SetEnabled(true);
			});
		})(this));
	}
Пример #4
0
	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();
	}
Пример #5
0
	void window_WindowClosing(GuiGraphicsComposition* sender, GuiRequestEventArgs& arguments)
	{
		arguments.cancel=!comboSelector->GetEnabled();
	}