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

📄 button.lst

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


C51 COMPILER V8.05a, COMPILATION OF MODULE BUTTON
OBJECT MODULE PLACED IN button.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Widget\button.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND 
                    -PRINT(.\button.lst) OBJECT(button.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        : BUTTON.c
  16          Purpose     : emWin GSC button widget
  17          ---------------------------END-OF-HEADER------------------------------
  18          */
  19          
  20          #include <stdlib.h>
  21          #include <string.h>
  22          #include "gui\Widget\BUTTON.h"
  23          #include "gui\Widget\WIDGET.h"
  24          #include "gui\Core\GUIDebug.h"
  25          #include "gui\Core\GUI.h"
  26          #include "gui\Core\GUI_Protected.h"
  27          
  28          #if GUI_WINSUPPORT
              
              /*********************************************************************
              *
              *       Private config defaults
              *
              **********************************************************************
              */
              
              /* Define default fonts */
              #ifndef BUTTON_FONT_DEFAULT
                #define BUTTON_FONT_DEFAULT &GUI_Font13_1
              #endif
              
              /* Support for 3D effects */
              #ifndef BUTTON_USE_3D
                #define BUTTON_USE_3D 1
              #endif
              
              #ifndef BUTTON_3D_MOVE_X
                #define BUTTON_3D_MOVE_X 1
              #endif
              #ifndef BUTTON_3D_MOVE_Y
                #define BUTTON_3D_MOVE_Y 1
              #endif
              
              /* Define colors */
C51 COMPILER V8.05a   BUTTON                                                               04/11/2008 14:19:31 PAGE 2   

              #ifndef BUTTON_BKCOLOR0_DEFAULT
                #define BUTTON_BKCOLOR0_DEFAULT 0xAAAAAA
              #endif
              
              #ifndef BUTTON_BKCOLOR1_DEFAULT
                #define BUTTON_BKCOLOR1_DEFAULT GUI_WHITE
              #endif
              
              #ifndef BUTTON_TEXTCOLOR0_DEFAULT
                #define BUTTON_TEXTCOLOR0_DEFAULT GUI_BLACK
              #endif
              
              #ifndef BUTTON_TEXTCOLOR1_DEFAULT
                #define BUTTON_TEXTCOLOR1_DEFAULT GUI_BLACK
              #endif
              
              /*********************************************************************
              *
              *       Object definition
              *
              **********************************************************************
              */
              
              typedef struct {
                WIDGET Widget;
                GUI_COLOR aBkColor[2];
                GUI_COLOR aTextColor[2];
                const GUI_FONT* pFont;
                const GUI_BITMAP* apBitmap[2];
                WM_HMEM hpText;
                #if BUTTON_SUPPORT_STREAMED_BITMAP
                  U8 aBitmapIsStreamed[2];
                #endif
                #if BUTTON_SUPPORT_BITMAP_OFFSET    /* Support for bitmap offsets */
                  I16 xOffBitmap[2], yOffBitmap[2];
                #endif
                #ifdef _DEBUG
                  int DebugId;
                #endif  
              } BUTTON_Obj;
              
              /*********************************************************************
              *
              *       Static data
              *
              **********************************************************************
              */
              
              /* None */
              
              /*********************************************************************
              *
              *       Macros for internal use
              *
              **********************************************************************
              */
              
              #define BUTTON_ID 0x42555454
              
              #define BUTTON_H2P(h) (BUTTON_Obj*) WM_HMEM2Ptr(h)
              
              #ifdef _DEBUG
C51 COMPILER V8.05a   BUTTON                                                               04/11/2008 14:19:31 PAGE 3   

                #define BUTTON_ASSERT_IS_VALID_PTR(p) GUI_DEBUG_ERROROUT_IF(p->DebugId != BUTTON_ID, "BUTTON.C: Wrong ha
             -ndle type or object not init'ed")
                #define BUTTON_INIT_ID(p)   p->DebugId = BUTTON_ID
                #define BUTTON_DEINIT_ID(p) p->DebugId = BUTTON_ID+1
              #else
                #define BUTTON_ASSERT_IS_VALID_PTR(p)
                #define BUTTON_INIT_ID(p)
                #define BUTTON_DEINIT_ID(p)
              #endif
              
              /*********************************************************************
              *
              *       Static routines
              *
              **********************************************************************
              */
              
              
              /*********************************************************************
              *
              *       _Paint
              */
              static void _Paint(BUTTON_Obj* pObj) {
                const char*s =NULL;
                int State = pObj->Widget.State;
                int PressedState = (State & BUTTON_STATE_PRESSED) ? 1:0;
                GUI_RECT rClient;
                GUI_RECT r;
                GUI_SetFont(pObj->pFont);
                GUI_DEBUG_LOG("BUTTON: Paint(..)\n");
                if (pObj->hpText) {
                  s = (const char*) WM_HMEM2Ptr(pObj->hpText);
                }
                GUI_GetClientRect(&rClient);
                r = rClient;
              /* Draw background */
                GUI_SetBkColor (pObj->aBkColor[PressedState]);
                GUI_SetColor   (pObj->aTextColor[PressedState]);
                GUI_Clear();
              /* Draw bitmap.
                 If we have only one, we will use it.
                 If we have to we will use the second one (Index 1) for the pressed state
              */
                {
                  int Index =0;
                  if (pObj->apBitmap[1] && PressedState) {
                    Index =1;   
                  }
                  if (pObj->apBitmap[Index]) {
                    #if BUTTON_SUPPORT_STREAMED_BITMAP
                      if(pObj->aBitmapIsStreamed[Index]) {
                      #if BUTTON_SUPPORT_BITMAP_OFFSET
                        GUI_DrawStreamedBitmap((const GUI_BITMAP_STREAM*)(pObj->apBitmap[Index]), pObj->xOffBitmap, pObj
             -->yOffBitmap);
                      #else
                        GUI_DrawBitmapStreamed((const GUI_BITMAP_STREAM*)(pObj->apBitmap[Index]), 0,0);
                      #endif
                      } else
                    #endif
                    {
                      #if BUTTON_SUPPORT_BITMAP_OFFSET
                        GUI_DrawBitmap(pObj->apBitmap[Index], pObj->xOffBitmap[Index], pObj->yOffBitmap[Index]);
C51 COMPILER V8.05a   BUTTON                                                               04/11/2008 14:19:31 PAGE 4   

                      #else
                        GUI_DrawBitmap(pObj->apBitmap[Index], 0,0);
                      #endif
                    }
                  }
                }
              /* Draw the actual button (background and text) */  
                #if BUTTON_USE_3D
                  if (pObj->Widget.State & BUTTON_STATE_PRESSED) {
                    GUI_MoveRect(&r, BUTTON_3D_MOVE_X,BUTTON_3D_MOVE_Y);
                  }
                #endif
                GUI_SetTextMode(GUI_TM_TRANS);
                GUI_DispStringInRect(s, &r, GUI_TA_HCENTER | GUI_TA_VCENTER);
              /* Draw the 3D effect (if configured) */
                #if BUTTON_USE_3D
                if ((State & BUTTON_STATE_PRESSED) == 0) {
                  WIDGET_EFFECT_3D_DrawUp();
                } else {
                  GUI_SetColor(0x000000);  /// TBD: Use halftone
                  GUI_DrawRect(rClient.y0, rClient.x0, rClient.x1, rClient.y1);
                }
                #endif
                /* Draw focus */
                if (State & BUTTON_STATE_FOCUS) {
                  GUI_SetColor(GUI_BLACK);
                  GUI_DrawFocusRect(&rClient, 2);
                }
              }
              
              /*********************************************************************
              *
              *       _Delete
              *
              * Delete attached objects (if any)
              */
              static void _Delete(BUTTON_Obj* pObj) {
                WM_FREEPTR(&pObj->hpText);
              }
              
              /*********************************************************************
              *
              *       _OnTouch
              */
              static void _OnTouch(BUTTON_Handle hObj, BUTTON_Obj* pObj, WM_MESSAGE*pMsg) {

⌨️ 快捷键说明

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