📄 mfw_win.c
字号:
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417) $Workfile:: mfw_win.c $|
| $Author: chenlang $ CONDAT GmbH $Revision: 1.2 $|
| CREATED: 21.09.98 $Modtime:: 23.03.00 9:08 $|
| STATE : code |
+--------------------------------------------------------------------+
MODULE : MFW_WIN
PURPOSE : window handling functions
EXPORT :
TO DO :
$History:: mfw_win.c $
* textMessage
* ***************** Version 23 *****************
* User: zy, 2002.8.01
*
* Add TraceInt() for trace int data
*
*
* ***************** Version 22 *****************
* User: zgz, 2002.7.13
*
* Update function winDelete(), make it only winUpdate the
* parent window.
*
* ***************** Version 21 *****************
* User: Es Date: 23.03.00 Time: 14:42
* Updated in $/GSM/Condat/MS/SRC/MFW
* Added 'winUnhide()': no update(), no event.
*
* ***************** Version 20 *****************
* User: Kk Date: 14.03.00 Time: 15:52
* Updated in $/GSM/Condat/MS/SRC/MFW
* changed update sequence
*
* ***************** Version 19 *****************
* User: Es Date: 3.03.00 Time: 12:04
* Updated in $/GSM/Condat/MS/SRC/MFW
* winUpdate(): first update windows children, then! call event
* handler
*
* ***************** Version 18 *****************
* User: Es Date: 18.02.00 Time: 17:46
* Updated in $/GSM/Condat/MS/SRC/MFW
* danger in winUpdate
*
* ***************** Version 17 *****************
* User: Nm Date: 17.02.00 Time: 9:23
* Updated in $/GSM/Condat/MS/SRC/MFW
* updated winIsFocussed
*
* ***************** Version 16 *****************
* User: Kk Date: 17.01.00 Time: 8:56
* Updated in $/GSM/Condat/MS/SRC/MFW
* added simple check functions for easy checking if win is visible,
* focussed, closed
*
* ***************** Version 15 *****************
* User: Kk Date: 10.01.00 Time: 13:46
* Updated in $/GSM/Condat/MS/SRC/MFW
* some changes done by ES
*
* ***************** Version 3 *****************
* User: Rm Date: 12/22/99 Time: 4:34p
* Updated in $/GSM/Condat/SND-MMI/MFW
*
* ***************** Version 2 *****************
* User: Es Date: 22.11.99 Time: 10:30
* Updated in $/GSM/Condat/SND-MMI/MFW
*
* ***************** Version 1 *****************
* User: Es Date: 18.11.99 Time: 16:35
* Created in $/GSM/Condat/SND-MMI/MFW
* Initial
*
* ***************** Version 13 *****************
* User: Es Date: 6.07.99 Time: 12:37
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 11 *****************
* User: Es Date: 14.04.99 Time: 17:34
* Updated in $/GSM/DEV/MS/SRC/MFW
* moved to CST
|
| ***************** Version 10 *****************
| User: Le Date: 14.04.99 Time: 9:51
| Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 9 *****************
* User: Es Date: 1.04.99 Time: 17:07
* Updated in $/GSM/DEV/MS/SRC/MFW
* removed lots of traces
*
* ***************** Version 8 *****************
* User: Es Date: 20.02.99 Time: 19:24
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 7 *****************
* User: Es Date: 20.02.99 Time: 18:22
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 6 *****************
* User: Es Date: 20.02.99 Time: 15:37
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 5 *****************
* User: Es Date: 18.02.99 Time: 17:01
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 4 *****************
* User: Es Date: 17.02.99 Time: 19:11
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 3 *****************
* User: Es Date: 14.01.99 Time: 17:19
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 2 *****************
* User: Es Date: 23.12.98 Time: 16:19
* Updated in $/GSM/DEV/MS/SRC/MFW
*/
#define ENTITY_MFW
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "mfw_mfw.h"
#include "mfw_sys.h"
#include "gdi.h"
#include "dspl.h"
#include "mfw_win.h"
static MfwHdr *autoFocus; /* focus of toplevel window */
static U8 winUseAutoFocus = 0; /* automatic focussing flag */
static int winCommand (U32 cmd, void *h);
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
| STATE : code ROUTINE : winInit |
+--------------------------------------------------------------------+
PURPOSE : initialize window handler
*/
MfwRes winInit (U16 *sx, U16 *sy)
{
dspl_DevCaps displayData;
dspl_Init(); /* init display driver */
displayData.DisplayType = DSPL_TYPE_GRAPHIC;
dspl_SetDeviceCaps(&displayData);
dspl_GetDeviceCaps(&displayData);
*sx = displayData.Width;
*sy = displayData.Height;
winUseAutoFocus = 0;
mfwCommand[MfwTypWin] = (MfwCb) winCommand;
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
| STATE : code ROUTINE : winExit |
+--------------------------------------------------------------------+
PURPOSE : finalize window handler
*/
MfwRes winExit (void)
{
mfwCommand[MfwTypWin] = 0;
dspl_Exit(); /* finit display driver */
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
| STATE : code ROUTINE : winCreate |
+--------------------------------------------------------------------+
PURPOSE : create window control
*/
MfwHnd winCreate (MfwHnd w, MfwWinAttr *a, MfwEvt e, MfwCb f)
{
MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
MfwWin *win = (MfwWin *) mfwAlloc(sizeof(MfwWin));
MfwHdr *eoc = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
if (!hdr || !win || !eoc)
return 0;
eoc->next = hdr; /* setup eoc element */
eoc->type = MfwTypMax;
eoc->data = 0;
win->mask = e; /* setup window control */
win->flags = 0;
win->handler = f;
win->attr = a;
win->elems = eoc;
win->user = 0;
hdr->data = win; /* setup header element */
hdr->type = MfwTypWin;
if (mfwSignallingMethod == 0)
return mfwInsert(w,hdr);
else
{
mfwInsert(mfwParent(mfwFocus),hdr);
mfwFocus = eoc;
return hdr;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
| STATE : code ROUTINE : winDelete |
+--------------------------------------------------------------------+
PURPOSE : delete window control
*/
MfwRes winDelete (MfwHnd w)
{
MfwCb f;
MfwHdr *e, *t, *r;
MfwRes res;
/*NM, p012a*/
MfwWin *parent_controlBlock;
MfwHdr *parent_win;
/* U8 uMode;
p012a end*/
TRACE_FUNCTION("win_delete()");
if (!w)
return MfwResIllHnd;
if (((MfwHdr *) w)->type != MfwTypWin)
return MfwResIllHnd; /* element is not a window */
e = ((MfwHdr *) w)->data;
if (!e)
return MfwResErr;
((MfwWin *) e)->flags |= MfwWinDelete;
if (((MfwWin *) e)->handler)
if (((MfwWin *) e)->mask & MfwWinDelete)
((MfwWin *) e)->handler(MfwWinDelete,e);
e = ((MfwWin *) e)->elems;
if (!e)
return MfwResErr;
if (mfwFocus == e) /* was focus window */
mfwFocus = 0; /* no focus anymore */
/*NM, p012b
uMode = dspl_Enable(0);
p012b end*/
/*NM, p012c
winHide(w);
p012c end*/
while (e && e->type != MfwTypMax) /* try to delete all elems */
{
t = e->next;
if (e->data)
{
if (mfwSignallingMethod != 0 && e->type == MfwTypWin)
{
r = (MfwHdr*) mfwParent(w);
mfwRemove(e); /* move up child window */
mfwAppend(&(((MfwWin*)(r->data))->elems),e);
}
else
{
f = mfwCommand[e->type];
if (f)
f(MfwCmdDelete,e);
}
}
e = t;
}
res = (mfwRemove(w)) ? MfwResOk : MfwResIllHnd;
/*NM, p012d
old: after deleting the focus-win start from root to top
new: after deleting the focus-win just give the new focus to
his parent-win (faster)
*/
if (mfwSignallingMethod != 0 && mfwRoot && (!mfwFocus))
{
parent_win = (MfwHdr*) mfwParent(w);
if (((MfwHdr *) parent_win)->type == MfwTypWin)
{
parent_controlBlock = ((MfwHdr *) parent_win)->data;
winUpdate(parent_controlBlock);
mfwFocus = autoFocus;
}
}
/* the old one
if (mfwSignallingMethod != 0 && mfwRoot)
{
r = mfwRoot; /* the beginning
autoFocus = 0; /* reset focus
while (r->type != MfwTypMax) /* more links in chain
{
if (r->type == MfwTypWin) /* link is a window
winUpdate(r->data);
r = r->next;
}
mfwFocus = autoFocus;
}
dspl_Enable(uMode);
NM, p012d end */
mfwFree((MfwHnd) e,sizeof(MfwHdr));
mfwFree(((MfwHdr *) w)->data,sizeof(MfwWin));
mfwFree(w,sizeof(MfwHdr));
return res;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
| STATE : code ROUTINE : winShow |
+--------------------------------------------------------------------+
PURPOSE : show window (put in front of visibles)
*/
MfwRes winShow (MfwHnd w)
{
MfwWin *win;
U8 uMode;
TRACE_FUNCTION("winShow()");
if (!w)
return MfwResIllHnd; /* window does not exist */
if (((MfwHdr *) w)->type != MfwTypWin)
return MfwResIllHnd; /* element is not a window */
uMode = dspl_Enable(0);
win = ((MfwHdr *) w)->data; /* get control block */
mfwAppend(mfwRemove(w),w); /* to front (draw at last) */
win->flags |= MfwWinVisible; /* window is visible */
winUpdate(win); /* draw window elements */
if (winUseAutoFocus) /* automatic focussing */
mfwFocus = autoFocus; /* determined by update() */
dspl_Enable(uMode);
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
| STATE : code ROUTINE : winHide |
+--------------------------------------------------------------------+
PURPOSE : hide window (and redraw remaining)
*/
MfwRes winHide (MfwHnd w)
{
MfwHdr *r;
MfwWin *win;
U8 uMode;
if (!w)
return MfwResIllHnd; /* element does not exist */
if (((MfwHdr *) w)->type != MfwTypWin)
return MfwResIllHnd; /* element is not a window */
//JVJE uMode = dspl_Enable(0);
win = ((MfwHdr *) w)->data;
win->flags &= ~MfwWinVisible; /* window is not visible */
if (win->handler) /* call event handler */
if (win->mask & MfwWinVisible)
win->handler(MfwWinVisible,win);
r = mfwRoot; /* the beginning */
autoFocus = 0; /* reset focus */
while (r->type != MfwTypMax) /* more links in chain */
{
if (r->type == MfwTypWin) /* link is a window */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -