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

📄 framewin.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
📖 第 1 页 / 共 2 页
字号:
                    if (pMsg->Data.v) {      /* Focus received */
                      if (pObj->hFocussedChild) {
                        WM_SendMessage(pObj->hFocussedChild, pMsg);
                      } else {
                        pObj->hFocussedChild = WM_SetFocusOnNextChild(hWin);
                      }
C51 COMPILER V8.05a   FRAMEWIN                                                             04/11/2008 14:19:34 PAGE 6   

                    }
                    return;
                  case WM_KEY:
                    if ( ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt >0) {
                      int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key;
                      switch (Key) {
                        case GUI_KEY_TAB:
                          pObj->hFocussedChild = WM_SetFocusOnNextChild(hWin);
                          break;                    /* Send to parent by not doing anything */
                      }
                    }
                    break;
                  case WM_NOTIFY_CHILD_HAS_FOCUS:
                    pObj->hFocussedChild = pMsg->hWinSrc;
                    if (pMsg->Data.v) {
                      pObj->Widget.State |= WIDGET_STATE_CHILD_HAS_FOCUS;
                    } else {
                      pObj->Widget.State &= ~WIDGET_STATE_CHILD_HAS_FOCUS;
                    }
                    WM_InvalidateWindow(hParent);
                    break;
                  case WM_GET_BKCOLOR:
                    pMsg->Data.Color = pObj->ClientColor;
                    return;                       /* Message handled */
                  case WM_GET_CLIENT_WINDOW:      /* return handle to client window. For most windows, there is no seper
             -ate client window, so it is the same handle */
                    WM_DefaultProc(pMsg);
                    return;                       /* We are done ! */
                }
                if (cb) {
                  pMsg->hWin = hParent;
                  (*cb)(pMsg);
                }
              }
              
              /*********************************************************************
              *
              *        Exported routines:  Create
              *
              **********************************************************************
              */
              
              FRAMEWIN_Handle FRAMEWIN_CreateAsChild( 
                                                  int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
                                                  const char* pText, WM_CALLBACK* cb, int Flags)
              {
                FRAMEWIN_Handle hObj;
                /* Create the window */
                GUI_LOCK();
                hObj = WM_CreateWindowAsChild(x0, y0, xsize/*+2*HBorder*/, ysize/*+TBorder+BBorder*/, hParent,
                                      Flags, _FRAMEWIN_Callback, sizeof(FRAMEWIN_Obj) - sizeof(WM_Obj));
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  /* init widget specific variables */
                  WIDGET__Init(&pObj->Widget, WIDGET_STATE_FOCUSSABLE | WIDGET_STATE_ENABLED);
                  /* init member variables */
                  pObj->pFont = _pDefaultFont;
                  memcpy(pObj->BarColor, _aBarColor, sizeof(pObj->BarColor));
                  pObj->TextColor    = 0xffffff;
                  pObj->TextAlign    = GUI_TA_LEFT;
                  pObj->ClientColor  = _DefaultClientColor;
                  pObj->pText        = pText;
C51 COMPILER V8.05a   FRAMEWIN                                                             04/11/2008 14:19:34 PAGE 7   

                  pObj->XOff = 1;
                  pObj->YOff = 1;
                  pObj->cb = cb;
                  _CalcPositions(hObj);
              #if 0
                  pObj->hClient = WM_CreateWindowAsChild(pObj->rClient.x0, pObj->rClient.y0,
                                                         pObj->rClient.x1 - pObj->rClient.x0 +1, 
                                                         pObj->rClient.y1 - pObj->rClient.y0 +1, 
                                                         hObj, WM_CF_SHOW, FRAMEWIN__cbClient, 0);
              #else
                  pObj->hClient = WM_CreateWindowAsChild(0,0,0,0,
                                                         hObj, WM_CF_SHOW, FRAMEWIN__cbClient, 0);
              #endif
                }
                GUI_UNLOCK();
                return hObj;
              }
              
              FRAMEWIN_Handle FRAMEWIN_Create( const char* pText,
                                                  WM_CALLBACK* cb,
                                                  int Flags,
                                                  int x0, int y0, int xsize, int ysize) {
              
                return FRAMEWIN_CreateAsChild(x0, y0, xsize, ysize, WM_HWIN_NULL, pText, cb, Flags);
              }
              
              
              FRAMEWIN_Handle FRAMEWIN_CreateIndirect(const GUI_WIDGET_CREATE_INFO* pCreateInfo, WM_HWIN hWinParent, int
             - x0, int y0, WM_CALLBACK* pCallback) {
                FRAMEWIN_Handle hObj;
                hObj = FRAMEWIN_CreateAsChild(
                  pCreateInfo->x0 + x0, pCreateInfo->y0 + y0, pCreateInfo->xSize, pCreateInfo->ySize, hWinParent,
                  pCreateInfo->pName, pCallback, 0);
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->Flags = pCreateInfo->Flags;
                }
                return hObj;
              }
              
              /*********************************************************************
              *
              *        Exported routines:  Various methods
              *
              **********************************************************************
              */
              void FRAMEWIN_SetFont(FRAMEWIN_Handle hObj, const GUI_FONT* pFont) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->pFont = pFont;
                  _CalcPositions(hObj);
                  FRAMEWIN_Invalidate(hObj);
                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetBarColor(FRAMEWIN_Handle hObj, int index, GUI_COLOR color) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->BarColor[index] = color;
