Boxed Groups

Boxed groups, as the name implies are simply a group that in addition to maintaining a group, also maintains a rectangle that implicitly resizes whenever children are added to or removed from the group.

The following contains an example that adds several shapes to a boxed group, then rotates the entire group by 45 degrees counter-clockwise.

boxed.png

Boxed group and shapes drawn by example code below

Boxed::pointer example_boxed(bool fill, bool outline) {
  // Create a boxed group to contain several shapes
  Papyrus::Boxed::pointer boxed = Papyrus::Boxed::create( );
  if (fill) boxed->get_box()->set_fill( Cairo::SolidPattern::create_rgba(1.0, 0.85, 1.0, 0.9) );
  if (outline) boxed->get_box()->set_outline( Cairo::SolidPattern::create_rgba(1.0, 0.0, 1.0, 0.9) );

  // Create some shapes to add to the boxed group
  Papyrus::Rectangle::pointer rectangle = example_rectangle( );
  Papyrus::Circle::pointer circle = example_circle( );
  Papyrus::Arc::pointer arc = example_arc( );

  // Add the shapes to the boxed group
  boxed->add( rectangle );
  boxed->add( circle );
  boxed->add( arc );

  // Translate the shapes and adjust size so they don't necessarily overlap
  rectangle->set_xywh(0, -60, 50, 30);
  circle->set_translate(40, 20);
  circle->set_radius(25);
  arc->set_translate(0, 20);

  return boxed;
}

Generated on Sun Mar 11 10:01:28 2007 by  doxygen 1.5.1