Exemple #1
0
static void _DeleteInSiblingList(WM_HWIN hWin) {
  WM_Obj* pWin;
  WM_Obj* pParent;
  WM_Obj* pi;
  WM_HWIN hParent;
  WM_HWIN hi;
  pWin = WM_H2P(hWin);
  if (pWin->hParent) {
    hParent = pWin->hParent;
    pParent = WM_H2P(hParent);
    hi = pParent->hFirstChild;
    if (hi == hWin) {
      pi = WM_H2P(hi);
      pParent->hFirstChild = pi->hNext;
    } else {
      while (hi) {
        pi = WM_H2P(hi);
        if (pi->hNext == hWin) {
          pi->hNext = pWin->hNext;
          return;
        }
        hi = pi->hNext;
      }
    }
  }
}
Exemple #2
0
/* Invalidate, using desktop coordinates */
void WM_InvalidateBWinAbs(WM_HWIN hWin, const GUI_RECT*pRect) {
  GUI_RECT r = *pRect;
  WM_LOCK();
  GUI_MoveRect(&r, -WM_H2P(hWin)->Rect.x0, -WM_H2P(hWin)->Rect.y0);
  WM_InvalidateRect(hWin, &r);
  WM_UNLOCK();
}
/*********************************************************************
*
*                Pull window in foreground (top of stack)
*
**********************************************************************
*/
void WM_BringToTop(WM_HWIN hWin) {
  WM_HWIN hPrev, hLast;
  WM_Obj* pWin;
  WM_Obj* pLast;
  if (hWin) {
    WM_LOCK();
    pWin = WM_H2P(hWin);
  /* First of all check if window is already top of stack */
    if (pWin->hNext && pWin->hParent) {
      /* unlink hWin */
      if ((hPrev = WM__GetPrevSibling(hWin)) != 0) {
        WM_Obj* pPrev;
        pPrev = WM_H2P(hPrev);
        pPrev->hNext = pWin->hNext;
      } else {
        WM_Obj* pParent;
        pParent= WM_H2P(pWin->hParent);
        pParent->hFirstChild = pWin->hNext;
      }
      /* Link last sibling */
      hLast = WM__GetLastSibling(hWin);
      pLast = WM_H2P(hLast);
      pLast->hNext = hWin;
      pWin->hNext = 0;
      /* Send message in order to make sure top window will be drawn */
      WM_InvalidateArea(&pWin->Rect);     /* Invalidate new area */
    }
    WM_UNLOCK();
  }
}
/*********************************************************************
*
*       WM__ForEachDesc
*/
void WM__ForEachDesc(WM_HWIN hWin, WM_tfForEach * pcb, void * pData) {
  WM_HWIN hChild;
  WM_Obj* pChild;
  WM_Obj* pWin;
  pWin = WM_H2P(hWin);
  for (hChild = pWin->hFirstChild; hChild; hChild = pChild->hNext) {
    pChild = WM_H2P(hChild);
    pcb(hChild, pData);
    WM_ForEachDesc(hChild, pcb, pData);
  }
}
Exemple #5
0
void _AddToLinList(WM_HWIN hNew) {
  WM_Obj* pFirst;
  WM_Obj* pNew;
  if (WM__FirstWin) {
    pFirst = WM_H2P(WM__FirstWin);
    pNew   = WM_H2P(hNew);
    pNew->hNextLin = pFirst->hNextLin;
    pFirst->hNextLin = hNew;
  } else {
    WM__FirstWin = hNew;
  }
}
Exemple #6
0
void WM__RemoveFromLinList(WM_HWIN hWin) {
  WM_Obj* piWin;
  WM_HWIN hiWin, hNext;
  for (hiWin = WM__FirstWin; hiWin; ) {
    piWin = WM_H2P(hiWin);
    hNext = piWin->hNextLin;
    if (hNext == hWin) {
      piWin->hNextLin = WM_H2P(hWin)->hNextLin;
      break;
    }
    hiWin = hNext;
  }
}
Exemple #7
0
/* Invalidate, using window coordinates */
static void WM_InvalidateBWin1(WM_HWIN hWin, const GUI_RECT*pRect) {
  GUI_RECT r;
  WM_Obj* pWin = WM_H2P(hWin);
  WM__GetClientRectWin(pWin, &r);
  if (pRect)
    GUI__IntersectRect(&r, pRect);
  if (WM__RectIsNZ(&r)) {
    if (pWin->Status & WM_SF_INVALID) {
      GUI_MergeRect(&pWin->InvalidRect, &pWin->InvalidRect, &r);
    } else {
      pWin->InvalidRect = r;
      pWin->Status |= WM_SF_INVALID;
      WM__NumInvalidWindows++;
      /* Debug code: shows invalid areas */
      #if (WM_SHOW_INVALID)
      {
        GUI_CONTEXT Context = GUI_Context;
        WM_SelectWindow(hWin);
        GUI_SetBkColor(GUI_GREEN);
        GUI_ClearRect(r.x0, r.y0, r.x1, r.y1);
        GUI_Context = Context;
      }
      #endif


    }
  }
}
/*********************************************************************
*
*       WM__IsEnabled
*/
int WM__IsEnabled(WM_HWIN hWin) {
  int r = 1;
  if ((WM_H2P(hWin)->Status) & WM_SF_DISABLED) {
    r = 0;
  }
  return r;
}
Exemple #9
0
WM_RESULT WM_DefaultProc(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  void *p = pMsg->Data.p;
  WM_Obj* pWin = WM_H2P(hWin);
  /* Exec message */
  switch (pMsg->MsgId) {
  case WM_GETORG:
    ((GUI_POINT*)p)->x = pWin->Rect.x0;
    ((GUI_POINT*)p)->y = pWin->Rect.y0;
    break;
  case WM_GETCLIENTRECT:     /* return client window in window coordinates */
    WM__GetClientRectWin(pWin, (GUI_RECT*)p);
    break;
  case WM_GETCLIENTRECT_ABS:      /* return client window in absolute (screen) coordinates */
    WM__GetClientRectWin(pWin, (GUI_RECT*)p);
    GUI_MoveRect((GUI_RECT*)p, pWin->Rect.x0, pWin->Rect.y0);
    break;
  case WM_GET_CLIENT_WINDOW:      /* return handle to client window. For most windows, there is no seperate client window, so it is the same handle */
    pMsg->Data.v = hWin;
    return;                       /* Message handled */
  case WM_KEY:
    WM_SendToParent(hWin, pMsg);
    return;                       /* Message handled */
   case WM_GET_BKCOLOR:
    pMsg->Data.Color = GUI_INVALID_COLOR;
    return;                       /* Message handled */
  }
  /* Message not handled. If it queries something, we return 0 to be on the safe side. */
  pMsg->Data.v = 0;
  pMsg->Data.p = 0;
}
Exemple #10
0
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; ) {
    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);
}
Exemple #11
0
/*********************************************************************
*
*       _UpdateChildPositions
*/
static void _UpdateChildPostions(WM_HWIN hObj, int Diff) {
  WM_Obj* pObj;
  WM_LOCK();
  pObj = (WM_Obj*)WM_H2P(hObj);
  WM__UpdateChildPositions(pObj, -Diff, -Diff, Diff, Diff);
  WM_UNLOCK();
}
/*********************************************************************
*
*       _HasOverlap
*/
static int _HasOverlap(WM_Obj * pWin, GUI_RECT * pRect) {
  WM_Obj * pParent;
  WM_HMEM hParent;
  /* Step 1:
   Check if there are any visible children. If this is so, then the
   window has an overlap.
   */
  /* Check all children */
  if (_WindowSiblingsOverlapRect(pWin->hFirstChild, pRect)) {
    return 1;
  }

  /* STEP 2:
       Find out the max. height (r.y1) if we are at the left border.
       Since we are using the same height for all IVRs at the same y0,
       we do this only for the leftmost one.
  */

  /* Iterate over all windows which are above */
  /* Check all siblings above (Iterate over Parents and top siblings (hNext) */
  for (hParent = pWin->hParent; hParent; hParent = pParent->hParent) {
    pParent = WM_H2P(hParent);
    if (_WindowSiblingsOverlapRect(pParent->hNext, pRect)) {
      return 1;
    }
  }
  return 0;
}
Exemple #13
0
/*
  Invalidate any transparent window above the given area
*/
void WM__InvalidateTransAreaAbove(const GUI_RECT* pRect, WM_HWIN StopWin) {
  GUI_USE_PARA(pRect);
  GUI_USE_PARA(StopWin);
#if 0
  WM_HWIN   iWin;
  /* Iterate over windows below StopWin */
  for (iWin = StopWin; iWin!=WM_HWIN_NULL; iWin = WM_H2P(iWin)->Next) {
    WM_Obj *pWin = WM_H2P(iWin);
    if (pWin->Status & WM_SF_HASTRANS) {
      GUI_RECT r = *pRect;
      if (GUI__IntersectRects(&r, &r, &WM_H2P(iWin)->Rect)) {
        WM_InvalidateBWin1Abs (iWin, &r);
      }
    }
  }
#endif
}
Exemple #14
0
static void _DeleteAllChildren(WM_HWIN hChild) {
  while (hChild) {
    WM_Obj* pChild = WM_H2P(hChild);
    WM_HWIN hNext = pChild->hNext;
    WM_DeleteWindow(hChild);
    hChild = hNext;
  }
}
Exemple #15
0
WM_HWIN WM_GetParent(WM_HWIN hWin) {
  WM_LOCK();
  if (hWin) {
    hWin = WM_H2P(hWin)->hParent;
  }
  WM_UNLOCK();
  return hWin;
}
Exemple #16
0
WM_HWIN WM_SelectWindow(WM_HWIN  hWin) {
  WM_HWIN hWinPrev;
  WM_LOCK();
  hWinPrev = GUI_Context.hAWin;
  if (hWin == 0) {
    hWin = WM__FirstWin;
  }
  if (!(WM_H2P(hWin)->Status & WM_SF_INUSE)) {
    GUI_DEBUG_ERROROUT1("Selecting invalid window", hWin);
    hWin=0;
  }
  /* Select new window */
  GUI_Context.hAWin = hWin;
  WM__SetMaxClipRect(WM_H2P(hWin));
  WM_UNLOCK();
  return hWinPrev;
}
/*********************************************************************
*
*       WM_GetParent
*/
WM_HWIN WM_GetParent(WM_HWIN hWin) {
  if (hWin) {
    WM_LOCK();
    hWin = WM_H2P(hWin)->hParent;
    WM_UNLOCK();
  }
  return hWin;
}
/*********************************************************************
*
*       WM__NotifyVisChanged
*
* Description
*   Notify all siblings & descendents
*/
void WM__NotifyVisChanged(WM_HWIN hWin, GUI_RECT * pRect) {
  WM_Obj * pWin;
  WM_HWIN hParent;
  pWin = WM_H2P(hWin);
  hParent = pWin->hParent;
  if (hParent) {
    _NotifyVisChanged(hParent, pRect);
  }
}
Exemple #19
0
/*******************************************************************
*
*       _ClipAtParentBorders

  Iterates over all its ancestors and intersects all rectangles to
  find out which part is actually visible.
  Reduces the rectangle to the visible area.
*/
void _ClipAtParentBorders(GUI_RECT* pRect, WM_Obj* pWin) {
  WM_HWIN hWin;
  hWin = pWin->hParent;
  while (hWin) {
    pWin = WM_H2P(hWin);
    GUI__IntersectRect(pRect, &pWin->Rect);
    hWin = pWin->hParent;
  }
}
/*********************************************************************
*
*       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;
}
/*********************************************************************
*
*       _InvalidateButton
*/
static void _InvalidateButton(FRAMEWIN_Obj* pObj, int Id) {
  WM_HWIN hChild;
  WM_Obj* pChild;
  for (hChild = pObj->Widget.Win.hFirstChild; hChild; hChild = pChild->hNext) {
    pChild = WM_H2P(hChild);
    if (WM_GetId(hChild) == Id) {
      WM_InvalidateWindow(hChild);
    }
  }
}
Exemple #22
0
int WM_BroadcastMessage( WM_MESSAGE* pMsg) {
  WM_HWIN hWin;
  WM_LOCK();
  for (hWin = WM__FirstWin; hWin; ) {
    WM_SendMessage(hWin, pMsg);
    hWin = WM_H2P(hWin)->hNextLin;
  }
  WM_UNLOCK();
  return 0;
}
Exemple #23
0
/*********************************************************************
*
*       WM__GetLastSibling

  Return value: Handle of last sibling

*/
WM_HWIN WM__GetLastSibling(WM_HWIN hWin) {
  WM_Obj* pWin;
  for (; hWin; hWin = pWin->hNext) {
    pWin = WM_H2P(hWin);
    if (pWin->hNext == 0) {
      break;
    }
  }
  return hWin;
}
Exemple #24
0
/*******************************************************************
*
*       _AddChild
*/
void _AddChild(WM_HWIN hParent, WM_HWIN hChild, int OnTop) {
  WM_Obj* pChild;
  WM_Obj* pParent;
  WM_Obj* pi;
  WM_HWIN hi;
  if (hParent) {
    pParent = WM_H2P(hParent);
    pChild  = WM_H2P(hChild);
    hi = pParent->hFirstChild;
    if (hi == 0) {   /* No child yet ... Makes things easy ! */
      pParent->hFirstChild = hChild;
        return;                         /* Early out ... We are done */
    }
    if (!OnTop) {
      pi = WM_H2P(hi);
      if (pi->Status & WM_SF_STAYONTOP) {
        pChild->hNext = hi;
        pParent->hFirstChild = hChild;
        return;                         /* Early out ... We are done */
      }
    }
    /* put if at the end of the list or after the last non "STAY-ON-TOP" child */
    do {
      WM_Obj* pNext;
      WM_HWIN hNext;
      pi = WM_H2P(hi);
      if ((hNext = pi->hNext) == 0) {
        pi->hNext = hChild;
        break;
      }
      if (!OnTop) {
        pNext = WM_H2P(hNext);
        if (pNext->Status & WM_SF_STAYONTOP) {
          pi->hNext = hChild;
          pChild->hNext = hNext;
          break;
        }
      }
      hi = hNext;
    }  while (1);
  }
}
Exemple #25
0
/*********************************************************************
*
*       WM_SetUserData
*
*  Purpose
*    Set the User data (extra bytes) associated with a window
*  Return value:
*    Number of bytes fetched. (<= SizeofBuffer)
*/
int WM_SetUserData(WM_HWIN hWin, const void* pSrc, int NumBytes) {
  if (hWin) {
    WM_Obj *pWin;
    NumBytes = _CalcNumBytes(hWin, NumBytes);
    WM_LOCK();
    pWin = WM_H2P(hWin);
    memcpy(pWin + 1, pSrc, NumBytes);
    WM_UNLOCK();
  }
  return NumBytes;
}
Exemple #26
0
/*********************************************************************
*
*       WM_GetUserData
*
*  Purpose
*    Get the User data (extra bytes) associated with a window
*    These bytes have typically been set using WM_SetUserData first.
*    (If not, they are 0)
*  Return value:
*    Number of bytes fetched. (<= SizeofBuffer)
*/
int WM_GetUserData(WM_HWIN hWin, void* pDest, int NumBytes) {
  if (hWin) {
    WM_Obj *pWin;
    NumBytes = _CalcNumBytes(hWin, NumBytes);
    WM_LOCK();
    pWin = WM_H2P(hWin);
    memcpy(pDest, pWin + 1, NumBytes);
    WM_UNLOCK();
  }
  return NumBytes;
}
Exemple #27
0
/*********************************************************************
*
*       WM_InvalidateWindowAndDescs
*
* Function description
*  Invalidate window and all descendents (children and grandchildren and ...
*/
void WM_InvalidateWindowAndDescs(WM_HWIN hWin) {
  WM_HWIN hChild;
  if (hWin) {
    WM_InvalidateWindow(hWin);    /* Invalidate window itself */
    for (hChild = WM_GetFirstChild(hWin); hChild;) {
      WM_Obj* pChild = WM_H2P(hChild);
      WM_InvalidateWindowAndDescs(hChild);
      hChild = pChild->hNext;
    }
  }
}
Exemple #28
0
/*********************************************************************
*
*       _ShowPage
*/
static void _ShowPage(MULTIPAGE_Obj* pObj, unsigned Index) {
  WM_HWIN hWin = 0;
  WM_HWIN hChild;
  WM_Obj* pChild;
  WM_Obj* pClient = WM_H2P(pObj->hClient);
  if ((int)Index < pObj->Handles.NumItems) {
    MULTIPAGE_PAGE* pPage;
    pPage = (MULTIPAGE_PAGE*) GUI_ARRAY_GetpItem(&pObj->Handles, Index);
    hWin = pPage->hWin;
  }
  for (hChild = pClient->hFirstChild; hChild; hChild = pChild->hNext) {
    pChild = WM_H2P(hChild);
    if (hChild == hWin) {
      WM_ShowWindow(hChild);
      WM_SetFocus(hChild);
    } else {
      WM_HideWindow(hChild);
    }
  }
}
/*********************************************************************
*
*       WM_GetClientRectEx
*
  Purpose:
    Return the client rectangle in client coordinates.
    This means for all windows that
    x0 = y0 = 0
    x1 = width - 1
    y1 = height - 1
*/
void WM_GetClientRectEx(WM_HWIN hWin, GUI_RECT* pRect) {
  WM_Obj *pWin;
  WM_LOCK();
  if (hWin) {
    if (pRect) {
      pWin = WM_H2P(hWin);  
      WM__GetClientRectWin(pWin, pRect);
    }
  }
  WM_UNLOCK();
}
Exemple #30
0
/*********************************************************************
*
*       WM_GetHasTrans
*/
int WM_GetHasTrans(WM_HWIN hWin) {
  int r = 0;
  WM_Obj *pWin;
  WM_LOCK();
  if (hWin) {
    pWin = WM_H2P(hWin);  
    r = pWin->Status & WM_SF_HASTRANS;
  }
  WM_UNLOCK();
  return r;
}