Пример #1
0
void GeometryListView::OnEditGeometry() 
// Called when user clicks "Edit" in the geometry list.
{
	// Figure out which geometry item to edit.
	int	index = GetSelectedItemIndex();
	if (index < 0) {
		// No item selected, so we don't know what to delete...
		return;
	}
	if (index == 0) {
		// Can't edit null geometry.
		return;
	}

	// Get the geometry object to edit.
	Geometry*	g = GetDocument()->GetGeometry(index);
	if (g == NULL) return;

	// Call edit dialog box.
	GeometryPropertiesDialog d;
	d.SetName(g->GetName());
	d.SetFilename(g->GetFilename()); 
	d.SetComment(g->GetComment());

	if (d.DoModal() != IDCANCEL) {
		// Apply the changes.
		g->SetName(d.GetName());
		g->SetFilename(d.GetFilename());
		g->SetComment(d.GetComment());

		GetDocument()->SetModifiedFlag();
		GetDocument()->UpdateAllViews(NULL);
	}
}
Пример #2
0
void GeometryListView::OnAddNewGeometry() 
// Called when user clicks "New Geometry" button.
{
	// Call the properties dialog box with some default initial values.
	GeometryPropertiesDialog d;
	d.SetName("Untitled");
	d.SetFilename("Unknown");
	d.SetComment("");

	if (d.DoModal() != IDCANCEL) {
		// Create a new geometry item with the new values, and add it to our list.
		Geometry*	g = new Geometry;

		g->SetName(d.GetName());
		g->SetFilename(d.GetFilename());
		g->SetComment(d.GetComment());

		GetDocument()->AddGeometry(g);
		GetDocument()->SetModifiedFlag();

		GetDocument()->UpdateAllViews(NULL);
	}
}