예제 #1
0
/*********************************************************************
*
*       CHECKBOX_Callback
*/
void CHECKBOX_Callback (WM_MESSAGE *pMsg) {
  CHECKBOX_Handle hObj;
  CHECKBOX_Obj* pObj;
  hObj = pMsg->hWin;
  pObj = (CHECKBOX_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_KEY:
    _OnKey(hObj, pObj, pMsg);
    break;
  case WM_PAINT:
    GUI_DEBUG_LOG("CHECKBOX: _Callback(WM_PAINT)\n");
    _Paint(pObj, hObj);
    return;
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    break;
  case WM_DELETE:
    GUI_DEBUG_LOG("CHECKBOX: _Callback(WM_DELETE)\n");
    _Delete(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  }
  WM_DefaultProc(pMsg);
}
예제 #2
0
파일: Terminal.c 프로젝트: byxob/calendar
static WM_RESULT _TERMINAL_Callback (/*const*/ WM_MESSAGE*pMsg) {
  TERMINAL_Handle hObj = pMsg->hWin;
  TERMINAL_Obj* pObj = TERMINAL_H2P(hObj);
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_DEBUG_LOG("BUTTON: _Callback(WM_PAINT)\n");
    Paint(pObj/*, (GUI_RECT*)pMsg->Data.p*/);
    return;
  case WM_DELETE:
    GUI_DEBUG_LOG("EDIT: _Callback(WM_DELETE)\n");
    Delete(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  }
  WM_DefaultProc(pMsg);
}
예제 #3
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);
}
예제 #4
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(RADIO_Handle hObj, RADIO_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification;
  int Hit = 0;
  GUI_PID_STATE* pState = (GUI_PID_STATE*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      int y, Sel;
      y   = pState->y;
      Sel = y   / pObj->Spacing;
      y  -= Sel * pObj->Spacing;
      if (y <= pObj->Height) {
        RADIO_SetValue(hObj, Sel);
      }
      if (WM_IsFocussable(hObj)) {
        WM_SetFocus(hObj);
      }
      Notification = WM_NOTIFICATION_CLICKED;
    } else {
      Hit = 1;
      Notification = WM_NOTIFICATION_RELEASED;
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("RADIO: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
예제 #5
0
/*********************************************************************
*
*       GUI_Init
*
* Purpose:
*   Init of GUI internal data structures & variables
*/
int GUI_Init(void) {
    int r;
    GUI_DEBUG_LOG("\nGUI_Init()");
    /* Init system wide globals first */
    GUI_DecChar = '.';
    GUI_X_Init();
    /* Init context */
    _InitContext(&GUI_Context);
    GUITASK_INIT();
    r = LCD_Init();
#if GUI_WINSUPPORT
    WM_Init();
#endif
    GUITASK_COPY_CONTEXT();
#if defined(GUI_TRIAL_VERSION)
#if GUI_TRIAL_VERSION
    GUI_DispString(  "This software\n"
                     "contains an eval-\n"
                     "uC/GUI build.\n"
                     "\n"
                     "A license is\n"
                     "required to use\n"
                     "it in a product.\n\n"
                     "www.segger.com\n");
    GUI_GotoXY(0, 0);
    GUI_X_Delay(1000);
    GUI_Clear();
#endif
#endif
    return r;
}
예제 #6
0
파일: Terminal.c 프로젝트: byxob/calendar
static void Delete(TERMINAL_Obj* pObj) {
  if (pObj->hpText) {
    GUI_ALLOC_Free(pObj->hpText);
    pObj->hpText = 0;
    GUI_DEBUG_LOG("TERMINAL: Delete: Deleting attached string\n");
  }
}
예제 #7
0
/*********************************************************************
*
*       _RADIO_Callback
*/
static void _RADIO_Callback (WM_MESSAGE* pMsg) {
  RADIO_Handle hObj;
  RADIO_Obj*   pObj;
  hObj = pMsg->hWin;
  pObj = RADIO_H2P(hObj);
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_DEBUG_LOG("RADIO: _Callback(WM_PAINT)\n");
    _OnPaint(hObj, pObj);
    return;
  case WM_GET_RADIOGROUP:
    pMsg->Data.v = pObj->GroupId;
    return;
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    break;
  case WM_KEY:
    _OnKey(hObj, pMsg);
    break;
  case WM_DELETE:
    GUI_ARRAY_Delete(&pObj->TextArray);
    break;
  }
  WM_DefaultProc(pMsg);
}
예제 #8
0
/*********************************************************************
*
*       _SCROLLBAR_Callback
*/
static void _SCROLLBAR_Callback (WM_MESSAGE *pMsg) {
  SCROLLBAR_Handle hObj;
  SCROLLBAR_Obj* pObj;
  hObj = pMsg->hWin;
  pObj = SCROLLBAR_H2P(hObj);
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_DELETE:
    SCROLLBAR__InvalidatePartner(hObj);
    break;
  case WM_PAINT:
    GUI_DEBUG_LOG("SCROLLBAR: _Callback(WM_PAINT)\n");
    _Paint(pObj);
    return;
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    break;
  case WM_KEY:
    _OnKey(hObj, pMsg);
    break;
  case WM_SET_SCROLL_STATE:
    _OnSetScrollState(hObj, pObj, (const WM_SCROLL_STATE*)pMsg->Data.p);
    break;
  case WM_GET_SCROLL_STATE:
    ((WM_SCROLL_STATE*)pMsg->Data.p)->NumItems = pObj->NumItems;
    ((WM_SCROLL_STATE*)pMsg->Data.p)->PageSize = pObj->PageSize;
    ((WM_SCROLL_STATE*)pMsg->Data.p)->v        = pObj->v;
    break;
  }
  WM_DefaultProc(pMsg);
}
예제 #9
0
파일: BUTTON.c 프로젝트: Jaly314/CH-K-Lib
/*********************************************************************
*
*       BUTTON_Callback
*/
void BUTTON_Callback(WM_MESSAGE *pMsg) {
  int PressedCnt, Key;
  BUTTON_Handle hObj = pMsg->hWin;
  BUTTON_Obj * pObj = (BUTTON_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
  /* 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 */
  case WM_KEY:
    PressedCnt = ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt;
    Key        = ((WM_KEY_INFO*)(pMsg->Data.p))->Key;
    switch (Key) {
    case GUI_KEY_ENTER:
      if (PressedCnt > 0) {
        _OnButtonPressed(hObj, pObj);
        _OnButtonReleased(hObj, pObj, WM_NOTIFICATION_RELEASED);
        return;
      }
      break;
    case GUI_KEY_SPACE:
      if (PressedCnt > 0) {
        _OnButtonPressed(hObj, pObj);
      } else {
        _OnButtonReleased(hObj, pObj, WM_NOTIFICATION_RELEASED);
      }
      return;
    }
  }
  WM_DefaultProc(pMsg);
}
예제 #10
0
/*********************************************************************
*
*       _TEXT_Callback
*/
static void _TEXT_Callback (WM_MESSAGE*pMsg) {
  TEXT_Handle hObj = pMsg->hWin;
  TEXT_Obj* pObj = TEXT_H2P(hObj);
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_DEBUG_LOG("TEXT: _Callback(WM_PAINT)\n");
    _Paint(hObj, pObj);
    return;
  case WM_DELETE:
    GUI_DEBUG_LOG("TEXT: _Callback(WM_DELETE)\n");
    _Delete(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  }
  WM_DefaultProc(pMsg);
}
예제 #11
0
/*********************************************************************
*
*       EDIT_Callback
*/
void EDIT_Callback (WM_MESSAGE * pMsg) {
  int IsEnabled;
  EDIT_Handle hObj;
  EDIT_Obj*   pObj;
  hObj = (EDIT_Handle) pMsg->hWin;       
  pObj = (EDIT_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
  IsEnabled = WM__IsEnabled(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("EDIT: _Callback(WM_PAINT)\n");
    _Paint(pObj, hObj);
    return;
  case WM_DELETE:
    GUI_DEBUG_LOG("EDIT: _Callback(WM_DELETE)\n");
    _Delete(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  case WM_KEY:
    if (IsEnabled) {
      if ( ((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt >0) {
        int Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key;
        switch (Key) {
          case GUI_KEY_ENTER:
          case GUI_KEY_ESCAPE:
          case GUI_KEY_TAB:
          case GUI_KEY_BACKTAB:
            break;                    /* Send to parent by not doing anything */
          default:
            EDIT_AddKey(hObj, Key);
            return;
        }
      }
    }
    break;
  }
  WM_DefaultProc(pMsg);
}
예제 #12
0
파일: BUTTON.c 프로젝트: Jaly314/CH-K-Lib
/*********************************************************************
*
*       _OnButtonReleased
*/
static void _OnButtonReleased(BUTTON_Handle hObj, BUTTON_Obj* pObj, int Notification) {
  WIDGET_AndState(hObj, BUTTON_STATE_PRESSED);
  if (Notification == WM_NOTIFICATION_RELEASED) {
    GUI_DEBUG_LOG("BUTTON: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
  if (pObj->Widget.Win.Status & WM_SF_ISVIS) {
    WM_NotifyParent(hObj, Notification);
  }
}
예제 #13
0
/*********************************************************************
*
*       GUI_ALLOC_Init
*/
void GUI_ALLOC_Init(void) {
  GUI_DEBUG_LOG("\nGUI_ALLOC_Init...");
  GUI_ALLOC.NumFreeBlocksMin = GUI_ALLOC.NumFreeBlocks = GUI_MAXBLOCKS-1;
  GUI_ALLOC.NumFreeBytesMin  = GUI_ALLOC.NumFreeBytes  = GUI_ALLOC_SIZE;
  GUI_ALLOC.NumUsedBlocks = 0;
  GUI_ALLOC.NumUsedBytes = 0;
  aBlock[0].Size = (1<<GUI_BLOCK_ALIGN);  /* occupy minimum for a block */
  aBlock[0].Off  = 0;
  aBlock[0].Next = 0;
  IsInitialized =1;
}
예제 #14
0
/*********************************************************************
*
*       Callback
*/
static void EDIT__Callback (WM_MESSAGE * pMsg) {
    int IsEnabled;
    EDIT_Handle hObj = (EDIT_Handle)pMsg->hWin;
    EDIT_Obj* pObj = (EDIT_Obj*)WM_HMEM2Ptr(hObj);
    IsEnabled = WIDGET__IsEnabled(&pObj->Widget);
    /* Let widget handle the standard messages */
    if (WIDGET_HandleActive(hObj, pMsg) == 0) {
        return;
    }
    switch (pMsg->MsgId) {
    case WM_TOUCH:
        if (IsEnabled) {
            _OnTouch(hObj, pObj, pMsg);
        }
        break;
    case WM_PAINT:
        GUI_DEBUG_LOG("EDIT: _Callback(WM_PAINT)\n");
        _Paint(pObj);
        return;
    case WM_DELETE:
        GUI_DEBUG_LOG("EDIT: _Callback(WM_DELETE)\n");
        _Delete(pObj);
        break;       /* No return here ... WM_DefaultProc needs to be called */
    case WM_KEY:
        if (IsEnabled) {
            if ( ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt >0) {
                int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key;
                switch (Key) {
                case GUI_KEY_TAB:
                    break;                    /* Send to parent by not doing anything */
                default:
                    EDIT_AddKey(hObj, Key);
                    return;
                }
            }
        }
        break;
    }
    WM_DefaultProc(pMsg);
}
예제 #15
0
int GUI_Init(void) {
  int r;
  GUI_DEBUG_LOG("\nGUI_Init()");
  /* Init system wide globals first */
  GUI_DecChar = '.';
  GUI_X_Init();
  /* Init context */
  _InitContext(&GUI_Context);
  GUITASK_INIT();
  r = LCD_Init();
  #if GUI_WINSUPPORT
    WM_Init();
  #endif
  return r;
}
예제 #16
0
파일: Terminal.c 프로젝트: byxob/calendar
static void Paint(TERMINAL_Obj* pObj/*, GUI_RECT*pRect*/) {
  char*s = (char*) WM_HMEM2Ptr(pObj->hpText);
  GUI_RECT rClient;
  GUI_DEBUG_LOG("TERMINAL: Paint(..)\n");
  GUI_GetClientRect(&rClient);
/* Draw background */
  GUI_SetBkColor (GUI_WHITE/*pObj->aBkColor[0]*/);
  GUI_SetColor   (GUI_BLACK /*pObj->aTextColor[0]*/);
  GUI_Clear();
/* Draw the text */  
  {
    GUI_RECT rText = rClient;
    rText.x0 +=3;
//    GUI_SetFont    (pObj->pFont);
    GUI_DispStringInRect(s, &rText, GUI_TA_LEFT);
  }
}
예제 #17
0
/*********************************************************************
*
*       _SLIDER_Callback
*/
static void _SLIDER_Callback (WM_MESSAGE *pMsg) {
  SLIDER_Handle hObj;
  SLIDER_Obj* pObj;
  hObj = pMsg->hWin;
  pObj = SLIDER_H2P(hObj);
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_DEBUG_LOG("SLIDER: _Callback(WM_PAINT)\n");
    _Paint(pObj);
    return;
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    break;
  case WM_KEY:
    _OnKey(hObj, pMsg);
    break;
  }
  WM_DefaultProc(pMsg);
}
예제 #18
0
파일: SLIDER.c 프로젝트: Jaly314/CH-K-Lib
/*********************************************************************
*
*       SLIDER_Callback
*/
void SLIDER_Callback (WM_MESSAGE *pMsg) {
  SLIDER_Handle hObj;
  SLIDER_Obj* pObj;
  hObj = pMsg->hWin;
  pObj = (SLIDER_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    return;
  }
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_DEBUG_LOG("SLIDER: _Callback(WM_PAINT)\n");
    _Paint(pObj, hObj);
    return;
  case WM_TOUCH:
    _OnTouch(hObj, pObj, pMsg);
    break;
  case WM_KEY:
    _OnKey(hObj, pMsg);
    break;
  }
  WM_DefaultProc(pMsg);
}
예제 #19
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(CHECKBOX_Handle hObj, CHECKBOX_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification = 0;
  int Hit = 0;
  const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (!WM_HasCaptured(hObj)) {
      if (pState->Pressed) {
        WM_SetCapture(hObj, 1);
        CHECKBOX_SetState(hObj, (pObj->CurrentState + 1) % pObj->NumStates);
        Notification = WM_NOTIFICATION_CLICKED;
      } else {
        Hit =1;
        Notification = WM_NOTIFICATION_RELEASED;
      }
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("CHECKBOX: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
예제 #20
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(BUTTON_Handle hObj, BUTTON_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification;
  int Hit = 0;
  GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      WIDGET_OrState(hObj, BUTTON_STATE_PRESSED);
      Notification = WM_NOTIFICATION_CLICKED;
      WM_SetFocus(hObj);
    } else {
      Hit =1;
      Notification = WM_NOTIFICATION_RELEASED;
      WIDGET_AndState(hObj, BUTTON_STATE_PRESSED);
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
    WIDGET_AndState(hObj, BUTTON_STATE_PRESSED);
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("BUTTON: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
예제 #21
0
/*********************************************************************
*
*       _Delete
*/
static void _Delete(CHECKBOX_Obj * pObj) {
  /* Delete attached objects (if any) */
  GUI_DEBUG_LOG("CHECKBOX: Delete() Deleting attached items");
  GUI_ALLOC_FreePtr(&pObj->hpText);
}
예제 #22
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(BUTTON_Obj* pObj) {
  const char*s =NULL;
  int State = pObj->Widget.State;
  int PressedState = (State & BUTTON_STATE_PRESSED) ? 1:0;
  GUI_RECT rClient;
  GUI_RECT r;
  GUI_SetFont(pObj->pFont);
  GUI_DEBUG_LOG("BUTTON: Paint(..)\n");
  if (pObj->hpText) {
    s = (const char*) WM_HMEM2Ptr(pObj->hpText);
  }
  GUI_GetClientRect(&rClient);
  r = rClient;
/* Draw background */
  GUI_SetBkColor (pObj->aBkColor[PressedState]);
  GUI_SetColor   (pObj->aTextColor[PressedState]);
  GUI_Clear();
/* Draw bitmap.
   If we have only one, we will use it.
   If we have to we will use the second one (Index 1) for the pressed state
*/
  {
    int Index =0;
    if (pObj->apBitmap[1] && PressedState) {
      Index =1;   
    }
    if (pObj->apBitmap[Index]) {
      #if BUTTON_SUPPORT_STREAMED_BITMAP
        if(pObj->aBitmapIsStreamed[Index]) {
        #if BUTTON_SUPPORT_BITMAP_OFFSET
          GUI_DrawStreamedBitmap((const GUI_BITMAP_STREAM*)(pObj->apBitmap[Index]), pObj->xOffBitmap, pObj->yOffBitmap);
        #else
          GUI_DrawBitmapStreamed((const GUI_BITMAP_STREAM*)(pObj->apBitmap[Index]), 0,0);
        #endif
        } else
      #endif
      {
        #if BUTTON_SUPPORT_BITMAP_OFFSET
          GUI_DrawBitmap(pObj->apBitmap[Index], pObj->xOffBitmap[Index], pObj->yOffBitmap[Index]);
        #else
          GUI_DrawBitmap(pObj->apBitmap[Index], 0,0);
        #endif
      }
    }
  }
/* Draw the actual button (background and text) */  
  #if BUTTON_USE_3D
    if (pObj->Widget.State & BUTTON_STATE_PRESSED) {
      GUI_MoveRect(&r, BUTTON_3D_MOVE_X,BUTTON_3D_MOVE_Y);
    }
  #endif
  GUI_SetTextMode(GUI_TM_TRANS);
  GUI_DispStringInRect(s, &r, GUI_TA_HCENTER | GUI_TA_VCENTER);
/* Draw the 3D effect (if configured) */
  #if BUTTON_USE_3D
  if ((State & BUTTON_STATE_PRESSED) == 0) {
    WIDGET_EFFECT_3D_DrawUp();
  } else {
    GUI_SetColor(0x000000);  /// TBD: Use halftone
    GUI_DrawRect(rClient.y0, rClient.x0, rClient.x1, rClient.y1);
  }
  #endif
  /* Draw focus */
  if (State & BUTTON_STATE_FOCUS) {
    GUI_SetColor(GUI_BLACK);
    GUI_DrawFocusRect(&rClient, 2);
  }
}
예제 #23
0
파일: BUTTON.c 프로젝트: Jaly314/CH-K-Lib
/*********************************************************************
*
*       _Paint
*/
static void _Paint(BUTTON_Obj* pObj, BUTTON_Handle hObj) {
  const char* s = NULL;
  unsigned int Index;
  int State, PressedState, ColorIndex;
  GUI_RECT rClient, rInside;
  State = pObj->Widget.State;
  PressedState = (State & BUTTON_STATE_PRESSED) ? 1 : 0;
  ColorIndex   = (WM__IsEnabled(hObj)) ? PressedState : 2;
  GUI_SetFont(pObj->Props.pFont);
  GUI_DEBUG_LOG("BUTTON: Paint(..)\n");
  if (pObj->hpText) {
    s = (const char*) GUI_ALLOC_h2p(pObj->hpText);
  }
  GUI_GetClientRect(&rClient);
  /* Start drawing */
  rInside = rClient;
/* Draw the 3D effect (if configured) */
  #if BUTTON_USE_3D
  {
    int EffectSize;
    if ((PressedState) == 0) {
      pObj->Widget.pEffect->pfDrawUp();  /* _WIDGET_EFFECT_3D_DrawUp(); */
      EffectSize = pObj->Widget.pEffect->EffectSize;
    } else {
      LCD_SetColor(0x000000);
      GUI_DrawRect(rClient.y0, rClient.x0, rClient.x1, rClient.y1);
      EffectSize = 1;
    }
    GUI__ReduceRect(&rInside, &rInside, EffectSize); 
  }
  #endif
  /* Draw background */
  LCD_SetBkColor (pObj->Props.aBkColor[ColorIndex]);
  LCD_SetColor   (pObj->Props.aTextColor[ColorIndex]);
  WM_SetUserClipRect(&rInside);
  GUI_Clear();
  /* Draw bitmap.
     If we have only one, we will use it.
     If we have to we will use the second one (Index 1) for the pressed state
  */
  if (ColorIndex < 2) {
    Index = (pObj->ahDrawObj[BUTTON_BI_PRESSED] && PressedState) ? BUTTON_BI_PRESSED : BUTTON_BI_UNPRESSED;
  } else {
    Index = pObj->ahDrawObj[BUTTON_BI_DISABLED] ? BUTTON_BI_DISABLED : BUTTON_BI_UNPRESSED;
  }
  GUI_DRAW__Draw(pObj->ahDrawObj[Index], 0, 0);
/* Draw the actual button (background and text) */  
  {
    GUI_RECT r;
    r = rInside;
    #if BUTTON_USE_3D
      if (PressedState) {
        GUI_MoveRect(&r, BUTTON_3D_MOVE_X,BUTTON_3D_MOVE_Y);
      }
    #endif
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_DispStringInRect(s, &r, pObj->Props.Align);
  }
  /* Draw focus */
  if (State & BUTTON_STATE_FOCUS) {
    LCD_SetColor(pObj->Props.FocusColor);
    GUI_DrawFocusRect(&rClient, 2);
  }
  WM_SetUserClipRect(NULL);
}
예제 #24
0
/*********************************************************************
*
*       _Delete
*/
static void _Delete(TEXT_Obj* pObj) {
  /* Delete attached objects (if any) */
  GUI_DEBUG_LOG("TEXT: Delete() Deleting attached items");
  _FreeAttached(pObj);
}
예제 #25
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(EDIT_Obj* pObj) {
    int PixelLen, xSize, ySize, xPosText = 0,
                                xPosCursor = 0, yPosText = 0, yPosCursor = 0, XSizeCursor, YSizeCursor;
    int IsEnabled;
    GUI_RECT rClient, rWindow;
    char * s;
    s = (char*) WM_HMEM2Ptr(pObj->hpText);
    GUI_DEBUG_LOG("BUTTON: _Paint(..)\n");
    if (pObj->Border) {
        GUI_SetBkColor(pObj->aBkColor[0]);
        GUI_Clear();
    }
    IsEnabled = WIDGET__IsEnabled(&pObj->Widget);
    /* Set clipping rectangle */
    WIDGET__GetInsideRect(&pObj->Widget, &rWindow);
    WM_SetUserClipRect(&rWindow);
    /* Calculate size */
    GUI_GetClientRect(&rClient);
    xSize = rClient.x1 - rClient.x0 + 1;
    ySize = rClient.y1 - rClient.y0 + 1;
    /* Draw background */
    GUI_SetBkColor (pObj->aBkColor[IsEnabled]);
    GUI_SetColor   (pObj->aTextColor[0]);
    GUI_Clear();
    /* Calculate length */
    GUI_SetFont    (pObj->pFont);
    PixelLen = GUI_GetStringDistX(s);
    /* Calculate size of cursor */
    YSizeCursor = GUI_GetFontDistY();
    if (pObj->EditMode == GUI_EDIT_MODE_INSERT) {
        if (pObj->XSizeCursor != 0) {
            XSizeCursor = pObj->XSizeCursor;
        } else {
            XSizeCursor = GUI_GetCharDistX(' ');
        }
    } else {
        if (pObj->CursorPos < (int)strlen(s))  {
            XSizeCursor = GUI_GetCharDistX(*(s + pObj->CursorPos));
        } else {
            XSizeCursor = pObj->XSizeCursor;
        }
    }
    /* Calculate X-pos */
    switch (pObj->Align & GUI_TA_HORIZONTAL) {
    case GUI_TA_CENTER:
        xPosCursor = (xSize - PixelLen + 1) / 2;
        xPosText = xSize / 2;
        break;
    case GUI_TA_LEFT:
        xPosCursor = pObj->Border + EDIT_XOFF;
        xPosText   = pObj->Border + EDIT_XOFF;
        break;
    case GUI_TA_RIGHT:
        xPosCursor = xSize - (pObj->Border + EDIT_XOFF) - PixelLen;
        xPosText   = xSize - (pObj->Border + EDIT_XOFF);
        break;
    }
    /* Calculate Y-pos */
    switch (pObj->Align & GUI_TA_VERTICAL) {
    case GUI_TA_TOP:
        yPosCursor = 0;
        yPosText = 0;
        break;
    case GUI_TA_BOTTOM:
        yPosCursor = ySize - YSizeCursor;
        yPosText = ySize;
        break;
    case GUI_TA_VCENTER:
        yPosCursor = (ySize - YSizeCursor + 1) / 2;
        yPosText = ySize / 2;
        break;
    }
    /* Display text */
    GUI_SetTextAlign(pObj->Align);
    GUI_DispStringAt(s, xPosText, yPosText);
    /* Display cursor */
    if (pObj->Widget.State & WIDGET_STATE_FOCUS) {
        int i;
        for (i = 0; i != pObj->CursorPos; i++) {
            xPosCursor += GUI_GetCharDistX(*(s + i));
        }
        GUI_InvertRect(xPosCursor,
                       yPosCursor,
                       xPosCursor + XSizeCursor - 1,
                       yPosCursor + YSizeCursor - 1);
    }
    WM_SetUserClipRect(NULL);
    /* Draw the 3D effect (if configured) */
    WIDGET__EFFECT_DrawDown(&pObj->Widget);
}