/**
  * @brief  Callback function of the Settings dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialogSettings(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode, idx;
  static int8_t sec, min, hour;
  static int8_t asec, amin, ahour;
  static int8_t day, month, max_days;
  static int16_t  year;
  SPINBOX_Handle   hSpin;
  DROPDOWN_Handle  hDropMonth; 
  TEXT_Handle     hText  ;
  static  CALENDAR_DATE   current_date;
  RTC_TimeTypeDef   RTC_TimeStructure;
  RTC_DateTypeDef   RTC_DateStructure;
  static uint8_t TempStr[50];  
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    
    /* Get Clock setting from RTC */
    RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
    
    sec    =  RTC_TimeStructure.RTC_Seconds;
    min    =  RTC_TimeStructure.RTC_Minutes;
    hour   =  RTC_TimeStructure.RTC_Hours;
    
    RTC_GetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
    
    asec  = RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds;
    amin  = RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes;
    ahour = RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours;
    
    RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
    
    year =  RTC_DateStructure.RTC_Year + 2000;
    month =  RTC_DateStructure.RTC_Month;
    day =  RTC_DateStructure.RTC_Date;
    
    max_days = GetMaxDays(month, year);
    
    /* Update the dialog items */
    hItem = pMsg->hWin;
    FRAMEWIN_SetFont(hItem, GUI_FONT_13B_ASCII);
    
    /* Date */
    
    hText = TEXT_CreateEx(20, 20, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x11F," Date : ");
    TEXT_SetFont(hText, GUI_FONT_13B_ASCII);
    TEXT_SetTextColor(hText, 0x00804000);
    
    hSpin = SPINBOX_CreateEx(20, 35, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_DAY, 1, max_days);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);
    SPINBOX_EnableBlink(hSpin, 250, 1);
      
      
    SPINBOX_SetValue(hSpin, day);
    
    hDropMonth = DROPDOWN_CreateEx(65, 35, 80, 160, pMsg->hWin, WM_CF_SHOW, 0,  ID_CLOCK_MONTH);
    DROPDOWN_SetFont(hDropMonth, GUI_FONT_13B_ASCII);
    DROPDOWN_SetTextColor(hDropMonth, DROPDOWN_CI_UNSEL, 0x00804000);
    DROPDOWN_SetTextColor(hDropMonth, DROPDOWN_CI_SEL, 0x00804000);    
    
    for (idx = 0; idx < 12; idx++ )
    {
      DROPDOWN_AddString (hDropMonth, (char *)strMonth[idx]);
    }
    
    DROPDOWN_SetSel(hDropMonth, month - 1);
    
    hSpin = SPINBOX_CreateEx(150, 35, 50, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_YEAR, 2000, 2099);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);  
    SPINBOX_EnableBlink(hSpin, 250, 1);
    SPINBOX_SetValue(hSpin, year);
    
    hItem = CHECKBOX_Create(205, 37, 20, 26, pMsg->hWin, ID_CLOCK_CHECK_DATE ,WM_CF_SHOW);
    CHECKBOX_SetState(hItem, 1);
    
    /* Time */
    
    hText = TEXT_CreateEx(20, 50 + 20, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x123," Time : ");
    TEXT_SetFont(hText, GUI_FONT_13B_ASCII);
    TEXT_SetTextColor(hText, 0x00804000);    
    
    hSpin = SPINBOX_CreateEx(20, 65 + 20, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_HOUR, 0,23);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);      
    SPINBOX_SetValue(hSpin, hour);
    SPINBOX_EnableBlink(hSpin, 250, 1);
    
    hSpin = SPINBOX_CreateEx(75, 65 + 20, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_MIN, 0, 59);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);  
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);  
    SPINBOX_SetValue(hSpin, min);
    SPINBOX_EnableBlink(hSpin, 250, 1);
    
    hSpin = SPINBOX_CreateEx(130, 65 + 20, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_SEC, 0, 59);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);  
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);  
    SPINBOX_SetValue(hSpin, sec);
    SPINBOX_EnableBlink(hSpin, 250, 1);
    
    
    hItem = CHECKBOX_Create(205, 65 + 20, 20, 26, pMsg->hWin, ID_CLOCK_CHECK_TIME ,WM_CF_SHOW);
    CHECKBOX_SetState(hItem, 1);
    
    /* Alarm */
    
    hText = TEXT_CreateEx(20, 78 + 40, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x126," Alarm : ");
    TEXT_SetFont(hText, GUI_FONT_13B_ASCII);
    TEXT_SetTextColor(hText, 0x00804000);    
    
    hSpin = SPINBOX_CreateEx(20, 93 + 40, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_AHOUR, 0,23);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);      
    SPINBOX_SetValue(hSpin, ahour);
    SPINBOX_EnableBlink(hSpin, 250, 1);
    
    
    hSpin = SPINBOX_CreateEx(75, 93 + 40, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_AMIN, 0, 59);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII); 
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);  
    SPINBOX_SetValue(hSpin, amin);
    SPINBOX_EnableBlink(hSpin, 250, 1);
        
    hSpin = SPINBOX_CreateEx(130, 93 + 40, 40, 18, pMsg->hWin, WM_CF_SHOW, ID_CLOCK_ASEC, 0, 59);
    SPINBOX_SetFont(hSpin, GUI_FONT_13B_ASCII);  
    SPINBOX_SetTextColor(hSpin, SPINBOX_CI_ENABLED, 0x00804000);  
    SPINBOX_SetValue(hSpin, asec);
    hItem = CHECKBOX_Create(205, 93 + 40, 20, 26, pMsg->hWin, ID_CLOCK_CHECK_ALARM ,WM_CF_SHOW);
    CHECKBOX_SetState(hItem, 1);
    SPINBOX_EnableBlink(hSpin, 250, 1);
    
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
      
    case ID_CLOSE_SETTINGS: /* Notifications sent by 'Close' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        /* Exit */
        GUI_EndDialog(pMsg->hWin, 0);
        GUI_EndDialog (hNumPad, 0);
        break;
      }
      break;
    case ID_SET_SETTINGS: /* Notifications sent by 'Apply' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if(CHECKBOX_GetState( WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CLOCK_CHECK_DATE)))
        { 
          current_date.Year = year =  SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_YEAR));
          current_date.Month = month = DROPDOWN_GetSel (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_MONTH)) + 1;
          current_date.Day = day =  SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_DAY)); 
          
          
          RTC_DateStructure.RTC_Year  = year - 2000;
          RTC_DateStructure.RTC_Month = month;
          RTC_DateStructure.RTC_Date  = day;
          RTC_DateStructure.RTC_WeekDay = 0;
          RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure);
          
          hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CALENDAR);
          CALENDAR_SetDate(hItem, &current_date);
          CALENDAR_SetSel(hItem, &current_date);
          
          /* Date */
          hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_TEXT_DATE);    
          sprintf((char *)TempStr, "%02d, %s, %04d",day , strMonth[month-1], year);
          TEXT_SetText(hItem, (char *)TempStr);
        }
        
        if(CHECKBOX_GetState( WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CLOCK_CHECK_TIME)))
        {
          /* Save new param in RTC */
          sec    =  SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_SEC));
          min    =  SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_MIN));
          hour   =  SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_HOUR));
          
          RTC_TimeStructure.RTC_Seconds = sec;
          RTC_TimeStructure.RTC_Minutes = min;
          RTC_TimeStructure.RTC_Hours   = hour;
          RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure);
        }
        
        if(CHECKBOX_GetState( WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CLOCK_CHECK_ALARM)))
        {
          asec  = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_ASEC));
          amin  = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_AMIN));
          ahour = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_AHOUR));
          
          /* Disable the Alarm A */
          RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
          
          /* Disable the RTC Alarm A Interrupt */
          RTC_ITConfig(RTC_IT_ALRA, DISABLE);
          
          STM_EVAL_LEDOff(LED4);
          
          RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = asec;
          RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = amin;
          RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = ahour;
          RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
          RTC_AlarmStructure.RTC_AlarmDateWeekDay = day;
          RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
          
          /* Enable the RTC Alarm A Interrupt */
          RTC_ITConfig(RTC_IT_ALRA, ENABLE);
          
          /* Enable the alarm  A */
          RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
          
          alarm_set = 1;
        }
        
        /* Exit */
        WM_InvalidateWindow(WM_GetParent(pMsg->hWin));
        GUI_EndDialog(pMsg->hWin, 0);
        GUI_EndDialog (hNumPad, 0);
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 2
0
/*********************************************************************
*
*       WIDGET_HandleActive
*/
int WIDGET_HandleActive(WM_HWIN hObj, WM_MESSAGE* pMsg) {
  int Diff, Notification;
  WIDGET* pWidget = WIDGET_H2P(hObj);
  switch (pMsg->MsgId) {
  case WM_WIDGET_SET_EFFECT:
    Diff = pWidget->pEffect->EffectSize;
    pWidget->pEffect = (const WIDGET_EFFECT*)pMsg->Data.p;
    Diff -= pWidget->pEffect->EffectSize;
    _UpdateChildPostions(hObj, Diff);
    WM_InvalidateWindow(hObj);
    return 0;                        /* Message handled -> Return */
  case WM_GET_ID:
    pMsg->Data.v = pWidget->Id;
    return 0;                        /* Message handled -> Return */
  case WM_PID_STATE_CHANGED:
    if (pWidget->State & WIDGET_STATE_FOCUSSABLE) {
      const WM_PID_STATE_CHANGED_INFO * pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p;
      if (pInfo->State) {
        WM_SetFocus(hObj);
      }
    }
    break;
  case WM_TOUCH_CHILD:
    /* A descendent (child) has been touched or released.
       If it has been touched, we need to get to top.
     */
    {
      const WM_MESSAGE * pMsgOrg;
      const GUI_PID_STATE * pState;
      pMsgOrg = (const WM_MESSAGE*)pMsg->Data.p;      /* The original touch message */
      pState = (const GUI_PID_STATE*)pMsgOrg->Data.p;
      if (pState) {          /* Message may not have a valid pointer (moved out) ! */
        if (pState->Pressed) {
          WM_BringToTop(hObj);
          return 0;                    /* Message handled -> Return */
        }
      }
    }
    break;
  case WM_SET_ID:
    pWidget->Id = pMsg->Data.v;
    return 0;                        /* Message handled -> Return */
  case WM_SET_FOCUS:
    if (pMsg->Data.v == 1) {
      WIDGET_SetState(hObj, pWidget->State |  WIDGET_STATE_FOCUS);
      Notification = WM_NOTIFICATION_GOT_FOCUS;
    } else {
      WIDGET_SetState(hObj, pWidget->State & ~WIDGET_STATE_FOCUS);
      Notification = WM_NOTIFICATION_LOST_FOCUS;
    }
    WM_NotifyParent(hObj, Notification);
    pMsg->Data.v = 0;   /* Focus change accepted */
    return 0;
  case WM_GET_ACCEPT_FOCUS:
    pMsg->Data.v = (pWidget->State & WIDGET_STATE_FOCUSSABLE) ? 1 : 0;               /* Can handle focus */
    return 0;                         /* Message handled */
  case WM_GET_INSIDE_RECT:
    WIDGET__GetInsideRect(pWidget, (GUI_RECT*)pMsg->Data.p);
    return 0;                         /* Message handled */
  }
  return 1;                           /* Message NOT handled */
}
Esempio n. 3
0
/**
  * @brief  Callback routine of desktop window status.
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbStatus(WM_MESSAGE * pMsg) {
  int xSize, ySize;
  static uint8_t TempStr[50];
  static WM_HTIMER hTimerTime;
  static WM_HTIMER hSpriteTime;  

  RTC_TimeTypeDef   RTC_Time;
  RTC_DateTypeDef   RTC_DateStructure;
  uint8_t sec, min, hour, day, month;
  uint16_t year;
  WM_HWIN hWin;

  hWin = pMsg->hWin;
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0);
    if(settings.b.enable_sprite)
    {
      hSpriteTime = WM_CreateTimer(hWin, ID_SPRITE_TIME, 50, 0);    
    }
    break;
    
  case WM_DELETE:
    WM_DeleteTimer(hTimerTime);
    if(settings.b.enable_sprite)
    {    
      WM_DeleteTimer(hSpriteTime);    
    }
    break;
    
  case WM_TIMER:
    if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME)
    {
      WM_InvalidateWindow(hWin);
      WM_RestartTimer(pMsg->Data.v, 1000);
    }
    else if( WM_GetTimerId(pMsg->Data.v) == ID_SPRITE_TIME)
    {
      if(settings.b.enable_sprite)
      {    
        if(SpriteDisabled == 0)
        {
          _MoveSprite(&_aSprite[0]);
        }
      }
      WM_RestartTimer(pMsg->Data.v, 100);
    }
    break;
    
  case WM_PAINT:
    xSize = WM_GetWindowSizeX(hWin);
    ySize = WM_GetWindowSizeY(hWin);
    
    /* Draw background */
    GUI_SetColor(0x40303030);
    GUI_FillRect(0, 0, xSize , ySize - 3);
    GUI_SetColor(0x808080);
    GUI_DrawHLine(ySize - 2, 0, xSize );
    GUI_SetColor(0x404040);
    GUI_DrawHLine(ySize - 1, 0, xSize );

    /* Draw time & Date */
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_SetColor(GUI_WHITE);
    GUI_SetFont(GUI_FONT_20B_ASCII);
    
    k_GetTime(&RTC_Time);
    sec    =  RTC_Time.Seconds;
    min    =  RTC_Time.Minutes;
    hour   =  RTC_Time.Hours;
    
    k_GetDate(&RTC_DateStructure);
    
    sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec);
    GUI_DispStringAt((char *)TempStr, xSize - 80, 8);
    
    year =  RTC_DateStructure.Year + 2014;
    month =  RTC_DateStructure.Month;
    day =  RTC_DateStructure.Date;
    
    if((day > 0) && (day <= 31) && 
       (month > 0)&& (month <= 12) && 
         (year >= 1900))
    {
      sprintf((char *)TempStr, "%02d, %s, %04d", day , strMonth[month-1], year);
    }
    else
    {
      sprintf((char *)TempStr, "01, January, 2014");
    }

    GUI_DispStringHCenterAt((char *)TempStr, xSize / 2, 8);
    
    /* USB */
    if(k_StorageGetStatus(USB_DISK_UNIT))
    {
       GUI_DrawBitmap(&bmusbdisk, xSize - 110, 8);
    }
    
    /* MSD */
    if(k_StorageGetStatus(MSD_DISK_UNIT))
    {
       GUI_DrawBitmap(&bmmicrosd, xSize - 110 - 35 * k_StorageGetStatus(USB_DISK_UNIT) , 8);
    }    
    
    sprintf((char *)TempStr, "CPU : %d %%", osGetCPUUsage());
    
    if(osGetCPUUsage() > 95 )
    {
      /* waiting for user input when using dialog box*/
      sprintf((char *)TempStr, "CPU : 95 %%");
    }
    GUI_DispStringAt( (char *)TempStr, 70, 8);
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
}
/**
  * @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     NCode;
  int     result;
  int     Id, ItemNbr;
  int duration, volume, index;
  static char tmp[FILEMGR_FILE_NAME_SIZE];  
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
      
    pWavList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    pWavList->ptr = 0;
      
    /* Initialization of 'Listview' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
    LISTVIEW_AddColumn(hItem, 250, "Track", GUI_TA_VCENTER | GUI_TA_LEFT);
    LISTVIEW_AddColumn(hItem, 93, "Duration   ", GUI_TA_VCENTER | GUI_TA_RIGHT);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN);
    
    /* Title Initialization in play list */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_CAPTION);
    TEXT_SetText(hItem, "TITLE:");
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Title Initialization in play list */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE);
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);    
    
    /* Duration */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
    TEXT_SetText(hItem, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_D64);
    TEXT_SetTextColor(hItem, GUI_GRAY);
    
    /* Author initialization */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR_CAPTION);
    TEXT_SetText(hItem, "AUTHOR:");
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Author */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR);
    TEXT_SetText(hItem, "");
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Sampling Rate */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_CAPTION);
    TEXT_SetText(hItem, "SAMPLING:");
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Sampling Rate Value */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_VALUE);
    TEXT_SetText(hItem, "");
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Duration */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME);
    TEXT_SetText(hItem, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Initialization of 'Add' Button */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON);
    BUTTON_SetFont(hItem, GUI_FONT_24_1);
    
    volume = AUDIOPLAYER_GetVolume();
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER);
    SLIDER_SetValue(hItem, volume);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER);
    SLIDER_SetNumTicks(hItem, 25);
    
    PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP);
    PlayerSettings.b.mute = MUTE_OFF;  
    PlayerSettings.b.pause = PLAY_ACTIVE;  
      
    hItem = BUTTON_CreateEx(25,  150, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON);
    WM_SetCallback(hItem, _cbButton_repeat);
    
    hItem = BUTTON_CreateEx(100,  145, 40,  40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON);
    WM_SetCallback(hItem, _cbButton_speaker);    
    
    hItem = BUTTON_CreateEx(22,  337, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON);
    WM_SetCallback(hItem, _cbButton_stop);    
       
    hItem = BUTTON_CreateEx(89, 337, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
    WM_SetCallback(hItem, _cbButton_previous);   
    
    hItem = BUTTON_CreateEx(148, 330, 50,  50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON);
    WM_SetCallback(hItem, _cbButton_play);
    
    hItem = BUTTON_CreateEx(222, 337, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
    WM_SetCallback(hItem, _cbButton_next);
    
    hItem = WM_GetClientWindow(pMsg->hWin);
    hItem = BUTTON_CreateEx(20, 395, 50,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON);
    WM_SetCallback(hItem, _cbButton_open); 
    
    hItem = BUTTON_CreateEx(80, 395, 50,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
    WM_SetCallback(hItem, _cbButton_add);      
       
    hItem = BUTTON_CreateEx(235,  395, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
    WM_SetCallback(hItem, _cbButton_close);
    
    hTimerWin = WM_CreateWindowAsChild(0,
                           100,
                           10,
                           10,
                           pMsg->hWin, 
                           WM_CF_SHOW | WM_CF_HASTRANS,
                           _cbAudioProcess, 
                           0);
    
    hItem = WM_CreateWindowAsChild(15,
                                   125,
                                   255,
                                   20,
                                   pMsg->hWin, 
                                   WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
                                   _cbDrawProgressSlider, 
                                   0);
    
    hItem = WM_CreateWindowAsChild(145,
                                   
                                   155,
                                   125,
                                   20,
                                   pMsg->hWin, 
                                   WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
                                   _cbDrawVolumeSlider, 
                                   0);    
    
    WM_CreateWindowAsChild(639, 460, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); 
    
    break;
    
  case WM_PAINT:
    
    GUI_SetBkColor(GUI_BLACK);
    GUI_ClearRect(15, 6, 270, 120); 
    GUI_DrawGradientRoundedV(15, 190, 270, 310, 30, 0x00A77009, 0x00FFFF00);
    DrawRect3D(15, 325, 255, 60);
    DrawRect3D(15, 390, 255, 40);
    
    break;
    
  case WM_DELETE:
    AUDIOPLAYER_DeInit();
    
    k_free(pWavList);
    k_free(pFileInfo);
    
    pWavList->ptr = 0;
    PlayerSettings.b.mute = MUTE_OFF;       
    PlayerSettings.b.pause = PLAY_ACTIVE;        
    k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32);
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;

    switch(Id) {
      
    /* Notification sent by "Button_Close" */  
    case ID_CLOSE_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;
      
    /* Notifications sent by 'Repeat' Button */
    case ID_REPEAT_BUTTON:
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON);   
        
        if(PlayerSettings.b.repeat == REPEAT_NONE)
        {
          PlayerSettings.b.repeat = REPEAT_ONCE;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ONCE)
        {
          PlayerSettings.b.repeat = REPEAT_ALL;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ALL)
        {
          PlayerSettings.b.repeat = REPEAT_NONE;
        }
      }
      break;
      
    /* Notifications sent by 'Mute' Button */
    case ID_MUTE_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON);         
        if(PlayerSettings.b.mute == MUTE_OFF)
        {          
          AUDIOPLAYER_Mute(MUTE_ON);
          PlayerSettings.b.mute = MUTE_ON;
        }
        else
        {         
          AUDIOPLAYER_Mute(MUTE_OFF);
          PlayerSettings.b.mute = MUTE_OFF;
        }
      }
      break;
      
      
    /* Notifications sent by 'Volume' Slider */
    case ID_VOLUME_SLIDER: 
      if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER);
        AUDIOPLAYER_SetVolume(SLIDER_GetValue(hItem));
        
        if(PlayerSettings.b.mute == MUTE_ON)
        {          
          AUDIOPLAYER_Mute(MUTE_OFF);
          PlayerSettings.b.mute = MUTE_OFF;
        }        
      }
      break;
      
      
    /* Notifications sent by 'progress' Slider */
    case ID_DURATION_SLIDER: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER);
        AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem));
        
        if(PlayerSettings.b.mute == MUTE_ON)
        {
          AUDIOPLAYER_Mute(MUTE_ON);
        }
      }
      break;
      
      
    /* Notifications sent by 'ListView' Slider */
    case ID_WAVFILE_LIST: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
        index = LISTVIEW_GetSel(hItem);
        
        if(index < pWavList->ptr)
        {
          if(playlist_select == 0)
          {
            hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0);           
            playlist_select = (index + 1);
          }
          
          else if(playlist_select == (index + 1))
          {
            WM_DeleteTimer(hPlaylistTimer); 
            hPlaylistTimer = 0;          
            playlist_select = 0;
            
            if(index < pWavList->ptr)
            {
                
              if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
              {             
                AUDIOPLAYER_Stop();
              }
              
              PlayerSettings.b.pause = PLAY_ACTIVE;
              hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem);
              
              file_pos = index;
              _PlayFile((char *)pWavList->file[index].name); 
            }
          }
        }
      }
      break;
      
    /* Notifications sent by 'Play' Button */
    case ID_PLAY_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        
        if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP)
        {
          if(pWavList->ptr > 0)
          {
            _PlayFile((char *)pWavList->file[file_pos].name);
            LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
          }
          else
          {
            pFileInfo->pfGetData = k_GetData;
            pFileInfo->pMask = acMask_audio;     
            hItem = CHOOSEFILE_Create(pMsg->hWin,  70, 40, 450, 250, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo);  
            WM_MakeModal(hItem);
            result = GUI_ExecCreatedDialog(hItem);
            if (result == 0) 
            {
              if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV")))
              {         
                if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0)
                {
                  if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
                  {
                    /* Stop current audio sample */
                    AUDIOPLAYER_Stop();   
                  }
                  
                  pWavList->ptr = 0;
                  file_pos = 0;
                  
                  strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
                  FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
                  hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
                  
                  /* Update Play list */
                  strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
                  
                  ItemNbr = LISTVIEW_GetNumRows(hItem);
                  while(ItemNbr--)
                  {
                    LISTVIEW_DeleteRow(hItem, ItemNbr);
                  }
                  
                  LISTVIEW_AddRow(hItem, NULL);         
                  LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
                  duration = WavInfo.FileSize / WavInfo.ByteRate; 
                  sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
                  LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
                  pWavList->ptr++;  
                  
                  LISTVIEW_SetSel(hItem, 0);
                  _PlayFile(pFileInfo->pRoot);              
                }
              }          
            }
          }
        }
        else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
        {
          PlayerSettings.b.pause = (PlayerSettings.b.pause == PLAY_ACTIVE ? PAUSE_ACTIVE : PLAY_ACTIVE);
          
          if(PlayerSettings.b.pause == PAUSE_ACTIVE)
          {            
            AUDIOPLAYER_Pause();
          }
          else if(PlayerSettings.b.pause == PLAY_ACTIVE)
          {            
            AUDIOPLAYER_Resume();
          }
        }
      }
      break;
      
      
    /* Notifications sent by 'STOP' Button */
    case ID_STOP_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
        {
          if(PlayerSettings.b.pause == PAUSE_ACTIVE)
          {  
            PlayerSettings.b.pause = PLAY_ACTIVE;
          } 
          AUDIOPLAYER_Stop();
          hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
          TEXT_SetText(hItem, "00:00");            
          
          hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);          
        }
      }
      break;
      
      
    /* Notifications sent by 'Next' Button */
    case ID_NEXT_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        if( pWavList->ptr > 0)
        {        
          if(file_pos < (pWavList->ptr - 1))
          {
            file_pos++;
          }
          else if(PlayerSettings.b.repeat == REPEAT_ALL)
          {
            file_pos = 0; 
            
          }
          LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
          if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
          {    
            if(PlayerSettings.b.pause == PAUSE_ACTIVE)
            {  
              PlayerSettings.b.pause = PLAY_ACTIVE;
              hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem);
            }
            
            AUDIOPLAYER_Stop();
            _PlayFile((char *)pWavList->file[file_pos].name); 
          }
        }
      }
      break;
      
      /* Notifications sent by 'Previous' Button */
    case ID_PREVIOUS_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        if( pWavList->ptr > 0)
        {
          if(file_pos > 0)
          {   
            file_pos--;           
          }
          else if(PlayerSettings.b.repeat == REPEAT_ALL)
          {
            file_pos = (pWavList->ptr - 1); 
            
          }          
          LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
          if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
          {  
            if(PlayerSettings.b.pause == PAUSE_ACTIVE)
            {  
              PlayerSettings.b.pause = PLAY_ACTIVE;
              hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem);
            }
            
            AUDIOPLAYER_Stop();
            _PlayFile((char *)pWavList->file[file_pos].name);              
          }
        }
      }
      break;    
      
    /* Notifications sent by 'Open' Button */
    case ID_WAV_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        
        break;
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_dir;     
        hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); 
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        {  
          _AddEntireFolder(pFileInfo->pRoot);
        }
        break;
        
      }
      break;
            
    /* Notifications sent by 'Add' Button */
    case ID_ADD_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_audio;     
        hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, pFileInfo);
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        {
          if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV")))
          {
            if(pWavList->ptr < FILEMGR_LIST_DEPDTH)
            {
              strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
              FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
              hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
              
              if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0)
              {
                LISTVIEW_AddRow(hItem, NULL);         
                LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
                duration = WavInfo.FileSize / WavInfo.ByteRate; 
                sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
                LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
                pWavList->ptr++;      
              }
            }
          }
        }
        break;
        
      }
      break;
      
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/**
  * @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;
  GUI_RECT r;
  int      result;  
  int      Id, NCode, Index;
  char tmp[FILEMGR_FILE_NAME_SIZE];
  
  switch (pMsg->MsgId)
  {
  case WM_INIT_DIALOG:
    
    
    pImageList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    
    pImageList->ptr = 0;
    file_pos = 0;
    effects = 0;
    
    ImSettings.d32 = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP);
    if(ImSettings.b.ss_timer == 0)
    {
      ImSettings.b.ss_timer = 1;
    }

    
    /* Image frame initialization */
    IMAGE_Enlarge = 0;
    hItem = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hItem, &r);
    imFrame = WM_CreateWindowAsChild(r.x0 + 15, r.y0 + 15, r.x1 - 219, r.y1 - 73, hItem, WM_CF_SHOW, _cbImageWindow, 0);

    /* Buttons initialization */
    
    hItem = BUTTON_CreateEx(138, 390, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
    WM_SetCallback(hItem, _cbButton_previous);
    
    hItem = BUTTON_CreateEx(185, 383,  50,  50, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDE_BUTTON);
    WM_SetCallback(hItem, _cbButton_play);
    slideshow_state = OFF;
    
    hItem = BUTTON_CreateEx(247, 390, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
    WM_SetCallback(hItem, _cbButton_next);
    
    
    hItem = BUTTON_CreateEx(546, 393, 50,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
    WM_SetCallback(hItem, _cbButton_add);
    
    hItem = BUTTON_CreateEx(474, 393, 50,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON);
    WM_SetCallback(hItem, _cbButton_open);
    
    hItem = BUTTON_CreateEx(400, 392, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_SETTINGS_BUTTON);
    WM_SetCallback(hItem, _cbButton_settings);
    
    hItem = BUTTON_CreateEx(20, 392, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
    WM_SetCallback(hItem, _cbButton_close);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
    LISTBOX_SetBkColor(hItem, LISTBOX_CI_SEL, GUI_BLUE);
    LISTBOX_SetTextColor(hItem, LISTBOX_CI_SEL, GUI_WHITE);
    LISTBOX_SetBkColor(hItem, LISTBOX_CI_UNSEL, GUI_BLACK);
    LISTBOX_SetTextColor(hItem, LISTBOX_CI_UNSEL, GUI_CYAN);
    LISTBOX_SetAutoScrollV(hItem, 1);
    
    break;
     
  case WM_TIMER:
    playlist_select = 0;
    break; 
    
 case WM_PAINT:
    DrawRect3D(15, 381, 420, 53);
    DrawRect3D(445, 381, 175, 53);
    
    break;
  case WM_NOTIFY_PARENT:
    Id = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    
    switch (Id) {
    /* Notification sent by "Button_Settings" */   
    case ID_SETTINGS_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, IMAGE_hWin, 0, 0);
        break;
      }
      break;
      
     /* Notifications sent by 'ListView' Slider */
    case ID_IMAGE_LIST: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
        Index = LISTBOX_GetSel(hItem);
        
        if(Index < pImageList->ptr)
        {
          if(playlist_select == 0)
          {
            hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0);           
            playlist_select = (Index + 1);
          }
          
          else if(playlist_select == (Index + 1))
          {
            WM_DeleteTimer(hPlaylistTimer); 
            hPlaylistTimer = 0;          
            playlist_select = 0;
            
            if(Index < pImageList->ptr)
            {
              file_pos = Index;
              if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
              {
                IMAGE_Type = IMAGE_TYPE_BMP;
              }
              else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
              {
                IMAGE_Type = IMAGE_TYPE_JPG;
              }        
              f_close(&Image_File);
              f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
              WM_InvalidateWindow(imFrame);
            }
          }
        }
      }
      break;   
      
    /* Notification sent by "Button_Close" */
    case ID_CLOSE_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        f_close(&Image_File);
        k_free(pImageList); 
        k_free(pFileInfo);        
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;
      
    /* Notification sent by "Button_Open" */  
    case ID_OPEN_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:

        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_dir;
        hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "add a folder", 0, pFileInfo);
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        {          
          if(pImageList->ptr == 0)
          {
            _AddEntireFolder(pFileInfo->pRoot);
            file_pos = 0;
            if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
            {
              IMAGE_Type = IMAGE_TYPE_BMP;
            }
            else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
            {
              IMAGE_Type = IMAGE_TYPE_JPG;
            }
            
            f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
            WM_InvalidateWindow(imFrame);
          }
          else
          {
            _AddEntireFolder(pFileInfo->pRoot);
          }
        }
        break;
      }
      break;
      
    /* Notification sent by "Button_Open" */  
    case ID_ADD_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_img;
        hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add an image to playlist", 0, pFileInfo);  
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        {
          if((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP")))
          {
            strcpy((char *)pImageList->file[pImageList->ptr].name, pFileInfo->pRoot);
            FILEMGR_GetFileOnly(tmp, (char *)pFileInfo->pRoot);
            hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
            LISTBOX_AddString(hItem, tmp);
            LISTBOX_SetSel(hItem, pImageList->ptr);
            pImageList->ptr++;
            file_pos = pImageList->ptr - 1;
            f_close(&Image_File);
            
            if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
            {
              IMAGE_Type = IMAGE_TYPE_BMP;
            }
            else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
            {
              IMAGE_Type = IMAGE_TYPE_JPG;
            }
            
            f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
            WM_InvalidateWindow(imFrame);
          }          
        }
        break;
      }
      break;
      
    /* Notification sent by "Button_SlideShow" */  
    case ID_SLIDE_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        if(pImageList->ptr > 1)
        {
          f_close(&Image_File);
          f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
          
          if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
          {
            IMAGE_Type = IMAGE_TYPE_BMP;
          }
          else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
          {
            IMAGE_Type = IMAGE_TYPE_JPG;
          }
          
          WM_InvalidateWindow(imFrame);
          if (slideshow_state == OFF)
          {
            hTimerTime = WM_CreateTimer(imFrame, ID_SLIDER_TIMER, (ImSettings.b.ss_timer * 1000) , 0);
          }
          else if(hTimerTime != 0)
          {
            WM_DeleteTimer(hTimerTime);
            hTimerTime = 0;
          } 
          
          slideshow_state = (slideshow_state == OFF ? ON : OFF);
        }
        break;
      }
      break;
      
    /* Notification sent by "Button_Next" */  
    case ID_NEXT_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        
        if(pImageList->ptr > 0)
        {
          if (file_pos < (pImageList->ptr - 1))
          {
            file_pos++;
            f_close(&Image_File);
          }
          else
          {
            file_pos = 0; 
            f_close(&Image_File);            
          }
            
            if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
            {
              IMAGE_Type = IMAGE_TYPE_BMP;
            }
            else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
            {
              IMAGE_Type = IMAGE_TYPE_JPG;
            }
            
            f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
            WM_InvalidateWindow(imFrame);
            hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
            LISTBOX_SetSel(hItem, file_pos);
        }
        
        break;
      }
      break;
      
    /* Notification sent by "Button_Previous" */  
    case ID_PREVIOUS_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:   
        
        if(pImageList->ptr > 0)
        {
          if (file_pos > 0 )
          {
            file_pos--;
            f_close(&Image_File);
          }
          else
          {
            file_pos = (pImageList->ptr - 1);
            f_close(&Image_File);
          }
            
            if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
            {
              IMAGE_Type = IMAGE_TYPE_BMP;
            }
            else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
            {
              IMAGE_Type = IMAGE_TYPE_JPG;
            }
            
            f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
            WM_InvalidateWindow(imFrame);
            hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
            LISTBOX_SetSel(hItem, file_pos);
        }
        
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 6
0
/*********************************************************************
*
*       _InvalidateWindowAndDescs
*/
static void _InvalidateWindowAndDescs(WM_HWIN hWin) {
  WM_InvalidateWindow(hWin);
  WM_ForEachDesc(hWin, _cbInvalidateOne, 0);
}
Esempio n. 7
0
/**
  * @brief  Callback routine of Info dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE 
  * @retval None
  */
static void _cbPlaylistDialog(WM_MESSAGE * pMsg) {
  int     NCode;
  int     Id;
  int     r;
  WM_HWIN hItem;

  static char tmp[64];
  uint32_t i = 0;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OKPL);
    WM_SetCallback(hItem, _cbButton_okPL);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ADDPL);
    WM_SetCallback(hItem, _cbButton_add2PL);   
    
    
    hItem = LISTVIEW_CreateEx(60, 30, 300, 250, pMsg->hWin, WM_CF_SHOW, 0, ID_VIDEO_LIST);

    LISTVIEW_SetFont(hItem, &GUI_Font16_1);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, 0x00DCA939);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SEL, GUI_WHITE);
    LISTVIEW_SetHeaderHeight(hItem, 0);
    LISTVIEW_AddColumn(hItem, 300, "", GUI_TA_VCENTER | GUI_TA_LEFT);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetAutoScrollV(hItem, 1);  
    WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
    LISTVIEW_SetTextAlign(hItem, 0, GUI_TA_HCENTER); 
    
    if(VideoList.ptr > 0)
    {
      for(i=0; i<VideoList.ptr; i++)
      {
        strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
        FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
        
        LISTVIEW_AddRow(hItem, NULL);         
        LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
      }
    }     
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;   
    switch(Id) {
    case ID_BUTTON_OKPL: /* Notifications sent by 'OK' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0); 
        break;
      }
      break;
      
    case ID_BUTTON_ADDPL: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        FileInfo.pfGetData = k_GetData;
        FileInfo.pMask = acMask_video;     
        hItem = CHOOSEFILE_Create(pMsg->hWin, 48, 30, 330, 240, apDrives, GUI_COUNTOF(apDrives), 0, "Video files", 0, &FileInfo);
        WM_MakeModal(hItem);
        r = GUI_ExecCreatedDialog(hItem);
        if (r == 0) 
        {
          if((strstr(FileInfo.pRoot, ".emf")) || (strstr(FileInfo.pRoot, ".EMF")))
          {
            if(VideoList.ptr < FILEMGR_LIST_DEPDTH)
            {
              strcpy((char *)VideoList.file[VideoList.ptr].name, FileInfo.pRoot);
              FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
              hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
              
              LISTVIEW_AddRow(hItem, NULL);         
              LISTVIEW_SetItemText(hItem, 0, VideoList.ptr, (char *)tmp);
              VideoList.ptr++;
            }
          }
          WM_InvalidateWindow(pMsg->hWin);
        }
        
        break;
      }
      break;        
      
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 8
0
/**
  * @brief  Callback function of the MJPEG frame
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbVideoWindow(WM_MESSAGE * pMsg) 
{
  char temp[20];
  static WM_HTIMER hTimerTime;
  WM_HWIN hItem;  
  const GUI_PID_STATE * pState;
  
  GUI_RECT r;
  WM_GetInsideRect(&r);
  
  switch (pMsg->MsgId) 
  {
    
  case  WM_TOUCH:
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      pState = (const GUI_PID_STATE *)pMsg->Data.p;
      if (pState) {
        if (pState->Pressed == 1) {
          VIDEO_Enlarge ^= 1;
          if(VIDEO_Enlarge)
          {
            GUI_SetOrientation(GUI_SWAP_XY | GUI_MIRROR_Y);
            TS_Orientation = 1;
            WM_AttachWindowAt(pMsg->hWin, WM_GetDesktopWindowEx(1), 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindow(pMsg->hWin, bkparent);
            GUI_SetOrientation(0);
            TS_Orientation = 0;
            WM_InvalidateWindow(bkparent);    
            
            WM_AttachWindowAt(pMsg->hWin, VIDEO_hWin, 5, 16);
            WM_SetSize(pMsg->hWin,230, 170);
            do_clear = 1;
          }
        }
      }
    }
    break;
    
    
  case WM_CREATE:
    /* Create timer */
    hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 50, 0);        
    break;
    
  case WM_TIMER:
    WM_InvalidateWindow(pMsg->hWin);
    WM_RestartTimer(pMsg->Data.v, 0);
    
    break; 
    
  case WM_DELETE:
    WM_DeleteTimer(hTimerTime);
    break;

    
  case WM_PAINT:
    
    if(do_clear)
    {
      GUI_ClearRectEx(&r);
      do_clear = 0;
    } 
    
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      if(_PlayMJPEG(&Video_File) < 0)
      {
        VideoPlayer_State = VIDEO_PLAY;
        ImageOffset = 0; 
        time_start = GUI_GetTime();    
        f_close(&Video_File);
        goto_next_file();      
        hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_FILE);
        TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);        
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_PROGRESS);
      
      if (progress_bar == 0)
      {
        SLIDER_SetValue(hItem, (ImageOffset * 100 )/ Video_File.fsize);
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_DURATION);
      
      duration = (GUI_GetTime() - time_start )/1000;
      if(duration < 0) duration = 0;
      sprintf(temp,"%02d:%02d", duration/60, duration%60); 
      TEXT_SetText(hItem, temp);  
    }
    else if(VideoPlayer_State == VIDEO_IDLE)
    {
      GUI_ClearRectEx(&r);
    }
    
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
  
}
Esempio n. 9
0
/*********************************************************************
*
*       HEADER_SetBitmapEx
*/
void HEADER_SetBitmapEx(HEADER_Handle hObj, unsigned Index, const GUI_BITMAP * pBitmap, int x, int y) {
  HEADER__SetDrawObj(hObj, Index, GUI_DRAW_BITMAP_Create(pBitmap, x, y));
  WM_InvalidateWindow(hObj);
}
Esempio n. 10
0
static void mylistview(WM_MESSAGE *pMsg)
{
	WM_HWIN hWin;
	CHAR RowNum;
	CHAR RowLineIndex;
	const WM_KEY_INFO *pInfo;
	int16_t  i  = 0;
	static char addrow = 0;
	hWin = pMsg->hWin;

	switch (pMsg->MsgId)
	{
		 case WM_KEY:
			     pInfo = (WM_KEY_INFO*)pMsg->Data.p;
		     switch (pInfo->Key)
	      {
								  case GUI_KEY_MENU:
											    WM_BringToTop(Menuwin);
										     WM_SetFocus(WM_GetDialogItem(Menuwin,ID_MENU));
										     MENU_SetSel(WM_GetDialogItem(Menuwin,ID_MENU),0);
										     MenuSel = 0;
											    break;
								  case GUI_KEY_PRINT:
														 WM_BringToTop(PrintWin);
														 WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu));
										     break;
										
			      	case GUI_KEY_LOC1:
							        pCannel = "  490 横";
							        WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
							        break;
										
			      	case GUI_KEY_LOC2:
															pCannel = "4209.5横";
															WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
							        break;
										
			      	case GUI_KEY_CHS:
							        pCannel = "  486 横";
															WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
												  	break;
			
			       case GUI_KEY_LOCK:							
															SelRow = LISTVIEW_GetSel(hListview);
															LISTVIEW_GetItemText(hListview,0,SelRow,pStrBuf,5);
															InfoId = atoi(pStrBuf);
															Info  = pInfoHeader;
															if (pInfoHeader)
															do 
															{
																	if (Info->ID == InfoId)
																	{
																				if (Info->isLocked == 0)
																				{      
																					LISTVIEW_SetItemText(hListview,6,SelRow,"          锁");
																					Info->isLocked = 1;
																				}
																				else if (Info->isLocked == 1)
																				{
																					LISTVIEW_SetItemText(hListview,6,SelRow,"");
																					Info->isLocked = 0;
																				}
																				break;
																	}
															}while (Info = Info->pNext);
														 break;
					 
			       case GUI_KEY_DOWN:

															SelRow = LISTVIEW_GetSel(hListview);
															if (thispage < pageNum)
															{
																		if (SelRow == 7)
																		{
																				thispage++;
																				InfoSel(InfoType,thispage);
																				DisPage();																						 
																				//WM_InvalidateRect(mainwin,&PageRect);
																		}
															}
													 	break;
				
										case GUI_KEY_UP:
															SelRow = LISTVIEW_GetSel(hListview);
															if(SelRow == 0 && thispage == 1)
																		WM_SetFocus(hButton);
															if (thispage>1)
															{
																		if(SelRow == 0)
																		{
																			  SelBottom = 1;		
																					thispage--;
																					InfoSel(InfoType,thispage);
																					DisPage();										
																					GUI_StoreKeyMsg(GUI_KEY_RIGHT,1);  //选择列表中最后一行
																		}
															}
															break;
					
									case GUI_KEY_RIGHT:
														if (SelBottom == 1)
														{
																	LISTVIEW_SetSel(hListview,7);
																	SelBottom = 0;
														}
														break;
									
									case GUI_KEY_ESCAPE:
														SelRow = LISTVIEW_GetSel(hListview);
														WM_SetFocus(hButton);
														break;
				
									case GUI_KEY_ENTER:
														SelRow = LISTVIEW_GetSel(hListview);
														LISTVIEW_GetItemText(hListview,0,SelRow,pStrBuf,5);
														InfoId = atoi(pStrBuf);
														Info  = pInfoHeader;
														if (pInfoHeader)
														do 
														{
																if (Info->ID == InfoId)
																{
																			if (Info->state == INFO_STT_New)
																				LISTVIEW_SetItemBitmap(hListview,6,SelRow,10,7,NULL);
																			if (Info->isLocked == 0)
																						TEXT_SetText(WM_GetDialogItem(InfoText,ID_TEXT_0),"");
																			else TEXT_SetText(WM_GetDialogItem(InfoText,ID_TEXT_0),"锁");
																			Info->state = INFO_STT_Choosen;
																			sprintf(pStrBuf,"%s",pStrBuf);
																			BUTTON_SetText(WM_GetDialogItem(InfoText,ID_BUTTON_0),pStrBuf);
																			MULTIEDIT_SetText(WM_GetDialogItem(InfoText, ID_MULTIEDIT_0),Info->pContent);
																			break;
																}
														}while (Info = Info->pNext);
															WM_BringToTop (InfoText);
															WM_SetFocus (InfoText);
														break;

							  }
		
	 	case WM_POST_PAINT: //行分割线
								RowNum = LISTVIEW_GetNumRows(hListview);
								GUI_SetColor(GUI_BLACK);
								for (RowLineIndex = 0; RowLineIndex<RowNum; RowLineIndex++)
												GUI_DrawLine(0,(68+40*(RowLineIndex)),720,(68+40*(RowLineIndex)));

		 default :
			     LISTVIEW_Callback(pMsg);
	      	break;
	}
}
Esempio n. 11
0
//
// Buttoncallback;
//
void mybutton (WM_MESSAGE *pMsg) 
{
	WM_HWIN hWin;
	WM_KEY_INFO *pInfo;
	int column,row,row_index,del_row;
	int i;
	hWin = pMsg->hWin;
	switch (pMsg->MsgId)
	{
		
		 case USER_MSG_LANGUAGE: //更改语言
				    pLanguage = &Lgumainwin[Language];
			     if (Language == 0)
								{
									  BUTTON_SetFont(hButton,&GUI_Font30);
									  TEXT_SetFont(mainwinText[5],&GUI_Font30);
									  HEADER_SetFont(hListhead,&GUI_Font24);
								}
								else
								{
									  BUTTON_SetFont(hButton,&GUI_Font20_1);
									  TEXT_SetFont(mainwinText[5],&GUI_Font24_1);
									  HEADER_SetFont(hListhead,&GUI_Font16_1);			
           LISTVIEW_SetHeaderHeight(hListview,29);									
								}
								DisPage();
			     BUTTON_SetText(hButton,pLanguage->ButtonInfo[0]);
			     for(i = 0; i<7; i++)
											HEADER_SetItemText(hListhead,i,pLanguage->ListHead[i]);
				    break;
			
			case WM_SET_FOCUS:
								if (pMsg->Data.v)
								{
											BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_GRAY);
											BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);
											BUTTON_SetFocusColor(hButton,GUI_GRAY);
								}
								else 	
								{
									BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);//BUTTON_SetTextColor (hButton,BUTTON_CI_UNPRESSED,GUI_BLACK);
									BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_BLACK);
									BUTTON_SetFocusColor(hButton,GUI_WHITE);
								}
								BUTTON_Callback(pMsg);
								break;
		
			case WM_KEY:
				    pInfo = (WM_KEY_INFO*)pMsg->Data.p;
							switch (pInfo->Key)
							{ 
								
								 case GUI_KEY_ENTER:
										    break;
									
								 case GUI_KEY_PRINT:
														WM_BringToTop(PrintWin);
														WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu));
										    break;
									case GUI_KEY_MENU:
										    WM_BringToTop(Menuwin);
										    WM_SetFocus  (WM_GetDialogItem(Menuwin,ID_MENU));
									     MENU_SetSel (WM_GetDialogItem(Menuwin,ID_MENU),0);
									     MenuSel = 0;
										    break;
				
				     case GUI_KEY_LOC1:
							       pCannel = "  490 横";
							       WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
							       break;
									
				     case GUI_KEY_LOC2:
							       pCannel = "4209.5横";
						       	WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
							       break;
									
				     case GUI_KEY_CHS:
							       pCannel = "  486 横";
							       WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
					         break;
				  
		     		case GUI_KEY_UP:
						       	break;
									
				     case GUI_KEY_DOWN:
					         if (LISTVIEW_GetNumRows(hListview))
				         	{
																	thispage = 1;
																	WM_SetFocus(hListview);
																	LISTVIEW_SetSel(hListview,0);
																	DisPage();			
																	//WM_InvalidateRect(mainwin,&PageRect);  //刷新页数提示
														}
														break;
				
									case GUI_KEY_LEFT:
										    if(InfoType > 0)
											     InfoType--;
										    else InfoType = 3;
					         switch (InfoType)
														{
																case 0:
																					BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]);
																					LISTVIEW_DeleteAllRows(hListview);
																					InfoSel(0,1);
																					break;
																
																case 1:
																					BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]);
																				 LISTVIEW_DeleteAllRows(hListview);
																					InfoSel(1,1);
																	    break;
																
																case 2:
																				BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]);
																			 LISTVIEW_DeleteAllRows(hListview);
																				InfoSel(2,1);
																			 break;
																
																case 3:
																					BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]);
																					LISTVIEW_DeleteAllRows(hListview);
																					InfoSel(3,1);					
																					break;
													}
													if (rowindex<8)
													{	
														pageNum = 1;
													}
													else if (rowindex%8 == 0)
														pageNum = rowindex/8;
													else pageNum = rowindex/8+1;
													thispage = 1;
													DisPage();			
													//WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示
													break;
													
								case GUI_KEY_RIGHT:
												InfoType++;
												if(InfoType == 4)
													  InfoType = 0;
												switch (InfoType)
												{
														case 0:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(0,1);
																		 break;
														
														case 1:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(1,1);
																		 break;
														
														case 2:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(2,1);
																	 	break;
														 
														case 3:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(3,1);		
																			break;
												}
												if (rowindex<8)
												  	pageNum = 1;
												else if (rowindex%8 == 0)
													  pageNum = rowindex/8;
												else pageNum = rowindex/8+1;
												thispage = 1;				
												DisPage();												
												//WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示
												break;
							}
				   break;
							
			default :
			    BUTTON_Callback(pMsg);
		     break;
	}
}
Esempio n. 12
0
/**
  * @brief  Refresh browser.
  * @param  hWin: pointer to the parent handle
  * @retval None
  */
static void _RefreshBrowser ( WM_HWIN hWin) {
  
  WM_HWIN hItem, Hint;
 
  TREEVIEW_ITEM_Handle  hTreeView;
  uint32_t free, total;
  char str[FILEMGR_FULL_PATH_SIZE];
  
  GUI_Exec();
  
  /* Show Hint */
  Hint = WM_CreateWindowAsChild(50,
                                80,
                                140, 32,
                                hWin,
                                WM_CF_SHOW , 
                                _cbHint, 
                                0);
  
  GUI_Exec();
  
  hItem = WM_GetDialogItem(hWin, ID_PROGBAR_USB);
  if(k_StorageGetStatus (MSD_DISK_UNIT))
  {
    free = k_StorageGetFree(MSD_DISK_UNIT);
    total = k_StorageGetCapacity(MSD_DISK_UNIT);
    PROGBAR_SetValue (hItem, ((total - free) * 100)/total);
    hItem = WM_GetDialogItem(hWin, ID_TEXT_MSD); 
    sprintf(str, "microSD  [%lu MB]", total / (2 * 1024)); 
    TEXT_SetText(hItem, str);      
  }
  else
  {
    PROGBAR_SetValue (hItem, 0); 
    hItem = WM_GetDialogItem(hWin, ID_TEXT_MSD); 
    TEXT_SetText(hItem, "microSD   [N/A]" );        
  }
  
  hItem = WM_GetDialogItem(hWin, ID_PROGBAR_MSD);    
  if(k_StorageGetStatus (USB_DISK_UNIT))
  {
    free = k_StorageGetFree(USB_DISK_UNIT);
    total = k_StorageGetCapacity(USB_DISK_UNIT);
    PROGBAR_SetValue (hItem, ((total - free) * 100)/total);
    hItem = WM_GetDialogItem(hWin, ID_TEXT_USB); 
    sprintf(str, "USB Disk [%lu MB]", total / (2 * 1024)); 
    TEXT_SetText(hItem, str);
  }
  else
  {
    PROGBAR_SetValue (hItem, 0); 
    hItem = WM_GetDialogItem(hWin, ID_TEXT_USB); 
    TEXT_SetText(hItem, "USB Disk  [N/A]" );        
  }        
  hTreeView = WM_GetDialogItem(hWin, ID_TREEVIEW);
  hItem = TREEVIEW_GetItem(hTreeView, 0, TREEVIEW_GET_FIRST);
  if(hItem != 0)
  {
    TREEVIEW_ITEM_Delete (hItem);
  }

  
  ExploreDisks(hTreeView);  
  WM_DeleteWindow(Hint); 
  
  WM_InvalidateWindow(hExplorerWin);
  WM_Update(hExplorerWin);
}
Esempio n. 13
0
static void _UpdateCmdWin(void) {
  #if GUI_WINSUPPORT && GUIDEMO_LARGE
    WM_InvalidateWindow(_ahInfoWin[1]);
  #endif
}
Esempio n. 14
0
/*********************************************************************
*
*       _LISTBOX_Callback
*/
static void _LISTBOX_Callback(WM_MESSAGE*pMsg) {
  LISTBOX_Handle hObj = pMsg->hWin;
  LISTBOX_Obj* pObj = LISTBOX_H2P(hObj);
  WM_SCROLL_STATE ScrollState;
  /* Let widget handle the standard messages */
  if (WIDGET_HandleActive(hObj, pMsg) == 0) {
    /* Owner needs to be informed about focus change */
    if (pMsg->MsgId == WM_SET_FOCUS) {
      if (pMsg->Data.v == 0) {            /* Lost focus ? */
        _NotifyOwner(hObj, LISTBOX_NOTIFICATION_LOST_FOCUS);
      }
    }
    return;
  }
  switch (pMsg->MsgId) {
  case WM_NOTIFY_PARENT:
    switch (pMsg->Data.v) {
    case WM_NOTIFICATION_VALUE_CHANGED:
      if (pMsg->hWinSrc  == WM_GetScrollbarV(hObj)) {
        WM_GetScrollState(pMsg->hWinSrc, &ScrollState);
        pObj->ScrollStateV.v = ScrollState.v;
        LISTBOX__InvalidateInsideArea(hObj);
        _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED);
      } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) {
        WM_GetScrollState(pMsg->hWinSrc, &ScrollState);
        pObj->ScrollStateH.v = ScrollState.v;
        LISTBOX__InvalidateInsideArea(hObj);
        _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED);
      }
      break;
    case WM_NOTIFICATION_SCROLLBAR_ADDED:
      LISTBOX_UpdateScrollers(hObj);
      break;
    }
    break;
  case WM_PAINT:
    _OnPaint(hObj, pObj, pMsg);
    break;
  case WM_PID_STATE_CHANGED:
    {
      const WM_PID_STATE_CHANGED_INFO* pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p;
      if (pInfo->State) {
        int Sel;
        Sel = _GetItemFromPos(hObj, pObj, pInfo->x, pInfo->y);
        if (Sel >= 0) {
          _ToggleMultiSel(hObj, pObj, Sel);
          LISTBOX_SetSel(hObj, Sel);
        }
        _NotifyOwner(hObj, WM_NOTIFICATION_CLICKED);
        return;
      }
    }
    break;
  case WM_TOUCH:
    _OnTouch(hObj, pMsg);
    return;
