static void _UpdateInfoWin(void) {
  #if GUI_WINSUPPORT && GUIDEMO_LARGE
    GUI_RECT rClient;
    WM_HWIN hWin;
    GUI_CONTEXT ContextOld;
    GUI_SaveContext(&ContextOld);
    /* Update info  window */
    WM_ShowWindow(_ahInfoWin[0]);
    WM_ShowWindow(_ahFrameWin[0]);
    hWin = WM_SelectWindow(_ahInfoWin[0]);
    GUI_GetClientRect(&rClient);
    GUI_SetBkColor(GUI_WHITE);
    GUI_Clear();
    GUI_SetColor(GUI_BLACK);
    //GUI_SetFont(&GUI_Font13_1);
	GUI_SetFont(&GUI_FontHZ12);
    GUI_SetTextAlign(GUI_TA_HCENTER);
    GUI_DispStringHCenterAt(_sInfo, (rClient.x1 - rClient.x0) / 2, 0);
    GUI_SetTextAlign(GUI_TA_LEFT);
    GUI_SetFont(&GUI_Font8_ASCII);
    GUI_DispStringAt(_sExplain, 0, 20);
    WM_SelectWindow(hWin);
    GUI_RestoreContext(&ContextOld);
  #endif
}
Exemple #2
0
/*******************************************************************
*
*       _DrawPolygon

  Draws polygons of different shapes and colors
*/
static void _DrawPolygon(void) {
  int y = 90;
  /* clear display */
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  /* display text */
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("DrawPolygon - Sample", 160, 5);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringAt("using", 5, 40);
  GUI_DispStringAt("GUI_FillPolygon", 5, 55);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("Polygons of arbitrary shape\nin any color", 160, y + 90);
  GUI_Delay(500);
  /* draw filled polygons */
  while (1) {
    GUI_ClearRect(100, y, 220, y + 85);
    GUI_SetColor(GUI_BLUE);
    GUI_FillPolygon (&_aPointArrow[0], 7, 160, y + 80);
    GUI_Delay(1000);
    GUI_ClearRect(100, y, 220, y + 85);
    GUI_SetColor(GUI_RED);
    GUI_FillPolygon (&_aPointStar[0], 8, 160, y + 45);
    GUI_Delay(1000);
    GUI_ClearRect(100, y, 220, y + 85);
    GUI_SetColor(GUI_GREEN);
    GUI_FillPolygon(&_aPointHexagon[0], 6, 160, y + 45);
    GUI_Delay(1000);
  }
}
Exemple #3
0
/*******************************************************************
*
*       _DemoAntialiasing

  Draws lines with different antialiasing factors
*/
static void _DemoAntialiasing(void) {
  int i, x1, x2, y1, y2;
  const GUI_FONT *font_old;
  y1 = 65;
  y2 = 5;
  /* Set drawing attributes */
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_BLACK);
  GUI_SetPenShape(GUI_PS_FLAT);
  GUI_Clear();
  /* draw headline */
  font_old = GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("AA_Lines - Sample", 160, 5);
  /* Draw lines without antialiased */
  GUI_Delay(1000);
  GUI_SetFont(&GUI_Font8x16);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_DispStringAtCEOL("draw normal lines using", 5, 40);
  GUI_DispStringAtCEOL("GUI_DrawLine", 5, 55);
  GUI_Delay(2500);
  x1 = 20;
  x2 = 100;
  GUI_SetFont(font_old);
  GUI_DispStringHCenterAt("Normal", (x1 + x2) / 2, 30 + y1);
  for (i = 1; i < 8; i++) {
    GUI_SetPenSize(i);
    GUI_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2);
  }
  /* Draw lines with antialiasing quality factor 2 */
  GUI_Delay(3000);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringAtCEOL("", 5, 40);
  GUI_DispStringAtCEOL("", 5, 55);
  GUI_Delay(200);
  GUI_DispStringAtCEOL("draw antialiased lines using", 5, 40);
  GUI_DispStringAtCEOL("GUI_AA_DrawLine", 5, 55);
  GUI_Delay(3500);
  x1 = 120;
  x2 = 200;
  GUI_AA_SetFactor(2);
  GUI_SetFont(font_old);
  GUI_DispStringHCenterAt("Antialiased\nusing factor 2", (x1 + x2) / 2, 30 + y1);
  for (i = 1; i < 8; i++) {
    GUI_SetPenSize(i);
    GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2);
  }
  /* Draw lines with antialiasing quality factor 6 */
  GUI_Delay(1500);
  x1 = 220;
  x2 = 300;
  GUI_AA_SetFactor(6);
  GUI_SetFont(font_old);
  GUI_DispStringHCenterAt("Antialiased\nusing factor 6", (x1 + x2) / 2, 30 + y1);
  for (i = 1; i < 8; i++) {
    GUI_SetPenSize(i);
    GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2);
  }
  GUI_Delay(7500);
}
Exemple #4
0
void ShowString(char* STR,int x,int y,int pos)
	{
	GUI_SetColor(GW_BLACKV);
	GUI_SetBkColor(GW_WHITE);        
	/*Clear 27 chars*/
	GUI_SetTextAlign(pos);
	GUI_GotoXY(x,y);
	GUI_DispChars(' ',18);//For Clear String
	/*Clear channel mark area.*/        
	GUI_SetBkColor(GW_WHITE);
	GUI_SetTextAlign(pos);        
	GUI_GotoXY(x,y);
	GUI_DispChar(' ');//For Clear String
	GUI_DispStringAt(STR,x+1,y);
	}
