📄 smi_wm.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-F&D (8411)
| Modul : SMI_WM
+-----------------------------------------------------------------------------
| 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 the window management
| on the LC Display.
+-----------------------------------------------------------------------------
*/
#ifndef SMI_WM_C
#define SMI_WM_C
#endif
#define ENTITY_SMI
/*==== INCLUDES ===================================================*/
#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "smi_lcd.h"
#include "tok.h"
#include "message.h"
#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"
#include "gdi.h"
#include "dspl.h"
/*==== CONSTANTS ==================================================*/
#define MAX_AREAS 14
/*
* macros for checking the validity of an area handle
*/
#define hValid(H) (H<MAX_AREAS AND !areaTable[H].free)
/*==== TYPES ======================================================*/
/*==== EXPORT =====================================================*/
/*==== VARIABLES ==================================================*/
LOCAL char virtScreen[SCREEN_DY][SCREEN_DX+1];
LOCAL char LCDScreen[SCREEN_DY][SCREEN_DX+1];
LOCAL T_AREA areaTable[MAX_AREAS], *topArea;
LOCAL USHORT numOfAreas;
/*
* the areaList contains the handle of all created areas. The last
* entry in the list is the last opened area. This list is used in
* the refreshing algorithmn.
*/
LOCAL USHORT areaList[MAX_AREAS];
LOCAL USHORT areaListIdx;
/*==== FUNCTIONS ==================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_WM |
| STATE : code ROUTINE : wm_clearVirtScreen |
+--------------------------------------------------------------------+
PURPOSE : clears the virtual screen buffer.
*/
LOCAL void wm_clearVirtScreen (void)
{
USHORT row;
for (row=0; row < screensize_y; row++)
{
memset (&virtScreen[row][0], ' ', screensize_x);
virtScreen[row][screensize_x] = NULL_TERM;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_WM |
| STATE : code ROUTINE : wm_sendDisplayReq |
+--------------------------------------------------------------------+
PURPOSE : sends an MMI_DISPLAY_REQ primitive to write
the text at position X,Y to PL. If the parameter
text is NULL only the cursor position
should change. If in this case the X and Y value
is 0xffff the cursor will be hide.
*/
LOCAL void wm_sendDisplayReq (USHORT x, USHORT y, char *text)
{
USHORT sdu_len = (text NEQ NULL) ? strlen (text) : 0;
USHORT sdu_bit_len = 8 * sdu_len;
PALLOC_SDU (mmi_display_req, MMI_DISPLAY_REQ, sdu_bit_len);
mmi_display_req->c_x = x;
mmi_display_req->c_y = y;
if (text NEQ NULL)
{
/*
* text output
*/
mmi_display_req->attrib.content = CON_TEXT;
mmi_display_req->attrib.control = CTL_NORMAL;
mmi_display_req->sdu.o_buf = 0;
mmi_display_req->sdu.l_buf = (sdu_len<<3);
memcpy (mmi_display_req->sdu.buf, text, sdu_len);
}
else
{
/*
* change the cursor position
*/
mmi_display_req->attrib.content = CON_CURSOR;
mmi_display_req->attrib.control = ((x EQ 0xffff) ? CTL_HIDDEN : CTL_NORMAL);
mmi_display_req->sdu.o_buf = 0;
mmi_display_req->sdu.l_buf = 0;
}
#if defined (NEW_FRAME)
PSEND (hCommPL, mmi_display_req);
#else
PSEND (PL, mmi_display_req);
#endif
PTRACE_OUT (MMI_DISPLAY_REQ);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_WM |
| STATE : code ROUTINE : wm_init |
+--------------------------------------------------------------------+
PURPOSE : Initialize the window management module.
*/
GLOBAL void wm_init (void)
{
USHORT row;
numOfAreas = MAX_AREAS;
while (numOfAreas)
areaTable[--numOfAreas].free = TRUE;
wm_clearVirtScreen ();
for (row=0; row<screensize_y; row++)
{
memset (&LCDScreen[row][0], ' ', screensize_x);
LCDScreen[row][screensize_x] = NULL_TERM;
}
topArea = NULL;
areaListIdx = 0;
dspl_Init ();
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_WM |
| STATE : code ROUTINE : wm_areaClearScreen |
+--------------------------------------------------------------------+
PURPOSE : clear the screen buffer of the area *a.
*/
LOCAL void wm_areaClearScreen (T_AREA *a)
{
int r, c;
for (r=0; r < a->dy; r++)
for (c=0; c < a->dx; c++)
a->screen[(r*a->dx)+c]= ' ';
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_WM |
| STATE : code ROUTINE : wm_areaOutput |
+--------------------------------------------------------------------+
PURPOSE : write a string into the screen buffer of area *a.
*/
GLOBAL void wm_areaOutput (T_AREA *a, int row, int col, char *s)
{
int len = strlen (s);
if (row < a->dy)
{
if ((col + len) > a->dx)
/* clip the string */
len = MAXIMUM (a->dx - col, 0);
memcpy (&a->screen[(row*a->dx)+col], s, len);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_WM |
| STATE : code ROUTINE : wm_refresh |
+--------------------------------------------------------------------+
PURPOSE : draw the window contents of all active windows into
the virtual screen buffer and transfer the entire content
to the LC Display.
*/
LOCAL void wm_refresh (void)
{
USHORT i = 0, j, row;
USHORT aHandle;
T_AREA *a;
char saveChar;
wm_clearVirtScreen ();
topArea = NULL;
while (i < areaListIdx)
{
aHandle = areaList[i];
if (hValid (aHandle))
{
a = &areaTable[aHandle];
if (a->state EQ AREA_DISPLAYED)
{
topArea = a;
for (row = 0; row < a->dy; row++)
{
memcpy (&virtScreen[a->y+row][a->x],
&a->screen[(row*a->dx)],
a->dx);
}
}
}
i++;
}
for (row = 0; row < screensize_y; row++)
if (memcmp (&virtScreen[row][0], &LCDScreen[row][0], screensize_x))
{
/*
* look in this row for changes and ouput only the changed
* characters because of the slow speed of the LCD Driver
* Minimized calls to LCD_WriteString
*/
i=0;
while (i<screensize_x)
{
if (virtScreen[row][i] NEQ LCDScreen[row][i])
{
j=i;
do
i++;
while (i<screensize_x AND virtScreen[row][i] NEQ LCDScreen[row][i]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -