⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sma_swim_font.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************
 * $Workfile:   SMA_swim_font.c  $
 * $Revision:   1.0  $
 * $Author:   WellsK  $
 * $Date:   Aug 27 2002 08:36:42  $
 *
 * Project: Font management for SWIM
 *
 * Description:
 *  See the sma_swim_font.h header file for a description of this
 *  package.
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/CHIPS/archives/SOC/Source/Graphics/SWIM/SWIM_Fonts/SMA_swim_font.c-arc  $
 * 
 *    Rev 1.0   Aug 27 2002 08:36:42   WellsK
 * Initial revision.
 * 
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 * OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 * AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 * SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 * FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 * SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 * FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 * COPYRIGHT (C) 2002 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *     CAMAS, WA
 **********************************************************************/

#include "SMA_types.h"
#include "SMA_swim_font.h"

//**********************************************************************
// Functions
//**********************************************************************

/***********************************************************************
 *
 * Function: swim_put_text_xy
 *
 * Purpose:
 *  Put text at x, y (char) position on screen.
 *
 * Processing:
 *  Set the virtual (upper left) text position in the window and
 *  render the text string at this position.
 *
 * Parameters: 
 *  win  : Window identifier
 *  text : Text string to output in window
 *  x    : Virtual X position of start of text
 *  y    : Virtual Y position of start of text
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  X, Y coords are in virtual pixels!
 *
 **********************************************************************/
void swim_put_text_xy (INT_32 win, const CHAR *text, INT_32 x,
    INT_32 y)
{
    // Convert virtual x, y positon to physical position
    swim_set_xy (win, x, y);

    // Display text string
    swim_put_text (win, text);
}

/***********************************************************************
 *
 * Function: swim_set_xy
 *
 * Purpose:
 *  Sets the X, Y pixel coordinates for the next text operation.
 *
 * Processing:
 *  Update the X, Y text position pointers, limiting the position to
 *  the window dimensions.
 *
 * Parameters: 
 *  win  : Window identifier
 *  x    : Virtual X position of start of text
 *  y    : Virtual Y position of start of text
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  X, Y coords are in virtual pixels!
 *
 **********************************************************************/
void swim_set_xy (INT_32 win, INT_32 x, INT_32 y)
{
    window [win].xvpos = x + window [win].xpvmin;
    window [win].yvpos = y + window [win].ypvmin;

    // Limit to window dimensions
    if (window [win].xvpos < window [win].xpvmin)
    {
        window [win].xvpos = window [win].xpvmin;
    }
    else if (window [win].xvpos > window [win].xpvmax)
    {
        window [win].xvpos = window [win].xpvmax;
    }

    if (window [win].yvpos < window [win].ypvmin)
    {
        window [win].yvpos = window [win].ypvmin;
    }
    else if (window [win].yvpos > window [win].ypvmax)
    {
        window [win].yvpos = window [win].ypvmax;
    }
}

/***********************************************************************
 *
 * Function: swim_get_xy
 *
 * Purpose:
 *  Returns the X, Y pixel coordinates for the next text operation.
 *
 * Processing:
 *  The logical X and Y positions are computed by subtracting the
 *  physical text position values by the physical minimum window
 *  limits.
 *
 * Parameters: 
 *  win  : Window identifier
 *  x    : Address of where to return virtual X value
 *  y    : Address of where to return virtual X value
 *
 * Outputs:
 *  The values at address x and y are updated.
 *
 * Returns:
 *  Nothing
 *
 * Notes:
 *  X, Y coords are in virtual pixels!
 *
 **********************************************************************/
void swim_get_xy (INT_32 win, INT_32 *x, INT_32 *y)
{
    *x = window [win].xvpos - window [win].xpvmin;
    *y = window [win].yvpos - window [win].ypvmin;
}

/***********************************************************************
 *
 * 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 (INT_32 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] >= window [win].font->first_char)
            && ((UNS_8) text [i] <= window [win].font->last_char))
        {
            // Put character on screen
            swim_put_char (win, text [i]);
        }

        i++;
    }
}

/***********************************************************************
 *
 * Function: swim_get_word_len
 *
 * Purpose:
 *  Determines the length of the word (in pixels) up to the first
 *  whitespace character.
 *
 * Processing:
 *  The string is searched for the first whitespace occurance. For
 *  each non-whitespace character, the required length of that character
 *  in the window is computed. For the entire string up to the first
 *  whitespace character, the total length is returned.
 *
 * Parameters: 
 *  win  : Window identifier
 *  text : Text string to output in window
 *
 * Outputs:
 *  None
 *
 * Returns:
 *  The length of the word (with a stop at the first whitespace) in
 *  the passed string.
 *
 * Notes:
 *  This function is private to this module.
 *
 **********************************************************************/
INT_16 swim_get_word_len (INT_32 win, const CHAR *text)
{
    INT_32 i;
    INT_16 wlen = 0;

    // Find the length in pixels of the next word (separated by
    // whitespace)
    i = 0;
    while (((UNS_8) text [i] > ' ') && ((UNS_8) text [i] <= 0x7E))
    {
        wlen = wlen + window [win].font->font_width_table
            [(UNS_8) text [i] - window [win].font->first_char];
        i++;
    }

    return wlen;
}

/***********************************************************************
 *
 * 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:
 *  This function is private to this module.
 *
 **********************************************************************/
INT_32 swim_put_word (INT_32 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) + window [win].xvpos) >
        window [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;
}

/***********************************************************************
 *
 * Function: swim_put_ltext
 *
 * Purpose:
 *  Puts a string of text in a window, but will adjust the position of
 *  a word if the word length exceeds the edge of the display.
 *
 * Processing:
 *  While the string has data in it, check for the newline character.
 *  If it exists, output a newline. If the string data is inside the
 *  font character table, output the first word in the string (with
 *  support for generating a newline if the word will exceed the window
 *  edge). Continue until all words/characters are output.
 *
 * Parameters: 
 *  win  : Window identifier
 *  text : Text string to output in window
 *
 * Outputs:
 *  None
 *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -