void resize_and_rescale(double scale) { int docwidth,docheight; double docscale; int sp_inner; double ltrimpct=0.0,rtrimpct=0.0; //ewl_object_maximum_h_set(EWL_OBJECT(pdfwidget),99999); //ewl_object_minimum_h_set(EWL_OBJECT(pdfwidget),0); sp_inner=CURRENT_W(scrollpane)-INSET_HORIZONTAL(scrollpane)-PADDING_HORIZONTAL(scrollpane); //if(EWL_SCROLLPANE(scrollpane)->vflag) // sp_inner-=CURRENT_W(EWL_OBJECT(EWL_SCROLLPANE(scrollpane)->vscrollbar)); //ewl_pdf_size_get(EWL_PDF(pdfwidget),&docwidth,&docheight); epdf_page_size_get (EWL_PDF(pdfwidget)->pdf_page,&docwidth,&docheight); if(fitmode==0) docscale=((double)sp_inner)/((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)/((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)sp_inner)*scale)); //ewl_object_custom_w_set(EWL_OBJECT(pdfwidget),floor(((double)sp_inner)*scale)); //ewl_object_custom_h_set(EWL_OBJECT(pdfwidget),floor(((double)docheight)/((double)docwidth)*((double)sp_inner)*scale)); 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_object_position_request(EWL_OBJECT(pdfwidget),0,0); ewl_widget_configure(pdfwidget); //ewl_object_custom_w_set(EWL_OBJECT(trimpane),floor(((double)docwidth)*docscale)); //ewl_object_custom_h_set(EWL_OBJECT(trimpane),floor(((double)docheight)*docscale)); ewl_object_custom_w_set(EWL_OBJECT(trimpane),floor(((double)sp_inner)*scale)); ewl_object_custom_h_set(EWL_OBJECT(trimpane),floor(((double)docheight)*docscale)); ewl_object_position_request(EWL_OBJECT(trimpane),0,0); //ewl_object_place(EWL_OBJECT(pdfwidget),0,0,floor(((double)docwidth)*docscale),floor(((double)docheight)*docscale)); 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)); }
static void move_hscrollbar(Ewl_Scrollpane *s, double direction) { double rel, abs; get_horizontal_pan_inc(&rel, &abs); rel *= direction; ewl_scrollpane_hscrollbar_value_set(s, scroll_pos_add(ewl_scrollpane_hscrollbar_value_get(s), rel)); update_statusbar(); }
/* Swap scrollbar values after an orientation change. * direction == -1 -> turn clockwise, 1 -> counter-clockwise. */ static void turn_scrollbars(Ewl_Scrollpane *s, int direction) { double h = from_scroll_position(ewl_scrollpane_hscrollbar_value_get(s)); double v = from_scroll_position(ewl_scrollpane_vscrollbar_value_get(s)); double new_h = v * direction; double new_v = -h * direction; ewl_scrollpane_hscrollbar_value_set(s, to_scroll_position(new_h)); ewl_scrollpane_vscrollbar_value_set(s, to_scroll_position(new_v)); update_statusbar(); }
static void move_hscrollbar(Ewl_Scrollpane *s, double amount) { ewl_scrollpane_hscrollbar_value_set(s, clamp(0.0, ewl_scrollpane_hscrollbar_value_get(s) + amount, 1.0)); update_statusbar(); }
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)); }