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

📄 wm.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
              /*********************************************************************
              *
              *              Get next IVR
              
                Sets the next clipping rectangle. If a valid one has
                been found (and set), 1 is returned in order to indicate
                that the drawing operation needs to be executed.
                Returning 0 signals that we have iterated over all
                rectangles.
              
                Returns: 0 if no valid rectangle is found
                         1 if rectangle has been found
              */
              
              int  WM__GetNextIVR   (void) {
                #if GUI_SUPPORT_CURSOR
                  static char _CursorHidden;
                #endif
                /* If WM is not active, we have no rectangles to return */
                if (WM_IsActive==0)
                  return 0;
                if (ClipContext.EntranceCnt > 1) {
                  ClipContext.EntranceCnt--;
                  return 0;
                }
                #if GUI_SUPPORT_CURSOR
                  if (_CursorHidden) {
                    _CursorHidden = 0;
                    (*GUI_CURSOR_pfTempUnhide) ();
                  }
                #endif
                ++ClipContext.Cnt;
C51 COMPILER V8.05a   WM                                                                   04/11/2008 14:19:41 PAGE 19  

                /* Find next rectangle and use it as ClipRect */
                if (!FindNext_IVR()) {
                  ClipContext.EntranceCnt--;  /* This search is over ! */
                  return 0;        /* Could not find an other one ! */
                }
                /* Hide cursor if necessary */
                LCD_SetClipRectEx(&ClipContext.CurRect);
                #if GUI_SUPPORT_CURSOR
                  if (GUI_CURSOR_pfTempHide) {
                    _CursorHidden = (*GUI_CURSOR_pfTempHide) ( &ClipContext.CurRect);
                  }
                #endif
                return 1;
              }
              
              
              
              /*********************************************************************
              *
              *              Init IVR  search
              
                This routine is called from the clipping level
                (the WM_ITERATE_START macro) when starting an iteration over the
                visible rectangles.
              
                Return value:
                  0 : There is no valid rectangle (nothing to do ...)
                  1 : There is a valid rectangle
              */
              
              
              int WM__InitIVRSearch(const GUI_RECT* pMaxRect) {
                GUI_RECT r;
                WM_Obj* pAWin;
                 /* If WM is not active -> nothing to do, leave cliprect alone */
                if (WM_IsActive==0)
                  return 1;            
                /* If we entered multiple times, leave Cliprect alone */
                if (++ClipContext.EntranceCnt > 1)
                  return 1;
                pAWin = WM_H2P(GUI_Context.hAWin);
                ClipContext.Cnt        = -1;
               /* When using callback mechanism, it is legal to reduce drawing
                  area to the invalid area ! */
                if (IsInCallback) {
                  WM__GetInvalidRectAbs(pAWin, &r);
                } else {  /* Not using callback mechanism, therefor allow entire rectangle */
                  if (pAWin->Status & WM_SF_ISVIS) {
                    r = pAWin->Rect;
                  } else {
                    --ClipContext.EntranceCnt;
                    return 0;  /* window is not even visible ! */
                  }
                }
                /* If the drawing routine has specified a rectangle, use it to reduce the rectangle */
                if (pMaxRect) {
                  GUI__IntersectRect(&r, pMaxRect);
                }
                /* If user has reduced the cliprect size, reduce the rectangle */
                if (GUI_Context.WM__pUserClipRect) {
                  GUI_RECT rUser = *(GUI_Context.WM__pUserClipRect);
                  WM__Client2Screen(pAWin, &rUser);
C51 COMPILER V8.05a   WM                                                                   04/11/2008 14:19:41 PAGE 20  

                  GUI__IntersectRect(&r, &rUser);
                }
                /* Iterate over all ancestors and clip at their borders */
                _ClipAtParentBorders(&r, pAWin);
                /* Store the rectangle and find the first rectangle of the area */
                ClipContext.ClientRect = r;
                return WM__GetNextIVR();
              }
              
              
              /*
                        ********************************************
                        *                                          *
                        *       Set default                        *
                        *                                          *
                        ********************************************
              
                This routine sets the defaults for WM and the layers below.
                It is used before a drawing routine is called in order to
                make sure that defaults are set (in case the default settings
                had been altered before by the application)
              */
              void WM_SetDefault(void) {
                GL_SetDefault();
                GUI_Context.WM__pUserClipRect = NULL;   /* No add. clipping */
              }
              
              /*
                ********************************************
                *
                *        Callback for Paint message
                *
                ********************************************
              
                This callback is used by the window manger in conjunction with banding
                memory devices. A pointer to this routine is given to the banding memory device.
                This callback in turn will send the paint message to the window.
              */
              #if GUI_SUPPORT_MEMDEV
              
              static void cbPaint(void* pMsg) {
                WM_SendMessage(((WM_MESSAGE*)pMsg)->hWin, (WM_MESSAGE*) pMsg);
              }
              
              #endif
              
              /*
                        ********************************************
                        *                                          *
                        *       Draw next window                   *
                        *                                          *
                        ********************************************
              */
              
              
              static void _DrawNext(void) {
                int UpdateRem = 1;
                WM_HWIN iWin = (NextDrawWin == WM_HWIN_NULL) ? WM__FirstWin : NextDrawWin;
                GUI_CONTEXT ContextOld;
                GUI_SaveContext(&ContextOld);
                /* Make sure the next window to redraw is valid */
                for (; (iWin!=WM_HWIN_NULL) && UpdateRem; ) {
C51 COMPILER V8.05a   WM                                                                   04/11/2008 14:19:41 PAGE 21  

                  WM_Obj* pWin = WM_H2P(iWin);
                  if (pWin->Status & WM_SF_INVALID) {
                    U8 Status = (pWin->Status &=  ~WM_SF_INVALID); /* Clear invalid flag */
                    WM__NumInvalidWindows--;
                    /* Send WM_PAINT if window is visible and a callback is defined */
                    if ((pWin->cb != NULL)  && (Status & WM_SF_ISVIS)) {
                      WM_MESSAGE Msg;
                      Msg.hWin   = iWin;
                      Msg.MsgId  = WM_PAINT;
                      Msg.Data.p = (GUI_RECT*)&pWin->InvalidRect;
                      WM_SelectWindow(iWin);
                      WM_SetDefault();
                      #if GUI_SUPPORT_MEMDEV
                        if (Status & WM_SF_MEMDEV) {
                          GUI_RECT r = pWin->InvalidRect;
                          GUI_MoveRect (&r, pWin->Rect.x0, pWin->Rect.y0);
                          GUI_MEMDEV_Draw(&r, cbPaint, &Msg, 0, (Status & WM_SF_HASTRANS) ? GUI_MEMDEV_HASTRANS : 0);
                        } else
                      #endif
                      WM_SendMessage(iWin, &Msg);
                      UpdateRem--;  /* Only the given number of windows at a time ... */
                    }
                  }
                  iWin = pWin->hNextLin;
                }  
                NextDrawWin = iWin;   /* Remember the window */
                GUI_RestoreContext(&ContextOld);
              }
              
              /*
                        *****************************************************************
                        *                                                               *
                        *                 Idle loop                                     *
                        *                                                               *
                        *****************************************************************
              */
              
              int WM_Exec1(void) {
                /* Poll PID if necessary */
                if (WM_pfPollPID) {
                  WM_pfPollPID();
                }
                if (WM_pfHandlePID) {
                  if (WM_pfHandlePID())
                    return 1;               /* We have done something ... */
                }
                if (GUI_PollKeyMsg()) {
                  return 1;               /* We have done something ... */
                }
                if (WM_IsActive && WM__NumInvalidWindows) {
                  WM_LOCK();
                  _DrawNext();
                  WM_UNLOCK();
                  return 1;               /* We have done something ... */
                }
                return 0;                  /* There was nothing to do ... */
              }
              
              int WM_Exec(void) {
                int r = 0;
                while (WM_Exec1()) {
                  r = 1;                  /* We have done something */
C51 COMPILER V8.05a   WM                                                                   04/11/2008 14:19:41 PAGE 22  

                }
                return r;
              }
              
              
              /****************************************************************
              *                                                               *
              *              Callback for background window                   *
              *                                                               *
              *****************************************************************
              */
              
              static WM_RESULT cbBackWin( WM_MESSAGE* pMsg) {
                WM_KEY_INFO* pKeyInfo;
                switch (pMsg->MsgId) {
                case WM_KEY:
                  pKeyInfo = (WM_KEY_INFO*)pMsg->Data.p;
                  if (pKeyInfo->PressedCnt == 0) {
                    GUI_StoreKey(pKeyInfo->Key);
                  }
                  break;
                case WM_PAINT:
                  if (WM__BkColor != GUI_INVALID_COLOR) {
                    GUI_SetBkColor(WM__BkColor);
                    GUI_Clear();
                  }
                default:
                  WM_DefaultProc(pMsg);
                }
              }
              
              
              /****************************************************************
              *
              *                    WM_Activate  / WM_Deactivate
              *
              *****************************************************************
              
              */
              
              void WM_Activate(void) {
                WM_IsActive = 1;       /* Running */
              }
              
              void WM_Deactivate(void) {
                WM_IsActive = 0;       /* No clipping performed by WM */
                WM__SetMaxClipRect(WM_H2P(WM_HBKWIN));
              }
              
              /*
                        *****************************************************************
          

⌨️ 快捷键说明

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