Example #1
0
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));
}
Example #2
0
/**
 * @param s: The separator to set the orientation on
 * @param o: The orientation to set on the separator
 * @return Returns no value
 * @brief Set the orientation of the separator
 */
void
ewl_separator_orientation_set(Ewl_Separator *s, Ewl_Orientation o)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(s);
        DCHECK_TYPE(s, EWL_SEPARATOR_TYPE);

        if (s->orientation == o)
                DRETURN(DLEVEL_STABLE);

        s->orientation = o;

        if (o == EWL_ORIENTATION_HORIZONTAL) {
                ewl_widget_appearance_set(EWL_WIDGET(s), "hseparator");
                ewl_object_fill_policy_set(EWL_OBJECT(s),
                                           EWL_FLAG_FILL_HFILL |
                                           EWL_FLAG_FILL_HSHRINKABLE);
        }
        else {
                ewl_widget_appearance_set(EWL_WIDGET(s), "vseparator");
                ewl_object_fill_policy_set(EWL_OBJECT(s),
                                           EWL_FLAG_FILL_VFILL |
                                           EWL_FLAG_FILL_VSHRINKABLE);
        }

        ewl_widget_configure(EWL_WIDGET(s));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #3
0
/**
 * @param sp: The Ewl_Spectrum to set the hsv value into
 * @param h: The hue to set
 * @param s: The saturation to set
 * @param v: The value to set
 * @return Returns no value
 * @brief Set the HSV values for the spectrum
 */
void
ewl_spectrum_hsv_set(Ewl_Spectrum *sp, double h, double s, double v)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(sp);
        DCHECK_TYPE(sp, EWL_SPECTRUM_TYPE);

        sp->hsv.h = h;
        sp->hsv.s = s;
        sp->hsv.v = v;

        if (sp->hsv.h > 360) sp->hsv.h = 360.0;
        if (sp->hsv.h <= 0) sp->hsv.h = 360.0;

        if (sp->hsv.s > 1.0) sp->hsv.s = 1.0;
        if (sp->hsv.s < 0.0) sp->hsv.s = 0.0;

        if (sp->hsv.v > 1.0) sp->hsv.v = 1.0;
        if (sp->hsv.v < 0.0) sp->hsv.v = 0.0;

        ewl_spectrum_rgb_from_hsv(sp);
        sp->dirty = TRUE;
        ewl_widget_configure(EWL_WIDGET(sp));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #4
0
void
widget_select( Ewler_Widget *w )
{
	w->selected = true;

	ewl_widget_state_set(w->fg, "default");
	ewl_widget_configure(w->fg);
}
Example #5
0
void
widget_deselect( Ewler_Widget *w )
{
	w->selected = false;

	ewl_widget_state_set(w->fg, "deselect");
	ewl_widget_configure(w->fg);

	widget_clear_ui_hooks(w);
}
Example #6
0
/**
 * @param sp: The Ewl_Spectrum to set the type on
 * @param type: The type to set the spectrum too
 * @return Returns no value
 * @brief Set the type of the spectrum
 */
void
ewl_spectrum_type_set(Ewl_Spectrum *sp, Ewl_Spectrum_Type type)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(sp);
        DCHECK_TYPE(sp, EWL_SPECTRUM_TYPE);

        sp->type = type;
        ewl_widget_configure(EWL_WIDGET(sp));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #7
0
/**
 * @param sp: The Ewl_Spectrum to set the mode on
 * @param mode: The mode to set the spectrum too
 * @return Returns no value.
 * @brief Set the mode of the spectrum
 */
void
ewl_spectrum_mode_set(Ewl_Spectrum *sp, Ewl_Color_Mode mode)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(sp);
        DCHECK_TYPE(sp, EWL_SPECTRUM_TYPE);

        sp->mode = mode;
        sp->dirty = TRUE;
        ewl_widget_configure(EWL_WIDGET(sp));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #8
