/* Puts a string of text in a window with breaks */
void swim_put_ltext(SWIM_WINDOW_T *win,
					const CHAR *text)
{
	int32_t i = 0;

	/* Continue until the entire string is output */
	while (text[i] != '\0') {
		if (text[i] == '\n') {
			swim_put_newline(win);
			i++;
		}
		else if (((uint8_t) text[i] >= win->font->first_char)
				 && ((uint8_t) text[i] <= win->font->last_char)) {
			/* Check for entire words first */
			if (((uint8_t) text[i] > ' ') && ((uint8_t) text[i] <= 0x7E)) {
				/* Put entire word on screen */
				i = i + swim_put_word(win, &text[i]);
			}
			else {
				swim_put_char(win, text[i]);
				i++;
			}
		}
		else {
			/* Put a space out */
			swim_put_char(win, ' ');
			i++;
		}
	}
}
static void IDrawTwoDigits(T_timeDateWorkspace *G_ws, T_region *r, char *aDigits, T_pixelColor aColor)
{
    INT_32 x, y;
    INT_32 nextX;

    swim_set_fill_color(&G_win, BLACK);
    swim_set_pen_color(&G_win, BLACK);
    swim_set_fill_transparent(&G_win, 0);
    swim_set_xy(&G_win, r->iLeft+1, r->iTop+1);
    swim_set_pen_color(&G_win, aColor);
    if (aDigits[0] != ' ')
        swim_put_char(&G_win, aDigits[0]);
    swim_get_xy(&G_win, &x, &y);
    nextX = r->iLeft+1+G_ws->iBigDigitWidth-1;
    if (x < nextX) {
        swim_set_pen_color(&G_win, BLACK);
        swim_put_box(&G_win, x, y, nextX, y+G_ws->iBigDigitHeight-1);
    }
    swim_set_xy(&G_win, r->iLeft+1+G_ws->iBigDigitWidth, r->iTop+1);
    swim_set_pen_color(&G_win, aColor);
    if (aDigits[1] != ' ')
        swim_put_char(&G_win, aDigits[1]);
    swim_get_xy(&G_win, &x, &y);
    nextX = r->iLeft+1+2*G_ws->iBigDigitWidth-3;
    if (x < nextX) {
        swim_set_pen_color(&G_win, BLACK);
        swim_put_box(&G_win, x, y, nextX, y+G_ws->iBigDigitHeight-1);
    }
}
Exemple #3
0
/***********************************************************************
 *
 * Function: swim_put_text
 *
 * Purpose: Puts a string of text in a window
 *
 * Processing:
 *     Each character will be routed to the swim_put_char function until
 *     a string terminator is reached. For newline characters, a newline
 *     will occur instead of a character output.
 *
 * Parameters:
 *     win  : Window identifier
 *     text : Text string to output in window
 *
 * Outputs: None
 *
 * Returns: Nothing
 *
 * Notes:  None
 *
 **********************************************************************/
void swim_put_text(SWIM_WINDOW_T *win, const CHAR *text)
{
    INT_32 i = 0;

    /* Continue until the entire string is output */
    while (text[i] != '\0') {
        if (text[i] == '\n') {
            swim_put_newline(win);
        } else if (((UNS_8)text[i] >= win->font->first_char)
            && ((UNS_8)text[i] <= win->font->last_char)) {
            /* Put character on screen */
            swim_put_char(win, text[i]);
        }

        i++;
    }
}
Exemple #4
0
/***********************************************************************
 *
 * Function: swim_put_word
 *
 * Purpose: Puts a word in the window, but adds a newline to keep the
 *          word contiguous (without an edge break) if necessary.
 *
 * Processing:
 *     The first word in the string (up to the first whitespace
 *     character) has its total length (based on font) computed and
 *     compared to the right window edge. If the length exceeds the
 *     window edge, a newline occurs and then the word is output.
 *
 * Parameters:
 *     win  : Window identifier
 *     text : Text string to output in window
 *
 * Outputs:  None
 *
 * Returns: The number of characters output to the display.
 *
 * Notes: None
 *
 **********************************************************************/
INT_32 swim_put_word(SWIM_WINDOW_T *win, const CHAR *text)
{
    INT_32 i;

    /* Will the length of the next word exceed the window margin? */
    if ((swim_get_word_len(win, text) + win->xvpos) > win->xpvmax) {
        /* Do a newline */
        swim_put_newline(win);
    }

    /* Put just the word characters on the display up to the next
     non-whitespace character or the end of the string */
    i = 0;
    while (((UNS_8)text[i] > ' ') && ((UNS_8)text[i] <= 0x7E)) {
        swim_put_char(win, text[i]);
        i++;
    }

    return i;
}