getting the canvas of iupplot and print it

new topic     » topic index » view thread      » older message » newer message

hi,

it driving me nuts. i can't get the canvas or image if iupplot and print it.

my application plots just fine, but i need to print the plot. so i took from pete's samples

function item_print_action_cb(Ihandle /*item_print*/) 
--Ihandle canvas = IupGetDialogChild(item_print, "CANVAS") 
imImage image 
--string title = IupGetAttribute(IupGetDialog(item_print), "TITLE") 
string title = IupGetAttribute(dlg, "TITLE") 
cdCanvan print_canvas = cdCreateCanvas(CD_PRINTER, "%s -d", {title}) 
    if print_canvas=NULL then 
        return IUP_DEFAULT 
    end if 
 
    -- do NOT draw the background, use the paper color 
 
    -- draw the image at the center of the canvas 
    image = IupGetInt(canvas, "IMAGE") 
    if image!=NULL then 
        integer x, y, canvas_width, canvas_height, view_width, view_height 
        atom canvas_width_mm, canvas_height_mm 
--      Ihandle config = IupGetInt(canvas, "CONFIG") 
        integer margin_width = IupConfigGetVariableInt(config, "Print", "MarginWidth", 20) 
        integer margin_height = IupConfigGetVariableInt(config, "Print", "MarginHeight", 20) 
 
        {canvas_width, canvas_height, canvas_width_mm, canvas_height_mm} = cdCanvasGetSize(print_canvas) 
 
        -- convert to pixels 
        margin_width = floor((margin_width*canvas_width)/canvas_width_mm) 
        margin_height = floor((margin_height*canvas_height)/canvas_height_mm) 
 
        {view_width, view_height} = view_fit_rect(canvas_width-2*margin_width, 
                                                  canvas_height-2*margin_height, 
                                                  im_width(image), im_height(image)) 
 
        x = (canvas_width-view_width)/2 
        y = (canvas_height-view_height)/2 
 
        cdCanvasPutImImage(print_canvas, image, x, y, view_width, view_height) 
    end if 
 
    cdKillCanvas(print_canvas) 
    return IUP_DEFAULT 
end function 

and tried to use it on iupplot. if tried

IupPlotPaintTo(plot, print_canvas)

or

image = IupGetInt(plot, "CANVAS")

but nothing works. is there anyone who knows how to do that? yes, i searched the iup c samples.

thanks

richard

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu