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

📄 progbar.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.05a   PROGBAR                                                              04/11/2008 14:19:37 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE PROGBAR
OBJECT MODULE PLACED IN progbar.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Widget\progbar.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND
                    - PRINT(.\progbar.lst) OBJECT(progbar.obj)

line level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/GUI
   4          *                        Universal graphic software for embedded applications
   5          *
   6          *                       (c) Copyright 2002, Micrium Inc., Weston, FL
   7          *                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
   8          *
   9          *              礐/GUI is protected by international copyright laws. Knowledge of the
  10          *              source code may not be used to write a similar product. This file may
  11          *              only be used in accordance with a license and should not be redistributed
  12          *              in any way. We appreciate your understanding and fairness.
  13          *
  14          ----------------------------------------------------------------------
  15          File        : ProgBar.c
  16          Purpose     : Progress bar for emWin GSC
  17          ---------------------------END-OF-HEADER------------------------------
  18          */
  19          
  20          
  21          #include <stdlib.h>
  22          #include <string.h>
  23          #include "gui\Core\GUI_Private.h"
  24          #include "ProgBar.h"
  25          #include "Widget.h"
  26          
  27          #if GUI_WINSUPPORT
              
              /*********************************************************************
              *
              *       Private config defaults
              *
              **********************************************************************
              */
              
              #ifndef PROGBAR_DEFAULT_FONT
                #define PROGBAR_DEFAULT_FONT GUI_DEFAULT_FONT
              #endif
              
              #ifndef PROGBAR_DEFAULT_BARCOLOR0
                #define PROGBAR_DEFAULT_BARCOLOR0 0x555555
              #endif
              
              #ifndef PROGBAR_DEFAULT_BARCOLOR1
                #define PROGBAR_DEFAULT_BARCOLOR1 0xAAAAAA
              #endif
              
              #ifndef PROGBAR_DEFAULT_TEXTCOLOR0
                #define PROGBAR_DEFAULT_TEXTCOLOR0 0xFFFFFF
              #endif
              
              #ifndef PROGBAR_DEFAULT_TEXTCOLOR1
                #define PROGBAR_DEFAULT_TEXTCOLOR1 0x000000
              #endif
C51 COMPILER V8.05a   PROGBAR                                                              04/11/2008 14:19:37 PAGE 2   

              
              /*********************************************************************
              *
              *       Object definition
              *
              **********************************************************************
              */
              
              typedef struct {
                WIDGET Widget;
                int v;
                const GUI_FONT* pFont;
                GUI_COLOR BarColor[2];
                GUI_COLOR TextColor[2];
                WM_HMEM hpText;
                I16 XOff, YOff;
                I16 TextAlign;
                int Min, Max;
              /*  I16 Options; */
                #if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_CHECK_ALL
                  int DebugId;
                #endif  
              } PROGBAR_Obj;
              
              /*********************************************************************
              *
              *       Static data
              *
              **********************************************************************
              */
              
              /* None */
              
              /*********************************************************************
              *
              *       Macros for internal use
              *
              **********************************************************************
              */
              
              #define Invalidate(h) WM_InvalidateWindow(h)
              
              #if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_CHECK_ALL
                #define OBJECT_ID 0x4569   /* Magic nubmer, should be unique if possible */
                #define INIT_ID(p)   p->DebugId = OBJECT_ID
                #define DEINIT_ID(p) p->DebugId = OBJECT_ID+1
              #else
                #define INIT_ID(p)
                #define DEINIT_ID(p)
              #endif
              
              /*********************************************************************
              *
              *       Static routines
              *
              **********************************************************************
              */
              
              #if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_CHECK_ALL
                PROGBAR_Obj* PROGBAR_h2p(PROGBAR_Handle h) {
                  PROGBAR_Obj* p = (PROGBAR_Obj*)WM_HMEM2Ptr(h);
                  if (p) {
C51 COMPILER V8.05a   PROGBAR                                                              04/11/2008 14:19:37 PAGE 3   

                    if (p->DebugId != OBJECT_ID) {
                      GUI_DEBUG_ERROROUT("PROGBAR.C: Wrong handle type or Object not init'ed");
                      return 0;
                    }
                  }
                  return p;
                }
                #define PROGBAR_H2P(h) PROGBAR_h2p(h)
              #else
                #define PROGBAR_H2P(h) (PROGBAR_Obj*) WM_HMEM2Ptr(h)
              #endif
              
              /*********************************************************************
              *
              *       _FreeText
              */
              static void _FreeText(PROGBAR_Handle hObj) {
                PROGBAR_Obj* pObj = PROGBAR_H2P(hObj);
                WM_FREEPTR(&pObj->hpText);
              }
              
              /*********************************************************************
              *
              *       _Value2X
              */
              static int _Value2X(PROGBAR_Handle hObj, int v) {
                PROGBAR_Obj* pObj = PROGBAR_H2P(hObj);
                int xsize  = WM_GetWindowSizeX(hObj);
                int Min = pObj->Min;
                int Max = pObj->Max;
                if (v<Min)
                        v = Min;
                if (v> Max)
                        v = Max;
                return (xsize* (I32)(v-Min)) / (Max-Min);
              }
              
              /*********************************************************************
              *
              *       _DrawPart
              */
              static void _DrawPart(PROGBAR_Obj* pThis,
                                   int Index,
                                                                                               int xText, int yText,
                                                                                               const char* pText)
              {
                  GUI_SetBkColor(pThis->BarColor[Index]);
                  GUI_SetColor(pThis->TextColor[Index]);
                  GUI_Clear();
                  GUI_GotoXY(xText,yText);
                              GUI_DispString(pText);
              }
              
              /*********************************************************************
              *
              *       _Paint
              */
              static void _Paint(PROGBAR_Handle hObj) {
                PROGBAR_Obj* pObj = PROGBAR_H2P(hObj);
                WM_HWIN hWin = hObj;
                int xsize = WM_GetWindowSizeX(hWin);
                int ysize = WM_GetWindowSizeY(hWin);
C51 COMPILER V8.05a   PROGBAR                                                              04/11/2008 14:19:37 PAGE 4   

                int tm;
                GUI_SetFont(pObj->pFont);
                {
                  int x1;
                  int FontSizeY = GUI_GetFontSizeY();
                  int xText;
                  int yText = (ysize-FontSizeY)/2;
                  GUI_RECT r;
                  int XSizeChar;
                  char ac[5];   /* Just enough for the percentage */
                  char*s = ac;
                  const char* pText;
                  if (pObj->hpText) {
                    pText = (const char*) WM_HMEM2Ptr(pObj->hpText);
                  } else {
                    GUI_AddDecMin((100*(I32)(pObj->v-pObj->Min))/(pObj->Max-pObj->Min), &s);
                    *s = '%';
                                      *(s+1) =0;
                                      pText = &ac[0];
                              }
              /* Calculate text positions */
                  XSizeChar = GUI_GetStringDistX(pText);
                  x1 = _Value2X(hObj, pObj->v);
                  switch (pObj->TextAlign &GUI_TA_HORIZONTAL) {
                  case GUI_TA_CENTER:
                    xText  = (xsize-XSizeChar)/2;
                                      break;
                  case GUI_TA_LEFT:
                    xText  = 0;
                                      break;
                  case GUI_TA_RIGHT:
                    xText  = xsize-XSizeChar-1;
                                      break;
                              }
                  xText += pObj->XOff;
                  yText += pObj->YOff;
                  tm = GUI_SetTextMode(GUI_TM_TRANS);
              /* Draw left bar */
                  r.x0=0; r.x1=x1-1; r.y0=0; r.y1 = GUI_YMAX;
                  WM_SetUserClipArea(&r);
                  _DrawPart(pObj, 0, xText, yText, pText);
              /* Draw right bar */

⌨️ 快捷键说明

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