/**
  * @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;
  }
}
void SWRB_TestCheckboxStateGet(WM_HWIN hWin, int id)
{
    WM_HWIN hItem;
    hItem = WM_GetDialogItem(hWin, id);
    if(gSwrbTestMode == SWRB_TEST_MODE_IDLE){
        if(CHECKBOX_GetState(hItem)){
            gSwrbTestValidTaskCnt++;
            gSwrbTestValidTaskCntTotal++;
        }else{
            gSwrbTestValidTaskCnt--;
            gSwrbTestValidTaskCntTotal--;
        }
    }
}
/*********************************************************************
*
*       _cbDialog
*
* Function description
*   Callback routine of dialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  static WM_HWIN   hCellEdit = 0;
  CELL_EDIT_ORG    CellEditOrg;
  WM_KEY_INFO    * pKeyInfo;
  GUI_RECT         ItemRect;
  WM_HWIN          hDlg;
  WM_HWIN          hItem;
  char             acItemText[LEN_ITEM_TEXT];
  int              CheckState;
  int              NCode;
  int              Id;
  int              i;

  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Set listview properties
    //
    hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
    WM_SetCallback(hItem, _cbList);
    HEADER_SetDragLimit(LISTVIEW_GetHeader(hItem), 1);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_SetRBorder(hItem, 5);
    LISTVIEW_SetLBorder(hItem, 5);
    for (i = 0; i < 3; i++) {
      LISTVIEW_AddColumn(hItem, _aColProps[i].Width, _aColProps[i].pText, _aColProps[i].Align);
      LISTVIEW_SetCompareFunc(hItem, i, _aColProps[i].fpCompare);
    }
    LISTVIEW_EnableSort(hItem);
    for (i = 0; i < 6; i++) {
      if (_AddRow(hItem, 1)) {
        break;
      }
    }
    //
    // Set radio button text
    //
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
    RADIO_SetText(hItem, "Sorted",   0);
    RADIO_SetText(hItem, "Unsorted", 1);
    //
    // Init checkbox text
    //
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0);
    CHECKBOX_SetTextAlign(hItem, GUI_TA_LEFT);
    CHECKBOX_SetText(hItem, "Cell select");
    break;
  case WM_KEY:
    hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
    if (pMsg->hWinSrc == hItem) {
      pKeyInfo = (WM_KEY_INFO *)pMsg->Data.p;
      if (pKeyInfo->PressedCnt == 0) {
        if (pKeyInfo->Key == GUI_KEY_ENTER) {
          if (hCellEdit == 0) {
            CellEditOrg.Row = LISTVIEW_GetSel(hItem);
            CellEditOrg.Col = LISTVIEW_GetSelCol(hItem);
            LISTVIEW_GetItemRect(hItem, CellEditOrg.Col, CellEditOrg.Row, &ItemRect);
            LISTVIEW_GetItemTextSorted(hItem, CellEditOrg.Col, CellEditOrg.Row, acItemText, LEN_ITEM_TEXT);
            hCellEdit = EDIT_CreateUser(ItemRect.x0, ItemRect.y0, ItemRect.x1 - ItemRect.x0 + 2, ItemRect.y1 - ItemRect.y0 + 1, hItem, WM_CF_SHOW, 0, 0, LEN_ITEM_TEXT, sizeof(CELL_EDIT_ORG));
            EDIT_SetUserData(hCellEdit, &CellEditOrg, sizeof(CELL_EDIT_ORG));
            WIDGET_SetEffect(hCellEdit, &WIDGET_Effect_Simple);
            WM_SetCallback(hCellEdit, _cbCellEdit);
            WM_SetFocus(hCellEdit);
            EDIT_SetText(hCellEdit, acItemText);
          }
        }
      }
    }
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch (NCode) {
    case WM_NOTIFICATION_CHILD_DELETED:
      if (pMsg->hWinSrc == hCellEdit) {
        hCellEdit = 0;
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED:
      switch (Id) {
      case GUI_ID_RADIO0:
        //
        // Enable/Disable sorting
        //
        hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
        switch (RADIO_GetValue(WM_GetDialogItem(hDlg, GUI_ID_RADIO0))) {
        case 0:
          LISTVIEW_EnableSort(hItem);
          break;
        default:
          LISTVIEW_DisableSort(hItem);
          break;
        }
        break;
      }
      break;
    case WM_NOTIFICATION_RELEASED:
      switch (Id) {
      case GUI_ID_BUTTON0:
        //
        // Add new row
        //
        hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
        _AddRow(hItem, 0);
        break;
      case GUI_ID_BUTTON1:
        //
        // Insert new row
        //
        hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
        i     = LISTVIEW_GetSelUnsorted(hItem);
        _AddRow(hItem, 1);
        if (i >= 0) {
          LISTVIEW_SetSelUnsorted(hItem, i + 1);
        }
        break;
      case GUI_ID_BUTTON2:
        //
        // Delete row
        //
        hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
        i     = LISTVIEW_GetSelUnsorted(hItem);
        LISTVIEW_DeleteRow(hItem, (i >= 0) ? i : 0);
        break;
      case GUI_ID_OK:
        //
        // End dialog
        //
        GUI_EndDialog(hDlg, 0);
        break;
      case GUI_ID_CHECK0:
        //
        // Enable/Disable cell selection
        //
        hItem      = WM_GetDialogItem(hDlg, GUI_ID_CHECK0);
        CheckState = CHECKBOX_GetState(hItem);
        hItem      = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0);
        if (CheckState) {
          LISTVIEW_EnableCellSelect(hItem, 1);
        } else {
          LISTVIEW_EnableCellSelect(hItem, 0);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
int Checkbox_Get_State(WM_HWIN hWin, int checkboxId)
{
    WM_HWIN hItem;
    hItem = WM_GetDialogItem(hWin, checkboxId);
    return(CHECKBOX_GetState(hItem));
}
/*********************************************************************
*
*       CHECKBOX_IsChecked
*/
int CHECKBOX_IsChecked(CHECKBOX_Handle hObj) {
  return (CHECKBOX_GetState(hObj) == 1) ? 1 : 0;
}
/*********************************************************************
*
*       _cbCallback
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  WM_KEY_INFO * pKeyInfo;
  WM_HWIN       hItem;
  WM_HWIN       hDlg;
  int           NCode;
  int           Id;
  int           i;

  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    _OnPaint();
    return;
  case WM_INIT_DIALOG:
    //
    // Init SLIDER and EDIT widgets
    //
    for (i = 0; i < 3; i++) {
      hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i);
      SLIDER_SetRange(hItem, 0, 255);
      SLIDER_SetValue(hItem, _aColorSep[i]);
      hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i);
      EDIT_SetDecMode(hItem, _aColorSep[i],   0, 255, 0, 0);
    }
    //
    // Init CHECKBOX
    //
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0);
    CHECKBOX_SetText(hItem, "Auto");
    CHECKBOX_SetState(hItem, _Auto);
    break;
  case WM_KEY:
    pKeyInfo = (WM_KEY_INFO *)(pMsg->Data.p);
    switch (pKeyInfo->Key) {
    case GUI_KEY_ESCAPE:
      break;
    case GUI_KEY_ENTER:
      GUI_EndDialog(hDlg, 0);
      break;
    }
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:
      if (Id == GUI_ID_OK) {
        GUI_EndDialog(hDlg, 0);
      }
      if (Id == GUI_ID_CANCEL) {
        GUI_EndDialog(hDlg, 1);
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED:
      switch (Id) {
      case GUI_ID_CHECK0:
        hItem = WM_GetDialogItem(hDlg, Id);
        _Auto = CHECKBOX_GetState(hItem);
        break;
      default:
        _OnValueChanged(hDlg, Id);
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
static void _cbDialog_VNC_SETTINGS(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG: 
    
    /* Restore VNC settings */
    _VNCServer_RestoreSettings(); 

    /* Initialization of 'VNC Server Settings' */
    hItem = pMsg->hWin;
    FRAMEWIN_SetTitleHeight(hItem, 18);

    /* Initialization of 'DHCP' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_DHCP);
    CHECKBOX_SetText(hItem, "Enable DHCP");
    CHECKBOX_SetState(hItem, VNCSettings.dhcp_use.b.dhcp);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3);
    EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr3, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2);
    EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr2, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1);
    EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr1, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0);
    EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr0, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3);
    EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr3, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2);
    EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr2, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1);
    EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr1, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0);
    EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr0, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3);
    EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr3, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2);
    EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr2, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1);
    EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr1, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    /* Initialization of 'Edit' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0);
    EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr0, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); 
    
    /* If DHCP enabled: disable all Edits*/
    if (VNCSettings.dhcp_use.b.dhcp)
    {
      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);
      
      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0);

      hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0);
      WM_DisableWindow(hItem);
      EDIT_SetFocussable(hItem, 0); 
    }
    break;
    

  case WM_DELETE:
    hWinVNC_Settings = 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_BUTTON_SETTINGS_CANCEL: /* Settings: Cancel */
        /* Delete NumPad VNC Window */
        WM_DeleteWindow(hNumPad);
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      case ID_BUTTON_SETTINGS_OK: /* Settings: OK */       
        
        /* Save Settings */
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_DHCP);
        if (CHECKBOX_GetState(hItem)) /* Use DHCP to allocate dynamic IP address */
        {
          if(VNCSettings.dhcp_use.b.dhcp == 0)
          {
            VNCSettings.dhcp_use.b.dhcp = 1;
            VNCSettings.ipaddr.b.addr0 = 0;
            VNCSettings.ipaddr.b.addr1 = 0;
            VNCSettings.ipaddr.b.addr2 = 0;
            VNCSettings.ipaddr.b.addr3 = 0;
            VNCSettings.maskaddr.b.addr0 = 0;
            VNCSettings.maskaddr.b.addr1 = 0;
            VNCSettings.maskaddr.b.addr2 = 0;
            VNCSettings.maskaddr.b.addr3 = 0;
            VNCSettings.gwaddr.b.addr0 = 0;
            VNCSettings.gwaddr.b.addr1 = 0;
            VNCSettings.gwaddr.b.addr2 = 0;
            VNCSettings.gwaddr.b.addr3 = 0;
            
            hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_DHCP_STATE);
            TEXT_SetText(hItem, (char const *)"Enabled");  
            
            hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_IPADDR_VALUE);
            TEXT_SetText(hItem, (char const *)"Not assigned");
            
            hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_SUBNETMASK_VALUE);
            TEXT_SetText(hItem, (char const *)"Not assigned");
            
            hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_GWADDR_VALUE);
            TEXT_SetText(hItem, (char const *)"Not assigned");
            
            if (start_button == VNC_HIDE)
            {
              hItem = WM_GetDialogItem(hWinVNC, ID_MULTIEDIT_VNC);
              MULTIEDIT_AddText(hItem, (const char *) "Network settings has been modified\r\n");
              MULTIEDIT_AddText(hItem, (const char *) "Restart to apply new settings\r\n"); 
            }
          }
        } /* Use static IP address */
        else
        {
          if (VNCSettings.dhcp_use.b.dhcp == 1)
          {
            VNCSettings.dhcp_use.b.dhcp = 0;
          }

          if (start_button == VNC_HIDE)
          {
            hItem = WM_GetDialogItem(hWinVNC, ID_MULTIEDIT_VNC);
            MULTIEDIT_AddText(hItem, (const char *) "Network settings has been modified\r\n");
            MULTIEDIT_AddText(hItem, (const char *) "Restart to apply new settings\r\n"); 
          }
          
          /* Get the new network addresses configuration */
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3);
          VNCSettings.ipaddr.b.addr3 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2);
          VNCSettings.ipaddr.b.addr2 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1);
          VNCSettings.ipaddr.b.addr1 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0);
          VNCSettings.ipaddr.b.addr0 = EDIT_GetValue(hItem);
          
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3);
          VNCSettings.maskaddr.b.addr3 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2);
          VNCSettings.maskaddr.b.addr2 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1);
          VNCSettings.maskaddr.b.addr1 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0);
          VNCSettings.maskaddr.b.addr0 = EDIT_GetValue(hItem);
          
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3);
          VNCSettings.gwaddr.b.addr3 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2);
          VNCSettings.gwaddr.b.addr2 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1);
          VNCSettings.gwaddr.b.addr1 = EDIT_GetValue(hItem);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0);
          VNCSettings.gwaddr.b.addr0 = EDIT_GetValue(hItem);
          
          _VNCApp_GetIPAddress(IP_ADDRESS, VNCSettings.ipaddr.b.addr3, VNCSettings.ipaddr.b.addr2, VNCSettings.ipaddr.b.addr1, VNCSettings.ipaddr.b.addr0);
          _VNCApp_GetIPAddress(SUBNET_MASK, VNCSettings.maskaddr.b.addr3, VNCSettings.maskaddr.b.addr2, VNCSettings.maskaddr.b.addr1, VNCSettings.maskaddr.b.addr0);
          _VNCApp_GetIPAddress(GW_ADDRESS, VNCSettings.gwaddr.b.addr3, VNCSettings.gwaddr.b.addr2, VNCSettings.gwaddr.b.addr1, VNCSettings.gwaddr.b.addr0);
        }
        
        /********** Save Settings ***********/
        _VNCServer_SaveSettings(); 
        
        /* Delete NumPad VNC Window */
        WM_DeleteWindow(hNumPad);
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED:
      switch (Id) {
      case ID_CHECKBOX_DHCP:
        {
          hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_DHCP);
          if (CHECKBOX_IsChecked(hItem))
          {
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0);
            WM_DisableWindow(hItem);
            EDIT_SetFocussable(hItem, 0);
          }
          else
          {
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0);
            WM_EnableWindow(hItem);
            EDIT_SetFocussable(hItem, 1);
          }
        }
        break;
      }
      break;
      
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemple #8
0
void OnCheckBoxClicked_MUlT(WM_MESSAGE * pMsg)
{
   
	disp_muit = CHECKBOX_GetState(WM_GetDialogItem(pMsg->hWin,GUI_ID_CHECKBOX_MULT));
	
}
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
	
	int i;
	
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'SensorsControl'
    //
    hItem = pMsg->hWin;
    FRAMEWIN_SetText(hItem, "Sensors Control");
    //
    // Initialization of 'exit_button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, " X");
    //
    // Initialization of 'refresh_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "delay of refresh:");
    //
    // Initialization of 'temperature_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "");
    //
    // Initialization of 'temp_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetText(hItem, "teperature:");
    //
    // Initialization of 'hum_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetText(hItem, "humidity:");
    //
    // Initialization of 'humidity_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetText(hItem, "");
    //
    // Initialization of 'sound_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetText(hItem, "sound:");
    //
    // Initialization of 'sound_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2);
    EDIT_SetText(hItem, "SILENCE");
    //
    // Initialization of 'distance_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
    TEXT_SetText(hItem, "distance:");
    //
    // Initialization of 'distance_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3);
    EDIT_SetText(hItem, "FAR");
    //
    // Initialization of 'pres_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
    TEXT_SetText(hItem, "presence:");
    //
    // Initialization of 'presence_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_4);
    EDIT_SetText(hItem, "NO");
    //
    // Initialization of 'vibro_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
    TEXT_SetText(hItem, "vibration:");
    //
    // Initialization of 'vibration_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_5);
    EDIT_SetText(hItem, "NO");
    //
    // Initialization of 'light_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
    TEXT_SetText(hItem, "light:");
    //
    // Initialization of 'light_edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_6);
    EDIT_SetText(hItem, "NO");
    //
    // Initialization of 'light_check'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
    CHECKBOX_SetText(hItem, "turn on all leds when there is no light in the area");
    //
    // Initialization of 'alarm_check'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1);
    CHECKBOX_SetText(hItem, "activate alarm on presence");
    //
    // Initialization of 'temp_check'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2);
    CHECKBOX_SetText(hItem, "activate alarm on temperature");
    //
    // Initialization of 'max_temp_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
    TEXT_SetText(hItem, "max temperature:");
    // USER START (Optionally insert additional code for further widget initialization)

			actual_hWin = pMsg->hWin;
			UEZSemaphoreRelease(semaphore_actual_hWin);

		// USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'exit_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
			  PlayAudio(600, 20);				
        PlayAudio(600, 20);				
        PlayAudio(200, 20);				
 
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)

				PlayAudio(900, 20);				
        PlayAudio(1000, 20);				
        PlayAudio(1100, 20);				

				check_sensors.alarm = 0;
				check_sensors.light = 0;
				check_sensors.temperature = 0;

				BS_wrapper(EXIT_CONTROLLER, INTERNAL, &pMsg);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SLIDER_0: // Notifications sent by 'refresh_slider'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
			
				hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0 );
				delay_from_slider = 10 + (SLIDER_GetValue(hItem) * 2);
				BS_wrapper(CHANGE_DELAY_QUERY_FROM_WINDOW, EXTERNAL, &delay_from_slider);
			
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_0: // Notifications sent by 'temperature_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_1: // Notifications sent by 'humidity_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_2: // Notifications sent by 'sound_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_3: // Notifications sent by 'distance_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_4: // Notifications sent by 'presence_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_5: // Notifications sent by 'vibration_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_6: // Notifications sent by 'light_edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_CHECKBOX_0: // Notifications sent by 'light_check'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
						        PlayAudio(180, 30);				

        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
			
					hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0 );
					check_sensors.light = CHECKBOX_GetState(hItem);
					BS_wrapper(NOTIFY_NO_LIGHT_SENSOR_CHANGED_FROM_WINDOW, EXTERNAL, NULL);
			
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_CHECKBOX_1: // Notifications sent by 'alarm_check'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
						        PlayAudio(180, 30);				

        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

				hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1 );
				check_sensors.alarm = CHECKBOX_GetState(hItem);
				BS_wrapper(NOTIFY_ALARM_PRESENCE_SENSOR_CHANGED_FROM_WINDOW, EXTERNAL, NULL);

			// USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_CHECKBOX_2: // Notifications sent by 'temp_check'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
						        PlayAudio(180, 30);				

        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

				hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2 );
				check_sensors.temperature = CHECKBOX_GetState(hItem);
				BS_wrapper(NOTIFY_ALARM_TEMPERATURE_SENSOR_CHANGED_FROM_WINDOW, EXTERNAL, NULL);

			// USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_0: // Notifications sent by 'Spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
						        PlayAudio(180, 30);				

        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
			
				hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0 );
				temperature_limit = SPINBOX_GetValue(hItem);
				BS_wrapper(NOTIFY_MAX_TEMPERATURE_THRESHOLD_FROM_WINDOW, EXTERNAL, &temperature_limit);
			
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
		
	case MB_MSG_SENSOR:

		//GESTISCO L'AGGIORNAMENTO DEI LABEL DEI SENSORI
	
		/** 
	i sensori sono stati mappati così:
	
	*(usRegHoldingBuf     ) = (USHORT *) &sensors.distance1;
	*(usRegHoldingBuf + 1 ) = (USHORT *) &sensors.distance2;
	*(usRegHoldingBuf + 2 ) = (USHORT *) &sensors.lumino;
	*(usRegHoldingBuf + 3 ) = (USHORT *) &sensors.mic;
	*(usRegHoldingBuf + 4 ) = (USHORT *) &sensors.vibro;
	*(usRegHoldingBuf + 5 ) = (USHORT *) &actual_DHT11.humidity;
	*(usRegHoldingBuf + 6 ) = (USHORT *) &actual_DHT11.temperature;

	
  "temperature_edit", ID_EDIT_0
  "humidity_edit", ID_EDIT_1
  "sound_edit", ID_EDIT_2
  "distance_edit", ID_EDIT_3
  "presence_edit", ID_EDIT_4
  "vibration_edit", ID_EDIT_5
  "light_edit", ID_EDIT_6

			*/
	
		//estrazione della temperatura
		
		
	break;
	
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemple #10
0
void update_conf_item() {
  WM_SetFocus(
    WM_GetDialogItem(
      configPageWin,
      ID_CONF_DSTP_CFG_PRT_ONB + current_ekran.index_position
    )
  );
  
  for (int i = 0; i < NUM_CONF_ITEMS; i++) {
    CHECKBOX_Handle checkBox = WM_GetDialogItem(configPageWin, ID_CONF_DSTP_CFG_PRT_ONB + i);
    if (sel_conf_language != sel_language) {
      CHECKBOX_SetText(checkBox, conf_checkbox_item[sel_language][i]);
    }
    if (WM_HasFocus(checkBox)) {
      CHECKBOX_SetTextColor(checkBox, GUI_YELLOW);
      CHECKBOX_SetBkColor(checkBox, GUI_BLUE);
    } else {
      CHECKBOX_SetTextColor(checkBox, GUI_BLACK);
      CHECKBOX_SetBkColor(checkBox, GUI_FRM_COLOR);
    }
    if (_CHECK_BIT_UCHAR(selInfConf, i)) {
      if (CHECKBOX_GetState(checkBox) == 0) {
        CHECKBOX_SetState(checkBox, 1);
      }
    } else {
      if (CHECKBOX_GetState(checkBox) != 0) {
        CHECKBOX_SetState(checkBox, 0);
      }
    }
  }
  
  if (sel_conf_language != sel_language) {
    sel_conf_language = sel_language;
    
    BUTTON_SetText(
      WM_GetDialogItem(
        configPageWin,
        ID_CONF_BUTTON_ESC
      ),
      escButtonExpl[sel_language]
    );
    BUTTON_SetText(
      WM_GetDialogItem(
        configPageWin,
        ID_CONF_BUTTON_ENTER
      ),
      enterButtonExpl[sel_language]
    );
  }
  
  char titleText[100] = {0};
  unsigned int i = 0;
  for (; confFrmText[sel_language][i] != '\0'; i++) {
    titleText[i] = confFrmText[sel_language][i];
  }
  
  if (current_ekran.edition != 0) {
    _CONCAT_STR(titleText, editModeAdditionalText[sel_language]);
  }
  
  FRAMEWIN_SetText(configPageWin, titleText);
  
  EDIT_SetText(hEdit, confExplText[sel_language]);
}