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

📄 mmi_sld.c

📁 是一个手机功能的模拟程序
💻 C
字号:
/* 
+----------------------------------------------------------------------------- 
|  Project :  GSM-F&D (8411)
|  Modul   :  MMI_SLD
+----------------------------------------------------------------------------- 
|  Copyright 2002 Texas Instruments Berlin, AG 
|                 All rights reserved. 
| 
|                 This file is confidential and a trade secret of Texas 
|                 Instruments Berlin, AG 
|                 The receipt of or possession of this file does not convey 
|                 any rights to reproduce or disclose its contents or to 
|                 manufacture, use, or sell anything it may describe, in 
|                 whole, or in part, without the specific written consent of 
|                 Texas Instruments Berlin, AG. 
+----------------------------------------------------------------------------- 
|  Purpose :  This Modul defines functions for input values over a
|             slider bar wich is controled via + and - keys on the
|             keypad.
+----------------------------------------------------------------------------- 
*/ 

#ifndef MMI_SLD_C
#define MMI_SLD_C
#endif

#ifdef SMI
#define ENTITY_SMI
#else
#define ENTITY_MMI
#endif

/*==== INCLUDES ===================================================*/
#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "tok.h"
#include "message.h"

#ifdef SMI
#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"
#else
#include "mmi.h"
#endif

/*==== CONSTANTS ==================================================*/

#define MAX_SLIDERS 3

/*==== TYPES ======================================================*/

/*==== EXPORT =====================================================*/

/*==== VARIABLES ==================================================*/

LOCAL T_SLID   sliderTable[MAX_SLIDERS];
LOCAL USHORT   numOfSliders;

/*==== FUNCTIONS ==================================================*/

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                  |
| STATE   : code                  ROUTINE : sld_init                 |
+--------------------------------------------------------------------+

  PURPOSE : Initialize the input module.

*/

GLOBAL void sld_init (void)
{
  numOfSliders  = MAX_SLIDERS;
   
  while (numOfSliders)
    sliderTable[--numOfSliders].free = TRUE;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                  |
| STATE   : code                  ROUTINE : sld_refreshSlider        |
+--------------------------------------------------------------------+

  PURPOSE : displays the slider as ------+------. The '+' marks the 
            actual position.

*/

LOCAL void sld_refreshSlider (T_AREA *a)
{
  T_SLID *slid;
  char    sliderLine[MAX_OUTPUT_SIZE+1];
  
  slid = &sliderTable[a->func];

  /*
   * build the slider line
   */  
  memset (sliderLine, '-', MAX_OUTPUT_SIZE);

  sliderLine[a->dx] = '\0';
  sliderLine[slid->sliderPos] = '+';

  wm_areaOutput (a, 0, 0, sliderLine);
  wm_areaRefresh (a);
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                  |
| STATE   : code                  ROUTINE : sld_startSlider          |
+--------------------------------------------------------------------+

  PURPOSE : Start the Slider processing for the area referenced by
            aHandle.

*/

GLOBAL void sld_startSlider (USHORT  aHandle,
                             USHORT  minValue,
                             USHORT  maxValue,
                             USHORT  aktValue)
{
  T_SLID *slid;
  USHORT  i=0;
  T_AREA *a = wm_getArea (aHandle);
  
  if (numOfSliders < MAX_SLIDERS
  AND a NEQ NULL
  AND a->funcType EQ FN_NONE)
  {
    while (i<MAX_SLIDERS)
    {
      if (sliderTable[i].free)
      {
        a->funcType = FN_SLIDER;
        slid = &sliderTable[i];
        slid->free = FALSE;
        numOfSliders++;
        a->func = (UBYTE) i;
        break;
      }
      i++;
    }

    if (i < MAX_SLIDERS)
    {
      slid->minValue  = minValue;
      slid->maxValue  = maxValue;
      slid->aktValue  = aktValue;
      slid->stepValue = (maxValue-minValue) / a->dx; 
      slid->sliderPos = slid->aktValue / slid->stepValue;

      sld_refreshSlider (a);
    }
  }
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                  |
| STATE   : code                  ROUTINE : sld_upSlider             |
+--------------------------------------------------------------------+

  PURPOSE : increments the slider with one step in the area
            referenced by aHandle.

*/

GLOBAL void sld_upSlider (USHORT aHandle)
{
  T_SLID *slid;
  T_AREA *a = wm_getArea (aHandle);
   
  if (a NEQ NULL AND a->funcType EQ FN_SLIDER)
  {
    slid = &sliderTable[a->func];
  
    if (slid->sliderPos < (a->dx - 1))
    {
      slid->sliderPos++;

      slid->aktValue += slid->stepValue;

      sld_refreshSlider (a);
    }
  }
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                   |
| STATE   : code                  ROUTINE : sld_downSlider            |
+--------------------------------------------------------------------+

  PURPOSE : decrements the slider with one step

*/

GLOBAL void sld_downSlider (USHORT aHandle)
{
  T_SLID *slid;
  T_AREA *a = wm_getArea (aHandle);
   
  if (a NEQ NULL AND a->funcType EQ FN_SLIDER)
  {
    slid = &sliderTable[a->func];
  
    if (slid->sliderPos > 0)
    {
      slid->sliderPos--;

      slid->aktValue -= slid->stepValue;

      sld_refreshSlider (a);
    }
  }
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                  |
| STATE   : code                  ROUTINE : sld_getSliderValue       |
+--------------------------------------------------------------------+

  PURPOSE : returns the value of the slider in the area referenced
            by aHandle.

*/

GLOBAL USHORT sld_getSliderValue (USHORT aHandle)
{
  T_SLID *slid;
  T_AREA *a = wm_getArea (aHandle);
   
  if (a NEQ NULL AND a->funcType EQ FN_SLIDER)
  {
    slid = &sliderTable[a->func];

    if (slid->sliderPos EQ 0)
      return slid->minValue;
    if (slid->sliderPos EQ (a->dx-1))
      return slid->maxValue;
    return slid->aktValue;
  }
  return 0;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MMI_SLD                  |
| STATE   : code                  ROUTINE : sld_stopSlider           |
+--------------------------------------------------------------------+

  PURPOSE : stops the slider process for the area referenced
            by aHandle.

*/

GLOBAL void sld_stopSlider (USHORT aHandle)
{
  T_AREA *a = wm_getArea (aHandle);
   
  if (a NEQ NULL AND a->funcType EQ FN_SLIDER)
  {
    if (!sliderTable[a->func].free)
    {
      a->funcType = FN_NONE;
      sliderTable[a->func].free = TRUE;
      numOfSliders--;
      a->func = 0;
    }
    wm_clearArea (aHandle);
  }
}

⌨️ 快捷键说明

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