C51 COMPILER V8.05a   FRAMEWIN                                                             04/11/2008 14:19:34 PAGE 8   

                  FRAMEWIN_Invalidate(hObj);
                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetTextColor(FRAMEWIN_Handle hObj, GUI_COLOR color) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->TextColor = color;
                  FRAMEWIN_Invalidate(hObj);
                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetText(FRAMEWIN_Handle hObj, const char* s) {
                char NeedsInvalidate;
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  NeedsInvalidate = 1;
                  if (s && pObj->pText) {
                    if (strcmp(s, pObj->pText) == 0) {
                      NeedsInvalidate = 0;
                    }
                  }
                  pObj->pText = s;
                  if (NeedsInvalidate) {
                    FRAMEWIN_Invalidate(hObj);
                  }
                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetTextAlign(FRAMEWIN_Handle hObj, int Align) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->TextAlign = Align;
                  switch (Align) {
                  case GUI_TA_HCENTER:
                    pObj->XOff = (pObj->rClient.x1 - pObj->rClient.x0) / 2;
                    break;
                  case GUI_TA_LEFT:
                    pObj->XOff = pObj->FrameSize;
                    break;
                  case GUI_TA_RIGHT:
                    pObj->XOff = pObj->rClient.x1 - pObj->FrameSize;
                    break;
                  }
                  FRAMEWIN_Invalidate(hObj);
                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetTextPos(FRAMEWIN_Handle hObj, int XOff, int YOff) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->XOff = XOff;
                  pObj->YOff = YOff;
                  FRAMEWIN_Invalidate(hObj);
C51 COMPILER V8.05a   FRAMEWIN                                                             04/11/2008 14:19:34 PAGE 9   

                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetClientColor(FRAMEWIN_Handle hObj, GUI_COLOR Color) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  pObj->ClientColor = Color;
                  FRAMEWIN_Invalidate(hObj);
                }
                GUI_UNLOCK();
              }
              
              
              void FRAMEWIN_SetMoveable(FRAMEWIN_Handle hObj, int State) {
                GUI_LOCK();
                if (hObj) {
                  FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj);
                  if (State) {
                    pObj->Flags |= FRAMEWIN_CF_MOVEABLE;
                  } else {
                    pObj->Flags &= ~FRAMEWIN_CF_MOVEABLE;
                  }
                }
                GUI_UNLOCK();
              }
              
              void FRAMEWIN_SetActive(FRAMEWIN_Handle hObj, int State) {
                GUI_LOCK();
                if (hObj) {
                  if (State) {
                    FRAMEWIN_SetBarColor(hObj, 0, FRAMEWIN_BARCOLOR_ACTIVE_DEFAULT);
                  } else {
                    FRAMEWIN_SetBarColor(hObj, 0, FRAMEWIN_BARCOLOR_INACTIVE_DEFAULT);
                  }
                }
                GUI_UNLOCK();
              }
              
              
              /***************************************************************
              *
              *                Set/Get defaults
              *
              ***************************************************************/
              
              void FRAMEWIN_SetDefaultFont(const GUI_FONT* pFont) {
                _pDefaultFont = pFont;
              }
              
              const GUI_FONT* FRAMEWIN_GetDefaultFont(void) {
                return _pDefaultFont;
              }
              
              void FRAMEWIN_SetDefaultBarColor(int Index, GUI_COLOR Color) {
                if ((Index >= 0) && (Index <= 1)) {
                  _aBarColor[Index] = Color;
                }
              }
              
              GUI_COLOR FRAMEWIN_GetDefaultBarColor(int Index) {
C51 COMPILER V8.05a   FRAMEWIN                                                             04/11/2008 14:19:34 PAGE 10  

                GUI_COLOR r = 0;
                if ((Index >= 0) && (Index <= 1)) {
                  r = _aBarColor[Index];
                }
                return r;
              }
              
              void FRAMEWIN_SetDefaultClientColor(GUI_COLOR Color) {
                _DefaultClientColor = Color;
              }
              
              GUI_COLOR FRAMEWIN_GetDefaultClientColor(void) {
                return _DefaultClientColor;
              }
              
              int FRAMEWIN_GetDefaultCaptionSize(void) {
                return _DefaultCaptionSize;
              }
              
              void FRAMEWIN_SetDefaultCaptionSize(int DefaultCaptionSize) {
                _DefaultCaptionSize = DefaultCaptionSize;
              }
              
              int FRAMEWIN_GetDefaultBorderSize(void) {
                return _DefaultBorderSize;
              }
              
              void FRAMEWIN_SetDefaultBorderSize(int DefaultBorderSize) {
                _DefaultBorderSize = DefaultBorderSize;
              }
              
              
              #else
 580            void WIDGET_FrameWin(void) {} /* avoid empty object files */
 581          #endif /* GUI_WINSUPPORT */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =      1    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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