Ejemplo n.º 1
0
void PhotoPrintOperation::CalcLayout(Glib::RefPtr<Gtk::PageSetup> PageSetup) {
	PaperArea.X=0;
	PaperArea.Y=0;
	PaperArea.Width=PageSetup->get_paper_width(Gtk::UNIT_POINTS)*CairoScale;
	PaperArea.Height=PageSetup->get_paper_height(Gtk::UNIT_POINTS)*CairoScale;

	PrintArea.X=std::max(
			PageSetup->get_left_margin(Gtk::UNIT_POINTS)*CairoScale,
			PageSetup->get_right_margin(Gtk::UNIT_POINTS)*CairoScale);
	PrintArea.Width=PaperArea.Width-2*PrintArea.X;

	PrintArea.Y=std::max(
		PageSetup->get_top_margin(Gtk::UNIT_POINTS)*CairoScale,
		PageSetup->get_bottom_margin(Gtk::UNIT_POINTS)*CairoScale);
	PrintArea.Height=PaperArea.Height-2*PrintArea.Y;

	LabelArea.X=LabelArea.Y=LabelArea.Width=LabelArea.Height=0;
	if (Label) {
		LabelArea.Width=Label->get_width();
		LabelArea.Height=Label->get_height();
		LabelArea.X=PaperArea.Width-PrintArea.X-LabelArea.Width;
		LabelArea.Y=PrintArea.Y;
	}

	float Padding=PhotoPadding*std::max(PrintArea.Width,PrintArea.Height);

	PhotosArea.X=PrintArea.X;
	PhotosArea.Y=PrintArea.Y;
	PhotosArea.Width=PrintArea.Width-LabelArea.Width;
	if (Label)
		PhotosArea.Width-=Padding;
	PhotosArea.Height=PrintArea.Height;

	float Width=(PhotosArea.Width-Padding)/2.0;
	float Height=(PhotosArea.Height-Padding)/2.0;
	for (int Row=0; Row<2; Row++) {
		for (int Col=0; Col<2; Col++) {
			PhotoArea[Col+Row*2].X=PhotosArea.X+Col*(Width+Padding);
			PhotoArea[Col+Row*2].Y=PhotosArea.Y+Row*(Height+Padding);
			PhotoArea[Col+Row*2].Width=Width;
			PhotoArea[Col+Row*2].Height=Height;
		}
	}
}