예제 #1
0
/*
 * End (raster) graphics mode. This may be called explicitly by either of the
 * end graphics mode commands (<esc>*rB or <esc>*rC), or implicitly by any
 * commmand which is neither legal nor ignored in graphics mode.
 */
  int
pcl_end_graphics_mode(
    pcl_state_t *   pcs
)
{
    gs_point        cur_pt;
    gs_matrix       dev2pd;

    /* close the raster; exit graphics mode */
    pcl_complete_raster(pcs);
    pcs->raster_state.graphics_mode = false;

    /* get the new current point; then restore the graphic state */
    gs_transform(pcs->pgs, 0.0, 0.0, &cur_pt);
    pcl_grestore(pcs);

    /* transform the new point back to "pseudo print direction" space */
    pcl_invert_mtx(&(pcs->xfm_state.pd2dev_mtx), &dev2pd);
    gs_point_transform(cur_pt.x, cur_pt.y, &dev2pd, &cur_pt);
    pcl_set_cap_x(pcs, (coord)(cur_pt.x + 0.5) - adjust_pres_mode(pcs), false, false);
    return pcl_set_cap_y( pcs,
                          (coord)(cur_pt.y + 0.5) - pcs->margins.top,
                          false,
                          false,
                          false,
                          false
                          );
}
예제 #2
0
파일: pcpage.c 프로젝트: ststeiger/ghostsvg
/*
 * ESC & l <line> E
 *
 * Set top margin. This will also reset the page length.
 */
  static int
set_top_margin(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    coord           hgt = pcs->xfm_state.pd_size.y;
    coord           tmarg = uint_arg(pargs) * pcs->vmi_cp;

    if ((pcs->vmi_cp != 0) && (tmarg <= hgt)) {
        bool was_default = (pcs->margins.top == TOP_MARGIN(hgt, DFLT_TOP_MARGIN) &&
                            pcs->margins.left == DFLT_LEFT_MARGIN);

        pcs->margins.top = tmarg;
        pcs->margins.length = PAGE_LENGTH(hgt - tmarg, DFLT_BOTTOM_MARGIN);

        /* If the cursor has been moved then we have a fixed cap and the
           top margin only affects the next page. If the cap is floating,
           unmarked and unmoved, then the cap moves to the first line of text.
           More restrictive than implementor's guide:
           iff a default margin is changed on an unmarked unmoved page to the new margin.
           margin_set(A) ^L margin_set(B)  --> use (A)
           escE margin_set(B) --> use (B)
         */
        if (was_default && pcl_page_marked(pcs) == 0 )
            return pcl_set_cap_y(pcs, 0L, false, false, true, false);
    }
    return 0;
}
예제 #3
0
/*
 * ESC & f <pp_enum> S
 *
 * Contrary to what is indicated in the "PCL 5 Printer Language Technical
 * Reference Manual", October 1992 ed., p. 6-16, pushd cursors are stored
 * in logical page space, not device space.
 */
static int
push_pop_cursor(pcl_args_t * pargs, pcl_state_t * pcs)
{
    int type = uint_arg(pargs);

    if ((type == 0) && (pcs->cursor_stk_size < countof(pcs->cursor_stk))) {
        gs_point *ppt = &(pcs->cursor_stk[pcs->cursor_stk_size++]);

        ppt->x = (double)pcs->cap.x;
        ppt->y = (double)pcs->cap.y;
        gs_point_transform(ppt->x, ppt->y, &(pcs->xfm_state.pd2lp_mtx), ppt);

    } else if ((type == 1) && (pcs->cursor_stk_size > 0)) {
        gs_point *ppt = &(pcs->cursor_stk[--pcs->cursor_stk_size]);
        gs_matrix lp2pd;

        pcl_invert_mtx(&(pcs->xfm_state.pd2lp_mtx), &lp2pd);
        gs_point_transform(ppt->x, ppt->y, &lp2pd, ppt);
        pcl_set_cap_x(pcs, (coord) ppt->x, false, false);
        pcl_set_cap_y(pcs,
                      (coord) ppt->y - pcs->margins.top,
                      false, false, false, false);
    }

    return 0;
}
예제 #4
0
int
pcl_do_LF(pcl_state_t * pcs)
{
    pcs->cursor_moved = true;
    return pcl_set_cap_y(pcs,
                         pcs->vmi_cp,
                         true, (pcs->perforation_skip == 1), true, false);
}
예제 #5
0
/*
 * ESC =
 */
static int
half_line_feed(pcl_args_t * pargs,      /* ignored */
               pcl_state_t * pcs)
{
    pcs->cursor_moved = true;
    return pcl_set_cap_y(pcs,
                         pcs->vmi_cp / 2,
                         true, (pcs->perforation_skip == 1), true, false);
}
예제 #6
0
/*
 * Unconditionally feed a page, and move the the "home" verical position on
 * the followin page.
 */
int
pcl_do_FF(pcl_state_t * pcs)
{
    int code = pcl_end_page_always(pcs);

    if (code >= 0) {
        code = pcl_set_cap_y(pcs, 0L, false, false, true, false);
        pcl_continue_underline(pcs);    /* (after adjusting y!) */
    }
    return code;
}
예제 #7
0
static inline int
do_vertical_move(pcl_state_t * pcs, pcl_args_t * pargs, float mul,
                 bool use_margins, bool by_row, bool by_row_command,
                 bool truncate_arg)
{
    pcs->cursor_moved = true;
    return pcl_set_cap_y(pcs,
                         (coord) (motion_args(pargs, truncate_arg) * mul),
                         arg_is_signed(pargs), use_margins, by_row,
                         by_row_command);
}
예제 #8
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <line> E
 *
 * Set top margin. This will also reset the page length.
 */
static int
set_top_margin(pcl_args_t * pargs, pcl_state_t * pcs)
{
    coord hgt = pcs->xfm_state.pd_size.y;
    coord tmarg = uint_arg(pargs) * pcs->vmi_cp;

    if ((pcs->vmi_cp != 0) && (tmarg <= hgt)) {
        pcs->margins.top = tmarg;
        pcs->margins.length = PAGE_LENGTH(hgt - tmarg, DFLT_BOTTOM_MARGIN);
        /* See the discussion in the Implementor's guide concerning
           "fixed" and "floating" cap.  If the page is not dirty we
           home the cursor - the guide talks about tracking the cursor
           for any movement and checking for data on the page */
        if (!pcl_page_marked(pcs) && !pcl_cursor_moved(pcs))
            return pcl_set_cap_y(pcs, 0L, false, false, true, false);
    }
    return 0;
}
예제 #9
0
/*
 * Return the cursor to its "home" position
 */
void
pcl_home_cursor(pcl_state_t * pcs)
{
    pcl_set_cap_x(pcs, pcs->margins.left, false, false);
    pcl_set_cap_y(pcs, 0L, false, false, true, false);
}