0
File: ewl_dvi.c Project: Limsik/e17
/**
 * @param dvi: the dvi 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_dvi_orientation_set(Ewl_Dvi *dvi, Edvi_Page_Orientation o)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(dvi);
        DCHECK_TYPE(dvi, EWL_DVI_TYPE);

        if (!dvi->dvi_page || (edvi_page_orientation_get(dvi->dvi_page) == o))
                DRETURN(DLEVEL_STABLE);

        dvi->dirty = 1;
        edvi_page_orientation_set(dvi->dvi_page, o);
        ewl_widget_configure(EWL_WIDGET(dvi));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #9
0
File: ewl_ps.c Project: Limsik/e17
/**
 * @param ps: the ps 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_ps_orientation_set(Ewl_Ps *ps, Eps_Page_Orientation o)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(ps);
        DCHECK_TYPE(ps, EWL_PS_TYPE);

        if (!ps->ps_page || (eps_page_orientation_get(ps->ps_page) == o))
                DLEAVE_FUNCTION(DLEVEL_STABLE);

        ps->dirty = 1;
        eps_page_orientation_set(ps->ps_page, o);
        ewl_widget_configure(EWL_WIDGET(ps));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #10
0
/**
 * @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);
}
Example #11
0
/**
 * @param t: The toolbar to set the orientation on
 * @param o: The orientation to set on the toolbar
 * @return Returns no value
 * @brief Set the orientation of the toolbar
 */
void
ewl_toolbar_orientation_set(Ewl_Toolbar *t, Ewl_Orientation o)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(t);
        DCHECK_TYPE(t, EWL_TOOLBAR_TYPE);

        ewl_menubar_orientation_set(EWL_MENUBAR(t), o);
        if (o == EWL_ORIENTATION_HORIZONTAL)
                ewl_widget_appearance_set(EWL_WIDGET(t), "htoolbar");
        else
                ewl_widget_appearance_set(EWL_WIDGET(t), "vtoolbar");

        ewl_widget_configure(EWL_WIDGET(t));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #12
0
/**
 * @param b: The Ewl_Border to set the label position on
 * @param pos: The Ewl_Position to set on for the label.
 * @return Returns no value.
 * @brief Sets the position of the label in the border container
 */
void
ewl_border_label_position_set(Ewl_Border *b, Ewl_Position pos)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(b);
        DCHECK_TYPE(b, EWL_BORDER_TYPE);

        if (b->label_position == pos) 
                DRETURN(DLEVEL_STABLE);

        b->label_position = pos;
        switch (b->label_position) {
                case EWL_POSITION_LEFT:
                case EWL_POSITION_RIGHT:
                        ewl_box_orientation_set(EWL_BOX(b),
                                                EWL_ORIENTATION_HORIZONTAL);
                        break;

                case EWL_POSITION_TOP:
                case EWL_POSITION_BOTTOM:
                default:
                        ewl_box_orientation_set(EWL_BOX(b),
                                                EWL_ORIENTATION_VERTICAL);
                        break;
        }
        ewl_widget_appearance_set(EWL_WIDGET(b), EWL_BORDER_TYPE);

        /* need to remove the redirect so the label gets added back into the
         * border and not into the body. We put the redirect back on after
         */
        ewl_container_redirect_set(EWL_CONTAINER(b), NULL);
        ewl_container_child_remove(EWL_CONTAINER(b), b->label);

        if ((b->label_position == EWL_POSITION_LEFT)
                        || (b->label_position == EWL_POSITION_TOP))
                ewl_container_child_prepend(EWL_CONTAINER(b), b->label);
        else
                ewl_container_child_append(EWL_CONTAINER(b), b->label);

        ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body));
        ewl_widget_configure(EWL_WIDGET(b));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #13
0
File: ewl_dvi.c Project: Limsik/e17
/**
 * @param dvi: the dvi to change the magnification
 * @param mag: the magnification
 * @return Returns no value.
 * @brief Set the magnification of the document
 *
 * Sets the magnification @p mag of the document @p dvi
 */
void
ewl_dvi_mag_set(Ewl_Dvi *dvi, double mag)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(dvi);
        DCHECK_TYPE(dvi, EWL_DVI_TYPE);

        if (!dvi->dvi_page)
                DRETURN(DLEVEL_STABLE);

        if (mag == edvi_page_mag_get(dvi->dvi_page))
                DRETURN(DLEVEL_STABLE);

        dvi->dirty = 1;
        edvi_page_mag_set(dvi->dvi_page, mag);
        ewl_widget_configure(EWL_WIDGET(dvi));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #14
0
File: ewl_dvi.c Project: Limsik/e17
/**
 * @param dvi: the dvi to set the page of
 * @param page:  the page number
 * @return Returns no value.
 * @brief Set the page of the document
 *
 * Sets the page of the document @p dvi to @p page
 */
