Esempio n. 1
0
// general purpose return code, true by default, false in case of some failure
bool UI::drawPage(uint16_t id) {
	m_page = id;
	m_butCount = 0;
	switch (id) {
		case PAGE_INIT: return pageInit();
		case PAGE_MAIN: pageMain(); break;
		case PAGE_MEASURE: pageMeasure(); break;
		case PAGE_MONITOR: pageMonitor(); break;
		case PAGE_SETTINGS: pageSettings(); break;
		case PAGE_CALIBRATE: pageCalibrate(); break;
		case PAGE_WLAN: pageWLAN(); break;
	}
	return true;
}
//------------------------------------------------------------------------------
void WBPrintOperation::on_begin_print(const Glib::RefPtr<Gtk::PrintContext>& ctx)
{
  app_PageSettingsRef pageSettings(workbench_DocumentRef::cast_from(_diagram.get_grt()->get("/wb/doc"))->pageSettings());
  app_PaperTypeRef paperType(pageSettings->paperType());

  update_gtk_page_setup_from_grt(_page_setup, pageSettings, true);

  Gtk::PaperSize gpaperSize(_page_setup->get_paper_size());

  set_default_page_setup(_page_setup);
  set_print_settings(_print_settings);
  set_track_print_status();

  // page settings in cairo coordinates
  float paperWidth= (*paperType->width() * *pageSettings->scale());
  float paperHeight= (*paperType->height() * *pageSettings->scale());
  float marginLeft= (*pageSettings->marginLeft() * *pageSettings->scale());
  float marginRight= (*pageSettings->marginRight() * *pageSettings->scale());
  float marginTop= (*pageSettings->marginTop() * *pageSettings->scale());
  float marginBottom= (*pageSettings->marginBottom() * *pageSettings->scale());

  if (pageSettings->orientation() == "landscape")
  {
    std::swap(paperWidth, paperHeight);
    std::swap(marginLeft, marginTop);
    std::swap(marginRight, marginBottom);
  }

  // size of the printable area in cairo coords
  base::Size pageSize;
  pageSize.width= paperWidth - marginLeft - marginRight;
  pageSize.height= paperHeight - marginTop - marginBottom;
  
  _printer= new mdc::CanvasViewExtras(_diagram->get_data()->get_canvas_view());
  
  // margins are already added by the system
  _printer->set_page_margins(marginTop, marginLeft, marginBottom, marginRight);
  _printer->set_paper_size(paperWidth, paperHeight);
  //    _printer->set_orientation(pageSettings->orientation()=="landscape"?mdc::Landscape:mdc::Portrait);
  //
  
  _printer->set_print_border(true);

  set_n_pages(wbprint::getPageCount(_diagram));
  wbprint::getPageLayout(_diagram, _xpages, _ypages);
}
Esempio n. 3
0
BMessage* 
PrinterDriver::ConfigPage(BMessage* settings)
{
	DBGMSG((">%s: config_page\n", GetDriverName()));
	DUMP_BMESSAGE(settings);
	DUMP_BNODE(fSpoolFolder);
	
	BMessage pageSettings(*settings);
	_MergeWithPreviousSettings(kAttrPageSettings, &pageSettings);
	UIDriver uiDriver(&pageSettings, fPrinterData, fPrinterCap);
	BMessage *result = uiDriver.ConfigPage();
	_WriteSettings(kAttrPageSettings, result);

	DUMP_BMESSAGE(result);
	DBGMSG(("<%s: config_page\n", GetDriverName()));
	return result;
}