static void page_scale_get(double *hscale, double *vscale) { ewl_pdf_scale_get(EWL_PDF(pdfwidget), hscale, vscale); switch(epdf_page_orientation_get(EWL_PDF(pdfwidget)->pdf_page)) { case EPDF_PAGE_ORIENTATION_LANDSCAPE: case EPDF_PAGE_ORIENTATION_SEASCAPE: SWAP(double, hscale, vscale); } }
static void page_size_get(int *width, int *height) { epdf_page_size_get(EWL_PDF(pdfwidget)->pdf_page, width, height); switch(epdf_page_orientation_get(EWL_PDF(pdfwidget)->pdf_page)) { case EPDF_PAGE_ORIENTATION_LANDSCAPE: case EPDF_PAGE_ORIENTATION_SEASCAPE: SWAP(int, width, height); } }
/** * @param pdf: the pdf widget to get the orientation of * @return Returns the orientation of the document. * @brief get the orientation of the document @p pdf. If @p pdf * is NULL, return EPDF_PAGE_ORIENTATION_PORTRAIT */ Epdf_Page_Orientation ewl_pdf_orientation_get(Ewl_Pdf *pdf) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(pdf, EPDF_PAGE_ORIENTATION_PORTRAIT); DCHECK_TYPE_RET(pdf, EWL_PDF_TYPE, EPDF_PAGE_ORIENTATION_PORTRAIT); if (!pdf->pdf_page) DRETURN_INT(EPDF_PAGE_ORIENTATION_PORTRAIT, DLEVEL_STABLE); DRETURN_INT(epdf_page_orientation_get(pdf->pdf_page), DLEVEL_STABLE); }
/** * @param pdf: the pdf to change the orientation * @param o: the orientation * @return Returns no value. * @brief Set an orientation of the document * * Sets an orientation @p o of the document */ void ewl_pdf_orientation_set(Ewl_Pdf *pdf, Epdf_Page_Orientation o) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(pdf); DCHECK_TYPE(pdf, EWL_PDF_TYPE); if (!pdf->pdf_page || (epdf_page_orientation_get(pdf->pdf_page) == o)) DRETURN(DLEVEL_STABLE); pdf->dirty = 1; epdf_page_orientation_set(pdf->pdf_page, o); ewl_widget_configure(EWL_WIDGET(pdf)); DLEAVE_FUNCTION(DLEVEL_STABLE); }
void resize_and_rescale(double scale) { int docwidth,docheight; double docscale; double ltrimpct=0.0,rtrimpct=0.0; int sp_inner_w = CURRENT_W(scrollpane) - INSET_HORIZONTAL(scrollpane) - PADDING_HORIZONTAL(scrollpane); int sp_inner_h = CURRENT_H(scrollpane) - INSET_VERTICAL(scrollpane) - PADDING_VERTICAL(scrollpane); hide_hint(NULL); page_size_get(&docwidth, &docheight); int orientation_horizontal; switch(epdf_page_orientation_get(EWL_PDF(pdfwidget)->pdf_page)) { case EPDF_PAGE_ORIENTATION_PORTRAIT: case EPDF_PAGE_ORIENTATION_UPSIDEDOWN: orientation_horizontal = 0; break; case EPDF_PAGE_ORIENTATION_LANDSCAPE: case EPDF_PAGE_ORIENTATION_SEASCAPE: orientation_horizontal = 1; } if(fitmode==0) { if(orientation_horizontal) docscale = ((double)sp_inner_h)/((double)docheight)*scale; else // orientation vertical docscale = ((double)sp_inner_w)/((double)docwidth)*scale; } else if(fitmode==1) { ltrimpct=((double)get_settings()->ltrimpad)/((double)docwidth); rtrimpct=((double)get_settings()->rtrimpad)/((double)docwidth); docscale=((double)sp_inner_w)/((1.0-leftmarge+ltrimpct-rightmarge+rtrimpct)*((double)docwidth))*scale; } ewl_pdf_scale_set(EWL_PDF(pdfwidget),docscale,docscale); ewl_object_custom_w_set(EWL_OBJECT(pdfwidget),floor(((double)docwidth)*docscale)); ewl_object_custom_h_set(EWL_OBJECT(pdfwidget),floor(((double)docheight)*docscale)); ewl_widget_configure(pdfwidget); if(orientation_horizontal) { ewl_object_custom_w_set(EWL_OBJECT(trimpane), floor(((double)docwidth)*docscale)); ewl_object_custom_h_set(EWL_OBJECT(trimpane), floor(((double)sp_inner_h)*scale)); } else { ewl_object_custom_w_set(EWL_OBJECT(trimpane), floor(((double)sp_inner_w)*scale)); ewl_object_custom_h_set(EWL_OBJECT(trimpane), floor(((double)docheight)*docscale)); } ewl_object_position_request(EWL_OBJECT(trimpane),0,0); ewl_widget_configure(trimpane); ewl_widget_configure(scrollpane); if(fitmode==0) ewl_scrollpane_hscrollbar_value_set(EWL_SCROLLPANE(trimpane),0.0); else if(fitmode==1) ewl_scrollpane_hscrollbar_value_set(EWL_SCROLLPANE(trimpane),(leftmarge-ltrimpct)/(leftmarge-ltrimpct+rightmarge-rtrimpct)); }