Esempio n. 1
0
BUTTON_Handle BUTTON_CreateAsChild (int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags) {
  BUTTON_Handle hObj;
  /* Create the window */
  WM_LOCK();
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent,
                       Flags, _BUTTON_Callback,
                       sizeof(BUTTON_Obj)-sizeof(WM_Obj));
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    /* init widget specific variables */
    /* init member variables */
    BUTTON_INIT_ID(pObj);
    pObj->Widget.Id     = Id;
    pObj->pFont         = BUTTON_FONT_DEFAULT;
    pObj->aBkColor[0]   = BUTTON_BKCOLOR0_DEFAULT;
    pObj->aBkColor[1]   = BUTTON_BKCOLOR1_DEFAULT;
    pObj->aTextColor[0] = BUTTON_TEXTCOLOR0_DEFAULT;
    pObj->aTextColor[1] = BUTTON_TEXTCOLOR1_DEFAULT;
    pObj->Widget.State  = BUTTON_STATE_INACTIVE;
  } else {
    GUI_DEBUG_ERROROUT_IF(hObj==0, "BUTTON_Create failed")
  }
  WM_UNLOCK();
  return hObj;
}
Esempio n. 2
0
/*********************************************************************
*
*       BUTTON_SetFont
*/
void BUTTON_SetFont(BUTTON_Handle hObj, const GUI_FONT GUI_UNI_PTR * pfont) {
  if (hObj) {
    BUTTON_Obj* pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    pObj->Props.pFont = pfont;
    BUTTON_Invalidate(hObj);
    WM_UNLOCK();
  }
}
Esempio n. 3
0
void BUTTON_SetFont(BUTTON_Handle hObj, const GUI_FONT* pfont) {
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    pObj->pFont = pfont;
    BUTTON_Invalidate(hObj);
  } else {
    GUI_DEBUG_WARN("BUTTON_SetFont: Invalid handle");
  }
}
Esempio n. 4
0
void BUTTON_SetTextColor(BUTTON_Handle hObj, int Index, GUI_COLOR color) {
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    pObj->aTextColor[Index] = color;
    BUTTON_Invalidate(hObj);
  } else {
    GUI_DEBUG_WARN("BUTTON_SetTextColor: Invalid handle");
  }
}
Esempio n. 5
0
/*********************************************************************
*
*       BUTTON_SetTextColor
*/
void BUTTON_SetTextColor(BUTTON_Handle hObj,unsigned int Index, GUI_COLOR Color) {
  if (hObj && (Index <= 2)) {
    BUTTON_Obj* pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    pObj->Props.aTextColor[Index] = Color;
    BUTTON_Invalidate(hObj);
    WM_UNLOCK();
  }
}
Esempio n. 6
0
/*********************************************************************
*
*       BUTTON_SetText
*/
void BUTTON_SetText(BUTTON_Handle hObj, const char* s) {
  if (hObj) {
    BUTTON_Obj* pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    if (GUI__SetText(&pObj->hpText, s)) {
      BUTTON_Invalidate(hObj);
    }
    WM_UNLOCK();
  }
}
Esempio n. 7
0
/*********************************************************************
*
*       BUTTON_SetBkColor
*/
void BUTTON_SetBkColor(BUTTON_Handle hObj,unsigned int Index, GUI_COLOR Color) {
  if (hObj && (Index <= 2)) {
    BUTTON_Obj* pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    pObj->Props.aBkColor[Index] = Color;
    BUTTON_Invalidate(hObj);
    WM_UNLOCK();
  }
}
Esempio n. 8
0
void BUTTON_SetStreamedBitmap(BUTTON_Handle hObj, int Index, const GUI_BITMAP_STREAM* pBitmap) {
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    if ((unsigned int)Index > GUI_COUNTOF(pObj->apBitmap))
      return;
    pObj->apBitmap[Index] = (const GUI_BITMAP*)pBitmap;
    pObj->aBitmapIsStreamed[Index] = 1;
    BUTTON_Invalidate(hObj);
  }
}
/*********************************************************************
*
*       BUTTON_SetTextAlign
*/
void BUTTON_SetTextAlign(BUTTON_Handle hObj, int Align) {
  if (hObj) {
    BUTTON_Obj* pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    pObj->Props.Align = Align;
    BUTTON_Invalidate(hObj);
    WM_UNLOCK();
  }
}
Esempio n. 10
0
void BUTTON_SetBitmapEx(BUTTON_Handle hObj, int Index, const GUI_BITMAP* pBitmap, int x, int y) {
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    if ((unsigned int)Index > GUI_COUNTOF(pObj->apBitmap))
      return;
    pObj->apBitmap[Index] = pBitmap;
    pObj->xOffBitmap[Index] = x;
    pObj->yOffBitmap[Index] = y;
    BUTTON_Invalidate(hObj);
  }
}
Esempio n. 11
0
void BUTTON_SetBitmap(BUTTON_Handle hObj, int Index, const GUI_BITMAP* pBitmap) {
  #if BUTTON_SUPPORT_BITMAP_OFFSET
    BUTTON_SetBitmapEx(hObj, Index, pBitmap, 0,0);
  #else
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    if ((unsigned int)Index > GUI_COUNTOF(pObj->apBitmap))
      return;
    pObj->apBitmap[Index] = pBitmap;
    BUTTON_Invalidate(hObj);
  }
  #endif
}
/*********************************************************************
*
*       BUTTON_SetDrawObj
*/
void BUTTON__SetDrawObj(BUTTON_Handle hObj, int Index, GUI_DRAW_HANDLE hDrawObj) {
  if (hObj) {
    BUTTON_Obj* pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    if ((unsigned int)Index <= GUI_COUNTOF(pObj->ahDrawObj)) {
      GUI_ALLOC_FreePtr(&pObj->ahDrawObj[Index]);
      pObj->ahDrawObj[Index] = hDrawObj;
      BUTTON_Invalidate(hObj);
    }
    WM_UNLOCK();
  }
}
Esempio n. 13
0
/*********************************************************************
*
*       BUTTON_Callback
*/
void BUTTON_Callback(WM_MESSAGE *pMsg) {
  BUTTON_Handle hObj = pMsg->hWin;
  BUTTON_Obj* pObj = BUTTON_H2P(hObj);
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
#if BUTTON_REACT_ON_LEVEL
  case WM_PID_STATE_CHANGED:
    _OnPidStateChange(hObj, pObj, pMsg);
    return;      /* Message handled. Do not call WM_DefaultProc, because the window may have been destroyed */
#endif
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    return;      /* Message handled. Do not call WM_DefaultProc, because the window may have been destroyed */
  case WM_PAINT:
    GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_PAINT)\n");
    _Paint(pObj, hObj);
    return;
  case WM_DELETE:
    GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_DELETE)\n");
    _Delete(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  #if 0     /* TBD: Button should react to space & Enter */
  case WM_KEY:
    {
      int PressedCnt = ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt;
      int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key;
      if (PressedCnt > 0) {   /* Key pressed? */
        switch (Key) {
        case ' ':
          _ButtonPressed(hObj, pObj);
          return;
        }
      } else {
        switch (Key) {
        case ' ':
          _ButtonReleased(hObj, pObj, WM_NOTIFICATION_RELEASED);
          return;
        }
      }
    }
    break;
  #endif
  }
  WM_DefaultProc(pMsg);
}
Esempio n. 14
0
void BUTTON_SetText(BUTTON_Handle hObj, const char* s) {
  WM_LOCK();
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    BUTTON_ASSERT_IS_VALID_PTR(pObj);
    WM_FREEPTR(&pObj->hpText);
    {
      WM_HMEM hMem = WM_ALLOC(strlen(s)+1);
      if (hMem) {
        strcpy((char *) WM_HMEM2Ptr(hMem), s);
      }
      pObj->hpText = hMem;
    }
    BUTTON_Invalidate(hObj);
  } else {
    GUI_DEBUG_WARN("BUTTON_SetText: Invalid handle");
  }
  WM_UNLOCK();
}
Esempio n. 15
0
/*********************************************************************
*
*       BUTTON_CreateEx
*/
BUTTON_Handle BUTTON_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id) {
  BUTTON_Handle hObj;
  GUI_USE_PARA(ExFlags);
  /* Create the window */
  WM_LOCK();
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, BUTTON_Callback,
                                sizeof(BUTTON_Obj) - sizeof(WM_Obj));
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    /* init widget specific variables */
    WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE);
    /* init member variables */
    BUTTON_INIT_ID(pObj);
    pObj->Props = BUTTON__DefaultProps;
  } else {
    GUI_DEBUG_ERROROUT_IF(hObj==0, "BUTTON_Create failed")
  }
  WM_UNLOCK();
  return hObj;
}
Esempio n. 16
0
/*********************************************************************
*
*       BUTTON_GetBitmap
*/
const GUI_BITMAP GUI_UNI_PTR * BUTTON_GetBitmap(BUTTON_Handle hObj,unsigned int Index) {
  const GUI_BITMAP GUI_UNI_PTR * pBM;
  pBM = NULL;
  if (hObj) {
    BUTTON_Obj * pObj;
    WM_LOCK();
    pObj = BUTTON_H2P(hObj);
    if (Index <= GUI_COUNTOF(pObj->ahDrawObj)) {
      WM_HMEM hDrawObj;
      hDrawObj = pObj->ahDrawObj[Index];
      if (hDrawObj) {
        GUI_DRAW * pDrawObj;
        pDrawObj = (GUI_DRAW *)GUI_ALLOC_h2p(hDrawObj);
        pBM = (const GUI_BITMAP GUI_UNI_PTR *)pDrawObj->Data.pData;
      }
    }
    WM_UNLOCK();
  }
  return pBM;
}
Esempio n. 17
0
/*********************************************************************
*
*       Callback
*/
static void _BUTTON_Callback(WM_MESSAGE *pMsg) {
  BUTTON_Handle hObj = pMsg->hWin;
  BUTTON_Obj* pObj = BUTTON_H2P(hObj);
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    break;
  case WM_PAINT:
    GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_PAINT)\n");
    _Paint(pObj);
    return;
  case WM_DELETE:
    GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_DELETE)\n");
    _Delete(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  }
  WM_DefaultProc(pMsg);
}
/*********************************************************************
*
*       _OnPaint
*
* Purpose: Paints the owner drawn button
*/
static void _OnPaint(BUTTON_Handle hObj) {
  int Index;
  char ac[50];
  GUI_RECT Rect;
  BUTTON_Obj * pObj;
  pObj = BUTTON_H2P(hObj);
  Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
  WM_GetClientRect(&Rect);
  /* Draw filled ellipse with button background color */
  GUI_SetColor(BUTTON_GetBkColor(hObj, Index));
  GUI_FillEllipse(Rect.x1 / 2, Rect.y1 / 2, Rect.x1 / 2, Rect.y1 / 2);
  /* Draw black shape */
  GUI_SetColor(GUI_BLACK);
  GUI_DrawEllipse(Rect.x1 / 2, Rect.y1 / 2, Rect.x1 / 2, Rect.y1 / 2);
  /* Draw button text with widget attributes */
  GUI_SetColor(BUTTON_GetTextColor(hObj, Index));
  GUI_SetBkColor(BUTTON_GetBkColor(hObj, Index));
  GUI_SetFont(BUTTON_GetFont(hObj));
  BUTTON_GetText(hObj, ac, sizeof(ac));
  if (_Pressed) {
    strcpy(ac + strlen(ac), "\npressed");
  }
  GUI_DispStringInRect(ac, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);
}