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

📄 guicharline.c

📁 ucgui的3.98版本的源代码
💻 C
字号:
/*
*********************************************************************************************************
*                                             uC/GUI V3.98
*                        Universal graphic software for embedded applications
*
*                       (c) Copyright 2002, Micrium Inc., Weston, FL
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
*              礐/GUI is protected by international copyright laws. Knowledge of the
*              source code may not be used to write a similar product. This file may
*              only be used in accordance with a license and should not be redistributed
*              in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File        : GUICharLine.C
Purpose     : Implementation of character and string services
---------------------------END-OF-HEADER------------------------------
*/

#include <stddef.h>           /* needed for definition of NULL */
#include <stdio.h>
#include "GUI_Protected.h"

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/
/*********************************************************************
*
*       _DispLine
*/
static void _DispLine(const char GUI_UNI_PTR *s, int MaxNumChars, const GUI_RECT *pRect) {
  #if GUI_SUPPORT_ARABIC
    GUI__DispLineArabic(s, MaxNumChars, pRect);
  #else
    /* Check if we have anything to do at all ... */
    if (GUI_Context.pClipRect_HL) {
      if (GUI_RectsIntersect(GUI_Context.pClipRect_HL, pRect) == 0)
        return;
    }
    #if GUI_COMPILER_SUPPORTS_FP
    if (GUI_Context.pAFont->pafEncode) {
      GUI_Context.pAFont->pafEncode->pfDispLine(s, MaxNumChars);
    } else {
    #else
    {
    #endif
      U16 Char;
      while (--MaxNumChars >= 0) {
        Char = GUI_UC__GetCharCodeInc(&s);
        GUI_Context.pAFont->pfDispChar(Char);
        if (GUI_pfDispCharStyle) {
          GUI_pfDispCharStyle(Char);
        }
      }
    }
  #endif
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       GUI__GetLineNumChars
*/
int GUI__GetLineNumChars(const char GUI_UNI_PTR *s, int MaxNumChars) {
  int NumChars = 0;
  if (s) {
    #if GUI_COMPILER_SUPPORTS_FP
      if (GUI_Context.pAFont->pafEncode) {
        return GUI_Context.pAFont->pafEncode->pfGetLineLen(s, MaxNumChars);
      }
    #endif
    for (; NumChars < MaxNumChars; NumChars++) {
      U16 Data = GUI_UC__GetCharCodeInc(&s);
      if ((Data == 0) || (Data == '\n')) {
        break;
      }
    }
  }
  return NumChars;
}

/*********************************************************************
*
*       GUI__GetLineDistX
*
*  This routine is used to calculate the length of a line in pixels.
*/
int GUI__GetLineDistX(const char GUI_UNI_PTR *s, int MaxNumChars) {
  int Dist;
  #if GUI_SUPPORT_ARABIC
    Dist = GUI__GetLineDistXArabic(s, MaxNumChars);
  #else
    Dist = 0;
    if (s) {
      U16 Char;
      #if GUI_COMPILER_SUPPORTS_FP
        if (GUI_Context.pAFont->pafEncode) {
          return GUI_Context.pAFont->pafEncode->pfGetLineDistX(s, MaxNumChars);
        }
      #endif
      while (--MaxNumChars >= 0) {
        Char  = GUI_UC__GetCharCodeInc(&s);
        Dist += GUI_GetCharDistX(Char);
      }
    }
  #endif
  return Dist;
}

/*********************************************************************
*
*       GUI__DispLine
*/
void GUI__DispLine(const char GUI_UNI_PTR *s, int MaxNumChars, const GUI_RECT* pr) {
  GUI_RECT r;
  #if GUI_SUPPORT_ROTATION
  if (GUI_pLCD_APIList) {
    #if GUI_WINSUPPORT
    WM_ITERATE_START(NULL) {
    #endif
      /* Do the actual drawing via routine call. */
      _DispLine(s, MaxNumChars, &r);
    #if GUI_WINSUPPORT
    } WM_ITERATE_END();
    #endif
  } else
  #endif
  {
    r = *pr;
    #if GUI_WINSUPPORT
    WM_ADDORG(r.x0, r.y0);
    WM_ADDORG(r.x1, r.y1);
    WM_ITERATE_START(&r) {
    #endif
      GUI_Context.DispPosX = r.x0;
      GUI_Context.DispPosY = r.y0;
      /* Do the actual drawing via routine call. */
      _DispLine(s, MaxNumChars, &r);
    #if GUI_WINSUPPORT
    } WM_ITERATE_END();
    WM_SUBORG(GUI_Context.DispPosX, GUI_Context.DispPosY);
    #endif
  }
}

/*************************** End of file ****************************/
	 	 			 		    	 				 	  			   	 	 	 	 	 	  	  	      	   		 	 	 		  		  	 		 	  	  			     			       	   	 			  		    	 	     	 				  	 					 	 			   	  	  			 				 		 	 	 			     			 

⌨️ 快捷键说明

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