Exemplo n.º 1
0
/********************************************************************
*
*       _Draw
*
* Function description
*   Draws some coloured output to the current device (display or memory device)
*/
static void _Draw(void) {
  int i;
  GUI_SetBkColor(GUI_YELLOW);
  GUI_ClearRect(0, 75, 319, 138);
  GUI_SetColor(GUI_RED);
  GUI_SetFont(&GUI_Font32B_ASCII);
  GUI_DispStringHCenterAt("Printing demo", 160, 75);
  for (i = 0; i < 12; i += 2) {
    GUI_SetColor(GUI_GREEN);
    GUI_DrawRect(5 + i, 80 + i, 50 - i, 101 - i);
    GUI_SetColor(GUI_BLUE);
    GUI_DrawRect(269 + i, 80 + i, 314 - i, 101 - i);
  }
  for (i = 0; i < 32; i += 8) {
    GUI_SetColor(GUI_BLUE);
    GUI_FillRect(0, 107 + i, 319, 110 + i);
    GUI_SetColor(GUI_YELLOW);
    GUI_FillRect(0, 111 + i, 319, 114 + i);
  }
  i = 8;
  _DrawBitmap(&bmTestPicture1, i +   0, 111, 0, 0);
  _DrawBitmap(&bmTestPicture1, i +  35, 111, 1, 0);
  _DrawBitmap(&bmTestPicture1, i +  70, 111, 0, 1);
  _DrawBitmap(&bmTestPicture2, i + 105, 111, 0, 0);
  _DrawBitmap(&bmTestPicture2, i + 140, 111, 1, 0);
  _DrawBitmap(&bmTestPicture4, i + 175, 111, 0, 0);
  _DrawBitmap(&bmTestPicture4, i + 210, 111, 1, 0);
  _DrawBitmap(&bmTestPicture8, i + 245, 111, 0, 0);
  _DrawBitmap(&bmTestPicture8, i + 280, 111, 1, 0);
}
Exemplo n.º 2
0
/*********************************************************************
*
*       _WIDGET_EFFECT_Simple_DrawDownRect
*/
static void _WIDGET_EFFECT_Simple_DrawDownRect(const GUI_RECT* pRect) {
  GUI_CONTEXT Context;
  GUI_SaveContext(&Context);
  LCD_SetColor(GUI_BLACK);
  GUI_DrawRect(pRect->x0, pRect->y0, pRect->x1, pRect->y1);          /* Draw rectangle around it */
  GUI_RestoreContext(&Context);
}
Exemplo n.º 3
0
/*********************************************************************
*
*       _LabelGraph
*/
static void _LabelGraph(void) {
  GUI_RECT Rect;
  int      x;
  int      y;
  int      xSize;
  int      ySize;

  WM_GetClientRect(&Rect);
  xSize = Rect.x1;
  ySize = Rect.y1;
  GUI_SetBkColor(_ColorBackGround);
  GUI_Clear();
  GUI_SetColor(_ColorLabel);
  GUI_SetPenSize(1);
  GUI_ClearRect(0, (ySize - 21) - ySize, (xSize - 1), (ySize - 1));
  GUI_DrawRect(25, 0, xSize, ySize - 20);
  GUI_SetFont(&GUI_Font6x8);
  for (x = 0; x < (xSize - 20); x += 40) {
    int xPos = x + 25;
    GUI_DrawVLine(xPos, (ySize - 20), (ySize - 14));
    GUI_DispDecAt(x / 40, xPos - 2, (ySize - 9), 1);
  }
  for (y = 0; y < ySize - 20; y += 20) {
    int yPos = ySize - 20 - y;
    GUI_DrawHLine(yPos, 20, 25);
    GUI_GotoXY(1, yPos - 4);
    GUI_DispDecSpace(_TempMin + y, 3);
  }
}
Exemplo n.º 4
0
/*********************************************************************
*
*       _cbDialogNumPad
*
* Purpose:
*   Callback function of the numpad.
*/
static void _cbDialogNumPad(WM_MESSAGE * pMsg) {
  GUI_RECT r;
  int i, NCode, Id, Pressed = 0;
  WM_HWIN hDlg, hItem;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    WM_GetClientRect(&r);
    GUI_SetColor(0x000000);
    GUI_DrawRect(r.x0, r.y0, r.x1, r.y1);          /* Draw rectangle around it */
    /* Draw the bright sides */
    GUI_SetColor(0xffffff);
    GUI_DrawHLine(r.y0 + 1, r.x0 + 1, r.x1 - 2);   /* Draw top line */
    GUI_DrawVLine(r.x0 + 1, r.y0 + 1, r.y1 - 2);
    /* Draw the dark sides */
    GUI_SetColor(0x555555);
    GUI_DrawHLine(r.y1-1, r.x0 + 1, r.x1 - 1);
    GUI_DrawVLine(r.x1-1, r.y0 + 1, r.y1 - 2);
    break;
  case WM_INIT_DIALOG:
    for (i = 0; i < GUI_COUNTOF(_aDialogNumPad) - 1; i++) {
      hItem = WM_GetDialogItem(hDlg, GUI_ID_USER + i);
      BUTTON_SetFocussable(hItem, 0);                       /* Set all buttons non focussable */
      switch (i) {
      case 13:
        BUTTON_SetBitmapEx(hItem, 0, &_bmArrowLeft, 7, 7);  /* Set bitmap for arrow left button (unpressed) */
        BUTTON_SetBitmapEx(hItem, 1, &_bmArrowLeft, 7, 7);  /* Set bitmap for arrow left button (pressed) */
        break;
      case 14:
        BUTTON_SetBitmapEx(hItem, 0, &_bmArrowRight, 7, 7); /* Set bitmap for arrow right button (unpressed) */
        BUTTON_SetBitmapEx(hItem, 1, &_bmArrowRight, 7, 7); /* Set bitmap for arrow right button (pressed) */
        break;
      }
    }
    hItem = WM_GetDialogItem(hDlg, GUI_ID_USER + 12);
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);      /* Id of widget */
    NCode = pMsg->Data.v;                 /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_CLICKED:
      Pressed = 1;
    case WM_NOTIFICATION_RELEASED:
      if ((Id >= GUI_ID_USER) && (Id <= (GUI_ID_USER + GUI_COUNTOF(_aDialogNumPad) - 1))) {
        int Key;
        if (Id < GUI_ID_USER + 11) {
          char acBuffer[10];
          BUTTON_GetText(pMsg->hWinSrc, acBuffer, sizeof(acBuffer)); /* Get the text of the button */
          Key = acBuffer[0];
        } else {
          Key = _aKey[Id - GUI_ID_USER - 11];                        /* Get the text from the array */
        }
        GUI_SendKeyMsg(Key, Pressed);                                /* Send a key message to the focussed window */
      }
      break;
    }
  default:
    WM_DefaultProc(pMsg);
  }
}
Exemplo n.º 5
0
/*********************************************************************
*
*       _cbWin
*
* Purpose:
*   Callback routine of window which draws the content of the memory device
*/
static void _cbWin(WM_MESSAGE * pMsg) {
  WM_HWIN hWin;
  int xPos, yPos, xSize, ySize;
  GUI_MEMDEV_Handle hMem;

  hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    //
    // Get window position
    //
    xPos = WM_GetWindowOrgX(hWin);
    yPos = WM_GetWindowOrgY(hWin);
    xSize = WM_GetWindowSizeX(hWin);
    ySize = WM_GetWindowSizeY(hWin);
    //
    // Draw memory device
    //
    WINDOW_GetUserData(hWin, &hMem, sizeof(hMem));
    GUI_MEMDEV_WriteAt(hMem, xPos, yPos);
    //
    // Draw surrounding frame
    //
    GUI_DrawRect(0, 0, xSize - 1, ySize - 1);
    break;
  }
}
/*******************************************************************
*
*       _Label

  Labels the x & y-axis
*/
static void _Label(void) {
  int x, y;
  GUI_SetBkColor(GUI_RED);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("MEMDEV_DrawGraph - Sample", 160, 5);
  GUI_SetPenSize(1);
  GUI_ClearRect(0, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 1));
  GUI_DrawRect(18, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 20));
  GUI_SetFont(&GUI_Font6x8);
  for (x = 0; x < (LCD_XSIZE - 20); x += 40) {
    int xPos = x + 18;
    GUI_DrawVLine(xPos, (LCD_YSIZE - 20), (LCD_YSIZE - 14));
    GUI_DispDecAt(x / 40, xPos - 2, (LCD_YSIZE - 9), 1);
  }
  for (y = 0; y < YSIZE / 2; y += 20) {
    int yPos = (LCD_YSIZE - 20) - YSIZE / 2 + y;
    GUI_DrawHLine(yPos, 13, 18);
    if (y) {
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(-y / 20, 2);
      yPos = (LCD_YSIZE - 20) - YSIZE / 2 - y;
      GUI_DrawHLine(yPos, 13, 18);
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(y / 20, 2);
    } else {
      GUI_DispCharAt('0', 7, yPos - 4);
    }
  }
}
Exemplo n.º 7
0
//@@@@@@@@@@@@@@@@@@@@@  删除指针形状 @@@@@@@@@@@@@@@@@@@@@@@@@@
void delete_point(void)
{
GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_GREEN);

GUI_DrawRect(store_x+2,store_y+2,store_x+18,store_y+18);
}
Exemplo n.º 8
0
 void DispFrame(void)
{
	uint16_t x,y;
	GUI_SetColor(GUI_WHITE);					
	GUI_DrawRect(13, 19, 265, 221);						//这个函数对坐标值有影响 
	for (x = 0; x < 11; x++)							/* 绘制垂直刻度点 */
	{
		for (y = 0; y < 41; y++)
		{
			GUI_DrawPixel(14 + (x * 25), 20 + (y * 5));
		}
	}
	for (y = 0; y < 9; y++)								/* 绘制水平刻度点 */
	{
		for (x = 0; x < 51; x++)
		{
			GUI_DrawPixel(14 + (x * 5), 20 + (y * 25));
		}
	}
	for (y = 0; y < 41; y++)							/* 绘制垂直中心刻度点 */
	{	 
		GUI_DrawPixel(13 + (5 * 25), 20 + (y * 5));
		GUI_DrawPixel(15 + (5 * 25), 20 + (y * 5));
	}	
	for (x = 0; x < 51; x++)							/* 绘制水平中心刻度点 */
	{	 
		GUI_DrawPixel(14 + (x * 5), 19 + (4 * 25));
		GUI_DrawPixel(14 + (x * 5), 21 + (4 * 25));
	}
}
Exemplo n.º 9
0
void Rectangle::paint(int arg) {
	if(GUI_COLOR_NONE!=arg)
	{
		GUI_SetColor(arg);
		GUI_DrawRect(x0, y0, x1, y1);
	}
}
Exemplo n.º 10
0
static void _Label(void) {
  int x, y;
  GUI_SetPenSize(1);
  GUI_ClearRect(0, (LCD_GetYSize() - 21) - _YSize, (LCD_GetXSize() - 1), (LCD_GetYSize() - 1));
  GUI_DrawRect(18, (LCD_GetYSize() - 21) - _YSize, (LCD_GetXSize() - 1), (LCD_GetYSize() - 20));
  GUI_SetFont(&GUI_Font6x8);
  for (x = 0; x < (LCD_GetXSize() - 20); x += 40) {
    int xPos = x + 18;
    GUI_DrawVLine(xPos, (LCD_GetYSize() - 20), (LCD_GetYSize() - 14));
    GUI_DispDecAt(x / 40, xPos - 2, (LCD_GetYSize() - 9), 1);
  }
  for (y = 0; y < _YSize / 2; y += 20) {
    int yPos = (LCD_GetYSize() - 20) - _YSize / 2 + y;
    GUI_DrawHLine(yPos, 13, 18);
    if (y) {
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(-y / 20, 2);
      yPos = (LCD_GetYSize() - 20) - _YSize / 2 - y;
      GUI_DrawHLine(yPos, 13, 18);
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(y / 20, 2);
    } else {
      GUI_DispCharAt('0', 7, yPos - 4);
    }
  }
}
/*********************************************************************
*
*       _AnimDrawRect
*/
static void _AnimDrawRect(GUI_ANIM_INFO * pInfo, void * pVoid) {
  ANIM_DATA * pData;
  static int xPosOld;

  _PrepareDrawing(pInfo, pVoid, &pData, xPosOld, 2);
  GUI_DrawRect(pData->xPos - pData->ObjectSize, pData->yPos - pData->ObjectSize, pData->xPos + pData->ObjectSize, pData->yPos + pData->ObjectSize);
  xPosOld = pData->xPos;
}
Exemplo n.º 12
0
/**
  * @brief  Display the application header on the USER_LCD screen 
  * @param  header: pointer to the string to be displayed
  * @retval None
  */
void USER_LCD_LOG_SetTestArea (uint16_t x0,uint16_t y0,uint16_t xSize,uint16_t ySize)
{
  GUI_SetFont(&USER_LCD_LOG_TEXT_FONT);
  GUI_SetColor(USER_LCD_LOG_BACKGROUND_COLOR);
  GUI_FillRect(x0, y0-GUI_GetFontSizeY(), x0+xSize, y0+ySize);
  GUI_SetColor(USER_LCD_LOG_BACKGROUND_COLOR_EX);
  GUI_DrawRect(x0, y0-GUI_GetFontSizeY(), x0+xSize, y0+ySize);
}
Exemplo n.º 13
0
void CheckBoxMenu::drawOuter()
{
	GUI_SetColor(CHECKBOX_OUTER_COLOR);
	GUI_DrawRect(x0+CheckBox_A_margin,
			y0+CheckBox_A_margin,
			x0+CheckBox_A_margin+getAL(),
			y0+CheckBox_A_margin+getAL());
}
Exemplo n.º 14
0
//@@@@@@@@@@@@@@@@@@@@@  画出当前光标所在的位置 @@@@@@@@@@@@@@@@@@ 
void draw_point(void)
{
GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_BLUE);

GUI_DrawRect(point.x_point+2,point.y_point+2,point.x_point+18,point.y_point+18);

}
Exemplo n.º 15
0
void WIDGET_EFFECT_3D_DrawUpRect(const GUI_RECT* pRect) {
  GUI_RECT r;
  GUI_CONTEXT Context;
  GUI_SaveContext(&Context);
  r = *pRect;
  GUI_SetColor(0x000000);
  GUI_DrawRect(r.x0, r.y0, r.x1, r.y1);          /* Draw rectangle around it */
 /* Draw the bright sides */
  GUI_SetColor(0xffffff);
  GUI_DrawHLine(r.y0 + 1, r.x0 + 1, r.x1 - 2);    /* Draw top line */
  GUI_DrawVLine(r.x0 + 1, r.y0 + 1, r.y1 - 2);
  /* Draw the dark sides */
  GUI_SetColor(0x555555);
  GUI_DrawHLine(r.y1-1, r.x0 + 1, r.x1 - 1);
  GUI_DrawVLine(r.x1-1, r.y0 + 1, r.y1 - 2);
  GUI_RestoreContext(&Context);
}
Exemplo n.º 16
0
void GUI_DrawObject(struct guiObject *obj)
{
#ifdef DEBUG_DRAW
    switch (obj->Type) {
    case UnknownGUI: printf("Draw Unknown: "); break;
    case CheckBox:   printf("Draw Checkbox:"); break;
    case Dropdown:   printf("Draw Dropdown:"); break;
    case Button:     printf("Draw Button:  "); break;
    case Label:      printf("Draw Label:   "); break;
    case Image:      printf("Draw Image:   "); break;
    case Dialog:     printf("Draw Dialog:  "); break;
    case XYGraph:    printf("Draw XYGraph: "); break;
    case BarGraph:   printf("Draw BarGraph:"); break;
    case TextSelect: printf("Draw TextSel: "); break;
    case Keyboard:   printf("Draw Keyboard:"); break;
    case Scrollbar:  printf("Draw ScrlBar: "); break;
    case Scrollable: printf("Draw Scrlable:"); break;
    case Rect:       printf("Draw Rect:    "); break;
    }
    printf(" ptr: %08x Selected: %s\n", obj, obj == objSELECTED ? "true" : "false");
#endif
    switch (obj->Type) {
    case UnknownGUI: break;
    case CheckBox:   break;
    case Dropdown:   break;
    case Button:     GUI_DrawButton(obj);            break;
    case Label:      GUI_DrawLabel(obj);             break;
    case Image:      GUI_DrawImage(obj);             break;
    case Dialog:     GUI_DrawDialog(obj);            break;
    case XYGraph:    GUI_DrawXYGraph(obj);           break;
    case BarGraph:   GUI_DrawBarGraph(obj);          break;
    case TextSelect: GUI_DrawTextSelect(obj);        break;
    case Keyboard:   GUI_DrawKeyboard(obj);          break;
    case Scrollbar:  GUI_DrawScrollbar(obj);         break;
    case Scrollable: GUI_DrawScrollable(obj);        break;
    case Rect:       GUI_DrawRect(obj);              break;
    }
    if (obj == objSELECTED && obj->Type != Scrollable)
        _gui_hilite_selected(obj);
    OBJ_SET_DIRTY(obj, 0);
}
Exemplo n.º 17
0
/*********************************************************************
*
*       _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);
}
Exemplo n.º 18
0
void TH_GUI (void const *argument) {
	static volatile uint16_t i=0;
	static uint16_t Triggered_Sample=0;	
	osEvent evt;
	GUI_MEMDEV_Handle hMem0;
	GUI_SelectLayer(0);
	hMem0 = GUI_MEMDEV_Create(0,0,480,272);
	
	if(!GUI_CURSOR_GetState())
		GUI_CURSOR_Select(&GUI_CursorCrossM);
	
	GUI_CURSOR_Show();
  while (1) {
																															Anal_CH1_Set(/*Main loop start*/);
																															Anal_CH2_Set(/*Wait start*/);
		evt = osSignalWait(DMA_ConvCpltSig,(uint32_t)2);
		if( evt.status == osEventTimeout)
				Error_Handler();
																															Anal_CH2_Reset(/*Wait finish*/);
		//osSignalSet(tid_Touch,GUI_TouchStateReqSig);
		
																															Anal_CH3_Set(/*Copy start*/);
		for(i=0;i<ADC_BUFFER_LENGTH;i++)	// <- Temporary. Take the full advantage of DMA !
		values_BUF[i]=255-values[i];
																															Anal_CH3_Reset(/*Copy finish*/);
		
		HAL_ADC_Start_DMA(&g_AdcHandle, values, ADC_BUFFER_LENGTH);
		osSignalClear(tid_TH_GUI, DMA_ConvCpltSig);
																															Anal_CH4_Set(/*Wait start*/);		
		osSignalWait(GUI_TouchGetSig,(uint32_t)0);
		GUI_CURSOR_SetPosition(g_Touched.pState->x,g_Touched.pState->y);
																															Anal_CH4_Reset(/*Wait finish*/);
		
		Trigger_Point = g_Touched.MSG;
		Triggered_Sample = Trigger(Trigger_Point, values_BUF, ADC_BUFFER_LENGTH, 1348000UL);
		//if(Triggered_Sample >=20)Triggered_Sample -=20; // Offset to see the edge in the center <- bullshit ?
		
		GUI_MEMDEV_Select(hMem0);
		GUI_MEMDEV_Clear(hMem0);
		
		GUI_SetColor(GUI_DARKGRAY);
		GUI_FillRect(0,0,480,272);
		
		GUI_SetColor(GUI_BLACK);
		GUI_DrawRect(34,5,474,266);		
		
		GUI_SetColor(GUI_WHITE);
		GUI_FillRect(35,6,475,266);
		
		Draw_GraphGrid(440,260,40,40);
		
		GUI_SetColor(GUI_BLUE);
		/*Draw garph start*/HAL_GPIO_TogglePin(GPIOI,GPIO_PIN_1);
		GUI_DrawGraph((short*)&values_BUF[Triggered_Sample],440,35,6); // Useful: GUI_COUNTOF(values)
		/*Draw garph finish*/HAL_GPIO_TogglePin(GPIOI,GPIO_PIN_1);
		
		GUI_SetColor(GUI_ORANGE);
		GUI_DrawHLine(Trigger_Point,0,480);
		GUI_FillCircle(15,Trigger_Point,10);
		
		GUI_SetColor(GUI_YELLOW);
		GUI_DrawCircle(15,Trigger_Point,10);
		
		GUI_MEMDEV_CopyToLCD(hMem0);
																															Anal_CH1_Reset(/*Main loop finish*/);
    osThreadYield ();                                           // suspend thread
  }
}
Exemplo n.º 19
0
GUI_ColorDialog::GUI_ColorDialog(GUI_WinBase *pw,void (*client_display_cmd)(GUI_ColorDialog *)):
GUI_Dialog( pw, "", 0, 0, 578, 256 ),
selected_change(NULL),
activeColor(-1)
{
    num_pantone = num_pantone;
    
    static int scrollWidth = cellWidth * cellPerRow;
    static int scrollHeight = cellHeight * numRow;
    
    scrollBox = new GUI_WinBase( this->clientWin, "Scroll", 0, 0, scrollWidth, scrollHeight, cDarkGrey,
        [](GUI_WinBase *w) {
            for( int i=0; i<num_pantone; i++ ) {
                int nxx = i % cellPerRow;
                int nyy = i / cellPerRow;
                
                if( nyy + cellHeight < 0 )
                    continue;
                if( nyy > w->tw_area.h )
                    break;
                GUI_FillRect(1+nxx*cellWidth, 1+nyy*cellHeight, cellWidth-2, cellHeight-2, pantone_color[i] );
                GUI_ColorDialog *cd = (GUI_ColorDialog *)w->parent->parent;
                if( i == cd->activeColor ) {
                    GUI_DrawRect( 1+nxx*cellWidth, 1+nyy*cellHeight, cellWidth-2, cellHeight-2, cWhite );
                    GUI_DrawRect( nxx*cellWidth, nyy*cellHeight, cellWidth, cellHeight, cWhite );
                }
            }
        }
    );
    scrollBox->handle_event_cmd = [](GUI_WinBase *w, SDL_Event* ev ) -> bool {
        
        static int lastMouseX;
        static int lastMouseY;
        static bool bMousePress = false;
        static long mouseClickTime;
        static bool dragging = false;
        
        switch (ev->type) {
            case SDL_MOUSEBUTTONDOWN: {
                SDL_MouseButtonEvent e = ev->button;
                int x = e.x*GUI_mouseScale/GUI_scale;
                int y = e.y*GUI_mouseScale/GUI_scale;
                lastMouseX = x;
                lastMouseY = y;
                //GUI_Log( "Last: %i, %i\n", lastMouseX, lastMouseY );
                bMousePress = true;
                mouseClickTime = SDL_GetTicks();
                GUI_mouseCapturedWindow = w;
                return true;
            }
            case SDL_MOUSEMOTION: {
                SDL_MouseButtonEvent e = ev->button;
                int x = e.x*GUI_mouseScale/GUI_scale;
                int y = e.y*GUI_mouseScale/GUI_scale;
                //GUI_Log( "Last2: %i, %i\n", lastMouseX, lastMouseY );
                if( bMousePress ) {
                    if( abs(x-lastMouseX) > 5 || abs(y-lastMouseY) > 5 ) {
                        bMousePress = false;
                        dragging = true;
                    }
                }
                if( dragging ) {
                    int diffY = y - lastMouseY;
                    w->move( 0, diffY );
                    if( w->tw_area.y-w->parent->tw_area.y > 0 )
                    {
                        w->move(0, w->parent->tw_area.y-w->tw_area.y );
                    }
                    if( w->tw_area.y+w->tw_area.h < w->parent->tw_area.y+w->parent->tw_area.h ) {
                        w->move(0, (w->parent->tw_area.y+w->parent->tw_area.h)-(w->tw_area.y+w->tw_area.h) );
                    }
                    lastMouseX = x;
                    lastMouseY = y;
                }
                return true;
            }
            case SDL_MOUSEBUTTONUP: {
                if( dragging ) {
                    dragging = false;
                }
                GUI_mouseCapturedWindow = NULL;
                if( !bMousePress )
                    break;
                SDL_MouseButtonEvent e = ev->button;
                int x = e.x*GUI_mouseScale/GUI_scale;
                int y = e.y*GUI_mouseScale/GUI_scale;
                //GUI_Log( "Last2: %i, %i\n", lastMouseX, lastMouseY );
                if( abs(x-lastMouseX) > 5 || abs(y-lastMouseY) > 5 )
                    break;
                
                y -= (w->tw_area.y);
                x -= (w->tw_area.x);
                
                int color_index = (y/cellHeight) * cellPerRow + (x/cellWidth);
                //GUI_Log( "Color: %i\n", color_index );
                int pcode = pantone_code[color_index];
                SDL_Color pcolor = pantone_color[color_index];
                GUI_ColorDialog *cd = (GUI_ColorDialog *)w->parent->parent;
                cd->setActiveColor( pcolor, false );
                if( cd->selected_change ) {
                    cd->selected_change( cd, pcode, pcolor );
                }

                bMousePress = false;
                return true;
            }
        }
        return false;
    };
}
Exemplo n.º 20
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;
	WM_MESSAGE             Msg;
	WM_HWIN                hIteminfo;
	int 									  i;
	uint8_t     					sel;
	uint8_t     					items;
//	int  										wheelval=0;
  // USER START (Optionally insert additional variables)
  // USER END
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
	hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
	//WM_SetFocus(hItem);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
    TEXT_SetText(hItem, "测试文件选择");  
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"打开测试文件……");
		WM_HideWindow(hIteminfo);
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hItem,GUI_RED);
		TEXT_SetText(hItem, "系统被锁定,请解锁!");
		WM_HideWindow(hItem);
	  //
    // Initialization of 'Dropdown'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12);
		//if(k_StorageGetStatus(USB_DISK_UNIT) != 0)
    DROPDOWN_AddString(hItem, "U盘");
		//if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
    DROPDOWN_AddString(hItem, "SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
		//
    // Initialization of 'Listview'
    //
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestFolder_Init();
		
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		for(i=0;i<TestFolder.number_TotalFile;i++)
		{
			LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
		}
		LISTBOX_SetFont(hItem,GUI_FONT_20_1);
		LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile);

		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_SetSel(hItem,0);
		}
		break;
	case MY_MESSAGE_DOWN:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_IncSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,0);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}	

		break;
		case MY_MESSAGE_UP:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_DecSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel>0)
			{
				DROPDOWN_DecSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,1);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}

		break;
	case MY_MESSAGE_CANCEL://取消
		TestFile.command=2;//test cancel
		TestFile.item_total=0;
		GUI_EndDialog(pMsg->hWin,0);
		break;
	case MY_MESSAGE_OK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(LISTBOX_GetNumItems(hItem) ==0 ) break;
			TestFolder.number_CurrentFile=LISTBOX_GetSel(hItem);
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		TestFile.command = 0;
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		TEXT_SetText(hIteminfo, (char *)"读取测试文件!");
		WM_ShowWindow(hIteminfo);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		WM_HideWindow(hItem);
		GUI_Exec();
		WT_TestItem_Init((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);
	  if(TestFile.file_status == 1)//文件读取OK
		{
			Msg.MsgId = MY_MESSAGE_BUTTONOK;
			WM_SendMessage(pMsg->hWinSrc,&Msg);
			GUI_EndDialog(pMsg->hWin,0);
		}
		else
		{
			TEXT_SetText(hIteminfo, (char *)"读取测试文件错误!");
			WM_ShowWindow(hIteminfo);
		}


//		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
//		if(WM_HasFocus(hItem))//取消
//		{
//			TestFolder.number_CurrentFile=0;
//			TestFile.command = 0;
//			WT_TestItem_Init(TestFolder.FilesName[0]);
//			Msg.MsgId = MY_MESSAGE_BUTTONCANCEL;
//			WM_SendMessage(pMsg->hWinSrc,&Msg);
//			GUI_EndDialog(pMsg->hWin,0);
//		}
		//GUI_EndDialog(pMsg->hWin,0);
		//Number_Windos = 0;
		break;
	case MY_MESSAGE_LOCK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		WM_HideWindow(hItem);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		TEXT_SetText(hItem, "系统被锁定,请解锁!");
		WM_ShowWindow(hItem);
		GUI_Exec();
		break;
	case MY_MESSAGE_UNLOCK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		WM_HideWindow(hItem);
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,480,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(8);
		GUI_DrawRect(0,0,478,220);
//		GUI_DrawRoundedFrame(0, 0, 480, 222, 0, 4);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemplo n.º 21
0
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
    
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
         
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUAL);
    IMAGE_SetBitmap(hItem, &bmframe0);
    
    hItem = BUTTON_CreateEx(420, 0, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit);

    hItem = BUTTON_CreateEx(335, 185, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_RECORD_PAUSE);
    WM_SetCallback(hItem, _cbButton_pause);     
    
    hItem = BUTTON_CreateEx(200, 185, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_RECORD_STOP);
    WM_SetCallback(hItem, _cbButton_stop);    
    
    hItem = BUTTON_CreateEx(270, 185, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_RECORD_REC_CANCEL_PLAY);
    WM_SetCallback(hItem, _cbButton_record); 
    
    if((module_prop[k_ModuleGetIndex(&audio_player_board)].in_use) ||
      (k_StorageGetStatus(USB_DISK_UNIT) == 0))
    { 
      
      if(module_prop[k_ModuleGetIndex(&audio_player_board)].in_use)
      {
        
        hItem = WM_GetDialogItem(pMsg->hWin, ID_FILENAMECAPTION);
        TEXT_SetText(hItem, ">>>");   
        hItem = WM_GetDialogItem(pMsg->hWin, ID_FILENAME);
        TEXT_SetText(hItem, "Audio IF busy");
      }
      
      if (k_StorageGetStatus(USB_DISK_UNIT) == 0)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_FILENAMECAPTION);
        TEXT_SetText(hItem, ">>>");   
        hItem = WM_GetDialogItem(pMsg->hWin, ID_FILENAME);
        TEXT_SetText(hItem, "USB NOT ready");
      }

      RecorderMode = RECORDER_MODE_REC_DISABLED;
        
      hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_STOP);
      WM_DisableWindow(hItem);
      
      hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_REC_CANCEL_PLAY);
      WM_DisableWindow(hItem);    
      
      hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_PAUSE);
      WM_DisableWindow(hItem);         
        
    }
    else
    {
      RecorderMode = RECORDER_MODE_REC_IDLE;
    }
      WM_CreateWindowAsChild(0,
                             100,
                             10,
                             10,
                             pMsg->hWin, 
                             WM_CF_SHOW | WM_CF_HASTRANS,
                             _cbAudioProcess, 
                             0);
        
    
    
    WM_CreateWindowAsChild(479, 252, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); 

    break;     
    
  case WM_PAINT:
    GUI_DrawBitmap(&bmrecorder, 7, 40);
    
    GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);    
    GUI_SetPenSize( 5 );
    GUI_DrawRect(220, 233, 304, 257);

    GUI_AA_FillEllipse(285, 222, 114, 70);
    GUI_SetColor(GUI_WHITE);
    GUI_AA_FillEllipse(285, 224, 114, 70);    

    break;     

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    
    
    switch(Id) {
    case ID_BUTTON_EXIT: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if(module_prop[k_ModuleGetIndex(&audio_player_board)].in_use == 0)
        {          
          AUDIO_RECORDER_DeInit();
        }        
        GUI_EndDialog(pMsg->hWin, 0);
        
        break;
      }
      break;
      
    case ID_RECORD_PAUSE: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        
          if((AUDIO_RECORDER_GetState() == AUDIO_RECORDER_PLAY_PAUSE)||
             (AUDIO_RECORDER_GetState() == AUDIO_RECORDER_RECORD_PAUSE))
          {
            AUDIO_RECORDER_PauseResume();
            
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUAL);
            IMAGE_SetGIF(hItem, equal, sizeof(equal));
            WM_InvalidateWindow(hItem);
            WM_Update(hItem);    
          }
          else if((AUDIO_RECORDER_GetState() == AUDIO_RECORDER_PLAYING)||
             (AUDIO_RECORDER_GetState() == AUDIO_RECORDER_RECORDING))
          {
            AUDIO_RECORDER_PauseResume();
            
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUAL);
            IMAGE_SetBitmap(hItem, &bmframe0);
            WM_InvalidateWindow(hItem);
            WM_Update(hItem);    
          }

        break;
      }
      break;

    case ID_RECORD_STOP: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        if( RecorderMode == RECORDER_MODE_RECORDING)
        {
          AUDIO_RECORDER_StopRec();
          RecorderMode = RECORDER_MODE_PLAY_IDLE;
        }
        
        else if( RecorderMode == RECORDER_MODE_PLAYING)
        {
          AUDIO_RECORDER_StopPlayer();
          RecorderMode = RECORDER_MODE_PLAY_IDLE;
        }
        
        else if( RecorderMode == RECORDER_MODE_PLAY_IDLE)
        {
          RecorderMode = RECORDER_MODE_REC_IDLE;
        }
        
        hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_REC_CANCEL_PLAY);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);     

        hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_STOP);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);     
        
        hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_PAUSE);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);    
        break;
      }
      break;

    case ID_RECORD_REC_CANCEL_PLAY: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        if( RecorderMode == RECORDER_MODE_REC_IDLE) /* Start Recored */
        {
          _BuildFileName();
          
          hItem = WM_GetDialogItem(hMainWin, ID_FILENAMECAPTION);
          TEXT_SetText(hItem, "File : ");   
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);             
          hItem = WM_GetDialogItem(hMainWin, ID_FILENAME);
          TEXT_SetText(hItem, FileName);
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);   
          
          AUDIO_RECORDER_SelectFile(FileName, FA_CREATE_ALWAYS | FA_WRITE);
          AUDIO_RECORDER_StartRec(DEFAULT_AUDIO_IN_FREQ);
          RecorderMode = RECORDER_MODE_RECORDING;
          
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUAL);
          IMAGE_SetGIF(hItem, equal, sizeof(equal));
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);              
        }
        
        else if( RecorderMode == RECORDER_MODE_RECORDING) /* Cancel */
        {
          AUDIO_RECORDER_StopRec();
          RecorderMode = RECORDER_MODE_REC_IDLE; 
          AUDIO_RECORDER_RemoveAudioFile(FileName);
         }
        
        else if( RecorderMode == RECORDER_MODE_PLAY_IDLE) /* Start Play */
        {
          RecorderMode = RECORDER_MODE_PLAYING;
          AUDIO_RECORDER_SelectFile(FileName, FA_OPEN_EXISTING | FA_READ);          
          AUDIO_RECORDER_Play(DEFAULT_AUDIO_IN_FREQ);
          
                   
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUAL);
          IMAGE_SetGIF(hItem, equal, sizeof(equal));
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);            
        }
        
        hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_REC_CANCEL_PLAY);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);     

        hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_STOP);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);     
        
        hItem = WM_GetDialogItem(pMsg->hWin, ID_RECORD_PAUSE);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);          
        
        break;
      }
      break;
      
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }   
}
Exemplo n.º 22
0
 /**********************************************************
  *                 _Paint
  *
  */
