wm_getwindowsize.c

来自「uCGUI」· C语言 代码 · 共 93 行

C
93
字号
/*************************************************************************************************************
                                                   uC/GUI
                                               嵌入式通用图形软件
File        : WM_GetWindowSize.c
Purpose     : Implementation of WM_GetWindowSizeX,Y
************************************************************************************************************/

#include "WM_Intern.h"

#if GUI_WINSUPPORT    /* If 0, WM will not generate any code */

/*************************************************************************************************************
*       Static routines
************************************************************************************************************/

/*************************************************************************************************************
*

  When drawing, we have to start at the bottom window !
*/
static WM_HWIN _GetDefaultWin(WM_HWIN hWin) {
  if (!hWin)
    hWin = WM_GetActiveWindow();
  return hWin;
}

/*************************************************************************************************************
*             Module internal routines
************************************************************************************************************/


/*************************************************************************************************************
*       WM__GetWindowSizeX

  Return width of window in pixels
*/
int WM__GetWindowSizeX(WM_Obj* pWin) {
  return pWin->Rect.x1 - pWin->Rect.x0 +1;
}

/*************************************************************************************************************
*       WM__GetWindowSizeY

  Return height of window in pixels
*/
int WM__GetWindowSizeY(WM_Obj* pWin) {
  return pWin->Rect.y1 - pWin->Rect.y0 +1;
}


/*************************************************************************************************************
*      Public API code
************************************************************************************************************/
/*************************************************************************************************************
*       WM_GetWindowSizeX

  Return width of window in pixels
*/
int WM_GetWindowSizeX(WM_HWIN hWin) {
  int r;
  WM_Obj* pWin;
  WM_LOCK();
  hWin = _GetDefaultWin(hWin);
  pWin = WM_H2P(hWin);
  r = WM__GetWindowSizeX(pWin);
  WM_UNLOCK();
  return r;
}


/*************************************************************************************************************
*       WM_GetWindowSizeY

  Return height of window in pixels
*/
int WM_GetWindowSizeY(WM_HWIN hWin) {
  int r;
  WM_Obj* pWin;
  WM_LOCK();
  hWin = _GetDefaultWin(hWin);
  pWin = WM_H2P(hWin);
  r = WM__GetWindowSizeY(pWin);
  WM_UNLOCK();
  return r;
}


#else

void WM_GetWindowSize_C(void) {} /* avoid empty object files */

#endif /* WM_MAX_WINDOW */

⌨️ 快捷键说明

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