Hi,
The document says that the trans arguement in the PpPrintWidget() call
would affect only the widget and not the entire page ( when discussing
about the Pp_PC_SOURCE_OFFSET member of the PrintContext]. But, I found
that setting the trans arguement for printing one widget with
PpPrintWidget() also affects the positioning of the other widgets which
are printed in the same page.
Is this the way it is supposed to work (Have I misunderstood the document
?] or Is this a bug?
Here is the code.
#include <stdio.h>
#include <stdlib.h>
#include <Pt.h>
#include <errno.h>
PtWidget_t *pane, *window;
PpPrintContext_t *pc;
PtWidget_t *print, *quit,*but,*txt;
PhArea_t text_area = { {35, 20}, {130,30} };
PhArea_t but_area = { {35, 70}, {100,30} };
int quit_cb ( PtWidget_t *widget, void *data,
PtCallbackInfo_t *cbinfo)
{
PpReleasePC (pc);
exit (EXIT_SUCCESS);
return (Pt_CONTINUE);
}
int print_cb ( PtWidget_t *widget, void *data,
PtCallbackInfo_t *cbinfo)
{
int action;
int ret;
PhPoint_t pos = {0,0};
/* You could make these calls to PpSetPC() right
after creating the print context. Having it here
lets you reuse the print context. */
PhDim_t size = { 850, 1100 };
ret = PpSetPC(pc, Pp_PC_SOURCE_SIZE, &size, 0);
if(ret !=0)
printf(“Errno is = %s \n”,strerror(errno));
fflush(stdout);
action = PtPrintSelection(window, NULL,
“Demo Print Selector”, pc,
Pt_PRINTSEL_DFLT_LOOK);
if (action != Pt_PRINTSEL_CANCEL)
{
PpStartJob(pc);
PpContinueJob(pc);
/* Print the widget. */
//------------------------------------------------------------------------------
pos.x = text_area.pos.x - 200;
PpPrintWidget(pc,quit,NULL, NULL,Pt_PP_NO_RESIZE );
// PpPrintWidget(pc,txt, NULL, NULL, Pt_PP_NO_RESIZE);
PpPrintWidget(pc,txt,&pos , NULL, Pt_PP_NO_RESIZE);
PpPrintWidget(pc,print,NULL,NULL,Pt_PP_NO_RESIZE);
//-------------------------------------------------------------------------------
/* Close the print context. */
PpSuspendJob(pc);
PpEndJob(pc);
}
return (Pt_CONTINUE);
}
int main(int argc, char *argv[])
{
PtArg_t args[4];
PhDim_t win_dim = { 300, 300 };
PhArea_t pane_area = { {0, 0}, {200, 150} };
PhArea_t print_area = { {30, 170}, {60, 20} };
PhArea_t quit_area = { {110, 170}, {60, 20} };
PhPoint_t pos = {35,20};
PtCallback_t callbacks[2] = { {print_cb, NULL},
{quit_cb, NULL} };
if (PtInit(NULL) == -1)
PtExit(EXIT_FAILURE);
/* Create the main window. */
PtSetArg (&args[0], Pt_ARG_DIM, &win_dim, 0);
PtSetArg (&args[1], Pt_ARG_WINDOW_TITLE,
“Print Example”, 0);
if ((window = PtCreateWidget(PtWindow, Pt_NO_PARENT,
2, args)) == NULL)
PtExit(EXIT_FAILURE);
/* Create a print context. */
pc = PpCreatePC();
/* Create the pane to be printed. */
PtSetArg (&args[0], Pt_ARG_AREA, &pane_area, 0);
pane = PtCreateWidget (PtPane, window, 1, args);
/* put some stuff in the pane to be printed. */
//PtSetArg(&args[0],Pt_ARG_POS,&pos,0);
PtSetArg(&args[0],Pt_ARG_AREA,&text_area,0);
PtSetArg(&args[1],Pt_ARG_TEXT_STRING,“Are you seeing this”,0);
txt = PtCreateWidget(PtText,pane,2,args);
PtSetArg(&args[0],Pt_ARG_AREA,&but_area,0);
PtSetArg(&args[1],Pt_ARG_TEXT_STRING,“Button”,0);
PtSetArg(&args[2],Pt_ARG_COLOR,Pg_BLUE,0);
but = PtCreateWidget(PtButton,pane,3,args);
/* Create the print button. */
PtSetArg(&args[0], Pt_ARG_AREA, &print_area, 0);
PtSetArg(&args[1], Pt_ARG_TEXT_STRING, “Print”, 0);
PtSetArg(&args[2], Pt_CB_ACTIVATE, &callbacks[0], 0);
print = PtCreateWidget (PtButton, window, 3, args);
/* Create the quit button. */
PtSetArg(&args[0], Pt_ARG_AREA, &quit_area, 0);
PtSetArg(&args[1], Pt_ARG_TEXT_STRING, “Quit”, 0);
PtSetArg(&args[2], Pt_CB_ACTIVATE, &callbacks[1], 0);
quit = PtCreateWidget (PtButton, window, 3, args);
PtRealizeWidget(window);
PtMainLoop();
return (EXIT_SUCCESS);
}
TIA
Rajan