home *** CD-ROM | disk | FTP | other *** search
- /*
- opclipso.c 11/2/88
-
- % Pixel coordinate partial-character string clipping functions.
- Extracted from obox.c
- by Ted.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- */
-
- #include "oakhead.h"
- /* -------------------------------------------------------------------------- */
-
- int opbox_clipstrout(clipboxp, xp, yp, slenp, font)
- opbox *clipboxp;
- opcoord *xp;
- opcoord *yp;
- int *slenp;
- ofont_type font;
- /*
- Clip a string of length 'slen' plotted in font 'font' into box scrbox.
- Return a count of chars to be left off of the start of the string and
- shorten slen to the appropriate number of characters. If no character of
- the string is even partially in the box, slen will be shortened to <=0;
- Allow characters that are only partially in the box. For windows to work
- using this function, the character plotter must be able to use a clipbox.
- */
- {
- int delta;
- opcoord xr;
-
- /* Clip left, right, top and bottom */
- /* Quit if chars are completely out left or right */
- /* Quit if chars are completely out top or bottom */
- delta = 0;
- xr = *xp + *slenp * ofont_GetWidth(font);
- if (xr <= clipboxp->xmin ||
- *xp >= clipboxp->xmax ||
- *yp <= clipboxp->ymin ||
- (opcoord)(*yp - ofont_GetHeight(font)) >= clipboxp->ymax) {
- *slenp = 0;
- }
- else {
- /* Clip right; keep last partial char */
- if ((opcoord)(xr - ofont_GetWidth(font)) >= clipboxp->xmax) {
- *slenp = (clipboxp->xmax - *xp + ofont_GetWidth(font) - 1) /
- ofont_GetWidth(font);
- }
- /* Clip left; keep first partial char */
- if ((opcoord)(*xp + ofont_GetWidth(font)) <= clipboxp->xmin) {
- delta = (clipboxp->xmin - *xp) / ofont_GetWidth(font);
- *slenp -= delta;
- *xp += delta * ofont_GetWidth(font);
- }
- else delta = 0;
- }
- return(delta);
- }
- /* -------------------------------------------------------------------------- */
-
-