Ejemplo n.º 1
0
double get_vertical_pan_inc()
{
    double hs=(double)CURRENT_H(scrollpane);
    double ht=(double)CURRENT_H(trimpane);
    if(ht<=hs)
        return 0.0;
    return ((double)get_settings()->vpan)*hs/(100.0*(ht-hs));
}
Ejemplo n.º 2
0
Archivo: madpdf.c Proyecto: avm/madpdf
void update_statusbar()
{
    static char statlabel1str[100];
    sprintf(statlabel1str,"MadPDF (OK for Menu)");
    ewl_label_text_set(EWL_LABEL(statlabel1),statlabel1str);
    
    int curpage,totalpage;
    curpage=ewl_pdf_page_get(EWL_PDF(pdfwidget))+1;
    totalpage=epdf_document_page_count_get(ewl_pdf_pdf_document_get(EWL_PDF(pdfwidget)));
    
    static char statlabel2str[100];
    sprintf(statlabel2str,"pg: %d/%d  zoom: %d%%  ",curpage,totalpage,(int)round(curscale*100.0));
    double hpos,vpos;
    int leftarr=0,rightarr=0,downarr=0,uparr=0;
    if(CURRENT_W(trimpane)>CURRENT_W(scrollpane))
    {
        hpos=ewl_scrollpane_hscrollbar_value_get(EWL_SCROLLPANE(scrollpane));
        if(hpos>0.0)
        {
            leftarr=1;
        }
        if(hpos<1.0)
        {
            rightarr=1;    
        }
        
    }
    if(CURRENT_H(trimpane)>CURRENT_H(scrollpane))
    {
        vpos=ewl_scrollpane_vscrollbar_value_get(EWL_SCROLLPANE(scrollpane));
        if(vpos>0.0)
        {
            uparr=1;
        }
        if(vpos<1.0)
        {
            downarr=1;    
        }
        
    }
    if(leftarr||rightarr||downarr||uparr)
        strcat(statlabel2str,"pan: ");
    else
        strcat(statlabel2str,"pan: none");
    if(leftarr)
        strcat(statlabel2str,"←");
    if(rightarr)
        strcat(statlabel2str,"→");
    if(downarr)
        strcat(statlabel2str,"↓");
    if(uparr)
        strcat(statlabel2str,"↑");
    ewl_label_text_set(EWL_LABEL(statlabel2),statlabel2str);
}
Ejemplo n.º 3
0
static EWL_CALLBACK_DEFN(fg_mouse_down)
{
	Ewler_Widget *ewler_w = user_data;
	Ewl_Embed *embed;
	Ewl_Event_Mouse_Down *ev = ev_data;
	bool multi;

	if( !ewler_w->selectable ||
			widget_under_cursor )
		return;

	widget_under_cursor = true;

	ewler_w->mouse.state |= EWLER_WIDGET_MOUSE_DOWN;
	ewler_w->mouse.button = ev->button;
	ewler_w->mouse.state_x = ev->x;
	ewler_w->mouse.state_y = ev->y;

	ewler_w->corners.x = CURRENT_X(w);
	ewler_w->corners.y = CURRENT_Y(w);
	ewler_w->corners.u = CURRENT_X(w) + CURRENT_W(w);
	ewler_w->corners.v = CURRENT_Y(w) + CURRENT_H(w);

	if( ev->modifiers & (EWL_KEY_MODIFIER_CTRL | EWL_KEY_MODIFIER_SHIFT) )
		multi = true;
	else
		multi = false;

	if( ev->button == 1 && multi ) {
		form_toggle(ewler_w);
	} else if( ev->button == 1 ||
						 (!multi && !ecore_list_count(form_selected())) ) {
		Ecore_List *selected;

		selected = form_selected();
		if( selected &&
				(ecore_list_count(selected) != 1 ||
				 ecore_list_first_goto(selected) != ewler_w) ) {
			form_deselect_all();
			form_select(ewler_w);
		}
	}

	IF_FREE(ewler_w->source);

	embed = ewl_embed_widget_find(w);
	evas_event_feed_mouse_down(embed->evas, ev->button, EVAS_BUTTON_NONE,
														 0, NULL);
}
Ejemplo n.º 4
0
Archivo: madpdf.c Proyecto: avm/madpdf
static void display_hint(double scroll_amount)
{
    if(!scroll_hint) {
        Ewl_Embed *emb = ewl_embed_widget_find(pdfwidget);
        scroll_hint = evas_object_line_add(emb->canvas);
        evas_object_color_set(scroll_hint, 0, 200, 0, 255);
    }

    int y_coord = round(scroll_amount);
    if(y_coord < 0) {
        y_coord += CURRENT_H(scrollpane);
    }
    evas_object_line_xy_set(scroll_hint,
            0, y_coord, CURRENT_W(scrollpane), y_coord);
    evas_object_show(scroll_hint);

    if(hint_timer) { // previously set, did not fire
        ecore_timer_del(hint_timer);
    }
    hint_timer = ecore_timer_add(2.0, hide_hint, NULL);
}
Ejemplo n.º 5
0
Archivo: madpdf.c Proyecto: avm/madpdf
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));
}
Ejemplo n.º 6
0
Archivo: madpdf.c Proyecto: avm/madpdf
void get_vertical_pan_inc(double *rel, double *abs)
{
    double hs=(double)CURRENT_H(scrollpane);
    double ht=(double)CURRENT_H(trimpane);
    pan_inc(ht, hs, rel, abs);
}