/************************************************************************ * PrintOutputPageUp ************************************************************************/ Boolean PrintOutputPageUp(PrintOutput *pOutput) { XmTextPosition top_before, top_after; Boolean retval; #ifdef USE_DTEDITOR DtEditorGoToLine( pOutput->editor, pOutput->currentLine - pOutput->linesPerPage ); pOutput->currentLine -= pOutput->linesPerPage; if (pOutput->currentLine < 1) { pOutput->currentLine = 1; retval = FALSE; } #else top_before = (XmTextPosition) _poGetTopPosition(pOutput); XmTextScroll(pOutput->editor, -1 * pOutput->linesPerPage); top_after = (XmTextPosition) _poGetTopPosition(pOutput); retval = (top_before > top_after) ? TRUE : FALSE; #endif return retval; }
/****adjusttext()*************************************************************/ void adjusttext(int iadjust) { #ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/ if(Lquiet==0) /*was Lcommanded before 990402*/ { XmTextScroll(textwindow,iadjust); } #endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/ /*this should NOT do any scrolling unless reach bottom of text window*/ /*so needs to check height and lines available, etc... */ }
DtMailBoolean DmxPrintOutput::pageDown () { XmTextPosition top_before, top_after; #ifdef USE_DTEDITOR return DTM_FALSE; #else top_before = XmTextGetTopCharacter(_editor); XmTextScroll(_editor, _lines_per_page); top_after = XmTextGetTopCharacter(_editor); return (top_before < top_after) ? DTM_TRUE : DTM_FALSE; #endif }
/************************************************************************ * PrintOutputPageDown ************************************************************************/ Boolean PrintOutputPageDown(PrintOutput *pOutput) { XmTextPosition top_before, top_after; top_before = (XmTextPosition) _poGetTopPosition(pOutput); #ifdef USE_DTEDITOR DtEditorGoToLine( pOutput->editor, pOutput->currentLine + pOutput->linesPerPage ); pOutput->currentLine += pOutput->linesPerPage; #else XmTextScroll(pOutput->editor, pOutput->linesPerPage); #endif top_after = (XmTextPosition) _poGetTopPosition(pOutput); return (top_before < top_after) ? TRUE : FALSE; }
static void PrintOnePageCB(Widget pshell, XtPointer context, XtPointer call_data) { MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; int curr_page; curr_page = GetCurrPageNum(pshell); Log(("--> PrintOnePageCB, printing page %d of %d\n", curr_page, mpcd->num_pages)); /* Get ready for next page * Scroll widget to display the next page (except for the first page :) */ if (!psp->last_page_in_job && curr_page > 1) { /* XmText allows two solutions to scroll a page down * - Either scroll num_rows_per_page down (this is XmText-specific) * or * - Call the "next-page" action procedure (this works for all widgets * which support this action proc) */ #define USE_ACTION_TO_SCROLL_DOWN 1 #ifdef USE_ACTION_TO_SCROLL_DOWN Log(("Scrolling down one page ...\n")); XtCallActionProc(mpcd->printshell_content, "next-page", NULL, NULL, 0); #else Log(("Scrolling down %d rows (=one page) ...\n", mpcd->num_visible_rows)); XmTextScroll(mpcd->printshell_content, mpcd->num_visible_rows); #endif /* USE_ACTION_TO_SCROLL_DOWN */ } if (curr_page == (int)mpcd->num_pages) { Log(("Printing last page.\n")); psp->last_page_in_job = True; } Log(("PrintOnePageCB: done\n")); }
void CreateWindow(Widget top, Display *pdpy, XPContext pctxt, Screen *scr) { Widget form, shell, tw; FILE *f; static char buffer[64000]; Arg al[20]; int ac; unsigned short wid, ht; XRectangle rect; Dimension width, height; short nrows = 80; int nlines = 481, npages, page, i; int save_data = XPGetData; /* * Here we are sure that printer name, print display, screen are * initialized, and a print context has been created. */ if (XpGetPageDimensions(pdpy, pctxt, &wid, &ht, &rect)) { fprintf(stderr, "Paper size is %d %d\n", wid, ht); } else { fprintf(stderr, "test8: failed to get Page Dimensions\n"); exit(1); } ac = 0; /* Size from paper size */ XtSetArg(al[ac], XmNheight, ht); ac++; XtSetArg(al[ac], XmNwidth, wid); ac++; shell = XmPrintSetup(top, scr, "Print", al, ac); /* start job must precede XpGetDocumentData in XmPrintToFile */ fprintf(stderr, "test8: XpStartJob\n"); XpStartJob(XtDisplay(shell), save_data); /* Maintain sequence StartJob - GetDocument */ XFlush(XtDisplay(shell)); XmPrintToFile(XtDisplay(shell), "test8.out", FinishPrintToFile, NULL); /* * Now we can get the size of the shell, create widgets, etc. */ XtVaGetValues(shell, XmNheight, &height, XmNwidth, &width, NULL); /* * Create a text widget as big as the page */ fprintf(stderr, "test8: XmCreateText(wid %d ht %d)\n", width, height); ac=0; XtSetArg(al[ac], XmNheight, height); ac++; XtSetArg(al[ac], XmNwidth, width); ac++; form = XmCreateForm(shell, "form", al, ac); XtManageChild(form); /* Re-use settings from above */ XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++; XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; tw = XmCreateText(form, "tw", al, ac); XtManageChild(tw); /* * Get some data in here - the LGPL text (you probably * need to be in the LessTif source tree for this to work). */ for (i=0; i<10; i++) { f = fopen("COPYING.LIB", "r"); if (f) break; chdir(".."); } if (f) { fread(buffer, 1, sizeof(buffer), f); fclose(f); } XmTextSetString(tw, buffer); XmTextShowPosition(tw, 0); fprintf(stderr, "test8: XtRealizeWidget()\n"); XtRealizeWidget(shell); /* Get data to calculate number of pages to print */ XtVaGetValues(tw, XmNrows, &nrows, XmNtotalLines, &nlines, NULL); /* Calculate number of pages to print */ npages = nlines / nrows + 1; fprintf(stderr, "Text lines %d rows %d pages %d\n", nlines, nrows, npages); for (page = 0; page < npages; page++) { XpStartPage(XtDisplay(shell), XtWindow(shell)); fprintf(stderr, "test8: XmRedisplayWidget\n"); XmRedisplayWidget(tw); /* works !! */ /* Calling XmRedisplayWidget() only works for * widgets that have an expose() method. This simple * point is documented in the XmRedisplayWidget docs. * Not so obvious consequence is what to do with other * widgets. It seems to be up to the application * programmer to figure out which widget to use. * * Calling it on a shell or on a form won't work. XmRedisplayWidget(shell); */ XpEndPage(XtDisplay(shell)); if (XmIsText(tw)) XmTextScroll(tw, nrows); } XpEndJob(XtDisplay(shell)); }