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

📄 slider.lst

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


C51 COMPILER V8.05a, COMPILATION OF MODULE SLIDER
OBJECT MODULE PLACED IN Slider.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Widget\Slider.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND 
                    -PRINT(.\Slider.lst) OBJECT(Slider.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        : SLIDER.c
  16          Purpose     : SLIDER for new emWin GSC widgets
  17          ---------------------------END-OF-HEADER------------------------------
  18          */
  19          
  20          #include <stdlib.h>
  21          #include <string.h>
  22          #include "gui\Core\GUI_Private.h"
  23          #include "SLIDER.h"
  24          #include "Widget.h"
  25          
  26          
  27          #if GUI_WINSUPPORT
              
              /*********************************************************************
              *
              *       Private config defaults
              *
              **********************************************************************
              */
              
              /* Support for 3D effects */
              #ifndef SLIDER_USE_3D
                #define SLIDER_USE_3D 1
              #endif
              
              /* Define colors */
              #ifndef SLIDER_BKCOLOR0_DEFAULT
                #define SLIDER_BKCOLOR0_DEFAULT 0xc0c0c0
              #endif
              
              #ifndef SLIDER_BKCOLOR1_DEFAULT
                #define SLIDER_BKCOLOR1_DEFAULT GUI_WHITE
              #endif
              
              #ifndef SLIDER_COLOR0_DEFAULT
                #define SLIDER_COLOR0_DEFAULT 0xc0c0c0
              #endif
              
              #ifndef SLIDER_COLOR1_DEFAULT
C51 COMPILER V8.05a   SLIDER                                                               04/11/2008 14:19:38 PAGE 2   

                #define SLIDER_COLOR1_DEFAULT GUI_BLACK
              #endif
              
              
              /*********************************************************************
              *
              *       Object definition
              *
              **********************************************************************
              */
              
              typedef struct {
                WIDGET Widget;
                GUI_COLOR aBkColor[2];
                GUI_COLOR aColor[2];
                int Min, Max, v;
                int Flags;
                int NumSections;
                I16 Width;
                #if GUI_DEBUG_LEVEL >1
                  int DebugId;
                #endif  
              } SLIDER_Obj;
              
              /*********************************************************************
              *
              *       Static data
              *
              **********************************************************************
              */
              
              /* None */
              
              /*********************************************************************
              *
              *       Macros for internal use
              *
              **********************************************************************
              */
              
              #define SLIDER_ID 0x4544   /* Magic numer, should be unique if possible */
              
              #define SLIDER_H2P(h) (SLIDER_Obj*) WM_H2P(h)
              
              #ifdef _DEBUG
                #define SLIDER_ASSERT_IS_VALID_PTR(p) DEBUG_ERROROUT_IF(p->DebugId != SLIDER_ID, "xxx.c: Wrong handle ty
             -pe or Object not init'ed")
                #define SLIDER_INIT_ID(p)   p->DebugId = SLIDER_ID
                #define SLIDER_DEINIT_ID(p) p->DebugId = SLIDER_ID+1
              #else
                #define SLIDER_ASSERT_IS_VALID_PTR(p)
                #define SLIDER_INIT_ID(p)
                #define SLIDER_DEINIT_ID(p)
              #endif
              
              /*********************************************************************
              *
              *       Static routines
              *
              **********************************************************************
              */
              
C51 COMPILER V8.05a   SLIDER                                                               04/11/2008 14:19:38 PAGE 3   

              /*********************************************************************
              *
              *       _Paint
              */
              static void _Paint(SLIDER_Obj* pObj/*, GUI_RECT*pRect*/) {
                int i;
                int xsize;
                int x0;
                GUI_RECT r, rFocus, rSlider, rSlot;
                WIDGET__GetClientRect(&pObj->Widget, &rFocus);
                GUI__ReduceRect(&r, &rFocus, 1);
                xsize = r.x1 - r.x0  + 1 - pObj->Width /*- 2*xSizeEffect*/;
                x0 = r.x0 + pObj->Width / 2;
                GUI_SetBkColor(pObj->aBkColor[0]);
                GUI_Clear();
                /* Calculate Slider position */
                rSlider = r;
                rSlider.y0 = 5;
                rSlider.x0 = x0 + xsize * (pObj->v - pObj->Min) / (pObj->Max - pObj->Min) - pObj->Width/2;
                rSlider.x1  = rSlider.x0 + pObj->Width;
                /* Calculate Slot position */
                rSlot.x0 = x0;
                rSlot.x1 = x0 + xsize;
                rSlot.y0 = (rSlider.y0 + rSlider.y1) /2 -1;
                rSlot.y1 = rSlot.y0 +3;
                WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &rSlot);        /* Draw slot */
                /* Draw the ticks */
                GUI_SetColor(GUI_BLACK);
                for (i = 0; i <= pObj->NumSections; i++) {
                  int x = x0 + xsize * i / pObj->NumSections;
                  WIDGET__DrawVLine(&pObj->Widget, x, 1, 3);
                }
                /* Draw the slider itself */
                GUI_SetColor(pObj->aColor[0]);
                WIDGET__FillRectEx(&pObj->Widget, &rSlider);
                GUI_SetColor(GUI_BLACK);
                WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &rSlider);
                /* Draw focus */
                if (pObj->Widget.State & WIDGET_STATE_FOCUS) {
                  GUI_SetColor(GUI_BLACK);
                  WIDGET__DrawFocusRect(&pObj->Widget, &rFocus, 0);
                }
              }
              
              
              /*********************************************************************
              *
              *       _OnTouch
              */
              static void _OnTouch(SLIDER_Handle hObj, SLIDER_Obj* pObj, WM_MESSAGE*pMsg) {
                GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p;
                if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
                  if (pState->Pressed) {
                    int Sel;
                    int Range = (pObj->Max - pObj->Min);
                    int x0, xsize;
                    int x;
                    x0 = 1 + pObj->Width/2;  /* 1 pixel focus rectangle + width of actual slider */
                    x = (pObj->Widget.State & WIDGET_STATE_VERTICAL) ? pState->y : pState->x;
                    x -= x0;
                    xsize = WIDGET__GetWindowSizeX(hObj) - 2 * x0;
                    if (x <= 0) {
C51 COMPILER V8.05a   SLIDER                                                               04/11/2008 14:19:38 PAGE 4   

                      Sel = pObj->Min;
                    } else if (x >= xsize) {
                      Sel = pObj->Max;
                    } else {
                      Sel = GUI__DivideRound(Range* x, xsize);
                      Sel += pObj->Min;
                    }
                    WM_SetFocus(hObj);
                    WM_SetCapture(hObj, 1);
                    SLIDER_SetValue(hObj, Sel);
                  } 
                }
              }
              
              /*********************************************************************
              *
              *       _OnKey
              */
              static void  _OnKey(SLIDER_Handle hObj, WM_MESSAGE*pMsg) {
                WM_KEY_INFO* pKeyInfo;
                int Key;
                pKeyInfo = (WM_KEY_INFO*)(pMsg->Data.p);
                Key = pKeyInfo->Key;
                if (pKeyInfo->PressedCnt > 0) {
                  switch (Key) {
                    case GUI_KEY_RIGHT:

⌨️ 快捷键说明

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