static void _Paint(SLIDER_Obj* pObj, WM_HWIN hObj)
{
   GUI_RECT r, rFocus, rSlider, rSlot;
   GUI_COLOR  SlotColor, SliderColor;
   int x0, xSize,  Range, NumTicks,hasFocus;
   WIDGET__GetClientRect(&pObj->Widget, &rFocus);
   GUI__ReduceRect(&r, &rFocus, 1);
   NumTicks  = pObj->NumTicks;
   xSize  = r.x1 - r.x0 + 1 - pObj->Width;
   x0     = r.x0 + pObj->Width / 2;
   Range  = pObj->Max - pObj->Min;
   
   if(Range == 0)
   {
      Range  = 1;
   }
   
   
   if(pObj->Widget.State & WIDGET_STATE_FOCUS)
   {
      LCD_SetColor(pObj->aBkColor[1]);
      SlotColor  = pObj->aColor[1];
      SliderColor  = pObj->aColor[3];
      
      hasFocus  = 1;
   }
   else
   {
      LCD_SetColor(pObj->aBkColor[0]);
      SlotColor  = pObj->aColor[0];
      SliderColor  = pObj->aColor[2];
      hasFocus  = 0;
   }
   
   GUI_Clear();
   GUI_FillRectEx(&rFocus);
   
   rSlider     = r;
   rSlider.y0  = 5;
   rSlider.x0  = x0 + (U32)xSize * (U32)(pObj->v - pObj->Min) / Range - pObj->Width / 2;
   rSlider.x1  = rSlider.x0 + pObj->Width;    
   
   LCD_SetColor(SlotColor);
   rSlot.x0  = x0;
   rSlot.x1  = x0 + xSize;
   rSlot.y0  = (rSlider.y0 + rSlider.y1) / 2 - 1;
   rSlot.y1  = rSlot.y0 + 3; 
   GUI_FillRectEx(&rSlot);
   
   if(hasFocus)
   {
      LCD_SetColor(GUI_WHITE);
      GUI_DrawRect(rSlot.x0-1, rSlot.y0-1, rSlot.x1+1,rSlot.y1+1);   
   }
    
   LCD_SetColor(SliderColor);   
   GUI_FillCircle(rSlider.x0+pObj->Width/2,(rSlider.y0+rSlider.y1)/2 , pObj->Width/2);  
   
   
   if(NumTicks > 0)
   {
      LCD_SetColor(GUI_BLACK);
      GUI_SetFont(GUI_FONT_16B_1);
      GUI_SetTextMode(GUI_TM_TRANS);
      GUI_DispDecAt(pObj->v, rSlider.x0+pObj->Width/2-3,(rSlider.y0+rSlider.y1)/2-8, 1);
   }
}
Exemplo n.º 23
0
/*********************************************************************
*
*       GUI_DrawRectEx
*/
void GUI_DrawRectEx(const GUI_RECT* pRect) {
  GUI_DrawRect(pRect->x0, pRect->y0, pRect->x1, pRect->y1);
}
Exemplo n.º 24
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;

	int cursorpos=0;
  int index=0;
	uint8_t res=0;
	uint8_t sel=0;
	char str[60];
	uint8_t filename[110];
  uint8_t NumChars=0;
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetTextAlign(hItem, TEXT_CF_HCENTER | TEXT_CF_VCENTER);
    TEXT_SetText(hItem, (char *)"保存自学习文件");  
	
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetText(hItem, (char *)"文件名称:"); 
		
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetText(hItem, (char *)"文件类型:WTR"); 
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetText(hItem, (char *)"保存路径:"); 
	
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_16);
    DROPDOWN_AddString(hItem, (char *)"U盘");
    DROPDOWN_AddString(hItem, (char *)"SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
	
		hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING);
    TEXT_SetFont(hItemwarn,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hItemwarn,GUI_RED);
		TEXT_SetText(hItemwarn, (char *)"警告:文件名不能为空!");
		WM_HideWindow(hItemwarn);
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"文件保存成功!");
		WM_HideWindow(hIteminfo);
		
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		//EDIT_SetDecMode(hItem, 24, 1,256, 0, 0);
		EDIT_SetFont(hItem,GUI_FONT_32_1);
		EDIT_SetMaxLen(hItem, 50);
		EDIT_EnableBlink(hItem, 600, 1);
		EDIT_SetInsertMode(hItem,1);
		//strcpy ((char*)str,(char *)path_studyfile);
		//strcat ((char*)str,"/");
		//strcat ((char*)str,"A.wtr");
    EDIT_SetText(hItem,"A");
		cursorindex=EDIT_GetCursorCharPos(hItem);
		WM_SetFocus(hItem);
    
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
	case WM_KEY:
		//GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
	
		break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		break;
	case MY_MESSAGE_OK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		if(EDIT_GetNumChars(hItem)==0)
		{
			hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING);
			WM_ShowWindow(hItemwarn);
			break;
		}
		else 
		{
			hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING);
			WM_HideWindow(hItemwarn);		
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		EDIT_GetText(hItem, str, 51);
		if(store_dev == 0)//usb
		{
			if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile);
			else														strcpy ((char*)filename,(char *)path_Default);
		}
		if(store_dev == 1)//sd
		{
			if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile_sd);
			else														strcpy ((char*)filename,(char *)path_Default_sd);
		}
		strcat ((char*)filename,"/");
		strcat ((char*)filename,str);
		strcat ((char*)filename,".wtr");
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
		TEXT_SetText(hIteminfo, "正在保存自学习文件!");
		WM_ShowWindow(hIteminfo);
		GUI_Exec();
		res=WT_StudyFiles_Write(filename);//0-ok, 1-hardware error, 2-file operate error, 
		if(res==0)
		{
			hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
			TEXT_SetText(hIteminfo, (char *)"文件保存成功!");
			WM_ShowWindow(hIteminfo);
		}
		else
		{
			hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
			TEXT_SetText(hIteminfo, "警告:保存失败,未检测到存储设备!");
			WM_ShowWindow(hIteminfo);
			break;
		}

		GUI_EndDialog(pMsg->hWin,0);

		break;
	case MY_MESSAGE_DOWN://向右移动光标
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))//选择存储路径
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=2 
			{
				DROPDOWN_SetSel(hItem,0);		
			}						
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);	
		cursorpos=EDIT_GetCursorCharPos(hItem);
		NumChars = EDIT_GetNumChars(hItem);
		if(cursorpos <= (NumChars-1) )
		{
			EDIT_SetCursorAtChar(hItem,cursorpos+1);
			EDIT_SetSel(hItem,cursorpos+1,cursorpos+1);
			cursorindex=EDIT_GetCursorCharPos(hItem);
		}
		//KeyLed_State.wheel=0;
		break;
	case MY_MESSAGE_UP://向左移动光标
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		cursorpos=EDIT_GetCursorCharPos(hItem);
		EDIT_SetCursorAtChar(hItem,cursorpos-1);
		EDIT_SetSel(hItem,cursorpos-1,cursorpos-1);
		cursorindex=EDIT_GetCursorCharPos(hItem);
		break;
	case	MY_MESSAGE_WHEEL://处理滚轮事件
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		EDIT_SetCursorAtChar(hItem,cursorindex);
		index=KeyLed_State.wheel;

		if(KeyLed_State.wheel>=65 && KeyLed_State.wheel <130) index=KeyLed_State.wheel-65;
		if(KeyLed_State.wheel>=130 && KeyLed_State.wheel <195) index=KeyLed_State.wheel-130;
		if(KeyLed_State.wheel>=195) index=64;
		if(KeyLed_State.wheel<0 && KeyLed_State.wheel >= -65) index=KeyLed_State.wheel+65;
		if(KeyLed_State.wheel<-65 && KeyLed_State.wheel >= -130) index=KeyLed_State.wheel+130;
		if(KeyLed_State.wheel<-130) index=0;
		if(cursorindex==EDIT_GetCursorCharPos(hItem))
		{
			EDIT_AddKey(hItem,GUI_KEY_DELETE);
			EDIT_AddKey(hItem,input_char[index]);
			cursorpos=EDIT_GetCursorCharPos(hItem);
			EDIT_SetSel(hItem,cursorpos-1,cursorpos-1);
		}

		break;
	case MY_MESSAGE_BUTTONDELETE://删除字符
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		if(WM_HasFocus(hItem))
		{
			EDIT_AddKey(hItem,GUI_KEY_BACKSPACE);
			cursorindex=EDIT_GetCursorCharPos(hItem);
		}
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,480,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(6);
		GUI_DrawRect(0,0,480-2,222-2);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemplo n.º 25