#if GUI_SUPPORT_MOUSE
  case WM_MOUSEOVER:
    if (_OnMouseOver(hObj, pObj, pMsg) == 0)
      return;
    break;
#endif
  case WM_DELETE:
    _FreeAttached(pObj);
    break;       /* No return here ... WM_DefaultProc needs to be called */
  case WM_KEY:
    if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) {
      int Key;
      Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key;
      if (LISTBOX_AddKey(hObj, Key)) {
        return;
      }
    }
    break;
  case WM_SIZE:
    LISTBOX_UpdateScrollers(hObj);
    WM_InvalidateWindow(hObj);
    break;
  }
  WM_DefaultProc(pMsg);
}
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN  hItem, hClient;
  int      NCode;
  int      Id, Index, newpos;
  GUI_RECT r;
  int  ItemNbr;
  static char tmp[FILEMGR_FILE_NAME_SIZE];  
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    
    pVideoList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    pVideoList->ptr = 0;
    
    
    PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP);
    
    /* Initialization of 'Listview' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
    LISTVIEW_AddColumn(hItem, 165, "Video", GUI_TA_VCENTER | GUI_TA_LEFT);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN);

    hItem = BUTTON_CreateEx(201, 182, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON);
    WM_SetCallback(hItem, _cbButton_stop);    
    
    hItem = BUTTON_CreateEx(72, 182, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
    WM_SetCallback(hItem, _cbButton_previous);     
    
    hItem = BUTTON_CreateEx(110, 175,  50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON);
    WM_SetCallback(hItem, _cbButton_play);
    
    hItem = BUTTON_CreateEx(163, 182, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
    WM_SetCallback(hItem, _cbButton_next);
    
    hItem = BUTTON_CreateEx(36,  184, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON);
    WM_SetCallback(hItem, _cbButton_repeat);
    
    hItem = BUTTON_CreateEx(184, 229, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
    WM_SetCallback(hItem, _cbButton_add);      
      
    hItem = BUTTON_CreateEx(184, 260, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON);
    WM_SetCallback(hItem, _cbButton_open); 

    hItem = BUTTON_CreateEx(2, 184, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
    WM_SetCallback(hItem, _cbButton_close);    
    
    hItem = BUTTON_CreateEx(210, 147, 25, 25, pMsg->hWin, WM_CF_SHOW, 0, ID_FULL_SCREEN_BUTTON);
    WM_SetCallback(hItem, _cbButton_fullscreen);      
    
    hClient = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hClient, &r);
    hFrame = WM_CreateWindowAsChild(r.x0 + 5, r.y0 + 5, r.x1 - 10, r.y1 - 148, hClient, WM_CF_SHOW, _cbVideoWindow , 0);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);    
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER);
    SLIDER_SetNumTicks(hItem, 25);
    
    hItem = WM_CreateWindowAsChild(5,
                                   150,
                                   205,
                                   19,
                                   pMsg->hWin, 
                                   WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
                                   _cbDrawProgressSlider, 
                                   0);
    WM_CreateWindowAsChild(240, 320, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0);
    break;
    
  case WM_TIMER:
    Id = WM_GetTimerId(pMsg->Data.v);
    if (Id == ID_PLAYLIST_TIMER)
    {
      playlist_select = 0;
    }    
    break; 
    
  case WM_DELETE:       
    k_BkupSaveParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP, PlayerSettings.d32);    
    WM_DeleteTimer(hPlaylistTimer);
    break;

    
case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    
    if (NCode == WM_NOTIFICATION_CHILD_DELETED)
    {
      if(pMsg->hWinSrc == chooser_openfile)
      {    

        if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF")))
        {                   
          
          pVideoList->ptr = 0;
          
          strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot);
          FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
          
          /* Update Play list */
          strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot);
          
          ItemNbr = LISTVIEW_GetNumRows(hItem);
          while(ItemNbr--)
          {
            LISTVIEW_DeleteRow(hItem, ItemNbr);
          }
          
          LISTVIEW_AddRow(hItem, NULL);         
          LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp);
          pVideoList->ptr++;  
          file_pos = 0;
          LISTVIEW_SetSel(hItem, 0);
          _StartPlay((char *)pVideoList->file[file_pos].name);
          WM_InvalidateWindow(hFrame);
          
        }
        chooser_openfile = 0;
      }
      
      if(pMsg->hWinSrc == chooser_addfolder)
      {
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Play(hMovie);
        }
        _AddEntireFolder(pFileInfo->pRoot);

        WM_InvalidateWindow(hFrame);
        chooser_addfolder = 0;
      }    
      
      if(pMsg->hWinSrc == chooser_add2playlist)
      {
        if(VideoPlayer_State == VIDEO_PLAY)
        {
           GUI_MOVIE_Play(hMovie);  
        }     
        if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF")))
        {
          if(pVideoList->ptr < FILEMGR_LIST_DEPDTH)
          {
            strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot);
            FILEMGR_GetFileOnly ((char *)tmp, (char *)pFileInfo->pRoot);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
            
            LISTVIEW_AddRow(hItem, NULL);         
            LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp);
            pVideoList->ptr++;
          }
        }
        
        WM_InvalidateWindow(hFrame);
        chooser_add2playlist = 0;
      } 
    }    

    switch(Id) {
      
      /* Notification sent by "Close Button" */  
    case ID_FULL_SCREEN_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_RELEASED:
        if( VideoPlayer_State != VIDEO_IDLE)
        {
          _ShowFullScreen();
        }
        break;
      }
      break;
      
    /* Notifications sent by 'Add' Button */
    case ID_ADD_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if((chooser_openfile == 0) && (chooser_addfolder == 0) && (chooser_add2playlist == 0))
        {
          pFileInfo->pfGetData = k_GetData;
          pFileInfo->pMask = acMask_video;     
          chooser_add2playlist = CHOOSEFILE_Create(pMsg->hWin,  10, 10, 220, 210, &apDrives, 1, 0, "Add a video file to playlist", 0, pFileInfo);        
          if(VideoPlayer_State == VIDEO_PLAY)
          {
            GUI_MOVIE_Pause(hMovie);
          }
        }
        break;
        
      }
      break;       
      
    /* Notifications sent by 'Open' Button */
    case ID_OPEN_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if((chooser_openfile == 0) && (chooser_addfolder == 0) && (chooser_add2playlist == 0))
        {
          pFileInfo->pfGetData = k_GetData;
          pFileInfo->pMask = acMask_dir;     
          chooser_addfolder = CHOOSEFILE_Create(pMsg->hWin,  10, 10, 220, 210, &apDrives, 1, 0, "Add a folder", 0, pFileInfo);        
          if(VideoPlayer_State == VIDEO_PLAY)
          {
            GUI_MOVIE_Pause(hMovie);
          }
        }
        break;
      }
      break;      
      
      /* Notification sent by "Full Screen button" */  
    case ID_CLOSE_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_RELEASED:
        k_free(pVideoList); 
        k_free(pFileInfo);   
        _StopPlay();
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;      
      
      /* Notification sent by "Play Button" */  
    case ID_PLAY_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if(VideoPlayer_State == VIDEO_IDLE)
        {
          if (pVideoList->ptr > 0)
          {
            _StartPlay((char *)pVideoList->file[file_pos].name);
            LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos);
          }
          else
          {
            pFileInfo->pfGetData = k_GetData;
            pFileInfo->pMask = acMask_video;     
            chooser_openfile = CHOOSEFILE_Create(pMsg->hWin,  10, 10, 220, 210, &apDrives, 1, 0, "Open a video file", 0, pFileInfo);         
          }        
          
        }
        else if(VideoPlayer_State == VIDEO_PLAY)
        {
          _PausePlay();         
        }
        else if(VideoPlayer_State == VIDEO_PAUSE)
        {
          _ResumePlay();  
        }        
        break;
      }
      break;

    case ID_REPEAT_BUTTON:      
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON);   
        
        if(PlayerSettings.b.repeat == REPEAT_NONE)
        {
          PlayerSettings.b.repeat = REPEAT_ONCE;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ONCE)
        {
          PlayerSettings.b.repeat = REPEAT_ALL;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ALL)
        {
          PlayerSettings.b.repeat = REPEAT_NONE;
        }
      }
      break;
      
    case ID_STOP_BUTTON:
      _StopPlay();  
      hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PROGRESS_SLIDER);
      SLIDER_SetValue(hItem, 0);
      WM_InvalidateWindow(hFrame);
      break;
      
    case ID_NEXT_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(file_pos < (pVideoList->ptr - 1))
        {
          /*Play Next */
          file_pos++;
          LISTVIEW_IncSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); 
        }
        else if(PlayerSettings.b.repeat == REPEAT_ALL)
        {
          file_pos = 0; 
          LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos);
        }           

        if(VideoPlayer_State == VIDEO_PLAY)
        {
          _StopPlay();
          _StartPlay((char *)pVideoList->file[file_pos].name);
          WM_InvalidateWindow(hFrame);
        }
        break;
      }
      break;
      
      
    case ID_PREVIOUS_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if( pVideoList->ptr > 0)
        {
          if(file_pos > 0)
          {   
            file_pos--;
            LISTVIEW_DecSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST));             
          }
          else if(PlayerSettings.b.repeat == REPEAT_ALL)
          {
            file_pos = (pVideoList->ptr - 1); 
            LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos);
          } 
          if(VideoPlayer_State == VIDEO_PLAY)
          {
            _StopPlay();
            _StartPlay((char *)pVideoList->file[file_pos].name);
            WM_InvalidateWindow(hFrame);
          }
        }    
        break;
        
      }
      break;
      
    /* Notifications sent by 'progress' Slider */
    case ID_PROGRESS_SLIDER: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          GUI_MOVIE_Pause(hMovie);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER);
          newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100;
          GUI_MOVIE_GotoFrame(hMovie, newpos);
          if(VideoPlayer_State == VIDEO_PLAY)
          {
            GUI_MOVIE_Play(hMovie);
          }
        }
      }
      break;
      
    /* Notifications sent by 'ListView' Slider */
    case ID_VIDEO_LIST: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
        Index = LISTVIEW_GetSel(hItem);
        
        if(Index < pVideoList->ptr)
        {
          file_pos = Index;
          
          if(playlist_select == 0)
          {
            hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0);           
            playlist_select = (Index + 1);
          }
          
          else if(playlist_select == (Index + 1))
          {
            WM_DeleteTimer(hPlaylistTimer); 
            hPlaylistTimer = 0;          
            playlist_select = 0;
            
            if(Index < pVideoList->ptr)
            {
              if(VideoPlayer_State != VIDEO_IDLE)
              {
                _StopPlay();
              } 
              
              _StartPlay((char *)pVideoList->file[Index].name); 
              hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem); 
              WM_InvalidateWindow(hFrame);
            }
          }
        }
      }
      break;   
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/**
  * @brief  Start play
  * @param  filename: pointer to the video file name
  * @retval None
  */
