JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkPageSetup_gtk_1page_1setup_1set_1right_1margin ( JNIEnv* env, jclass cls, jlong _self, jdouble _margin, jint _unit ) { GtkPageSetup* self; gdouble margin; GtkUnit unit; // convert parameter self self = (GtkPageSetup*) _self; // convert parameter margin margin = (gdouble) _margin; // convert parameter unit unit = (GtkUnit) _unit; // call function gtk_page_setup_set_right_margin(self, margin, unit); // cleanup parameter self // cleanup parameter margin // cleanup parameter unit }
static GtkPrintOperation *create_print_operation(GtkTextView *text_view) { GtkPrintOperation *op; static GtkPageSetup *page_setup = NULL; op = gtk_print_operation_new(); if (settings) gtk_print_operation_set_print_settings(op, settings); if (!page_setup) { page_setup = gtk_page_setup_new(); gtk_page_setup_set_top_margin(page_setup, 25.0, GTK_UNIT_MM); gtk_page_setup_set_bottom_margin(page_setup, 20.0, GTK_UNIT_MM); gtk_page_setup_set_left_margin(page_setup, 20.0, GTK_UNIT_MM); gtk_page_setup_set_right_margin(page_setup, 20.0, GTK_UNIT_MM); } gtk_print_operation_set_default_page_setup(op, page_setup); g_signal_connect(op, "begin-print", G_CALLBACK(cb_begin_print), text_view); g_signal_connect(op, "draw-page", G_CALLBACK(cb_draw_page), NULL); g_signal_connect(op, "end-print", G_CALLBACK(cb_end_print), NULL); return op; }
static VALUE rg_set_right_margin(VALUE self, VALUE margin, VALUE unit) { gtk_page_setup_set_right_margin(_SELF(self), NUM2DBL(margin), RVAL2GTKUNIT(unit)); return self; }
/* attribute double unwriteableMarginRight; */ NS_IMETHODIMP nsPrintSettingsGTK::SetUnwriteableMarginRight(double aUnwriteableMarginRight) { nsPrintSettings::SetUnwriteableMarginRight(aUnwriteableMarginRight); gtk_page_setup_set_right_margin(mPageSetup, NS_TWIPS_TO_INCHES(mUnwriteableMargin.right), GTK_UNIT_INCH); return NS_OK; }
/** * NOTE: Need a custom set of SetUnwriteableMargin functions, because * whenever we change mUnwriteableMargin, we must pass the change * down to our GTKPageSetup object. (This is needed in order for us * to give the correct default values in nsPrintDialogGTK.) * * It's important that the following functions pass * mUnwriteableMargin values rather than aUnwriteableMargin values * to gtk_page_setup_set_[blank]_margin, because the two may not be * the same. (Specifically, negative values of aUnwriteableMargin * are ignored by the nsPrintSettings::SetUnwriteableMargin functions.) */ NS_IMETHODIMP nsPrintSettingsGTK::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) { nsPrintSettings::SetUnwriteableMarginInTwips(aUnwriteableMargin); gtk_page_setup_set_top_margin(mPageSetup, NS_TWIPS_TO_INCHES(mUnwriteableMargin.top), GTK_UNIT_INCH); gtk_page_setup_set_left_margin(mPageSetup, NS_TWIPS_TO_INCHES(mUnwriteableMargin.left), GTK_UNIT_INCH); gtk_page_setup_set_bottom_margin(mPageSetup, NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom), GTK_UNIT_INCH); gtk_page_setup_set_right_margin(mPageSetup, NS_TWIPS_TO_INCHES(mUnwriteableMargin.right), GTK_UNIT_INCH); return NS_OK; }
/* Dia has it's own thing */ static void _dia_to_gtk_page_setup (const DiagramData *data, GtkPageSetup *setup) { GtkPaperSize *paper_size; const double points_per_cm = 28.346457; const PaperInfo *paper = &(data->paper); int index = find_paper (paper->name); if (index < 0) index = get_default_paper (); paper_size = gtk_paper_size_new_from_ppd ( paper->name, paper->name, get_paper_pswidth (index) * points_per_cm, get_paper_psheight (index) * points_per_cm); gtk_page_setup_set_orientation (setup, data->paper.is_portrait ? GTK_PAGE_ORIENTATION_PORTRAIT : GTK_PAGE_ORIENTATION_LANDSCAPE); gtk_page_setup_set_paper_size (setup, paper_size); gtk_page_setup_set_left_margin (setup, data->paper.lmargin * 10, GTK_UNIT_MM); gtk_page_setup_set_top_margin (setup, data->paper.tmargin * 10, GTK_UNIT_MM); gtk_page_setup_set_right_margin (setup, data->paper.rmargin * 10, GTK_UNIT_MM); gtk_page_setup_set_bottom_margin (setup, data->paper.bmargin * 10, GTK_UNIT_MM); }
void XAP_UnixDialog_Print::setupPrint() { double blockMrgnLeft, blockMrgnRight, mrgnTop, mrgnBottom, mrgnLeft, mrgnRight = 0.; double width, height; bool portrait; m_pView = static_cast<FV_View*>(m_pFrame->getCurrentView()); m_pPO = gtk_print_operation_new(); // // Set filename if it's not present already // std::string sURI = m_pView->getDocument()->getPrintFilename(); if(sURI.empty()) { const std::string & filename = m_pView->getDocument()->getFilename(); if(!filename.empty()) { sURI = filename; UT_addOrReplacePathSuffix(sURI, ".pdf"); } } if(!sURI.empty()) { GtkPrintSettings * pSettings = gtk_print_settings_new(); gtk_print_settings_set(pSettings, GTK_PRINT_SETTINGS_OUTPUT_URI, sURI.c_str() ); gtk_print_operation_set_print_settings(m_pPO,pSettings); g_object_unref(pSettings); } s_getPageMargins(m_pView, blockMrgnLeft, blockMrgnRight, mrgnLeft, mrgnRight, mrgnTop, mrgnBottom); portrait = m_pView->getPageSize().isPortrait(); width = m_pView->getPageSize().Width (DIM_MM); height = m_pView->getPageSize().Height (DIM_MM); m_pPageSetup = gtk_page_setup_new(); const char * pszName = m_pView->getPageSize().getPredefinedName(); bool isPredefined = false; const char * pszGtkName = NULL; if(pszName == NULL) { } else if(g_ascii_strcasecmp(pszName,"Custom") == 0) { } else if(g_ascii_strcasecmp(pszName,"A0") == 0) { isPredefined = true; pszGtkName = "iso_a0"; } else if(g_ascii_strcasecmp(pszName,"A1") == 0) { isPredefined = true; pszGtkName = "iso_a1"; } else if(g_ascii_strcasecmp(pszName,"A2") == 0) { isPredefined = true; pszGtkName = "iso_a2"; } else if(g_ascii_strcasecmp(pszName,"A3") == 0) { isPredefined = true; pszGtkName = "iso_a3"; } else if(g_ascii_strcasecmp(pszName,"A4") == 0) { isPredefined = true; pszGtkName = "iso_a4"; } else if(g_ascii_strcasecmp(pszName,"A5") == 0) { isPredefined = true; pszGtkName = "iso_a5"; } else if(g_ascii_strcasecmp(pszName,"A6") == 0) { isPredefined = true; pszGtkName = "iso_a6"; } else if(g_ascii_strcasecmp(pszName,"A7") == 0) { isPredefined = true; pszGtkName = "iso_a7"; } else if(g_ascii_strcasecmp(pszName,"A8") == 0) { isPredefined = true; pszGtkName = "iso_a8"; } else if(g_ascii_strcasecmp(pszName,"A9") == 0) { isPredefined = true; pszGtkName = "iso_a9"; } else if(g_ascii_strcasecmp(pszName,"B0") == 0) { isPredefined = true; pszGtkName = "iso_b0"; } else if(g_ascii_strcasecmp(pszName,"B1") == 0) { isPredefined = true; pszGtkName = "iso_b1"; } else if(g_ascii_strcasecmp(pszName,"B2") == 0) { isPredefined = true; pszGtkName = "iso_b2"; } else if(g_ascii_strcasecmp(pszName,"B3") == 0) { isPredefined = true; pszGtkName = "iso_b3"; } else if(g_ascii_strcasecmp(pszName,"B4") == 0) { isPredefined = true; pszGtkName = "iso_b4"; } else if(g_ascii_strcasecmp(pszName,"B4") == 0) { isPredefined = true; pszGtkName = "iso_b4"; } else if(g_ascii_strcasecmp(pszName,"B5") == 0) { isPredefined = true; pszGtkName = "iso_b5"; } else if(g_ascii_strcasecmp(pszName,"B6") == 0) { isPredefined = true; pszGtkName = "iso_b6"; } else if(g_ascii_strcasecmp(pszName,"B7") == 0) { isPredefined = true; pszGtkName = "iso_b7"; } else if(g_ascii_strcasecmp(pszName,"Legal") == 0) { isPredefined = true; pszGtkName = "na_legal"; } else if(g_ascii_strcasecmp(pszName,"Letter") == 0) { isPredefined = true; pszGtkName = "na_letter"; } if(isPredefined) { m_pGtkPageSize = gtk_paper_size_new(static_cast<const gchar *>(pszGtkName)); } else { /* * Width() and Height() will return the paper size as shown in the UI. * Gtk wants the real paper size, however, and will swap the two * itself when we specify the orientation. */ m_pGtkPageSize = gtk_paper_size_new_custom("custom", "custom", portrait ? width : height, portrait ? height : width, GTK_UNIT_MM); } // // Set the Page Size // gtk_page_setup_set_paper_size(m_pPageSetup,m_pGtkPageSize); // // Set the margins // gtk_page_setup_set_top_margin(m_pPageSetup,mrgnTop,GTK_UNIT_INCH); gtk_page_setup_set_bottom_margin(m_pPageSetup,mrgnBottom,GTK_UNIT_INCH); gtk_page_setup_set_left_margin(m_pPageSetup,mrgnLeft,GTK_UNIT_INCH); gtk_page_setup_set_right_margin(m_pPageSetup,mrgnRight,GTK_UNIT_INCH); // // Set orientation // if( portrait) gtk_page_setup_set_orientation(m_pPageSetup,GTK_PAGE_ORIENTATION_PORTRAIT); else gtk_page_setup_set_orientation(m_pPageSetup,GTK_PAGE_ORIENTATION_LANDSCAPE); gtk_print_operation_set_default_page_setup(m_pPO,m_pPageSetup); gtk_print_operation_set_use_full_page (m_pPO, true); m_pDL = m_pView->getLayout(); m_iCurrentPage = m_pDL->findPage(m_pView->getCurrentPage()); m_iNumberPages = (gint) m_pDL->countPages(); gtk_print_operation_set_current_page(m_pPO,m_iCurrentPage); g_signal_connect (m_pPO, "begin_print", G_CALLBACK (s_Begin_Print), this); g_signal_connect (m_pPO, "draw_page", G_CALLBACK (s_Print_Page), this); }