Exemplo n.º 1
0
/*********************************************************************
*
*       _MoveDescendents
*
* Description
*   Moves _MoveDescendents.
*   Since the parent has already been moved, there is no need to
*   take care of invalidation.
*
* Parameters
*   hWin    The first of all descendents to be moved (first child)
*/
static void _MoveDescendents(WM_HWIN hWin, int dx, int dy) {
  WM_Obj* pWin;

  for (;hWin; hWin = pWin->hNext) {
    pWin = WM_HANDLE2PTR(hWin);
    GUI_MoveRect(&pWin->Rect, dx, dy);
    GUI_MoveRect(&pWin->InvalidRect, dx, dy);
    _MoveDescendents(pWin->hFirstChild, dx, dy);  /* Children need to be moved along ...*/
    WM__SendMsgNoData(hWin, WM_MOVE);
  }
}
Exemplo n.º 2
0
/*********************************************************************
*
*       _NotifyVisChanged
*
* Description
*   Notify all descendents
*/
static void _NotifyVisChanged(WM_HWIN hWin, GUI_RECT * pRect) {
  WM_Obj* pWin;

  for (hWin = WM_GetFirstChild(hWin); hWin; hWin = pWin->hNext) {
    pWin = WM_H2P(hWin);
    if (pWin->Status & WM_SF_ISVIS) {
      if (GUI_RectsIntersect(&pWin->Rect, pRect)) {
        WM__SendMsgNoData(hWin, WM_NOTIFY_VIS_CHANGED);             /* Notify window that visibility may have changed */
        _NotifyVisChanged(hWin, pRect);
      }
    }
  }
}
Exemplo n.º 3
0
/*********************************************************************
*
*       Public module internal code
*
**********************************************************************
*/
void WM__MoveWindow(WM_HWIN hWin, int dx, int dy) {
  GUI_RECT r;
  WM_Obj* pWin;
  pWin = WM_HANDLE2PTR(hWin);
  r = pWin->Rect;
  GUI_MoveRect(&pWin->Rect, dx, dy);
  /* Invalidate old and new area ... */
  if (pWin->Status & WM_SF_ISVIS) {
    WM_InvalidateArea(&pWin->Rect);     /* Invalidate new area */
    WM_InvalidateArea(&r)         ;     /* Invalidate old area */
  }
  WM__SendMsgNoData(hWin, WM_MOVE); /* Notify window it has been moved */
  _MoveAllChildren(pWin->hFirstChild, dx, dy);  /* Children need to be moved along ...*/
}
Exemplo n.º 4
0
void WM_ResizeWindow(WM_HWIN hWin, int dx, int dy) {
  GUI_RECT r;
  WM_LOCK();
  r = WM_HANDLE2PTR(hWin)->Rect;
  if (dx>0)
    r.x1+=dx;
  if (dy>0)
    r.y1+=dy;
  WM_HANDLE2PTR(hWin)->Rect.x1+=dx;
  WM_HANDLE2PTR(hWin)->Rect.y1+=dy;
  WM_InvalidateArea(&r);
/* Send size message to the window */
  WM__SendMsgNoData(hWin, WM_SIZE);
  WM_UNLOCK();
}
Exemplo n.º 5
0
void WM_DeleteWindow (WM_HWIN Win) {
  WM_Obj* pWin;
  if (!Win)
    return;
  WM_LOCK();
  if (WM__IsWindow(Win)) {
    pWin = WM_H2P(Win);
    ResetNextDrawWin();              /* Make sure the window will no longer receive drawing messages */
  /* Make sure that focus is set to an existing window */
    if (WM__hWinFocus == Win) {
      WM__hWinFocus = 0;
    }
    if (Win == WM__hCapture) {
      WM__hCapture = 0;
    }
  /* Delete all children */
    _DeleteAllChildren(pWin->hFirstChild);
    _DeleteInSiblingList(Win);
  /* Send WM_DELETE message to window in order to inform window itself */
    WM__SendMsgNoData(Win, WM_DELETE);     /* tell window about it */
    /* Inform other modules if necessary */
    if (WM__pfDeleteWindowHook) {
      (*WM__pfDeleteWindowHook)(Win);
    }
  /* Remove window from window stack */
    if (pWin->Status & WM_SF_INVALID) {
      WM__NumInvalidWindows--;
    }
    WM__RemoveFromLinList(Win);
  /* Clear area used by this window */
    WM_InvalidateArea(&pWin->Rect);
  /* Free window memory */
    WM__NumWindows--;
    WM_FREE(Win);
  /* Select a valid window */
    WM_SelectWindow(WM__FirstWin);
  } else {
    GUI_DEBUG_WARN("WM_DeleteWindow: Invalid handle");
  }
  WM_UNLOCK();
}
Exemplo n.º 6
0
WM_HWIN WM_CreateWindowAsChild(
                    int x0, int y0, int width, int height
                   ,WM_HWIN hWinParent
                   ,U16 Style
                   ,WM_CALLBACK* cb
                   ,int NumExtraBytes)
{
  WM_Obj* pWin;
  WM_HWIN hWin;
  WM_LOCK();
  Style |= WM__CreateFlags;
  /* Get Parent info */
  if (!hWinParent) {
    if (WM__NumWindows) {
      hWinParent = WM_HBKWIN;
    }
  }
  if (hWinParent) {
    GUI_RECT Rect;
    WM_MESSAGE Msg;
    Msg.MsgId = WM_GETCLIENTRECT_ABS;
    Msg.Data.p = &Rect;
    WM_SendMessage(hWinParent, &Msg);
    x0 += Rect.x0;
    y0 += Rect.y0;
    if (width==0)
      width = Rect.x1-Rect.x0+1;
    if (height==0)
      height = Rect.y1-Rect.y0+1;
  }
  if ((hWin = (WM_HWIN) WM_ALLOC(NumExtraBytes+sizeof(WM_Obj))) == 0) {
    GUI_DEBUG_ERROROUT("WM_CreateWindow: No memory to create window");
  } else {
    WM__NumWindows++;
    pWin = WM_H2P(hWin);
    memset (pWin,   0, sizeof(WM_Obj));        /* erase this data structure
           The explicit zero-init is no longer needed since the entire data structure
           is already zeroed. The advantage is that it reduces program size.
           */
    pWin->Rect.x0 = x0;
    pWin->Rect.y0 = y0;
    pWin->Rect.x1 = x0+width-1;
    pWin->Rect.y1 = y0+height-1;
    pWin->Status = WM_SF_INUSE;     /* Mark window as in use */
    pWin->cb = cb;
    /* Add to linked lists */
    pWin->hParent = hWinParent;
    _AddChild(hWinParent, hWin, Style & WM_CF_STAYONTOP);
    _AddToLinList(hWin);
  /* Put Window on top (or bottom) of windows stack */
    if (Style & WM_CF_ACTIVATE /*| (cb==NULL)*/) {
      WM_SelectWindow(hWin);  /* This is not needed
                                 if callbacks are being used, but it
                                 does not cost a lot and makes life
                                 easier ... */
    }
  /* Mark client area as invalid */
    WM__SendMsgNoData(hWin, WM_CREATE);
  /* Handle the Style flags, one at a time */
    if (Style & WM_CF_SHOW) {
      WM_ShowWindow(hWin);
    }
  /* Hide if parent is not visible */
    if (hWinParent) {
      WM_Obj* pWinParent = WM_H2P(hWinParent);
      if (!(pWinParent->Status & WM_SF_ISVIS)) {
        WM_HideWindow(hWin);
      }
    }
    /* Copy the flags which can simply be accepted */
    pWin->Status |= (Style & (WM_SF_MEMDEV|WM_SF_STAYONTOP|WM_SF_HASTRANS));
  }
  WM_UNLOCK();
  return hWin;
}