0
void DrawAlarmShip(void) {
	BULY_BERTH* thisbully;
  int i;	
	int L1 = t90_set.dst.dst1,L2 = t90_set.dst.dst2,L3 = t90_set.dst.dst3-t90_set.dst.dst1,Space = t90_set.alarm.invd_dst*37/20;	pColor = &homeColors[t90_set.sys.nightmode];
	thisbully = pBulyHeader;
  screen_hcenter=SCREEN_HCENTER;
	screen_vcenter=(SCREEN_HEIGHT-45)/2+45; //-(L1+L2)/Diff
//	DrawBullyShip(2000,1000,3.1416/2,GUI_YELLOW);
     /*************************************************************/
     GUI_DrawRect(screen_hcenter-100,screen_vcenter-50,screen_hcenter+100,screen_vcenter+50) ;
//     GUI_DrawRect(screen_hcenter-150,screen_vcenter-75,screen_hcenter+150,screen_vcenter+75) ;
//     GUI_DrawRect(screen_hcenter-200,screen_vcenter-100,screen_hcenter+200,screen_vcenter+100) ;
//     GUI_DrawRect(screen_hcenter-250,screen_vcenter-125,screen_hcenter+250,screen_vcenter+125);
//     GUI_DrawRect(screen_hcenter-300,screen_vcenter-150,screen_hcenter+300,screen_vcenter+150) ;
     /*************************************************************/
     max_x = 0;
     max_y = 0;
     min_x = 0;
     min_y = 0;
     for(i = 0;i < N_boat; i++)
     {
				if(SimpBerthes[i].pBerth->isInvader) 
				Draw_things(SimpBerthes[i].pBerth->x_to_cross,SimpBerthes[i].pBerth->y_to_cross);
		 }
//	 if(monitorState == ON)
//	 {
     while(thisbully)
     {
          thisbully->pBoatLink->x_to_cross=(int)(cos(mothership.COG*3.14/1800)*(thisbully->pBoatLink->Boat.longitude - mothership.longitude)
																				 -sin(mothership.COG*3.14/1800)*(thisbully->pBoatLink->Boat.latitude  - mothership.latitude));
          thisbully->pBoatLink->y_to_cross=(int)(sin(mothership.COG*3.14/1800)*(thisbully->pBoatLink->Boat.longitude - mothership.longitude)
																				 +cos(mothership.COG*3.14/1800)*(thisbully->pBoatLink->Boat.latitude  - mothership.latitude) + t90_set.dst.dst1*20/37);
          if((thisbully->pBoatLink->Boat.category & 0xf0) == 0)
          {
               Draw_things(thisbully->pBoatLink->x_to_cross,thisbully->pBoatLink->y_to_cross);
						   while((max_x-half_x)*Diff > 390)
							 {
										Diff = Diff*1.1;
							 }
							 while((max_y-half_y)*Diff > 205)
							 {
										Diff = Diff*1.1;
							 }
							 while((half_x-min_x)*Diff < 30)
							 {
										Diff = Diff*1.1;
							 }
							 while((half_y-min_y)*Diff < 30)
							 {
										Diff = Diff*1.1;
							 }
               DrawBullyShip(thisbully->pBoatLink->x_to_cross*37/20, thisbully->pBoatLink->y_to_cross*37/20, (thisbully->pBoatLink->Boat.COG-mothership.COG)/1800.0*3.1416,GUI_GREEN);                   
          }     
          thisbully = thisbully->pNext;
     }
//	 }
	 
	 
  for(i = 0; i < N_boat; i++)
	{
		if(SimpBerthes[i].pBerth->isInvader)
		{
               if(SimpBerthes[i].pBerth->mntState == MNTState_Triggered)
               {
                    DrawBullyShip(SimpBerthes[i].pBerth->x_to_cross*37/20, SimpBerthes[i].pBerth->y_to_cross*37/20, (SimpBerthes[i].pBerth->Boat.COG-mothership.COG)/1800.0*3.1416,GUI_YELLOW);                   
               }
               else
               {			
                    DrawBullyShip(SimpBerthes[i].pBerth->x_to_cross*37/20, SimpBerthes[i].pBerth->y_to_cross*37/20, (SimpBerthes[i].pBerth->Boat.COG-mothership.COG)/1800.0*3.1416,pColor->bullyColor);                   
		     }
     }
		if(!SimpBerthes[i].pBerth->isInvader && SimpBerthes[i].pBerth->x_to_cross && SimpBerthes[i].pBerth->y_to_cross)
		{
			DrawBullyShip(SimpBerthes[i].pBerth->x_to_cross*37/20, SimpBerthes[i].pBerth->y_to_cross*37/20, (SimpBerthes[i].pBerth->Boat.COG-mothership.COG)/1800.0*3.1416,GUI_BLACK);        
		}
	}
     
     DrawBullyShip(half_x, half_y, 0,GUI_MAGENTA);        
		 DrawCursor(pSnapLink->x_to_cross*37/20, pSnapLink->y_to_cross*37/20, pColor->textColor);
	
}
Exemplo n.º 26
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;
	WM_MESSAGE             Msg;
	WM_HWIN                hIteminfo;
	int 									  i;
	int 	     					sel;
	uint8_t     					items;
	FRESULT res;
 // FILINFO fno;
  //DIR dir;
  // USER START (Optionally insert additional variables)
  // USER END
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
	hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
	//WM_SetFocus(hItem);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
    TEXT_SetText(hItem, "自学习文件选择");  
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"打开文件……");
		WM_HideWindow(hIteminfo);
	  //
    // Initialization of 'Dropdown'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12);
    DROPDOWN_AddString(hItem, "U盘");
    DROPDOWN_AddString(hItem, "SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
	//
    // Initialization of 'Treeview'
    //
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestFolder_Init();
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		for(i=0;i<TestFolder.number_TotalFile;i++)
		{
			LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
		}
		LISTBOX_SetFont(hItem,GUI_FONT_20_1);
		LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile);
    
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		break;
	case MY_MESSAGE_DOWN:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_IncSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,0);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}	
		break;
	case MY_MESSAGE_UP:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_DecSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel>0)
			{
				DROPDOWN_DecSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,1);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}
		break;
	case MY_MESSAGE_CANCEL://取消
		GUI_EndDialog(pMsg->hWin,0);
		break;
	case MY_MESSAGE_OK:
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		TEXT_SetText(hIteminfo, (char *)"打开文件中……");
		WM_ShowWindow(hIteminfo);
	  GUI_Exec();
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		TestFolder.number_CurrentFile=LISTBOX_GetSel(hItem);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestItem_Init((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);
		//WT_TestFile_Write2Flash((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);//将文件内容复制到Flash
	  //WT_TestFiles_Write2card((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);//将文件内容复制到SD card

	  if(TestFile.file_status == 1)//文件读取OK
		{
			Msg.MsgId = MY_MESSAGE_BUTTONOK;
			WM_SendMessage(pMsg->hWinSrc,&Msg);
			GUI_EndDialog(pMsg->hWin,0);
		}
		else
		{
			TEXT_SetText(hIteminfo, (char *)"读取文件错误!");
			WM_ShowWindow(hIteminfo);
		}
		Msg.MsgId = MY_MESSAGE_BUTTONOK;
		WM_SendMessage(pMsg->hWinSrc,&Msg);
		GUI_EndDialog(pMsg->hWin,0);

		break;
	case MY_MESSAGE_BUTTONDELETE:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		if(store_dev==0) //usb
		strcpy(filename,path_testfile);
		//f_opendir(&dir, path_testfile);
		if(store_dev==1) //sd
		strcpy(filename,path_testfile_sd);
		//f_opendir(&dir, path_testfile_sd);
		//res = f_opendir(&dir, "1:/LZY_WireTester/Test Files");
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		strcat(filename,"/");
		sel = LISTBOX_GetSel(hItem);
		if(sel < 0) break;
		strcat(filename,(char *)TestFolder.FilesName[LISTBOX_GetSel(hItem)]);
		res=f_unlink((const TCHAR*)filename);
		if(res == FR_OK)
		{
			hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
			WM_SetFocus(hItem);
			if(sel > 0) LISTBOX_SetSel(hItem,sel - 1);
			else LISTBOX_SetSel(hItem,0);
		}
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,380,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(8);
		GUI_DrawRect(0,0,378,220);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemplo n.º 27
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);
  }
}
Exemplo n.º 28
0
int
main(int argc, char *argv[])
{
    /* initialize SDL */
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        GUI_Log("Could not initialize SDL");
    }
    if (TTF_Init() != 0){
        GUI_Log( "TTF_Init failed.");
        SDL_Quit();
        return 1;
    }
    if( GUI_Init() != 0 ) {
        GUI_Log( "GUI_Init failed." );
        TTF_Quit();
        SDL_Quit();
        return 1;
    }
    
    char *pref = SDL_GetPrefPath( "JimmySoftware.com", "ToolBarDialog" );
    strcpy( preferenctPath, pref );
    strcat( preferenctPath, "preference.conf" );
    
    SDL_Log( "Pref: %s\n", preferenctPath );
    if( access( preferenctPath, 0 ) != -1 ) {
        GUI_Log( "File Existed\n" );
        loadPalette( preferenctPath );
    } else {
        GUI_Log( "File not existed\n" );
        for( int i=0; i<numPalette; i++ ) {
            for( int j=0; j<numColor; j++ ) {
                mainPalette[i][j] = mColor[j];
            }
        }
    }
    activePalette = 0;
    
    //int sx = 720, sy = 405;