void ewl_dvi_page_set(Ewl_Dvi *dvi, int page)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(dvi);
        DCHECK_TYPE(dvi, EWL_DVI_TYPE);

        if (!dvi->dvi_document ||
            !dvi->dvi_page ||
            (page < 0) ||
            (page >= edvi_document_page_count_get(dvi->dvi_document)) ||
            (page == edvi_page_page_get(dvi->dvi_page)))
                DRETURN(DLEVEL_STABLE);

        dvi->dirty = 1;
        edvi_page_page_set(dvi->dvi_page, page);
        ewl_widget_configure(EWL_WIDGET(dvi));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #15
0
File: ewl_ps.c Project: Limsik/e17
/**
 * @param ps: the ps to set the page of
 * @param page: the page number
 * @return Returns no value.
 * @brief Set the page of the document
 *
 * Sets the page of the document @p ps to @p page
 */
void
ewl_ps_page_set(Ewl_Ps *ps, int page)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(ps);
        DCHECK_TYPE(ps, EWL_PS_TYPE);

        if (!ps->ps_document ||
            !ps->ps_page ||
            (page < 0) ||
            (page >= eps_document_page_count_get(ps->ps_document)) ||
            (page == eps_page_page_get(ps->ps_page)))
                DLEAVE_FUNCTION(DLEVEL_STABLE);

        ps->dirty = 1;
        eps_page_page_set(ps->ps_page, page);
        ewl_widget_configure(EWL_WIDGET(ps));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #16
0
/**
 * @param pdf the pdf to set the page of
 * @param page:  the page number
 * @return Returns no value.
 * @brief Set the page of the document
 *
 * Sets the page of the document @p pdf to @p page
 */
void
ewl_pdf_page_set(Ewl_Pdf *pdf, int page)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(pdf);
        DCHECK_TYPE(pdf, EWL_PDF_TYPE);

        if (!pdf->pdf_document ||
            !pdf->pdf_page ||
            (page < 0) ||
            (page >= epdf_document_page_count_get(pdf->pdf_document)) ||
            (page == epdf_page_page_get(pdf->pdf_page)))
                DRETURN(DLEVEL_STABLE);

        pdf->dirty = 1;
        epdf_page_page_set(pdf->pdf_page, page);
        ewl_widget_configure(EWL_WIDGET(pdf));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #17
0
/**
 * @param sp: The Ewl_Spectrum to set the colour into
 * @param r: The red value to set
 * @param g: The green value to set
 * @param b: The blue value to set
 * @return Returns no value
 * @brief Set the RGB values for the spectrum
 */
void
ewl_spectrum_rgb_set(Ewl_Spectrum *sp, unsigned int r,
                        unsigned int g, unsigned int b)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(sp);
        DCHECK_TYPE(sp, EWL_SPECTRUM_TYPE);

        sp->rgb.r = r;
        sp->rgb.g = g;
        sp->rgb.b = b;

        if (sp->rgb.r > 255) sp->rgb.r = 255;
        if (sp->rgb.g > 255) sp->rgb.g = 255;
        if (sp->rgb.b > 255) sp->rgb.b = 255;

        ewl_spectrum_hsv_from_rgb(sp);
        sp->dirty = TRUE;
        ewl_widget_configure(EWL_WIDGET(sp));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #18
0
/**
 * @param pdf: the pdf to change the scale
 * @param hscale: the horizontal scale
 * @param vscale: the vertical scale
 * @return Returns no value.
 * @brief Set the scale of the document
 *
 * Sets the horizontal scale @p hscale and the vertical scale @p vscale
 * of the document @p pdf
 */
void
ewl_pdf_scale_set(Ewl_Pdf *pdf, double hscale, double vscale)
{
        double hs;
        double vs;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(pdf);
        DCHECK_TYPE(pdf, EWL_PDF_TYPE);

        if (!pdf->pdf_page)
                DRETURN(DLEVEL_STABLE);

        epdf_page_scale_get(pdf->pdf_page, &hs, &vs);
        if ((hs == hscale) && (vs == vscale))
                DRETURN(DLEVEL_STABLE);

        pdf->dirty = 1;
        epdf_page_scale_set(pdf->pdf_page, hscale, vscale);
        ewl_widget_configure(EWL_WIDGET(pdf));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Example #19
0
File: madpdf.c Project: 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));
}