static uint8_t _StartPlay(GUI_MOVIE_HANDLE *hmovie, char * filename, FIL * file, uint16_t x0, uint16_t y0) 
{

  static char tmp[FILEMGR_FILE_NAME_SIZE]; 
  uint32_t ms, frames, duration;  
  WM_HWIN  hItem;
  
  if(f_open(file, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK)
  {
    
    
    PrevFrameIndex = 0;
    LostFrames = 0;
    previous_total = 0;
    
    GUI_MOVIE_GetInfoEx(_GetData, file, &Video_Info);
    
    *hmovie = GUI_MOVIE_CreateEx(_GetData, file, _cbNotify) ;
    GUI_MOVIE_SetPeriod (*hmovie, VIDEO_FRAME_TIME);
    
    if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || 
       (Video_Info.xSize > LCD_GetXSize()) || (Video_Info.ySize > LCD_GetYSize()))
    {
      _StopPlay(hmovie, file);
      VideoPlayer_State = VIDEO_STOP;
      
      hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME);
      FILEMGR_GetFileOnly (tmp, filename);
      TEXT_SetText(hItem, tmp);
      
      hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
      TEXT_SetText(hItem, "00:00");
      WM_InvalidateWindow(hItem);
      WM_Paint(hItem);
      
      hItem = WM_GetDialogItem(playbackwin, ID_TIME);
      TEXT_SetText(hItem, "00:00");
      WM_InvalidateWindow(hItem);
      WM_Paint(hItem);
      
      hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_FORMAT);
      sprintf(tmp, "Format : UNSUPPORTED      [%lu/%d]", Video_FilePos + 1, VideoList.ptr) ;
      TEXT_SetText(hItem, tmp);
      WM_InvalidateWindow(hItem);
      WM_Paint(hItem);   
      return 1;
    }
    
    GUI_MOVIE_Show(*hmovie, ((LCD_GetXSize() - Video_Info.xSize)/2), ((LCD_GetYSize() - Video_Info.ySize)/2), 0); 
    
    hTimer = WM_CreateTimer(playbackwin, ID_TIMER_PROCESS, 1000, 0);  
    
    /* Update video total time */
    hItem = WM_GetDialogItem(playbackwin, ID_TIME);
    ms = Video_Info.msPerFrame;
    frames = Video_Info.NumFrames;
    duration = (frames * ms)/1000;
    sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
    TEXT_SetText(hItem, tmp);          
    WM_InvalidateWindow(playbackwin);  
    elapsed_time = 0;
    
    hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME);
    FILEMGR_GetFileOnly (tmp, filename);
    TEXT_SetText(hItem, tmp);
    
    hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
    TEXT_SetText(hItem, "00:00");
    WM_InvalidateWindow(hItem);
    WM_Paint(hItem);
    
    hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_FORMAT);
    sprintf(tmp, "Format : MJPEG            [%lu/%d]", Video_FilePos + 1, VideoList.ptr) ;
    TEXT_SetText(hItem, tmp);
    WM_InvalidateWindow(hItem);
    WM_Paint(hItem);    
    
  }
  return 0;
}
/**
  * @brief  Callback function of the media connection status
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbMediaConnection(WM_MESSAGE * pMsg) 
{
  static WM_HTIMER      hStatusTimer;  
  static uint8_t        prev_usb_status = 0;
  WM_HWIN hItem = 0;

  static char tmp[64];
  uint32_t i = 0;
  
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);    
    hStatusTimer = WM_CreateTimer(pMsg->hWin, ID_TIMER_CONNECTION, 500, 0);      
    break;
    
  case WM_TIMER:
  if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
    {
      prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
      if(prev_usb_status == 0)
      { 
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        VideoList.ptr = 0;
        if(playbackwin)
        {
          GUI_EndDialog(playbackwin, 0);
          playbackwin = 0;
          
          SelLayer = 0;
          GUI_SetLayerVisEx (1, 0);
          GUI_SelectLayer(0);
          WM_InvalidateWindow(VideoWin);
        }
        if(hFrame)
        {
          WM_HideWindow(hFrame);        
          WM_Exec();        
          WM_DeleteWindow(hFrame);
          hFrame = 0;
        }
        if(hPlaylistWin)
        {
          hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
          i = LISTVIEW_GetNumRows(hItem);
          while(i--)
          {
            LISTVIEW_DeleteRow(hItem, i);
          }
        }
      }
      else
      {
        VideoList.ptr = 0;
        _AddEntireFolder("0:");
        _AddEntireFolder("0:/Video");
        
        if(hPlaylistWin)
        {
          if(VideoList.ptr > 0)
          {
            for(i=0; i<VideoList.ptr; i++)
            {
              strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
              FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
              hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
              
              LISTVIEW_AddRow(hItem, NULL);         
              LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
            }
            WM_InvalidateWindow(hItem);
            WM_Update(hItem); 
          } 
        }
        
      }
    }
    WM_RestartTimer(pMsg->Data.v, 500);
    break;
    
  case WM_DELETE:
    if(hStatusTimer != 0)
    {
      WM_DeleteTimer(hStatusTimer);
      hStatusTimer = 0;
    }
    break;   
    
  default:
    WM_DefaultProc(pMsg);
  }
}
Esempio n. 18
0
/**
  * @brief  Callback routine of the main 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:
    
    frame = 0;
    hTimer = WM_CreateTimer(pMsg->hWin, 0, 50, 0);
  
    hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit);
    
    /* Initialization of 'Board*/
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOARD);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);

    /* Initialization of 'Core: STM32F-4 Series' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CORE);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);

    /* Initialization of 'CPU Speed : 180MHz' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CPU);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);

    /* Initialization of 'Firmware Version*/
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_VERSION);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE); 

    /* Initialization of 'Board*/
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOARD_1);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);

    /* Initialization of 'Board */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOARD_2);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);    
    
    /* Initialization of 'Core: STM32F-4 Series' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CORE_1);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);

    /* Initialization of 'CPU Speed : 180MHz' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CPU_1);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);

    /* Initialization of 'Firmware Version*/
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_VERSION_1);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE); 
    
    /* ST Copyright */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_COPYRIGHT);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph16);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);

    /* ST Copyright */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_TITLE);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph32B);
    TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);
    
    break;     
    
  case WM_PAINT:    
    GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
    GUI_AA_DrawRoundedRect(30,  140, 200, 340, 30);
    GUI_AA_DrawRoundedRect(220, 140, 390, 340, 30);
    GUI_AA_DrawRoundedRect(410, 140, 580, 340, 30);
    GUI_AA_DrawRoundedRect(600, 140, 770, 340, 30);
    
    GUI_DrawBitmap(open_board[frame]   , 65,  190);
    GUI_DrawBitmap(open_mcu[frame]     , 255, 190);
    GUI_DrawBitmap(open_cpu[frame]     , 445, 190);
    GUI_DrawBitmap(open_fversion[frame], 635, 190);
      
    break;     

  case WM_TIMER:
    if(frame < 4)
    {
      WM_InvalidateWindow(pMsg->hWin);
      WM_RestartTimer(pMsg->Data.v, 50);
      frame++;
    }
    else
    {
      if(hTimer != 0)
      {
        WM_DeleteTimer(hTimer);
        hTimer = 0;
      }  
    }    
    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(hTimer != 0)
        {
          WM_DeleteTimer(hTimer);
          hTimer = 0;
        }         
        GUI_EndDialog(pMsg->hWin, 0);

        break;
      }
      break;      
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }    
}
Esempio n. 19
0
/**
  * @brief  callback for video window
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbplaybackwin(WM_MESSAGE * pMsg) 
{
  WM_HWIN hItem;
  int Id, NCode;
  char tmp[64];
  
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    SelLayer = 1;    
   
    hItem = BUTTON_CreateEx(398 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_BACK);
    WM_SetCallback(hItem, _cbButton_back);
    
    hItem = BUTTON_CreateEx(449 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_STOP);
    WM_SetCallback(hItem, _cbButton_stop); 

    hItem = BUTTON_CreateEx(495 - 160, 441, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, PLAY_VIDEO_ID);
    WM_SetCallback(hItem, _cbButton_play);
        
    hItem = BUTTON_CreateEx(540 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_FORE);
    WM_SetCallback(hItem, _cbButton_fore);
    
    hItem = SLIDER_CreateEx(72, 420, 510, 13, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDER_DURATION);
    SLIDER_SetBkColor(hItem, GUI_TRANSPARENT);
    SLIDER_SetFocusColor (hItem, 0x00DCA939);
    SLIDER_SetValue(hItem, 0);
    SLIDER_SetWidth(hItem, 0);
    SLIDER_SetSTSkin(hItem);    
       
    hItem = BUTTON_CreateEx(568, 0, 70, 70, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_MENU);
    WM_SetCallback(hItem, _cbButton_menu);     
    
    hItem = BUTTON_CreateEx(0, 410, 70, 70, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT_FROM_VIDEO);
    WM_SetCallback(hItem, _cbButton_exit1);   
    
    /* Title Initialization in play list */   
    hItem = TEXT_CreateEx(10, 20, 100, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_ELAPSED_TIME, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_20B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);     
    
    /* Title Initialization in play list */   
    hItem = TEXT_CreateEx(50, 40, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_TIME, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_16B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);  
    
    hItem = TEXT_CreateEx(150, 20, 350, 30, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_NAME, "File Name");
    TEXT_SetFont(hItem, GUI_FONT_20B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE); 
    
    hItem = TEXT_CreateEx(150, 48, 350, 30, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_FORMAT, "Format : MJPEG");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);
    
    hItem = TEXT_CreateEx(548, 200, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FPS, "Rate : 20 fps");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);   
    
    hItem = TEXT_CreateEx(548, 220, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_FPU, "FPU : ON");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE); 
    
    hItem = TEXT_CreateEx(548, 240, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_IC, "I-Cache : ON");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);     
    
    hItem = TEXT_CreateEx(548, 260, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_DC, "D-Cache : ON");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);  

    hItem = TEXT_CreateEx(548, 280, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_CPU, "MCU Load : 0%");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);       
    
    break;
    
  case WM_TIMER:
    { 
      WM_RestartTimer(pMsg->Data.v, 1000);
      /* show elapsed time */
      hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
      elapsed_time++;
      sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 );
      TEXT_SetText(hItem, tmp);
      sprintf((char *)tmp , "MCU Load : %d%%", ((osGetCPUUsage() > 90) ? (osGetCPUUsage() - 10) : osGetCPUUsage()));
      hItem = WM_GetDialogItem(pMsg->hWin, ID_FEATURES_CPU);
      TEXT_SetText(hItem, tmp);
      
      hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
      SLIDER_SetValue(hItem, (GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames);
      
      if(step == 0)
      {
        step = ((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames);
      }

      if(((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames) > (100 - 2*step - 1))
      {
        SLIDER_SetValue(hItem, 100);
        GUI_Exec();
      }
      
    }
    break;
    
  case WM_DELETE:
    if(hTimer != 0)
    {
      WM_DeleteTimer(hTimer);
      hTimer = 0;
    }
    
  case WM_PAINT: 
    GUI_SetColor(0xFF000000 | GUI_BLACK);
    GUI_SetBkColor(GUI_TRANSPARENT);
    GUI_Clear();

    GUI_SetColor(GUI_BLACK);
    GUI_DrawHLine(0, 0, 640);
    GUI_DrawHLine(479, 0, 640);
    GUI_DrawLine(639, 0, 639, 480);   
    GUI_DrawLine(0, 0, 0, 480);

    /* Background for total time */
    GUI_SetColor(0x00DCA939);
    GUI_AA_FillRoundedRect((-30), 5, 90, 65, 30);
    
    /*Video Information */
    GUI_AA_FillRoundedRect(150, 5, 500, 65, 30);
    
    /*H/W Information */
    GUI_AA_FillRoundedRect(538, 180, 780, 320, 30);    
    
    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_FROM_VIDEO: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        GUI_EndDialog(pMsg->hWin, 0);
        SelLayer = 0;
        GUI_SetLayerVisEx (1, 0);
        GUI_SelectLayer(0); 
        WM_HideWindow(hFrame);        
        WM_Exec();        
        WM_DeleteWindow(hFrame);
        WM_InvalidateWindow(VideoWin);
        break;
      }
      break;

    case ID_BUTTON_MENU: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        GUI_EndDialog(pMsg->hWin, 0);
        SelLayer = 0;
        GUI_SetLayerVisEx (1, 0);
        GUI_SelectLayer(0); 
        WM_DeleteWindow(hFrame);
        WM_HideWindow(VideoWin);        
        WM_Exec();
        WM_DeleteWindow(VideoWin);
        break;
      }
      break;
      
    case ID_BUTTON_STOP: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          VideoPlayer_State = VIDEO_STOP;
          _StopPlay(&hvideo, &Video_File);
        }
         WM_InvalidateWindow(pMsg->hWin);
        break;
      }
      break;
     
    case ID_BUTTON_FORE: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          if(file_pos < (VideoList.ptr - 1))
          {
            file_pos++;
          }
          else 
          {        
            file_pos = 0; 
          }  
          _StopPlay(&hvideo, &Video_File);
          _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0);

        }
        break;
      }
      break;
      
    /* Notifications sent by 'progress' Slider */
    case ID_SLIDER_DURATION: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
        int32_t newpos;
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Pause(hvideo);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
          newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100;
          GUI_MOVIE_GotoFrame(hvideo, newpos);
          GUI_MOVIE_Play(hvideo);
          elapsed_time = (Video_Info.msPerFrame * newpos)/ 1000;
          hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
          sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 );
          TEXT_SetText(hItem, tmp); 
          WM_InvalidateWindow(hItem);
          WM_Paint(hItem);
        }
        
      }
      break;
      
      
    case ID_BUTTON_BACK: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          if(file_pos > 0)
          {   
            file_pos--;
          }
          else 
          {        
            file_pos = VideoList.ptr - 1; 
          }  
          
          _StopPlay(&hvideo, &Video_File);
          _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0); 
        }
        break;
      }
      break;
      
    case PLAY_VIDEO_ID: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
          if((VideoPlayer_State == VIDEO_IDLE) || (VideoPlayer_State == VIDEO_PAUSE))
          {
            hTimer = WM_CreateTimer(playbackwin, 0, 1000, 0);  
            GUI_MOVIE_Play(hvideo); 
            VideoPlayer_State = VIDEO_PLAY;
          }
          else if(VideoPlayer_State == VIDEO_STOP)
          {
            _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0);             
            VideoPlayer_State = VIDEO_PLAY;
          }
          else
          {
            GUI_MOVIE_Pause(hvideo);
            VideoPlayer_State = VIDEO_PAUSE; 
            if(hTimer != 0)
            {
              WM_DeleteTimer(hTimer);
              hTimer = 0;
            }            
          }
        break;
      }
      break;       
    }
    break;

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 20
0
/*********************************************************************
*
*       _DemoMultiedit
*/
static void _DemoMultiedit(void) {
  GUI_RECT Rect;
  int WinFlags;
  _hFrame = 1;
  _Overwrite = 0;
  _ReadOnly  = 0;
  _Password  = 0;
  /* Create framewin */
  _ChangeInfoText("Create framewin", SPEED);
  _hFrame = FRAMEWIN_CreateEx(60, 80, 200, 120, WM_HBKWIN, WM_CF_SHOW, 0, 0, "Notepad", 0);
  _hClient = WM_GetClientWindow(_hFrame);
  _pcbFrameWin       = WM_SetCallback(_hFrame,  _cbFrameWin);
  _pcbFrameWinClient = WM_SetCallback(_hClient, _cbFrameWinClient);
  /* Set framewin properties */
  FRAMEWIN_SetMoveable(_hFrame, 1);
  FRAMEWIN_SetActive(_hFrame, 1);
  FRAMEWIN_SetTextAlign(_hFrame, GUI_TA_HCENTER | GUI_TA_VCENTER);
  FRAMEWIN_SetFont(_hFrame, &GUI_Font8x12_ASCII);
  FRAMEWIN_SetTitleHeight(_hFrame, 16);
  /* Add framewin buttons */
  if (_ChangeInfoText("Add framewin buttons", SPEED)) return;
  FRAMEWIN_AddCloseButton(_hFrame, FRAMEWIN_BUTTON_LEFT,  0);
  FRAMEWIN_AddMaxButton(_hFrame, FRAMEWIN_BUTTON_RIGHT, 0);
  FRAMEWIN_AddMinButton(_hFrame, FRAMEWIN_BUTTON_RIGHT, 1);
  WM_InvalidateWindow(_hFrame);
  /* Create buttons */
  if (_ChangeInfoText("Add option buttons", SPEED)) return;
  _hWrapButton = _CreateLButton("None",   0, 36, 16, _hClient, ID_NONEWRAP);
                 _CreateLButton("Word",  37, 36, 16, _hClient, ID_WORDWRAP);
                 _CreateLButton("Char",  74, 36, 16, _hClient, ID_CHARWRAP);
                 _CreateRButton("PSW",   52, 25, 16, _hClient, ID_PASSWORD);
                 _CreateRButton("OVR",   26, 25, 16, _hClient, ID_OVERWRITE);
                 _CreateRButton("R/O",    0, 25, 16, _hClient, ID_READONLY);
  _SetButtonState(_hWrapButton, 1);
  /* Create multiedit */
  if (_ChangeInfoText("using\nMULTIEDIT_CreateEx", SPEED)) return;
  WinFlags = WM_CF_SHOW | WM_CF_ANCHOR_RIGHT | WM_CF_ANCHOR_LEFT | WM_CF_ANCHOR_TOP | WM_CF_ANCHOR_BOTTOM;
  WM_GetClientRectEx(_hClient, &Rect);
  _hMEdit = MULTIEDIT_CreateEx(0, 0, 0, Rect.y1 - 16 + 1, _hClient, WinFlags, MULTIEDIT_CF_INSERT, 0, 0, "");
  _pcbMultiEdit = WM_SetCallback(_hMEdit,  _cbMultiEdit);
  MULTIEDIT_SetAutoScrollH(_hMEdit, 1);
  MULTIEDIT_SetAutoScrollV(_hMEdit, 1);
  WM_SetFocus(_hMEdit);
  if (_ChangeInfoText("using\nMULTIEDIT_SetText", SPEED)) return;
  MULTIEDIT_SetText(_hMEdit, "This sample demonstrates the use of a multiedit widget!");
  if (_ChangeInfoText("using\nMULTIEDIT_SetFont", SPEED)) return;
  MULTIEDIT_SetFont(_hMEdit, &GUI_Font16_1);
  if (_ChangeInfoText("using\nMULTIEDIT_SetTextColor", SPEED)) return;
  MULTIEDIT_SetTextColor(_hMEdit, 0, 0xE00000);
  if (_ChangeInfoText("using\nMULTIEDIT_SetBkColor", SPEED)) return;
  MULTIEDIT_SetBkColor(_hMEdit, 0, 0xD0FFFF);
  if (_ChangeInfoText("using\nMULTIEDIT_SetWrapWord", SPEED)) return;
  MULTIEDIT_SetWrapWord(_hMEdit);
  _SetButtonState(_hWrapButton, 0);
  _hWrapButton = WM_GetDialogItem(_hClient, ID_WORDWRAP);
  _SetButtonState(_hWrapButton, 1);
  if (_ChangeInfoText("using\nMULTIEDIT_SetHBorder", SPEED)) return;
  MULTIEDIT_SetHBorder(_hMEdit, 3);
  if (_ChangeInfoText("using\nMULTIEDIT_SetPrompt", SPEED)) return;
  MULTIEDIT_SetPrompt(_hMEdit, "Type: ");
  if (_ChangeInfoText("Play with multiedit...", SPEED)) return;
  while (_hFrame) {
    GUI_Delay(100);
  }
}
Esempio n. 21
0
/*********************************************************************
*
*       _cbInvalidateOne
*/
static void _cbInvalidateOne(WM_HWIN hWin, void * p) {
  GUI_USE_PARA(p);
  WM_InvalidateWindow(hWin);
}
/**
  * @brief  Callback function of the Clock window
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbClockWindow(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  static WM_HTIMER hTimerTime;  
  RTC_TimeTypeDef   RTC_TimeStructure;
  RTC_DateTypeDef   RTC_DateStructure;
  uint8_t sec, min, hour, day, month;
  uint16_t year;
  static uint8_t TempStr[50];
  static  CALENDAR_DATE   current_date;
  
  switch (pMsg->MsgId) 
  {
    
  case WM_CREATE:
    RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
    current_date.Year = RTC_DateStructure.RTC_Year + 2000;
    current_date.Month = RTC_DateStructure.RTC_Month;
    current_date.Day = RTC_DateStructure.RTC_Date;
    /* Create timer */
    hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 1000, 0);        
    break;
    
  case WM_TIMER:
    /* Write date and clock */
    RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
    sec    =  RTC_TimeStructure.RTC_Seconds;
    min    =  RTC_TimeStructure.RTC_Minutes;
    hour   =  RTC_TimeStructure.RTC_Hours;
    
    RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
    year =  RTC_DateStructure.RTC_Year + 2000;
    month =  RTC_DateStructure.RTC_Month;
    day =  RTC_DateStructure.RTC_Date;  
    
    if((current_date.Day != day) ||(current_date.Month != month)
       ||(current_date.Year != year))
    {
      current_date.Year = year =  RTC_DateStructure.RTC_Year + 2000;
      current_date.Month = month =  RTC_DateStructure.RTC_Month;
      current_date.Day = day =  RTC_DateStructure.RTC_Date;
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_TEXT_DATE);    
      sprintf((char *)TempStr, "%02d, %s, %04d",day , strMonth[month-1], year);
      TEXT_SetText(hItem, (char *)TempStr);
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CALENDAR);
      CALENDAR_SetDate(hItem, &current_date);
      CALENDAR_SetSel(hItem, &current_date);
      WM_InvalidateWindow(hItem);
    }
    
    hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_TEXT_CLOCK);
    sprintf((char *)TempStr, "%02d:%02d:%02d",hour , min, sec);
    TEXT_SetText(hItem, (char *)TempStr);
    
    WM_InvalidateWindow(pMsg->hWin);
    WM_RestartTimer(pMsg->Data.v, 0);
    
    break; 
    
  case WM_DELETE:
    WM_DeleteTimer(hTimerTime);
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
}
/**
  * @brief  Callback function of the image frame
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbImageWindow(WM_MESSAGE * pMsg)
{
  WM_HWIN  hItem;
  GUI_RECT r;
  int Id;
  const GUI_PID_STATE * pState;
  
  switch (pMsg->MsgId)
  {
  case  WM_TOUCH:
    pState = (const GUI_PID_STATE *)pMsg->Data.p;
    if(pImageList->ptr > 0)
    {
      if (pState) {
        if (pState->Pressed == 1)
        {
          IMAGE_Enlarge ^= 1;
          if (IMAGE_Enlarge)
          {
            WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindowAt(pMsg->hWin, IMAGE_hWin, 15, 15);
            WM_SetSize(pMsg->hWin, 420, 370);
          }
          WM_InvalidateWindow(pMsg->hWin);
        }
      }
    }
    break;
      
    
  case WM_PAINT:
    WM_GetInsideRect(&r);
    GUI_ClearRectEx(&r);
    if (pImageList->ptr > 0)
    {
      if(_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0)
      {
        f_close(&Image_File);
                  
        GUI_ClearRectEx(&r);
        GUI_DispStringAt("Error : Image cannot be displayed", 35,  100); 
        if(hTimerTime != 0)
        {
          slideshow_state = OFF;
          
          hItem = WM_GetDialogItem(IMAGE_hWin, ID_SLIDE_BUTTON);
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);
          
          WM_DeleteTimer(hTimerTime);
          hTimerTime = 0;

        }        
      }
    }
    break;
    
  case WM_TIMER:
    
   Id = WM_GetTimerId(pMsg->Data.v);
            
   if(Id == ID_SLIDER_TIMER)
   {
     if(pImageList->ptr > 1)
     {
       if (file_pos < (pImageList->ptr - 1))
       {
         file_pos++;
       }
       else if (file_pos == (pImageList->ptr - 1))
       {
         file_pos=0;
       }
       
       if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
       {
         IMAGE_Type = IMAGE_TYPE_BMP;
       }
       else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
       {
         IMAGE_Type = IMAGE_TYPE_JPG;
       }
       
       f_close(&Image_File);
       f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
       WM_InvalidateWindow(imFrame);
       hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
       LISTBOX_SetSel(hItem, file_pos);
     }
     
     WM_RestartTimer(pMsg->Data.v, (ImSettings.b.ss_timer * 1000));
   }
   else if (Id == ID_PLAYLIST_TIMER)
   {
     playlist_select = 0;
   }    
   break;
    
  case WM_DELETE:
    if(hTimerTime != 0)
    {
      WM_DeleteTimer(hTimerTime);
      hTimerTime = 0;
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
  
}
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN  hItem;
  int Id, NCode;
  RTC_TimeTypeDef   RTC_TimeStructure;
  RTC_DateTypeDef   RTC_DateStructure;
  uint8_t sec, min, hour, day, month;
  uint16_t year;
  uint8_t offset, max;
  static uint8_t TempStr[50];
  
  switch (pMsg->MsgId) {
    
  case WM_PAINT:
    break;
    
  case WM_INIT_DIALOG:
    
    RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
    sec    =  RTC_TimeStructure.RTC_Seconds;
    min    =  RTC_TimeStructure.RTC_Minutes;
    hour   =  RTC_TimeStructure.RTC_Hours;
    
    RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
    year =  RTC_DateStructure.RTC_Year + 2000;
    month =  RTC_DateStructure.RTC_Month;
    day =  RTC_DateStructure.RTC_Date;
    
    /* Initialization of 'System Information' */
    hItem = pMsg->hWin;
    FRAMEWIN_SetFont(hItem, GUI_FONT_13B_ASCII);
    
    /* Initialization of 'Close' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CLOSE_CLOCK);
    BUTTON_SetFont(hItem, GUI_FONT_13B_ASCII);
    
    /* Set date in text mode */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DATE);
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, 0x00804000);
    
    WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbClockWindow , 0);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CLOCK);
    TEXT_SetFont(hItem, &GUI_FontBauhaus9332);
    TEXT_SetTextColor(hItem, 0x00804000);   
    
    /* Set Init values */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DATE);
    
    /* Write date and clock */
    sprintf((char *)TempStr, "%02d, %s, %04d",day , strMonth[month-1], year);
    TEXT_SetText(hItem, (char *)TempStr);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CLOCK);
    sprintf((char *)TempStr, "%02d:%02d:%02d",hour , min, sec);
    TEXT_SetText(hItem, (char *)TempStr);
    
    GetDateOffset (year, month, &offset , &max);
    
    CALENDAR_SetDefaultSize(CALENDAR_SI_HEADER, 25 );
    CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_X, 30 );
    CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_Y, 20 );
    
    CALENDAR_SetDefaultFont(CALENDAR_FI_CONTENT,GUI_FONT_16B_1 );
    CALENDAR_SetDefaultFont(CALENDAR_FI_HEADER, GUI_FONT_16B_1) ;    
    
    CALENDAR_Create(pMsg->hWin, 15, 70, year, month, day, 2, ID_CALENDAR, WM_CF_SHOW);
    
    WM_InvalidateWindow(pMsg->hWin);    
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:      /* React only if released */
      switch (Id) {
      case ID_BUTTON_CLOSE_CLOCK:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
        
      case ID_BUTTON_SETTINGS_CLOCK:
        GUI_CreateDialogBox(_aDialogSettingsCreate, GUI_COUNTOF(_aDialogSettingsCreate), &_cbDialogSettings, pMsg->hWin, 0, 0);
        hNumPad = GUI_CreateDialogBox(_aDialogNumPad, 
                                      GUI_COUNTOF(_aDialogNumPad), 
                                      _cbDialogNumPad, WM_GetDesktopWindowEx(1), 0, 0); /* Create the numpad dialog */
        WM_SetStayOnTop(hNumPad, 1);        
        break;
      }
      
      break;
      
    case WM_NOTIFICATION_CHILD_DELETED:
      WM_NotifyParent(WM_GetParent(pMsg->hWin), 0x500);
      break; 
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/**
  * @brief  Callback function of the media connection status
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbMediaConnection(WM_MESSAGE * pMsg) 
{
  WM_HWIN hItem;
  static WM_HTIMER      hStatusTimer;  
  static uint8_t        prev_sd_status = 0;
  static uint8_t        prev_usb_status = 0;
  
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    prev_sd_status = k_StorageGetStatus(MSD_DISK_UNIT);
    prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);    
    hStatusTimer = WM_CreateTimer(pMsg->hWin, 0, 500, 0);      
    break;
    
  case WM_TIMER:
    if(prev_sd_status != k_StorageGetStatus(MSD_DISK_UNIT))
    {
      prev_sd_status = k_StorageGetStatus(MSD_DISK_UNIT);
      if(pWavList->file[file_pos].name[0] == '1')
      {
        if(PlayerSettings.b.pause == PAUSE_ACTIVE)
        {  
          PlayerSettings.b.pause = PLAY_ACTIVE;
        } 
        AUDIOPLAYER_Stop();
        hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_ELAPSED_TIME);
        TEXT_SetText(hItem, "00:00");            

        hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_PLAY_BUTTON);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);          
      }
    }
    else if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
    {
      prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
      if(pWavList->file[file_pos].name[0] == '0')
      {
        
        if(PlayerSettings.b.pause == PAUSE_ACTIVE)
        {  
          PlayerSettings.b.pause = PLAY_ACTIVE;
        } 
        AUDIOPLAYER_Stop();
        hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_ELAPSED_TIME);
        TEXT_SetText(hItem, "00:00");            

        hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_PLAY_BUTTON);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);          
      }
    }
    WM_RestartTimer(pMsg->Data.v, 500);
    break;
    
  case WM_DELETE:
    if(hStatusTimer != 0)
    {
      WM_DeleteTimer(hStatusTimer);
      hStatusTimer = 0;
    }
    break;   
    
  default:
    WM_DefaultProc(pMsg);
  }
}
Esempio n. 26
0
/**
  * @brief  Callback routine of desktop window.
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbBk(WM_MESSAGE * pMsg) {
  
  uint32_t NCode, Id;
  uint8_t sel;
    
  switch (pMsg->MsgId) 
  {
  case WM_PAINT:
    GUI_SetBkColor(GUI_WHITE);
    GUI_Clear();

    /*H/W Information */
    GUI_SetColor(0x007B10D3);
    GUI_AA_FillRoundedRect(520, 220, 780, 478, 30);
    GUI_DrawBitmap(&bmF7Logo, 530, 240); 
    break;
       
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);     
    NCode = pMsg->Data.v;  
    
    switch (NCode) 
    {  
      
    case WM_NOTIFICATION_RELEASED:
      if (Id == ID_ICONVIEW_MENU)
      {
        sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc);
        
        if(sel < k_ModuleGetNumber())
        {
          ST_AnimatedIconView_SetSel(pMsg->hWinSrc, -1);
          if(module_active == 0)
          {
            module_prop[sel].module->startup(pMsg->hWin, 0, 0);
            if(sel != 5)
            {
              module_active = 1;
            }
            sel = 0;
          }
        }
        else
        {
          WM_InvalidateWindow (pMsg->hWinSrc);
        }
      }
      break;

    case WM_NOTIFICATION_CHILD_DELETED:
      module_active = 0;
        break;
      
    default:
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
/**
  * @brief  Callback routine of the Benchmark 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;
  WM_HWIN hGraph;
  int cpu_speed = 0;
  RTC_TimeTypeDef   RTC_Time;
  uint8_t sec, min, hour;
  char temp[50];
  WM_CALLBACK  *_cb;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    hItem = pMsg->hWin;
    FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0);   
    
    /* Initialization of 'CPU' */    
    hItem = TEXT_CreateEx(20, 30, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x123,"");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, 0x00804000);
    TEXT_SetText(hItem, "CPU Usage %:");
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetTextColor(hItem, GUI_DARKRED);

    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_CPU_GRAPH);  
    FRAMEWIN_SetBarColor(hItem, 0, GUI_DARKGRAY);  
    FRAMEWIN_SetBarColor(hItem, 1, GUI_DARKGRAY);   
 
    hGraph = GRAPH_CreateEx(20, 45, 280, 105, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_GRAPH0);
    hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20);
    GRAPH_SetGridVis(hGraph, 1);
    GRAPH_SetBorder(hGraph, 20, 4, 5, 4); 
    GRAPH_AttachData(hGraph, hData);
    
    hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_AttachScale(hGraph, hScale);  
    GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW);
    GRAPH_SetGridDistX(hGraph, 25);
    GRAPH_SetGridDistY(hGraph, 25);   
    
    WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0); 
    
    break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:      /* React only if released */
      switch (Id) {
   
      case ID_BENCH_CPU:
        Stop_Test = 0;
        
        WM_HideWindow(pMsg->hWin);
        
        _cb = WM_GetCallback(WM_HBKWIN);
        WM_SetCallback(WM_HBKWIN, _ClearDesktop);
        cpu_speed = Run_SpeedTest();
        
        hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
        
        k_GetTime(&RTC_Time);
        sec    =  RTC_Time.Seconds;
        min    =  RTC_Time.Minutes;
        hour   =  RTC_Time.Hours; 
    
        sprintf(temp,"[%02d:%02d:%02d]: %d Pix/s ", hour , min, sec, cpu_speed); 
        LISTBOX_AddString(hItem, temp);

        WM_ShowWindow(pMsg->hWin);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU);
        sprintf (temp, "%d  Pixels/s ", cpu_speed); 
        TEXT_SetText(hItem, temp);
        WM_SetCallback(WM_HBKWIN, _cb);
        hItem = WM_GetDialogItem(WM_HBKWIN, ID_BUTTON_BKGND);
        WM_InvalidateWindow(hItem);
        WM_InvalidateWindow(WM_HBKWIN);
        WM_Paint(WM_HBKWIN);
        break;
      }
      break;
    
    case WM_NOTIFICATION_CHILD_DELETED:
      Stop_Test = 1;
      break; 
    }
    break;

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 28
0
/*********************************************************************
*
*       _cbDialog
*
* Purpose: Dialog callback routine
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  int NCode, Id;
  WM_HWIN hDlg;
  BUTTON_Handle hButton;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_PAINT:
      WM_DefaultProc(pMsg); // Handle dialog items
      //
      // After drawing the dialog items add some user drawn items to the window
      //
      GUI_SetPenSize(10);
      GUI_SetColor(GUI_GREEN);
      GUI_DrawLine( 95,  5, 185, 95);
      GUI_SetColor(GUI_RED);
      GUI_DrawLine( 95, 95, 185,  5);
      break;
    case WM_INIT_DIALOG:
      hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
      WM_SetHasTrans(hButton);              // Set transparency flag for button
      break;
    case WM_KEY:
      switch (((WM_KEY_INFO *)(pMsg->Data.p))->Key) {
        case GUI_KEY_ESCAPE:
          GUI_EndDialog(hDlg, 1);
          break;
        case GUI_KEY_ENTER:
          GUI_EndDialog(hDlg, 0);
          break;
      }
      break;
    case WM_NOTIFY_PARENT:
      Id    = WM_GetId(pMsg->hWinSrc);      // Id of widget
      NCode = pMsg->Data.v;                 // Notification code
      switch (NCode) {
        case WM_NOTIFICATION_RELEASED:      // React only if released
          hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
          if (Id == GUI_ID_BUTTON1) {       // Toggle callback
            if (WM_GetCallback(hButton) == _cbButton) {
              WM_SetCallback(hButton, BUTTON_Callback);
            } else {
              WM_SetCallback(hButton, _cbButton);
            }
            WM_InvalidateWindow(hButton);
          }
          if (Id == GUI_ID_BUTTON2) {       // Toggle font
            if (_Font) {
              BUTTON_SetFont(hButton, &GUI_Font13_1);
            } else {
              BUTTON_SetFont(hButton, &GUI_Font8x16);
            }
            _Font ^= 1;
          }
          if (Id == GUI_ID_BUTTON3) {       // Toggle color
            if (_Color) {
              BUTTON_SetBkColor(hButton, 0, 0xaaaaaa);
              BUTTON_SetBkColor(hButton, 1, GUI_WHITE);
              BUTTON_SetTextColor(hButton, 0, GUI_BLACK);
              BUTTON_SetTextColor(hButton, 1, GUI_BLACK);
            } else {
              BUTTON_SetBkColor(hButton, 0, GUI_BLUE);
              BUTTON_SetBkColor(hButton, 1, GUI_RED);
              BUTTON_SetTextColor(hButton, 0, GUI_WHITE);
              BUTTON_SetTextColor(hButton, 1, GUI_YELLOW);
            }
            _Color ^= 1;
          }
          if (Id == GUI_ID_OK) {            // OK Button
            GUI_EndDialog(hDlg, 0);
          }
          if (Id == GUI_ID_CANCEL) {        // Cancel Button
            GUI_EndDialog(hDlg, 1);
          }
          break;
      }
      break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Esempio n. 29
0
/**
  * @brief  Callback routine of the main 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(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit);

    hItem = BUTTON_CreateEx(540, 350, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_RECORD_PAUSE);
    WM_SetCallback(hItem, _cbButton_pause);     
    
    hItem = BUTTON_CreateEx(320, 350, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_RECORD_STOP);
    WM_SetCallback(hItem, _cbButton_stop);    
    
    hItem = BUTTON_CreateEx(430, 350, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_RECORD_REC_CANCEL_PLAY);
    WM_SetCallback(hItem, _cbButton_record); 
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_FILENAMECAPTION);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);

    hItem = WM_GetDialogItem(pMsg->hWin, ID_FILENAME);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
    TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
    
    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(799, 460, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); 

    break;     
    
  case WM_PAINT:
    GUI_DrawBitmap(&bmrecorder, 60, 120);
    
    GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
    GUI_FillEllipse(470, 430, 214, 140);
    GUI_SetColor(GUI_WHITE);
    GUI_FillEllipse(470, 435, 214, 140);   
    
    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:

        /* Start Recored */
        if( RecorderMode == RECORDER_MODE_REC_IDLE) 
        {
          _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);              
        }
        
        /* Cancel */
        else if( RecorderMode == RECORDER_MODE_RECORDING) 
        {
          AUDIO_RECORDER_StopRec();
          RecorderMode = RECORDER_MODE_REC_IDLE; 
          AUDIO_RECORDER_RemoveAudioFile(FileName);
         }
        /* Start Play */
        else if( RecorderMode == RECORDER_MODE_PLAY_IDLE) 
        {
          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;
  }   
}
Esempio n. 30
0
/*********************************************************************
*
*       _cbDialogColor
*
* Function description
*   Callback routine of DialogColor
*/
static void _cbDialogColor(WM_MESSAGE * pMsg) {
  GUI_COLOR Color;
  WM_HWIN   hDlg;
  WM_HWIN   hItem;
  int       i;
  int       NCode;
  int       Id;

  hDlg = pMsg->hWin;
  Color = 0;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    //
    // Draw RGB values
    //
    GUI_SetColor(_aColorSep[0]);
    GUI_FillRect(180,  60, 199,  79);
    GUI_SetColor(_aColorSep[1] << 8);
    GUI_FillRect(180,  90, 199, 109);
    GUI_SetColor(((U32)_aColorSep[2]) << 16);
    GUI_FillRect(180, 120, 199, 139);
    //
    // Draw resulting color
    //
    GUI_SetColor(_aColorSep[0] | (((U32)_aColorSep[1]) << 8) | (((U32)_aColorSep[2]) << 16));
    GUI_FillRect(205,  60, 285, 139);
    return;
  case WM_INIT_DIALOG:
    _ColorIndex = 0;
    for (i = 0; i < 3; i++) {
      hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i);
      _aColorSep[i] = (_ColorBackGround & (0xff << (i * 8))) >> (i * 8);
      SLIDER_SetRange(hItem, 0, 255);
      SLIDER_SetValue(hItem, _aColorSep[i]);
      //
      // Init EDIT-widgets
      //
      hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i);
      EDIT_SetDecMode(hItem, _aColorSep[i],   0, 255, 0, 0);
    }
    //
    // Init dropdown widgets
    //
    hItem = WM_GetDialogItem(hDlg, GUI_ID_DROPDOWN0);
    DROPDOWN_SetAutoScroll(hItem, 1);
    DROPDOWN_AddString(hItem, "Background");
    DROPDOWN_AddString(hItem, "Grid");
    DROPDOWN_AddString(hItem, "Label");
    DROPDOWN_AddString(hItem, "Temperature 1");
    DROPDOWN_AddString(hItem, "Temperature 2");
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    // Id of widget
    NCode = pMsg->Data.v;               // Notification code
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:      // React only if released
      if (Id == GUI_ID_OK) {            // OK Button
        _SaveCurrentColor();
        _UpdateTextColors(_hDialogMain);
        hItem = WM_GetClientWindow(WM_GetDialogItem(_hDialogMain, ID_TEMPERATURE));
        WM_InvalidateWindow(hItem);
        WM_SetFocus(WM_GetDialogItem(_hDialogMain, ID_TEMPERATURE));
        GUI_SetOrg(0, 0);
      }
      break;
    case WM_NOTIFICATION_SEL_CHANGED:
      _SaveCurrentColor();
      if (Id == GUI_ID_DROPDOWN0) {
        for (i = 0; i < 3; i++) {
          hItem = WM_GetDialogItem(hDlg, GUI_ID_DROPDOWN0);
          _ColorIndex = DROPDOWN_GetSel(hItem);
          hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i);
          switch (_ColorIndex) {
          case 0: Color = _ColorBackGround; break;
          case 1: Color = _ColorGrid;       break;
          case 2: Color = _ColorLabel;      break;
          case 3: Color = _ColorTemp1;      break;
          case 4: Color = _ColorTemp2;      break;
          }
          _aColorSep[i] = (Color & (0xff << (i * 8))) >> (i * 8);
          SLIDER_SetRange(hItem, 0, 255);
          SLIDER_SetValue(hItem, _aColorSep[i]);
          //
          // Init EDIT-widgets
          //
          hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i);
          EDIT_SetDecMode(hItem, _aColorSep[i],   0, 255, 0, 0);
        }
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED: // Value has changed
      {
        unsigned Index, v;
        WM_HWIN hSlider, hEdit;
        Index = 0;
        v     = 0;
        if ((Id >= GUI_ID_SLIDER0) && (Id <= GUI_ID_SLIDER2)) {
          Index = Id - GUI_ID_SLIDER0;
          //
          // SLIDER-widget has changed, update EDIT-widget
          //
          hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
          hEdit   = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
          v = SLIDER_GetValue(hSlider);
          EDIT_SetValue(hEdit, v);
        } else if ((Id >= GUI_ID_EDIT0) && (Id <= GUI_ID_EDIT2)) {
          Index = Id - GUI_ID_EDIT0;
          //
          // If EDIT-widget has changed, update SLIDER-widget
          //
          hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
          hEdit   = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
          v = EDIT_GetValue(hEdit);
          SLIDER_SetValue(hSlider, v);
        }
        _aColorSep[Index] = v;
        //
        // At last invalidate dialog client window
        //
        WM_InvalidateWindow(WM_GetClientWindow(hDlg));
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}