#if __IPHONEOS__ or __ANDROID__
    int sx = 640, sy = 360;
#else
    int sx = 640, sy = 360;
#endif
    SDL_Window *window = GUI_CreateWindow( "GUI", sx, sy );
    if (window == NULL) {
        fatalError("GUI_CreateWindow Error");
        return 1;
    }
    
    SCREEN_WIDTH = GUI_windowWidth;
    SCREEN_HEIGHT = GUI_windowHeight;
    
    topWin=new GUI_TopWin( "TopWin", GUI_Rect(0,0,GUI_windowWidth,GUI_windowHeight),0,
       []( GUI_WinBase *tw ) {
           //tw->clear();
       }
    );
    
    textureFileIcon = loadTexture( "icon_file.png", GUI_renderer );

    
    GUI_WinBase *topBar = new GUI_WinBase( topWin, "TopBar", 0, 0, GUI_windowWidth, 48, cDarkGrey );
    if( topBar ) {
        GUI_Button *bttnFile = new GUI_Button( topBar, "F", 8, 8, 32, 32, cGrey,
            [](GUI_Button *bt) {
                if( menuFile == NULL ) {
                    GUI_Log( "create new MenuFile\n" );
                    static const char *menuText[] = {
                        "File", "Open", "Save", "Exit", NULL
                    };
                    menuFile = new GUI_List( topWin, menuText, 4, bt->tw_area.x, bt->tw_area.y+bt->tw_area.w+10, 240, 0, 0, true,
                        [](GUI_List *l,const char *sel, int index) {
                            switch (index) {
                                case 1:
                                    OpenFile();
                                    break;
                                case 3:
                                    SDL_AddTimer( 100, ExitCallback, NULL );
                                    break;
                                default:
                                    break;
                            }
                            menuFile = NULL;
                        }
                    );
                    menuFile->title_str = "Menu File";
                    menuFile->onClose = [] (GUI_WinBase *) -> bool {
                        menuFile = NULL;
                        return true;
                    };
                }
            }
        );
        bttnFile->texImage = textureFileIcon;
        bttnFile->color = cClear;
        
        new GUI_Button( topBar, "C", 48, 8, 32, 32, cGrey,
            [](GUI_Button *bt) {
                OpenColor();
            }
        );
        
        GUI_WinBase *colorBox = new GUI_WinBase( topBar, "สี", 88, 6, 32*9+18, 36, cClear,
                                                [](GUI_WinBase *wb) {
                                                    GUI_FillRoundRect( 0, 0, wb->tw_area.w, wb->tw_area.h, wb->tw_area.h/2, sdl_color( 0x484848ff ) );
                                                }
                                                );
        if( colorBox ) {
            for( int i=0; i<numColor; i++ ) {
                c[i] = new GUI_Button( colorBox, "", 6+32*i, 3, 31, 31, mainPalette[activePalette][i], setActiveColor );
                c[i]->tag = i;
                c[i]->radius = 15;
                c[i]->border = 1;
            }
            
            setActiveColor( c[0] );
            
            GUI_WinBase *paletteButton = new GUI_WinBase( colorBox, "Palette", 6+32*numColor+5, 3+8, 25, 15, cClear,
                [](GUI_WinBase *w)
                {
                    //GUI_DrawRect( GUI_MakeRect(0, 0, w->tw_area.w, w->tw_area.h), cBlack );
                    SDL_RenderCopy(GUI_renderer, GUI_dropdownTexture, NULL, GUI_MakeRect(1, 1, w->tw_area.w-2, w->tw_area.h-2));
                }
            );
            paletteButton->handle_event_cmd = [](GUI_WinBase *w, SDL_Event* ev ) -> bool {
                switch (ev->type) {
                    case SDL_MOUSEBUTTONUP: {
                        static const char *menuPalette[] = {
                            "Palette1", "Palette2", "Palette3", "Palette4", "Palette5", "---", "Load", "Save", NULL
                        };

                        //GUI_Log( "Palette\n" );
                        GUI_List *listPal = new GUI_List( topWin, menuPalette, 8, w->tw_area.x, w->tw_area.y+w->tw_area.h+18, 240, 0, 0, true,
                                     [](GUI_List* l,const char*sz,int n) {
                                         if( n < numPalette ) {
                                             activePalette = n;
                                             l->setCheck( n );
                                             for( int i=0; i<numColor; i++ ) {
                                                 c[i]->color = mainPalette[n][i];
                                             }
                                         }
                                         else if( n == numPalette + 1 ) {
                                             SDL_AddTimer( 100, LoadPaletteCallback, NULL );
                                         }
                                         else if( n == numPalette + 2 ) {
                                             SDL_AddTimer( 100, SavePaletteCallback, NULL );
                                         }
                                     });
                        for( int i=0; i<numPalette; i++ ) {
                            GUI_ListCell *cell = listPal->getCell( i );
                            cell->checkable = true;
                            cell->display_cmd = cellDraw;
                        }
                        listPal->setCheck( activePalette );
                    }
                }
                return false;
            };

        }
    }
    
    GUI_WinBase *sizeBox = new GUI_WinBase( topBar, "สี", 402, 6, 32*3+6, 36, cClear,
                                            [](GUI_WinBase *wb) {
                                                GUI_FillRoundRect( 0, 0, wb->tw_area.w, wb->tw_area.h, 10, sdl_color( 0x484848ff ) );
                                            }
                                            );
    if( sizeBox ) {
        for( int i=0; i<numSize; i++ ) {
            s[i] = new GUI_Button( sizeBox, "", 3+32*i, 3, 30, 30, cClear, setActiveSize );
            s[i]->tag = i;
            s[i]->radius = 5;
            s[i]->border = 1;
            s[i]->display_cmd = [](GUI_WinBase *w) {
                int bw = 12 + w->tag * 6;
                int cw = 0;
                if( w->tag == 1 )
                    cw -= 3;
                GUI_FillRect( cw+(w->tw_area.w-bw)/2, (w->tw_area.h-bw)/2, bw, bw, cGrey );
                GUI_DrawRect( cw+(w->tw_area.w-bw)/2, (w->tw_area.h-bw)/2, bw, bw, ((GUI_Button*)w)->borderColor );
            };
        }
        setActiveSize( s[0] );
    }
    
    GUI_WinBase *bottomBar = new GUI_WinBase( topWin, "BottomBar", 0, GUI_windowHeight-48, GUI_windowWidth, 48, cDarkGrey );


    //createTestWindows( 20, 20, "Red", cRed );

    
    GUI_Run();
    
    savePalette( preferenctPath );
    
    
    
    /* shutdown SDL */
    GUI_Quit();
    TTF_Quit();
    SDL_Quit();
    
    return 0;
}