Beispiel #1
0
/*********************************************************************
*
*       GUI_EditHex
*/
U32 GUI_EditHex(U32 Value, U32 Min, U32 Max, int Len, int xsize) {
  U32 Ret = Value;
  int Key, x, y, ysize, Id;
  EDIT_Handle hEdit;
  EDIT_Obj* pObj;
  const GUI_FONT GUI_UNI_PTR * pOldFont = GUI_SetFont(EDIT_GetDefaultFont());
  x = GUI_GetDispPosX();
  y = GUI_GetDispPosY();
  if (xsize == 0)
    xsize = GUI_GetCharDistX('X') * Len + 6;
  ysize = GUI_GetFontSizeY();
  Id = 0x1234;
  hEdit = EDIT_Create(x, y, xsize, ysize, Id, Len, 0);
  pObj = EDIT_H2P(hEdit);
  EDIT_SetHexMode(hEdit, Value, Min, Max);
  WM_SetFocus(hEdit);
  do {
    Key = GUI_WaitKey();
  } while ((Key != GUI_KEY_ESCAPE) && (Key != GUI_KEY_ENTER) && (Key != 0));
  GUI_SetFont(pOldFont);
  if (Key == GUI_KEY_ENTER)
    Ret = pObj->CurrentValue;
  EDIT_Delete(hEdit);
  return Ret;
}
Beispiel #2
0
/*********************************************************************
*
*       GUI_EditString
*/
void GUI_EditString(char * pString, int Len, int xsize) {
  int Key, x, y, ysize, Id;
  EDIT_Handle hEdit;
  EDIT_Obj* pObj;
  const GUI_FONT GUI_UNI_PTR * pOldFont;
  WM_LOCK();
  pOldFont = GUI_SetFont(EDIT_GetDefaultFont());
  x = GUI_GetDispPosX();
  y = GUI_GetDispPosY();
  if (xsize == 0) {
    xsize = GUI_GetCharDistX('X') * Len + 6;
  }
  ysize = GUI_GetFontSizeY();
  Id = 0x1234;
  hEdit = EDIT_Create(x, y, xsize, ysize, Id, Len, 0);
  EDIT_SetText(hEdit, pString);
  pObj = EDIT_H2P(hEdit);
  WM_SetFocus(hEdit);
  do {
    Key = GUI_WaitKey();
  } while ((Key != GUI_KEY_ESCAPE) && (Key != GUI_KEY_ENTER) && (Key != 0));
  if (Key == GUI_KEY_ENTER) {
    EDIT_GetText(hEdit, pString, pObj->MaxLen);
  }
  GUI_SetFont(pOldFont);
  EDIT_Delete(hEdit);
  WM_UNLOCK();
}
Beispiel #3
0
/*******************************************************************
*
*       _DemoButton
*/
static void _DemoButton(void) {
  BUTTON_Handle hButton;
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringHCenterAt("Click on button...", 160, 90);
  /* Create the button*/
  hButton = BUTTON_Create(110, 110, 100, 40, GUI_ID_OK, WM_CF_SHOW);
  /* Set the button text */
  BUTTON_SetText(hButton, "Click me...");
  /* Let window manager handle the button */
  while (GUI_WaitKey() != GUI_ID_OK);
  /* Delete the button*/
  BUTTON_Delete(hButton);
  GUI_ClearRect(0, 50, 319, 239);
  GUI_Delay(1000);
}
Beispiel #4
0
//@@@@@@@@@@@@@@@@@@@@@  屏幕上显示的按键  @@@@@@@@@@@@@@@@@@@@@@@@@@
static void Button(void) 
{

 BUTTON_Handle hButton[6];
 int t=0;
 int i=0;
 /* Create the button*/
      //BUTTON_SetBkColor(hButton[0],0,GUI_RED);

 hButton[0] = BUTTON_Create(260, 160, 20, 20, 1, WM_CF_SHOW);
 hButton[1] = BUTTON_Create(240, 180, 20, 20, 2, WM_CF_SHOW);
 hButton[2] = BUTTON_Create(260, 180, 20, 20, 3, WM_CF_SHOW);
 hButton[3] = BUTTON_Create(280, 180, 20, 20, 4, WM_CF_SHOW);
 hButton[4] = BUTTON_Create(260, 220, 20, 20, 5, WM_CF_SHOW);
 //hButton[5] = BUTTON_Create(240, 220, 20, 20, 6, WM_CF_SHOW);

 BUTTON_SetText(hButton[0], "w");
 BUTTON_SetText(hButton[1], "a");
 BUTTON_SetText(hButton[2], "s");
 BUTTON_SetText(hButton[3], "d");
 BUTTON_SetText(hButton[4], "B");
 //BUTTON_SetText(hButton[5], "W");

 t=GUI_WaitKey();
 
 switch( t )
 {
 case 1:
 point.y_point-=20;
 if(point.y_point<20)
 point.y_point+=20;
 break;
 case 2:
 point.x_point-=20;
 if(point.x_point<20)
 point.x_point+=20;
 break;
 case 3:
 point.y_point+=20;
 if(point.y_point>200)
 point.y_point-=20;
 break;
 case 4:
 point.x_point+=20;
 if(point.x_point>200)
 point.x_point-=20;
 break;
 case 5:
 if( map[point.y_map][point.x_map]==0 )
 {
change_color();
map[point.y_map][point.x_map]=point.color;
draw_map();

if( if_won(point.y_map,point.x_map,point.color) )
{
GUI_SetTextMode(GUI_DM_TRANS); //设置为透明
GUI_SetFont(&GUI_Font8x16x1x2);
GUI_DispStringAt("win!",250,90);

for(i=0;i<5;i++)
GUI_Delay(1000);
map_initial();

GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,320,240);
draw_net();
draw_point();
}

 }
 break;
 case 6:
 /*
 if( map[point.y_map][point.x_map]==0 )
map[point.y_map][point.x_map]=1;
 */
 break;
 default:

 break;
 
 }

 
 
 for(t=0;t<6;t++)
BUTTON_Delete(hButton[t]);
 
}