/*******************************************************************
*
*       _DemoListBoxAsChild
*/
static void _DemoListBoxAsChild(void) {
  FRAMEWIN_Handle hFrame;
  LISTBOX_Handle hListBox;
  /* Display titel */
  GUI_SetBkColor(0xB00000);
  GUI_SetColor(0xFFFFFF);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("Listbox as child - Sample", 160, 5);
  GUI_Delay(SPEED / 2);
  /* Create framewin */
  GUI_SetFont(&GUI_Font8x16);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_DispStringAtCEOL("using", 5, 40);
  GUI_DispStringAtCEOL("FRAMEWIN_Create", 5, 55);
  GUI_Delay(SPEED);
  hFrame = FRAMEWIN_Create("List box", NULL, WM_CF_SHOW, 100, 80, 120, 140);
  FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII);
  FRAMEWIN_SetActive(hFrame, 1);
  GUI_Delay(SPEED * 0.75);
  /* Create listbox */
  GUI_DispStringAtCEOL("LISTBOX_CreateAsChild", 5, 55);
  GUI_Delay(SPEED);
  hListBox = LISTBOX_CreateAsChild(_ListBox, WM_GetClientWindow(hFrame), 0, 0, 0, 0, WM_CF_SHOW);
  GUI_Delay(SPEED * 0.75);
  /* Show serveral functions of listbox */
  _ShowSeveralFunctions(hListBox);
  /* Delete framewin widget */
  GUI_DispStringAtCEOL("FRAMEWIN_Delete", 5, 55);
  GUI_Delay(SPEED);
  FRAMEWIN_Delete(hFrame);
  GUI_Delay(SPEED * 0.75);
  /* Clear display */
  GUI_Clear();
  GUI_Delay(SPEED * 1.5);
}
/*******************************************************************
*
*       _DemoHardkey

  Demonstrates HARDKEY simulation with a listbox
*/
static void _DemoHardkey(void) {
    LISTBOX_Handle hListBox;
    GUI_SetBkColor(GUI_BLACK);
    GUI_Clear();
    GUI_SetColor(GUI_WHITE);
    GUI_SetTextAlign(GUI_TA_HCENTER);
    GUI_SetFont(&GUI_Font24_ASCII);
    GUI_DispStringAt("Hardkey - Sample", 160, 5);
    GUI_SetFont(&GUI_Font8x8);
    GUI_DispStringHCenterAt("Exit",  65, 230);
    GUI_DispStringHCenterAt("Up",   160, 230);
    GUI_DispStringHCenterAt("Down", 255, 230);
    /* Create the listbox */
    hListBox = LISTBOX_Create(_aListBox, 100, 100, 120, 75, WM_CF_SHOW);
    WM_SetFocus(hListBox);
    LISTBOX_SetFont(hListBox, &GUI_Font13B_1);
    SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL);
    /* Handle the listbox */
    while (!_Ready) {
        GUI_Delay(10);
    }
    /* Delete listbox widget */
    LISTBOX_Delete(hListBox);
    GUI_Clear();
}
/*******************************************************************
*
*       _DemoDropDownAsChild
*/
static void _DemoDropDownAsChild(void) {
  WM_HWIN hFrame;
  WM_HWIN hDropDown;
  /* Display titel */
  GUI_SetBkColor(0xB00000);
  GUI_SetColor(0xFFFFFF);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("Dropdown as child - Sample", 160, 5);
  GUI_Delay(SPEED / 2);
  /* Create framewin */
  GUI_SetFont(&GUI_Font8x16);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_DispStringAtCEOL("using", 5, 40);
  GUI_DispStringAtCEOL("FRAMEWIN_Create", 5, 55);
  GUI_Delay(SPEED);
  hFrame = FRAMEWIN_Create("DropDown", NULL, WM_CF_SHOW, 80, 80, 160, 140);
  FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII);
  FRAMEWIN_SetActive(hFrame, 1);
  GUI_Delay(SPEED * 0.75);
  /* Create listbox */
  GUI_DispStringAtCEOL("DROPDOWN_CreateEx", 5, 55);
  GUI_Delay(SPEED);
  hDropDown = DROPDOWN_CreateEx(20, 20, 120, 65, WM_GetClientWindow(hFrame), WM_CF_SHOW, 0, 0);
  GUI_Delay(SPEED * 0.75);
  /* Show serveral functions of listbox */
  _ShowSeveralFunctions(hDropDown);
  /* Delete framewin widget */
  GUI_DispStringAtCEOL("FRAMEWIN_Delete", 5, 55);
  GUI_Delay(SPEED);
  FRAMEWIN_Delete(hFrame);
  GUI_Delay(SPEED * 0.75);
  /* Clear display */
  GUI_Clear();
  GUI_Delay(SPEED * 1.5);
}
Exemple #8
0
static void _Paint(FRAMEWIN_Obj* pObj) {
  WM_HWIN hWin = WM_GetActiveWindow();
  int xsize = WM_GetWindowSizeX(hWin);
  int ysize = WM_GetWindowSizeY(hWin);
  int FrameSize = pObj->FrameSize;
  GUI_RECT rClient; GUI_GetClientRect(&rClient);
  GUI_SetFont(pObj->pFont);
/* Draw Title */
  GUI_SetBkColor((pObj->Widget.State & WIDGET_STATE_CHILD_HAS_FOCUS) ? pObj->BarColor[1] : pObj->BarColor[0]);
  GUI_SetColor  (pObj->TextColor);
  GUI_SetTextAlign(pObj->TextAlign);
	GUI_ClearRect(FrameSize,FrameSize, xsize-1-FrameSize, FrameSize+pObj->rClient.y0-1);
  GUI_DispStringAt( pObj->pText,
                   FrameSize+pObj->XOff,
                   FrameSize+pObj->YOff);
/* Draw Frame */
  GUI_SetColor  (FRAMEWIN_FRAMECOLOR_DEFAULT);  /* pObj->BarColor[1]*/
  GUI_FillRect  (0, 0, xsize-1, FrameSize-1);
	GUI_FillRect  (0, 0, pObj->rClient.x0-1, ysize-1);
	GUI_FillRect  (pObj->rClient.x1+1, 0, xsize-1, ysize-1);
  GUI_FillRect  (0, pObj->rClient.y1+1, xsize-1, ysize-1);
  GUI_FillRect  (0, pObj->TitleHeight+FrameSize,
                    xsize-1, pObj->TitleHeight+2*FrameSize-1);
/* Draw Client area */
  WM_SetUserClipArea(&pObj->rClient);
  /*GUI_SetBkColor(pObj->ClientColor);
  GUI_Clear();*/
  WM_SetUserClipArea(NULL);
/* Draw the 3D effect (if configured) */
  #if FRAMEWIN_USE_3D
    WIDGET_EFFECT_3D_DrawUp();
  #endif
  
}
Exemple #9
0
void ShowKeyPadString(char* STR)
	{
	GUI_SetFont(Upper_Font); 
	GUI_SetColor(GW_BLACKV);
	GUI_SetBkColor(GW_WHITE);        
	/*Clear 27 chars*/
	GUI_SetTextAlign(GUI_TA_LEFT);
	GUI_GotoXY(73,97);
	//GUI_DispChars(' ',41);//For Clear String
	GUI_DispChars(' ',50);//For Clear String
	/*Clear channel mark area.*/        
	GUI_SetBkColor(GW_WHITE);
	GUI_SetTextAlign(GUI_TA_CENTER);        
	GUI_GotoXY(161,97);
	GUI_DispChar(' ');//For Clear String
	GUI_DispStringAt(STR,162,97);
	}
