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

📄 mfw_win.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    MfwWin *win;


	TRACE_FUNCTION("winShow()");

    if (!w)
        return MfwResIllHnd;            /* window does not exist    */
    if (((MfwHdr *) w)->type != MfwTypWin)
        return MfwResIllHnd;            /* element is not a window  */
    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()   */
    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;

    if (!w)
        return MfwResIllHnd;            /* element does not exist   */
    if (((MfwHdr *) w)->type != MfwTypWin)
        return MfwResIllHnd;            /* element is not a window  */

    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         */
            winUpdate(r->data);
        r = r->next;
    }
    if (winUseAutoFocus)                /* automatic focussing      */
        mfwFocus = autoFocus;           /* determined by update()   */

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winUnhide          |
+--------------------------------------------------------------------+

  PURPOSE : unhide window (without redrawing, no event)

*/

MfwRes winUnhide (MfwHnd w)
{
    MfwWin *win;

    if (!w)
        return MfwResIllHnd;            /* element does not exist   */
    if (((MfwHdr *) w)->type != MfwTypWin)
        return MfwResIllHnd;            /* element is not a window  */

    win = ((MfwHdr *) w)->data;
    win->flags |= MfwWinVisible;        /* window will be visible   */

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winFocus           |
+--------------------------------------------------------------------+

  PURPOSE : assign input/event focus to window

*/

MfwHnd winFocus (MfwHnd w)
{
    MfwWin *wNew, *wOld = 0;

    if (winUseAutoFocus)                /* automatic focussing      */
        return 0;                       /* ES!! only for testing !! */
    if (!w)
    {
        w = mfwFocus;
        mfwFocus = 0;                   /* delete focus             */
        return w;                       /* return old focus         */
    }

    if (((MfwHdr *) w)->type != MfwTypWin)
        return 0;                       /* element is not a window  */

    if (mfwFocus)
    {
        while (mfwFocus->type != MfwTypMax)
            mfwFocus = mfwFocus->next;  /* search focus root        */
        mfwFocus = mfwFocus->next;      /* the focus window         */
        if (mfwFocus->type != MfwTypWin)
        {
            mfwFocus = 0;               /* serious error:           */
            return 0;                   /* element is not a window  */
        }
        wOld = mfwFocus->data;          /* window control block     */
        wOld->flags &= ~MfwWinFocussed; /* input focus / deselected */
    }

    wNew = ((MfwHdr *) w)->data;
    w = mfwFocus;                       /* save old focus           */
    mfwFocus = wNew->elems;             /* focus on window elements */
    wNew->flags |= MfwWinFocussed;      /* input focus / selected   */

    if (wNew->handler)                  /* call new event handler   */
        if (wNew->mask & MfwWinFocussed)
            wNew->handler(MfwWinFocussed,wNew);
    if (wOld && wOld->handler)          /* call old event handler   */
        if (wOld->mask & MfwWinFocussed)
            wOld->handler(MfwWinFocussed,wOld);

    return w;                           /* return old focus         */
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winAutoFocus       |
+--------------------------------------------------------------------+

  PURPOSE : set auto focus mode

*/

U8 winAutoFocus (U8 useit)
{
    U8 winUseAutoFocusOld = winUseAutoFocus; /* save previous state */

    winUseAutoFocus = useit;

    return winUseAutoFocusOld;          /* return previous state    */
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winClear           |
+--------------------------------------------------------------------+

  PURPOSE : clear window

*/

MfwRes winClear (MfwHnd w)
{
    MfwWin *win;

    if (!w)
    {
        dspl_ClearAll();                /* clear screen             */
        return MfwResOk;
    }

    win = ((MfwHdr *) w)->data;         /* clear window area        */
    dspl_Clear(win->attr->win.px,win->attr->win.py,
               (U16) (win->attr->win.sx+win->attr->win.px-2),
               (U16) (win->attr->win.sy+win->attr->win.py-2));

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winUpdate          |
+--------------------------------------------------------------------+

  PURPOSE : draw all visible windows

*/

MfwRes winUpdate (MfwWin *w)
{
    MfwCb f = 0;                        /* modules command handler  */
    MfwHdr *e;                          /* windows elements         */

//	TRACE_FUNCTION("winUpdate()");
	
    if (!w)
        return MfwResIllHnd;

    if (mfwSignallingMethod == 0)
    {
        if (!(w->flags & MfwWinVisible))
            return MfwResOk;                /* hidden window            */

        if (w->handler)                     /* THEN: call event handler */
            if (w->mask & MfwWinVisible)
                w->handler(MfwWinVisible,w);
        e = w->elems;                       /* FIRST: update children   */
        autoFocus = e;                      /* gets focus of top window */
        while (e->type != MfwTypMax)        /* window has elements      */
        {
            if (e->type > MfwTypNone && e->type < MfwTypMax)
            {
                f = mfwCommand[e->type];
                if (f)                      /* cmd function implemented */
                    f(MfwCmdUpdate,e);
            }
            e = e->next;
        }
    }
    else
    {
        if (w->handler && (w->flags & MfwWinVisible))
            if (w->mask & MfwWinVisible){
                w->handler(MfwWinVisible,w);
            }

        e = w->elems;                       /* FIRST: update children   */
        autoFocus = e;                      /* gets focus of top window */
        while (e->type != MfwTypMax)        /* window has elements      */
        {
            if (e->type > MfwTypNone && e->type < MfwTypMax)
            {
                f = mfwCommand[e->type];
                if (f && ((w->flags & MfwWinVisible)
                                || (e->type == MfwTypWin)))
                    f(MfwCmdUpdate,e);
            }
            e = e->next;
        }
    }

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winNext            |
+--------------------------------------------------------------------+

  PURPOSE : show next window (for testing purposes only)

*/

MfwHnd winNext (MfwHnd winCur)
{
    MfwHdr *cw;                         /* current window pointer   */

    if (!winCur)
        return 0;

    cw = ((MfwWin *) (((MfwHdr *) winCur)->data))->elems;
    while (cw->type != MfwTypWin)
    {
        if (cw->type == MfwTypMax)
        {
            cw = cw->next;
            if (!cw)
                cw = mfwRoot;
            else
                cw = cw->next;          /* windows successor        */
        }
        else
            cw = cw->next;
    }

    return cw;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winPrev            |
+--------------------------------------------------------------------+

  PURPOSE : show previous window (for testing purposes only)

*/

MfwHnd winPrev (MfwHnd winCur)
{
    MfwHnd wo, wc;

    wo = wc = winNext(winCur);
    while (wc != winCur)
    {
        wo = wc;
        wc = winNext(wc);
    }

    return wo;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winCommand         |
+--------------------------------------------------------------------+

  PURPOSE : handle mfw windows command

*/

static int winCommand (U32 cmd, void *h)
{
    switch (cmd)
    {
        case MfwCmdDelete:              /* delete me                */
            if (!h)
                return 0;
            winDelete(h);
            return 1;
        case MfwCmdUpdate:              /* repaint                  */
            if (!h || ((MfwHdr *) h)->type != MfwTypWin)
                return 0;
            winUpdate(((MfwHdr *) h)->data);
            return 1;
        default:
            break;
    }

    return 0;
}

/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_WIN            |
| STATE   : code                        ROUTINE : winIsVisible       |
+--------------------------------------------------------------------+

  PURPOSE : check if window is visible

*/
int winIsVisible(MfwHnd w)
{
    MfwWin *win;

    if (!w)
        return 0;                       /* no handle                */

    if (((MfwHdr *) w)->type != MfwTypWin)
        return 0;                       /* element is not a window  */

    win = ((MfwHdr *) w)->data;

    return (win->flags & MfwWinVisible);
}


/*

⌨️ 快捷键说明

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