Exemple #10
0
void GL_SetDefault(void) {
  GUI_SetBkColor(GUI_DEFAULT_BKCOLOR);
  GUI_SetColor  (GUI_DEFAULT_COLOR);
  GUI_SetPenSize(1);
  GUI_SetTextAlign(0);
  GUI_SetTextMode(0);
  GUI_SetDrawMode(0);
  GUI_SetFont(GUI_DEFAULT_FONT);
  GUI_SetLineStyle(GUI_LS_SOLID);
}
Exemple #11
0
/**
  * @brief  Displays a maximum of 60 char on the USER_LCD.
  * @param  X: pointer to x position (in pixel)
  * @param  Y: pointer to y position (in pixel)    
  * @param  pText: pointer to string to display on USER_LCD
  * @param  mode: The display mode
  *    This parameter can be one of the following values:
  *                @arg CENTER_MODE 
  *                @arg RIGHT_MODE
  *                @arg LEFT_MODE   
  * @retval None
  */
void USER_LCD_LOG_DisplayStringAt(uint16_t X, uint16_t Y, char *pText, USER_Text_AlignModeTypdef mode, GUI_COLOR color)
{
  
  /* Clear first */
  GUI_SetFont(&USER_LCD_LOG_TEXT_FONT);
  #ifdef __USER_USE_SOLID_BK_
  GUI_SetColor(USER_LCD_LOG_BACKGROUND_COLOR);
  GUI_FillRect(X,Y,X0+XSIZE,Y+GUI_GetFontSizeY());
  #endif
  GUI_SetColor(color);
  GUI_SetTextMode(GUI_TEXTMODE_TRANS);
  switch (mode)
  {
  case USER_CENTER_MODE:
    {
      GUI_SetTextAlign(GUI_TA_HCENTER);
      //GUI_DispStringAtCEOL(pText,X,Y);
      GUI_DispStringAt(pText,X,Y);
      break;
    }
  case USER_LEFT_MODE:
    {
      GUI_SetTextAlign(GUI_TA_LEFT);
      //GUI_DispStringAtCEOL(pText,X,Y);
      GUI_DispStringAt(pText,X,Y);
      break;
    }
  case USER_RIGHT_MODE:
    {
      GUI_SetTextAlign(GUI_TA_RIGHT);
      //GUI_DispStringAtCEOL(pText,X,Y);
      GUI_DispStringAt(pText,X,Y);
      break;
    }
  default:
    {
      GUI_SetTextAlign(GUI_TA_LEFT);
      //GUI_DispStringAtCEOL(pText,X,Y);
      GUI_DispStringAt(pText,X,Y);
      break;
    }
  }
}
Exemple #12
0
TGUINode * GUI_CreateButton( float x, float y, float width, float height, TTexture * backgroundTex, TFont * font, const char * text ) {
    TGUINode * node = GUI_CreateNode();
    node->button = Memory_New( TGUIButton );
    node->button->background = GUI_CreateRect( x, y, width, height, backgroundTex );
    node->button->text = GUI_CreateText( x, y, width, height, text, font );
    GUI_SetTextAlign( node, GUITA_MIDDLE );
    node->button->normalColor = Vec3_Set( 1.0f, 1.0f, 1.0f );
    node->button->pressedColor = Vec3_Set( 0.8f, 0.8f, 0.8f );
    node->button->pickedColor = Vec3_Set( 0.9f, 0.9f, 0.9f );
    node->color = node->button->normalColor;
    return node;
}
Exemple #13
0
void Menu_Message(char *Message,int x,int y)
	{
	Wait_For_MDMA_Ready();
	Float_Windows_Setting(0,0,319,8,MEM_WHITE);
	GUI_SetFont(Parameter_Font);
	GUI_SetBkColor(MEM_WHITE);
	GUI_SetColor(Message_Font_Bolor);		
	GUI_SetTextAlign(GUI_TA_LEFT);
	FloatWindows_StringAt(Message,x,y);
	//FloatWindowsDispOn();	
	CtrlFlag1 |= Float_Windows_DispOn;
	DMA_Update_Flag = 1;
	}
Exemple #14
0
/*******************************************************************
*
*       _DemoScrollbarMove

  This function creates the window and his child objects. Then it
  runs into a idle-loop, so that the window manager can handle the
  objects.
*/
static void _DemoScrollbarMove(void) {
  int x, y;
  WM_HWIN hWindow;
  SCROLLBAR_Handle hScroll;
  /* Clear display and display headline */
  GUI_SetBkColor(GUI_BLUE);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("SCROLLBAR_Move - Sample", 160, 5);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_SetColor(0xFFFFFF);
  GUI_SetFont(&GUI_Font8x16);
  /* Create the window */
  hWindow = WM_CreateWindow(50, 90, 220, 79, WM_CF_SHOW, &_cbWindow, 0);
  /* Create the scrollbar */
  hScroll = SCROLLBAR_CreateAttached(hWindow, 0);
  SCROLLBAR_SetNumItems(hScroll, 48 * EDIT_MAX_X);
  SCROLLBAR_SetPageSize(hScroll, 220);
  /* Create the edit-fields */
  for (y = 0; y < EDIT_MAX_Y; y++) {
    for (x = 0; x < EDIT_MAX_X; x++) {
      _aahEdit[y][x] = EDIT_CreateAsChild(x * 48, y * 22, 48, 22, 
                                        hWindow, 13, WM_CF_SHOW, 5);
      EDIT_SetTextAlign(_aahEdit[y][x], GUI_TA_RIGHT | GUI_TA_VCENTER);
      EDIT_SetFont(_aahEdit[y][x], &GUI_Font8x16);
      EDIT_SetDecMode(_aahEdit[y][x], ((y * EDIT_MAX_X) + x) * 100, -99999, +99999, 2, 0);
	  }
  }
  /* idle-loop */
  while (1) {
    GUI_Exec();
    GUI_Delay(20);
  }
  /* delete window and clear display */
  WM_DeleteWindow(hWindow);
  GUI_Clear();
}
/*******************************************************************
*
*       _ShowHiresAntialiasing
*
* Function description
*   This function creates the memory auto devices and handle the
*   rotation of the pointers
*/
static void _ShowHiresAntialiasing(void) {
  GUI_AUTODEV aAuto[2];
  PARAM       Param;
  unsigned         i;

  Param.Factor = 3;
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringAt("AA_HiResAntialiasing - Sample", 160, 5);
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 110, 180);
  GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 210, 180);
  //
  // Create GUI_AUTODEV objects
  //
  for (i = 0; i < countof(aAuto); i++) {
    GUI_MEMDEV_CreateAuto(&aAuto[i]);
  }
  //
  // Calculate pointer for high resolution
  //
  for (i = 0; i < countof(_aPointer); i++) {
    _aPointerHiRes[i].x = _aPointer[i].x * Param.Factor;
    _aPointerHiRes[i].y = _aPointer[i].y * Param.Factor;
  }
  GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */
  while (1) {
    for (i = 0; i < 1800; i++) {
      float Angle = (i >= 900) ? 1800 - i : i;
      Angle *= 3.1415926f / 1800;
      //
      // Draw pointer with high resolution
      //
      GUI_AA_EnableHiRes();
      GUI_RotatePolygon(Param.aPoints, _aPointerHiRes, countof(_aPointer), Angle);
      GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, _DrawHiRes, &Param);
      //
      // Draw pointer without high resolution
      //
      GUI_AA_DisableHiRes();
      GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle);
      GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, _Draw, &Param);
      GUI_Delay(2);
    }
  }
}
Exemple #16
0
/*********************************************************************
*
*       _OnPaintVert
*/
static void _OnPaintVert(GRAPH_SCALE_OBJ * pScaleObj, GUI_RECT * pRectInvalid) {
  int BorderT, BorderB, EffectSize;
  GRAPH_OBJ * pObj;
  int xPos, xPosScreen, y0, y1, i, yStart, FontSizeY, TextOffY;
  GUI_RECT Rect;
  if (!pScaleObj->TickDist) {
    return;
  }
  pObj = (GRAPH_OBJ *)GUI_ALLOC_h2p(pScaleObj->PaintObj.hGraph);
  EffectSize = pObj->Widget.pEffect->EffectSize;
  xPos       = pScaleObj->Pos + EffectSize;
  xPosScreen = xPos + WM_GetOrgX();
  switch (pScaleObj->TextAlign) {
  case GUI_TA_RIGHT:
    if (pRectInvalid->x0 > xPosScreen) {
      return;
    }
    break;
  case GUI_TA_LEFT:
    if (pRectInvalid->x1 < xPosScreen) {
      return;
    }
    break;
  }
  WM_GetInsideRectExScrollbar(pScaleObj->PaintObj.hGraph, &Rect);
  BorderT = pObj->Props.BorderT;
  BorderB = pObj->Props.BorderB;
  FontSizeY = GUI_GetFontSizeY();
  TextOffY  = FontSizeY / 2;
  y0     = Rect.y0 + BorderT;
  y1     = Rect.y1 - BorderB;
  yStart = y1 - pScaleObj->Off + pObj->ScrollStateV.v;
  while (yStart < y1) {
    yStart += pScaleObj->TickDist;
  }
  for (i = yStart; i >= y0; i -= pScaleObj->TickDist) {
    if ((i >= y0) && (i <= y1)) {
      float Value;
      GUI_SetTextAlign(pScaleObj->TextAlign);
      Value = (y1 - i - pScaleObj->Off + pObj->ScrollStateV.v) * pScaleObj->Factor;
      GUI_GotoXY(xPos, i - TextOffY);
      GUI_DispFloatMin(Value, pScaleObj->NumDecs);
    }
  }
}
/*********************************************************************
*
*       _DrawLabel
*/
static void _DrawLabel(GUI_MEMDEV_Handle hMem, int xPos, int yPos) {
  GUI_MEMDEV_Handle hMemOld;
  int               FontSizeY;
  int               x0;
  int               y0;
  int               i;

  hMemOld = GUI_MEMDEV_Select(hMem);
  GUI_SetFont(&GUI_FontD9_AA4);
  GUI_SetTextMode(GUI_TM_TRANS);
  FontSizeY = GUI_GetFontSizeY();
  for (i = 0; i < 5; i++) {
    x0 = xPos - 7;
    y0 = yPos + 96 - i * 20 - 7;
    GUI_DrawBitmap(&_bmCircleOrange_14x14, x0, y0);
    GUI_GotoXY(x0 + 7, y0 + 7 - FontSizeY / 2);
    GUI_SetTextAlign(GUI_TA_HCENTER);
    GUI_SetColor(GUI_BLACK);
    GUI_DispDecMin((i + 1) * 2);
  }
  GUI_MEMDEV_Select(hMemOld);
}
Exemple #18
0
/*********************************************************************
*
*       _OnPaintHorz
*/
static void _OnPaintHorz(GRAPH_SCALE_OBJ * pScaleObj, GUI_RECT * pRectInvalid) {
  int BorderL, BorderR, EffectSize;
  GRAPH_OBJ * pObj;
  int yPos, yPosScreen, x0, x1, i, xStart, FontSizeY, xAdd;
  GUI_RECT Rect;
  if (!pScaleObj->TickDist) {
    return;
  }
  pObj = (GRAPH_OBJ *)GUI_ALLOC_h2p(pScaleObj->PaintObj.hGraph);
  EffectSize = pObj->Widget.pEffect->EffectSize;
  FontSizeY  = GUI_GetFontSizeY();
  yPos       = pScaleObj->Pos - EffectSize;
  yPosScreen = yPos + WM_GetOrgY();
  if (yPosScreen > pRectInvalid->y1) {
    return;
  }
  if ((yPosScreen + FontSizeY) < pRectInvalid->y0) {
    return;
  }
  WM_GetInsideRectExScrollbar(pScaleObj->PaintObj.hGraph, &Rect);
  BorderL = pObj->Props.BorderL;
  BorderR = pObj->Props.BorderR;
  x0     = Rect.x0 + BorderL;
  x1     = Rect.x1 - BorderR;
  xAdd   = (pObj->Flags & GRAPH_CF_GRID_FIXED_X) ? 0 : pObj->ScrollStateH.v;
  xStart = x0 + pScaleObj->Off + xAdd;
  while (xStart > x0) {
    xStart -= pScaleObj->TickDist;
  }
  for (i = xStart; i <= x1; i += pScaleObj->TickDist) {
    if ((i > x0) && (i <= x1)) {
      float Value;
      GUI_SetTextAlign(pScaleObj->TextAlign);
      Value = (i - pScaleObj->Off - BorderL - EffectSize - xAdd) * pScaleObj->Factor;
      GUI_GotoXY(i, yPos);
      GUI_DispFloatMin(Value, pScaleObj->NumDecs);
    }
  }
}
/*******************************************************************
*
*       _DemoListBox
*/
static void _DemoListBox(void) {
  LISTBOX_Handle hListBox;
  /* Display titel */
  GUI_SetBkColor(0xB00000);
  GUI_SetColor(0xFFFFFF);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("Listbox - Sample", 160, 5);
  GUI_Delay(SPEED / 2);
  /* Create listbox */
  GUI_SetFont(&GUI_Font8x16);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_DispStringAtCEOL("using", 5, 40);
  GUI_DispStringAtCEOL("LISTBOX_Create", 5, 55);
  GUI_Delay(SPEED * 0.9);
  hListBox = LISTBOX_Create(_ListBox, 100, 80, 120, 115, WM_CF_SHOW);
  GUI_Delay(SPEED * 0.75);
  /* Show serveral functions of listbox */
  _ShowSeveralFunctions(hListBox);
  /* Clear display */
  GUI_Clear();
  GUI_Delay(SPEED * 1.5);
}
/*******************************************************************
*
*       _DemoDropDown
*/
static void _DemoDropDown(void) {
  WM_HWIN hDropDown;
  /* Display titel */
  GUI_SetBkColor(0xB00000);
  GUI_SetColor(0xFFFFFF);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("Dropdown - Sample", 160, 5);
  GUI_Delay(SPEED / 2);
  /* Create listbox */
  GUI_SetFont(&GUI_Font8x16);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_DispStringAtCEOL("using", 5, 40);
  GUI_DispStringAtCEOL("DROPDOWN_CreateEx", 5, 55);
  GUI_Delay(SPEED * 0.9);
  hDropDown = DROPDOWN_CreateEx(100, 80, 120, 115-50, WM_HBKWIN, WM_CF_SHOW, 0, 0);
  GUI_Delay(SPEED * 0.75);
  /* Show serveral functions of listbox */
  _ShowSeveralFunctions(hDropDown);
  /* Clear display */
  GUI_Clear();
  GUI_Delay(SPEED * 1.5);
}
/*******************************************************************
*
*       _ShowHiResPixels

  This is frame-function for the callback. It creates the window
  and handles the rotation of polygons and colors.
*/
static void _ShowHiResPixels(void) {
    WM_HWIN hWindow;
    const GUI_FONT *font_old;
    float pi, step, angle;
    int i, tm;
    pi = 3.1415926f;
    step = pi / 180;
    GUI_SetBkColor(GUI_BLACK);
    GUI_Clear();
    GUI_SetColor(GUI_WHITE);
    GUI_SetTextAlign(GUI_TA_HCENTER);
    font_old = GUI_SetFont(&GUI_Font24_ASCII);
    GUI_DispStringAt("AA_HiResPixels - Sample", 160, 5);
    GUI_SetFont(font_old);
    GUI_SetColor(GUI_RED);
    GUI_DispStringHCenterAt("not\nantialised", 65, 100);
    GUI_SetColor(GUI_GREEN);
    GUI_DispStringHCenterAt("antialised", 160, 100);
    GUI_SetColor(GUI_BLUE);
    GUI_DispStringHCenterAt("antialised\nwith high\nresolution", 255, 100);
    hWindow = WM_CreateWindow(35, 140, 250, 60, WM_CF_SHOW | WM_CF_MEMDEV, &_cbWindow, 0);
    WM_SelectWindow(hWindow);
    GUI_AA_SetFactor(AA_FACTOR);
    while (1) {
        for (i=0, angle=0; i<360; i++) {
            tm = GUI_GetTime();
            angle += step;
            GUI_RotatePolygon(_aPolygonHiRes, _aPolygonHiRes_src, POLY_POINTS, angle);
            GUI_RotatePolygon(_aPolygon, _aPolygon_src, POLY_POINTS, angle);
            _CalcColor();
            WM_InvalidateWindow(hWindow);
            while (((GUI_GetTime()-tm) < 50) || (WM_Exec1() != 0));
        }
    }
    WM_DeleteWindow(hWindow);
}
void _ExecCalibration(void) {
  int ax_Phys[2],ay_Phys[2];
/* calculate log. Positions */
  int ax[2] = { 15, LCD_XSIZE -1-15};
//  const int ay[2] = { 15, LCD_YSIZE-1-15};
  int ay[2] = { LCD_YSIZE-1-15, 15};

  CalibrationComplete = 0;
  GUI_TOUCH_SetDefaultCalibration();
/* _Calibrate upper left */
  GUI_SetBkColor(GUI_RED);  
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);  GUI_FillCircle(ax[0], ay[0], 10);
  GUI_SetColor(GUI_RED);    GUI_FillCircle(ax[0], ay[0], 5);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Press here", ax[0]+20, ay[0]);
  do {
    GUI_PID_STATE State;
    GUI_TOUCH_GetState(&State);
    if (State.Pressed) {
      ax_Phys[0] = GUI_TOUCH_GetxPhys();
      ay_Phys[0] = GUI_TOUCH_GetyPhys();
      break;
    }
    GUI_Delay (100);
  } while (1);
/* Tell user to release */
  GUI_Clear();
  GUI_DispStringAt("OK", ax[0]+20, ay[0]);
  do {
    GUI_PID_STATE State;
    GUI_TOUCH_GetState(&State);
    if (State.Pressed == 0) {
      break;
    }
    GUI_Delay (100);
  } while (1);
/* _Calibrate lower right */
  GUI_SetBkColor(GUI_RED);  
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);  GUI_FillCircle(ax[1], ay[1], 10);
  GUI_SetColor(GUI_RED);    GUI_FillCircle(ax[1], ay[1], 5);
  GUI_SetColor(GUI_WHITE);
  GUI_SetTextAlign(GUI_TA_RIGHT);
  GUI_DispStringAt("Press here", ax[1]-20, ay[1]);
  do {
    GUI_PID_STATE State;
    GUI_TOUCH_GetState(&State);
    if (State.Pressed) {
      ax_Phys[1] = GUI_TOUCH_GetxPhys();
      ay_Phys[1] = GUI_TOUCH_GetyPhys();
      break;
    }
    GUI_Delay (100);
  } while (1);
  GUI_TOUCH_Calibrate(GUI_COORD_X, ax[0], ax[1], ax_Phys[0], ax_Phys[1]);
  GUI_TOUCH_Calibrate(GUI_COORD_Y, ay[0], ay[1], ay_Phys[0], ay_Phys[1]);
  { /* calculate and display values for configuration file */
    int x0, x1;
    int y0, y1;
    GUI_Clear();
    _Calibrate(GUI_COORD_X, ax[0], ax[1], ax_Phys[0], ax_Phys[1], &x0, &x1);
    _Calibrate(GUI_COORD_Y, ay[0], ay[1], ay_Phys[0], ay_Phys[1], &y0, &y1);
    GUI_DispStringAt("x0: ", 0, 0); GUI_DispDec(x0, 4); GUI_DispNextLine();
    GUI_DispString  ("x1: ");       GUI_DispDec(x1, 4); GUI_DispNextLine();
    GUI_DispString  ("y0: ");       GUI_DispDec(y0, 4); GUI_DispNextLine();
    GUI_DispString  ("y1: ");       GUI_DispDec(y1, 4); GUI_DispNextLine();
    GUI_DispString  ("Please touch display to continue...");
    GUI_Delay(1000);
    do {
      GUI_PID_STATE State;
      GUI_TOUCH_GetState(&State);
      if (State.Pressed)
        break;
      GUI_Delay (10);
    } while (1);
  }
  CalibrationComplete = 1;
}
Exemple #23
0
void MenuProcess(BYTE m_no)
{
	WORD 	its_no;//i_no;    /*denote as the item selection number for specified menu*/
	                               /*i_no: define as the subselected item*/
	MENU    tempMenu;        /*point to the specified menu content*/
	MITEMS 	*tempItem;       /*point to the specified item content*/
	MITEM 	*tempITEM;        /*point to the specified item with its internal data*/
	UWORD 	item=1;
	BYTE	typesel;
	BYTE 	POS;
	char 	i,j,str[8];
	int 	item_x_addr[5] = {	32, 96, 160, 224, 288};		/* Item string X location */
	///unsigned char Parallel_Num = 0;
	///unsigned char Booster_Num = 0;
	
	P3k_Disp_Str	*Disp_tmp = &P3k_Disp_Data;
	P3k_Data_Str	*Data_tmp = &P3k_Chan_Data;

	if((tempMenu=_menu[m_no])==NULL1)
	{
#if Normal_TEST
     	printf("No function");
#endif
    	return;
	}	
	
	if(m_no!=D_M_num)
	{
		D_M_num=m_no;					/*only the valid menu will be updata*/  
		ClearMenuBG(MEM_GRAY);  		/*Draw back ground of menu.*/
	}
	UTILITY.LANGUAGE = 0; //Adam
	
    GUI_SetBkColor(MEM_GRAY);

   	for(its_no=0;its_no<5;its_no++)
	{
		if(MenuRedrawFlag&item)			/* Redraw Menu bar by each issue */
		{
    		GUI_SetColor(MEM_WHITE); 
    		tempItem=&(tempMenu)[its_no];
    		tempITEM=&(tempItem->iptr)[0];

			///Parallel_Num = Disp_tmp->CONF.Para_Data.Parallel_Number;
			///Booster_Num = Disp_tmp->CONF.Para_Data.Booster_Number;

			if( (M_num==P_CC||M_num==P_CR||M_num==P_CV||M_num==P_CP||M_num==P_CAL_MODE)&&((its_no==1)||(its_no==0)))
			{
				if(its_no==1)
				{
					if(Model_Number==MODEL3032E)	
						GUI_DrawBitmap(tempITEM->pbmp[3],tempITEM->x,tempITEM->y);
					else							
						GUI_DrawBitmap(tempITEM->pbmp[0],tempITEM->x,tempITEM->y);
				}
				else
				{
					if(Data_tmp->CONF.CV_Func_En)
						GUI_DrawBitmap(tempITEM->pbmp[4],tempITEM->x,tempITEM->y);
					else
						GUI_DrawBitmap(tempITEM->pbmp[0],tempITEM->x,tempITEM->y);
				}
			}
			else if((M_num==P_CC||M_num==P_CR||M_num==P_CV||M_num==P_CP)&&(its_no==2)){
				if(Model_Number==MODEL3032E)	
						GUI_DrawBitmap(tempITEM->pbmp[3],tempITEM->x,tempITEM->y);
					else							
						GUI_DrawBitmap(tempITEM->pbmp[0],tempITEM->x,tempITEM->y);				
			}else 
				GUI_DrawBitmap(tempITEM->pbmp[(LONG)UTILITY.LANGUAGE],tempITEM->x,tempITEM->y);

			if(tempItem->i_max)
			{
         		if((*tempItem->i_condition)>=tempItem->i_max)   /*Prevent over boundary. Kevin Meng 2003.02.13*/
					*tempItem->i_condition=tempItem->i_max-1;
         		tempITEM=&(tempItem->iptr)[(*tempItem->i_condition)+1];

				if( (M_num==P_CC||M_num==P_CR||M_num==P_CV||M_num==P_CP||M_num==P_CAL_MODE)&&((its_no==1)||(its_no==0)) )
				{				
					if(its_no==1)
					{
						if(Model_Number==MODEL3032E)	
							GUI_DrawBitmap(tempITEM->pbmp[3],tempITEM->x,tempITEM->y);
						else							
							GUI_DrawBitmap(tempITEM->pbmp[0],tempITEM->x,tempITEM->y);
					}
					else
					{
						if(Data_tmp->CONF.CV_Func_En)
							GUI_DrawBitmap(tempITEM->pbmp[4],tempITEM->x,tempITEM->y);
						else
							GUI_DrawBitmap(tempITEM->pbmp[0],tempITEM->x,tempITEM->y);
					}
				}
				else if((M_num==P_CC||M_num==P_CR||M_num==P_CV||M_num==P_CP)&&(its_no==2))
				{
				if(Model_Number==MODEL3032E)	
						GUI_DrawBitmap(tempITEM->pbmp[3],tempITEM->x,tempITEM->y);
					else							
						GUI_DrawBitmap(tempITEM->pbmp[0],tempITEM->x,tempITEM->y);
				}	
				else
					GUI_DrawBitmap(tempITEM->pbmp[(LONG)UTILITY.LANGUAGE],tempITEM->x,tempITEM->y);  //draw title
   	     	}
			
			if(P3K_CALIBRATION_BAR.RANGE==3 && M_num==P_CAL_MODE)
				DrawMenuFrame(its_no,2);
			else
				DrawMenuFrame(its_no,tempItem->frame);
			
			MenuRedrawFlag&=(~item); //Kevin Meng 2005.05.16
		}
		item<<=1;
	}
	
	if(M_num==P_LUA_EXECUTE)
	{
		for(i=0;i<5;i++)
		{
			if(Script[i].functionname[0]!=0)
			{
				GUI_SetFont(&GUI_FontArial15);
				GUI_SetBkColor(GW_GRAY);
				GUI_SetColor(MEM_BLACK);
				strncpy(str,(const char *)&Script[i].functionname,8);	

				for(j=1;j<8;j++)
				{
					if((str[j]>=65)&&(str[j]<=90))
						str[j]+=32;
				}
				GUI_SetTextAlign(GUI_TA_CENTER);
				GUI_DispStringAt(str, item_x_addr[i], 216);	
			}
		}
	}
}
/**************************************************************************************
* FunctionName   : _FillCalendar()
* Description    : 日历填写
* EntryParameter : None
* ReturnValue    : None
**************************************************************************************/
void _FillCalendar(CLD_DAY *pDay, int year, U8 month, U8 day, U8 wekday)
{
	const U8 cstmonth[][4] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEQ", "OCT", "NOV", "DEC" };
	const U8 monthDay[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//非闰年
	const U8 monthDayLY[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//闰年
	int tmpWek;
	U8 i = 0;

	GUI_SetFont(&GUI_Font32_ASCII);
	GUI_SetColor(GUI_BLACK);                                      // 设置蓝色
	GUI_DispStringHCenterAt(cstmonth[month - 1], 120, 5);                      // 显示月份
	GUI_GotoXY(170, 5);
	GUI_DispDecSpace(year, 5); //显示年份 最大可显示9999
	tmpWek = wekday - (day % 7) + 1;                       // 获取本月第一天是星期几?
	if (tmpWek <= 0)
		tmpWek = 7 + wekday - (day % 7) + 1;

	for (i = 0; i < tmpWek; i++)        // 存储上月的
	{
		if (month == 1)
		{
			if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
				pDay[i].Date = monthDayLY[12 - 1] - tmpWek + i + 1;
			else pDay[i].Date = monthDay[12 - 1] - tmpWek + i + 1;
		}
		else
		{
			if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
				pDay[i].Date = monthDayLY[month - 2] - tmpWek + i + 1;
			else pDay[i].Date = monthDay[month - 2] - tmpWek + i + 1;
		}
		pDay[i].Color = GUI_GRAY;
	}

	if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
	{
		for (i = 0; i < monthDayLY[month - 1]; i++)
		{
			pDay[i + tmpWek].Date = i + 1;                               // 存储本月的
			pDay[i + tmpWek].Color = (day == i + 1) ? GUI_GREEN : GUI_BLACK;
		}
	}
	else
	{
		for (i = 0; i < monthDay[month - 1]; i++)
		{
			pDay[i + tmpWek].Date = i + 1;                               // 存储本月的
			pDay[i + tmpWek].Color = (day == i + 1) ? GUI_GREEN : GUI_BLACK;
		}
	}

	if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
	{
		for (i = 0; i < 42 - tmpWek - monthDayLY[month - 1]; i++)
		{
			if (month == 0x12)
			{
				pDay[i + tmpWek + monthDayLY[1 - 1]].Date = i + 1;
			}
			else
			{
				pDay[i + tmpWek + monthDayLY[month - 1]].Date = i + 1;    // 存储下月的
			}
			pDay[i + tmpWek + monthDayLY[month - 1]].Color = GUI_GRAY;
		}
	}
	else
	{
		for (i = 0; i < 42 - tmpWek - monthDay[month - 1]; i++)
		{
			if (month == 0x12)
			{
				pDay[i + tmpWek + monthDay[1 - 1]].Date = i + 1;
			}
			else
			{
				pDay[i + tmpWek + monthDay[month - 1]].Date = i + 1;    // 存储下月的
			}
			pDay[i + tmpWek + monthDay[month - 1]].Color = GUI_GRAY;
		}
	}

	for (i = 0; i < 42; i++)
	{
		GUI_SetFont(&GUI_Font24_ASCII);
		GUI_SetColor(pDay[i].Color);
		GUI_SetTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER);
		GUI_DispDecAt(pDay[i].Date, pDay[i].X, pDay[i].Y, ((pDay[i].Date > 10) ? 2 : 1));
	}
}
Exemple #25
0
/*******************************************************************
*
*       _DrawScale

  Drawing a scale using GUI-functions
*/
static void _DrawScale(void) {
  int XSize = LCD_GetXSize();
  int YSize = LCD_GetYSize();
  int XMid  = XSize / 2;
  int i;
  int r1   = 110;
  int r2   = 140;
  int rt   = 100;
  int y    = 240;
  int step =  15;
  int r = (r1 + r2) / 2;
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("DrawScale - Sample", 160, 5);
  while (1) {
    int c = 0;
    GUI_SetColor(GUI_WHITE);
    GUI_SetFont(&GUI_Font8x16);
    GUI_SetTextAlign(GUI_TA_LEFT);
    GUI_Delay(SPEED / 2);
    GUI_DispStringAtCEOL("using", 5, 40);
    GUI_DispStringAtCEOL("GUI_AA_DrawArc", 5, 55);
    GUI_Delay(SPEED * 2);
    GUI_SetPenSize(r2 - r1);
    GUI_SetColor(0x0000AA);
    GUI_AA_DrawArc(XMid, y, r, r, 45, 60);
    GUI_Delay(SPEED);
    GUI_SetColor(0x00AA00);
    GUI_AA_DrawArc(XMid, y, r, r, 60, 90);
    GUI_Delay(SPEED);
    GUI_SetPenSize(2);
    GUI_SetColor(GUI_WHITE);
    GUI_AA_DrawArc(XMid, y, r1, r1, 45, 135);
    GUI_Delay(SPEED);
    GUI_AA_DrawArc(XMid, y, r2, r2, 45, 135);
    GUI_Delay(SPEED);
    GUI_DispStringAtCEOL("", 5, 55);
    GUI_Delay(200);
    GUI_DispStringAtCEOL("using", 5, 40);
    GUI_DispStringAtCEOL("GUI_AA_DrawLine & GUI_DispCharAt", 5, 55);
    GUI_Delay(SPEED * 3);
    for (i = 45; i <= 135; i += step) {
      float co = cos(i * 3.1415926 / 180);
      float si = sin(i * 3.1415926 / 180);
      int   x1 = XMid - r1 * co;
      int   y1 = y    - r1 * si;
      int   x2 = XMid - (r2 - 1) * co;
      int   y2 = y    - (r2 - 1) * si;
      int   xt = XMid - rt * co;
      int   yt = y    - rt * si;
      GUI_SetColor(GUI_WHITE);
      GUI_SetPenSize(2);
      GUI_AA_DrawLine(x1, y1, x2, y2);
      GUI_SetColor(GUI_GREEN);
      GUI_SetFont(&GUI_Font8x8);
      GUI_DispCharAt('0' + c++, xt - 4, yt - 4);
      GUI_Delay(SPEED / 2);
    }
    GUI_Delay(SPEED * 3);
    GUI_ClearRect(0, 30, 320, 240);
  }
}
Exemple #26
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);
}
void _ExecCalibration(void) {
  int x,y;
  uint16_t data[6];
  uint16_t get_data[6];
  int ax_Phys[2],ay_Phys[2];
/* calculate log. Positions */
  int ax[2] = { 15, LCD_XSIZE -1-15};
//  const int ay[2] = { 15, LCD_YSIZE-1-15};
  int ay[2] = { LCD_YSIZE-1-15, 15};
  GUI_TOUCH_SetDefaultCalibration();
/* _Calibrate upper left */
  GUI_SetBkColor(GUI_RED);  
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);  GUI_FillCircle(ax[0], ay[0], 10);
  GUI_SetColor(GUI_RED);    GUI_FillCircle(ax[0], ay[0], 5);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Press here", ax[0]+20, ay[0]);
  do {

#if 0
    GUI_PID_STATE State;
    GUI_TOUCH_GetState(&State);
	 if (State.Pressed) {
#endif

#if 1
  x = TPReadX();
  y = TPReadY();
  if ((x>=3700)&&(y>=3400)&&(x<3800)&&(y<3600)) {

#endif
      ax_Phys[0] = GUI_TOUCH_GetxPhys();
      ay_Phys[0] = GUI_TOUCH_GetyPhys();
      break;
    }
    GUI_Delay (3000);
  } while (1);
/* Tell user to release */
  GUI_Clear();
  GUI_DispStringAt("OK", ax[0]+20, ay[0]);
  do {
    GUI_PID_STATE State;
    GUI_TOUCH_GetState(&State);
    if (State.Pressed == 0) {
      break;
    }
    GUI_Delay (100);
  } while (1);
/* _Calibrate lower right */
  GUI_SetBkColor(GUI_RED);  
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);  GUI_FillCircle(ax[1], ay[1], 10);
  GUI_SetColor(GUI_RED);    GUI_FillCircle(ax[1], ay[1], 5);
  GUI_SetColor(GUI_WHITE);
  GUI_SetTextAlign(GUI_TA_RIGHT);
  GUI_DispStringAt("Press here", ax[1]-20, ay[1]);
  do {

#if 1
  x = TPReadX();
  y = TPReadY();
  if ((y>450)&&(y<620)&&(x>350)&&(x<450)) {
#endif

#if 0
	GUI_PID_STATE State;
  	GUI_TOUCH_GetState(&State);
	if (State.Pressed) {
#endif

      ax_Phys[1] = GUI_TOUCH_GetxPhys();
      ay_Phys[1] = GUI_TOUCH_GetyPhys();
      break;
    }
    GUI_Delay (3000);
  } while (1);
  GUI_TOUCH_Calibrate(GUI_COORD_X, ax[0], ax[1], ax_Phys[0], ax_Phys[1]);
  GUI_TOUCH_Calibrate(GUI_COORD_Y, ay[0], ay[1], ay_Phys[0], ay_Phys[1]);
  { /* calculate and display values for configuration file */
    int x0, x1;
    int y0, y1;
    GUI_Clear();
    _Calibrate(GUI_COORD_X, ax[0], ax[1], ax_Phys[0], ax_Phys[1], &x0, &x1);
    _Calibrate(GUI_COORD_Y, ay[0], ay[1], ay_Phys[0], ay_Phys[1], &y0, &y1);
    GUI_DispStringAt("x0: ", 0, 0); GUI_DispDec(x0, 4); GUI_DispNextLine();
    GUI_DispString  ("x1: ");       GUI_DispDec(x1, 4); GUI_DispNextLine();
    GUI_DispString  ("y0: ");       GUI_DispDec(y0, 4); GUI_DispNextLine();
    GUI_DispString  ("y1: ");       GUI_DispDec(y1, 4); GUI_DispNextLine();
    GUI_DispString  ("Please touch display to continue...");
    GUI_Delay(1000);

	data[0]=  CAL_READY;
	data[1]= ax_Phys[0];
	data[2]= ay_Phys[0];
	data[3]= ax_Phys[1];
	data[4]= ay_Phys[1];

	#if 1
	save_calibrate_to_flash(data);
	get_calibrate_data(get_data);

	GUI_DispStringAt("x0: ", 100, 0); GUI_DispDec(get_data[1], 4); GUI_DispNextLine();
    GUI_DispString  ("x1: ");       GUI_DispDec(get_data[2], 4); GUI_DispNextLine();
    GUI_DispString  ("y0: ");       GUI_DispDec(get_data[3], 4); GUI_DispNextLine();
    GUI_DispString  ("y1: ");       GUI_DispDec(get_data[4], 4); GUI_DispNextLine();
	GUI_DispString  ("state: ");       GUI_DispDec(get_data[0], 4); GUI_DispNextLine();
	#endif

    do {
      GUI_PID_STATE State;
      GUI_TOUCH_GetState(&State);
      if (State.Pressed)
      break;
      GUI_Delay (10);
    } while (1);
  }
}



int run_cal(void)
{
  if(get_calibrate_state()== CAL_READY)
  {
  	get_calibration();
  }else{
	#if 1
  	 _ExecCalibration();
	#endif	

	#if 0
	Calibration();
	#endif
  }
}

int get_calibration(void)
{
  uint16_t cal_data[5];
  int ax_Phys[2],ay_Phys[2];
  int ax[2] = { 15, LCD_XSIZE -1-15};
  int ay[2] = { LCD_YSIZE-1-15, 15};

  get_calibrate_data(cal_data);

  ax_Phys[0] = cal_data[1];
  ay_Phys[0] = cal_data[2];
  
  ax_Phys[1] = cal_data[3];
  ay_Phys[1] = cal_data[4];
  
  GUI_TOUCH_Calibrate(GUI_COORD_X, ax[0], ax[1], ax_Phys[0], ax_Phys[1]);
  GUI_TOUCH_Calibrate(GUI_COORD_Y, ay[0], ay[1], ay_Phys[0], ay_Phys[1]);
}


#if 0			

void myAD2XY( int *adx , int *ady ){
 float f_dat;
 int dat1;

 f_dat = (float)(*ady - admy)/(float)(*adx - admx);
 if(f_dat>0){
  if( *adx>admx && admk[2] >=f_dat) dat1 = 1;
  else if( *adx>admx && admk[2] < f_dat ) dat1 =2;//2
  else if( *adx<admx && admk[0] >=f_dat ) dat1 =0;
  else if( *adx<admx && admk[0] < f_dat ) dat1 =3;//0
  else{ dat1 =0; }//*adx =0;*ady =0; }
 }else{
  if( *adx>admx && admk[1] >=f_dat) dat1 = 0;
  else if( *adx>admx && admk[1] < f_dat ) dat1 =1;//1
  else if( *adx<admx && admk[3] >=f_dat ) dat1 =3;
  else if( *adx<admx && admk[3] < f_dat ) dat1 =2;//3
  else{ dat1 =0; }//*adx =0;*ady =0; }
 }
 *adx = (int)(Factors[dat1][0].a*(*adx)+Factors[dat1][0].b*(*ady)+Factors[dat1][0].c); 
 *ady = (int)(Factors[dat1][1].a*(*adx)+Factors[dat1][1].b*(*ady)+Factors[dat1][1].c);
}