/*********************************************************************
*
*       _cbCallbackOptions
*
* Purpose:
*   Callback of the options dialog box, sets the widget effects
*/
static void _cbCallbackOptions(WM_MESSAGE * pMsg) {
  WM_HWIN hDlg, hItem;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      /* Init check box */
      hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0);
      CHECKBOX_Check(hItem);
      CHECKBOX_SetText(hItem, "Auto");
      /* Init radio button */
      hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
      RADIO_SetText(hItem, "3D",     0);
      RADIO_SetText(hItem, "Simple", 1);
      RADIO_SetText(hItem, "None",   2);
      break;
    case WM_NOTIFY_PARENT:
      if (pMsg->Data.v == WM_NOTIFICATION_VALUE_CHANGED) {
        hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
        if (pMsg->hWinSrc == hItem) {
          _SetEffect(RADIO_GetValue(hItem));
        }
      } else if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
        hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0);
        if (pMsg->hWinSrc == hItem) {
          _AutoMode = CHECKBOX_IsChecked(hItem);
        }
      }
      break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Esempio n. 2
0
/*********************************************************************
*
*       _cbCallback
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  int i;
  int NCode, Id;
  WM_HWIN hDlg, hItem;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
      for (i = 0; i < GUI_COUNTOF(_apLabel); i++) {
        RADIO_SetText(hItem, _apLabel[i], i);
      }
      _SetFont(hDlg);
      break;
    case WM_NOTIFY_PARENT:
      Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
      NCode = pMsg->Data.v;               /* Notification code */
      switch (NCode) {
      case WM_NOTIFICATION_VALUE_CHANGED: /* Value has changed */
        _SetFont(hDlg);
        break;
      case WM_NOTIFICATION_RELEASED:      /* React only if released */
        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. 3
0
/*
*********************************************************************************************************
*	函 数 名: _cbCallback
*	功能说明: 对话框回调函数	
*	形    参: pMsg  回调参数 
*	返 回 值: 无
*********************************************************************************************************
*/
static void _cbCallback(WM_MESSAGE * pMsg) 
{
	int i;
	int NCode, Id;
	WM_HWIN hDlg, hItem;
	hDlg = pMsg->hWin;
	switch (pMsg->MsgId) 
	{
		case WM_INIT_DIALOG:
			hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
			for (i = 0; i < GUI_COUNTOF(_apLabel); i++) 
			{
				RADIO_SetText(hItem, _apLabel[i], i);
			}
			_SetFont(hDlg);
			break;
			
		case WM_NOTIFY_PARENT:
			Id    = WM_GetId(pMsg->hWinSrc);    
			NCode = pMsg->Data.v;             
			switch (NCode) 
			{
				case WM_NOTIFICATION_VALUE_CHANGED: 
					_SetFont(hDlg);
					break;
				
				/* 两个按钮的消息处理 */
				case WM_NOTIFICATION_RELEASED:     
					if (Id == GUI_ID_OK) 
					{            
						GUI_EndDialog(hDlg, 0);
					}
					if (Id == GUI_ID_CANCEL) 
					{       
						GUI_EndDialog(hDlg, 1);
					}
					break;
			}
			break;
			
		default:
		WM_DefaultProc(pMsg);
	}
}
/*********************************************************************
*
*       _cbCallback
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  int     NCode;
  int     Id;
  int     Sel;
  char    ac[80];
  WM_HWIN hDlg;
  WM_HWIN hMulti;
  WM_HWIN hItem;

  hDlg   = pMsg->hWin;
  hMulti = WM_GetDialogItem(hDlg, GUI_ID_MULTIEDIT0);
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0);
    SLIDER_SetRange(hItem, 1, 100);
    SLIDER_SetValue(hItem, 100);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER1);
    SLIDER_SetRange(hItem, 1, 152);
    SLIDER_SetValue(hItem, 152);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER2);
    SLIDER_SetRange(hItem, 0, 5);
    SLIDER_SetValue(hItem, 2);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER3);
    SLIDER_SetRange(hItem, 0, 100);
    SLIDER_SetValue(hItem, 0);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT1);
    EDIT_SetDecMode(hItem, 0, 0, 1000, 0, 0);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO2);
    RADIO_SetText(hItem, "None", 0);
    RADIO_SetText(hItem, "Char", 1);
    RADIO_SetText(hItem, "Word", 2);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO3);
    RADIO_SetText(hItem, "None",   0);
    RADIO_SetText(hItem, "Simple", 1);
    RADIO_SetText(hItem, "3D",     2);
    RADIO_SetValue(hItem, 2);
    RADIO_SetTextColor(hItem, GUI_BLUE);
    MULTIEDIT_EnableBlink(hMulti, 300, 1);
    MULTIEDIT_SetFont(hMulti, &GUI_Font8x16);
    MULTIEDIT_SetBkColor(hMulti, 0, GUI_YELLOW);
    MULTIEDIT_SetTextColor(hMulti, 0, GUI_BLUE);
    MULTIEDIT_SetAutoScrollV(hMulti, 1);
    MULTIEDIT_SetInsertMode(hMulti, 1);
    MULTIEDIT_SetPrompt(hMulti, "C:\\>");
    MULTIEDIT_SetHBorder(hMulti, 2);
    MULTIEDIT_SetText(hMulti, "Multiedit - long line 12345678901234567890\nThis demonstrates the use of a MULTIEDIT widget");
    MULTIEDIT_AddKey(hMulti, 'A');
    MULTIEDIT_AddKey(hMulti, 'B');
    MULTIEDIT_AddKey(hMulti, 'C');
    MULTIEDIT_AddKey(hMulti, GUI_KEY_ENTER);
    MULTIEDIT_SetAutoScrollH(hMulti, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_BUTTON5);
    BUTTON_SetFocussable(hItem, 0);
    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);
    NCode  = pMsg->Data.v;
    hItem  = WM_GetDialogItem(hDlg, Id);
    switch (NCode) {
    case WM_NOTIFICATION_VALUE_CHANGED:
      switch (Id) {
      case GUI_ID_SLIDER0:
        Sel = SLIDER_GetValue(hItem);
        WM_SetYSize(hMulti, Sel);
        break;
      case GUI_ID_SLIDER1:
        Sel = SLIDER_GetValue(hItem);
        WM_SetXSize(hMulti, Sel);
        break;
      case GUI_ID_SLIDER2:
        Sel = SLIDER_GetValue(hItem);
        MULTIEDIT_SetHBorder(hMulti, Sel);
        break;
      case GUI_ID_SLIDER3:
        Sel = SLIDER_GetValue(hItem);
        MULTIEDIT_SetMaxNumChars(hMulti, Sel);
        break;
      case GUI_ID_RADIO0:
        //
        // Horizontal scrollbar
        //
        Sel = RADIO_GetValue(hItem);
        switch (Sel) {
        case 0:
          MULTIEDIT_SetAutoScrollH(hMulti, 1);           // Auto
          break;
        case 1:
          MULTIEDIT_SetAutoScrollH(hMulti, 0);           // Off
          WM_SetScrollbarH(hMulti, 0);
          break;
        case 2:
          MULTIEDIT_SetAutoScrollH(hMulti, 0);           // On
          WM_SetScrollbarH(hMulti, 1);
          break;
        }
        break;
      case GUI_ID_RADIO1:
        //
        // Vertical scrollbar
        //
        Sel = RADIO_GetValue(hItem);
        switch (Sel) {
        case 0:
          MULTIEDIT_SetAutoScrollV(hMulti, 1);
          break;
        case 1:
          MULTIEDIT_SetAutoScrollV(hMulti, 0);
          WM_SetScrollbarV(hMulti, 0);
          break;
        case 2:
          MULTIEDIT_SetAutoScrollV(hMulti, 0);
          WM_SetScrollbarV(hMulti, 1);
          break;
        }
        break;
      case GUI_ID_RADIO2:
        //
        // Wrap
        //
        Sel = RADIO_GetValue(hItem);
        switch (Sel) {
        case 0:
          MULTIEDIT_SetWrapNone(hMulti);
          break;
        case 1:
          MULTIEDIT_SetWrapChar(hMulti);
          break;
        case 2:
          MULTIEDIT_SetWrapWord(hMulti);
          break;
        }
        break;
      case GUI_ID_RADIO3:
        //
        // Effect type
        //
        Sel = RADIO_GetValue(hItem);
        switch (Sel) {
        case 0:
          WIDGET_SetEffect(hMulti, &WIDGET_Effect_None);
          break;
        case 1:
          WIDGET_SetEffect(hMulti, &WIDGET_Effect_Simple);
          break;
        case 2:
          WIDGET_SetEffect(hMulti, &WIDGET_Effect_3D);
          break;
        }
        break;
      }
      break;
      case WM_NOTIFICATION_RELEASED:      // React only if released
        WM_GetDialogItem(hDlg, Id);
        switch (Id) {
        case GUI_ID_OK:
          GUI_EndDialog(hDlg, 0);
          break;
        case GUI_ID_CANCEL:
          GUI_EndDialog(hDlg, 1);
          break;
        case GUI_ID_CHECK0:
          _RdOnly ^= 1;
          MULTIEDIT_SetReadOnly(hMulti, _RdOnly);
          break;
        case GUI_ID_CHECK1:
          _RTF8 ^= 1;
          if (_RTF8) {
            GUI_UC_SetEncodeUTF8();
          } else {
            GUI_UC_SetEncodeNone();
          }
          WM_InvalidateWindow(hMulti);
          break;
        case GUI_ID_CHECK2:
          _Password ^= 1;
          MULTIEDIT_SetPasswordMode(hMulti, _Password);
          break;
        case GUI_ID_BUTTON1:
          hItem  = WM_GetDialogItem(hDlg, GUI_ID_EDIT0);
          EDIT_GetText(hItem, &ac[0], sizeof(ac));
          MULTIEDIT_SetPrompt(hMulti, ac);
          break;
        case GUI_ID_BUTTON2:
          hItem  = WM_GetDialogItem(hDlg, GUI_ID_EDIT1);
          MULTIEDIT_SetCursorOffset(hMulti, EDIT_GetValue(hItem));
          WM_SetFocus(hMulti);
          break;
        case GUI_ID_BUTTON3:
          MULTIEDIT_SetText(hMulti, "Short text");
          break;
        case GUI_ID_BUTTON4:
          MULTIEDIT_SetText(hMulti, "Long text\n123456789012345678901234567890\nLast line\n");
          break;
        case GUI_ID_BUTTON5:
          MULTIEDIT_AddText(hMulti, "Added");
          break;
        case GUI_ID_BUTTON6:
          MULTIEDIT_SetFont(hMulti, &GUI_Font8x16);
          break;
        case GUI_ID_BUTTON7:
          MULTIEDIT_SetFont(hMulti, &GUI_Font16_1);
          break;
        }
        break;
    }
    break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Esempio n. 5
0
/*********************************************************************
*
*       _cbCallback
*
* Purpose:
*   Callback function of the dialog
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  int NCode, Id, Value, i;
  WM_HWIN hDlg, hItem;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
    _InitPoints();
    /* Add graphs */
    for (i = 0; i < 3; i++) {
      GRAPH_DATA_Handle  hDataXY;
      hDataXY = GRAPH_DATA_XY_Create(_aColor[i], GUI_COUNTOF(_aPoint[i]), _aPoint[i], GUI_COUNTOF(_aPoint[i]));
      GRAPH_DATA_XY_SetLineStyle(hDataXY, _aLStyle[i]);
      GRAPH_AttachData(hItem, hDataXY);
    }
    /* Set graph attributes */
    GRAPH_SetGridDistY(hItem, 25);
    GRAPH_SetGridVis(hItem, 1);
    GRAPH_SetUserDraw(hItem, _UserDraw);
    /* Create and add vertical scale */
    _hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_SCALE_SetOff(_hScaleV, 100);
    GRAPH_SCALE_SetFactor(_hScaleV, 0.04f);
    GRAPH_SCALE_SetTextColor(_hScaleV, GUI_RED);
    GRAPH_AttachScale(hItem, _hScaleV);
    /* Create and add horizontal scale */
    _hScaleH = GRAPH_SCALE_Create(70, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
    GRAPH_SCALE_SetFactor(_hScaleH, 0.02f);
    GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
    GRAPH_AttachScale(hItem, _hScaleH);
    /* Init check boxes */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK2);
    CHECKBOX_SetText(hItem, "L");
    CHECKBOX_SetState(hItem, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK3);
    CHECKBOX_SetText(hItem, "T");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK4);
    CHECKBOX_SetText(hItem, "R");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK5);
    CHECKBOX_SetText(hItem, "B");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK1);
    CHECKBOX_SetText(hItem, "Grid");
    CHECKBOX_SetState(hItem, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK6);
    CHECKBOX_SetText(hItem, "HScroll");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK7);
    CHECKBOX_SetText(hItem, "VScroll");
    /* Init slider widgets */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0);
    SLIDER_SetRange(hItem, 0, 10);
    SLIDER_SetValue(hItem, 5);
    SLIDER_SetNumTicks(hItem, 6);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER1);
    SLIDER_SetRange(hItem, 0, 20);
    SLIDER_SetValue(hItem, 5);
    SLIDER_SetNumTicks(hItem, 6);
    /* Init radio widget */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
    RADIO_SetText(hItem, "3D", 0);
    RADIO_SetText(hItem, "flat", 1);
    RADIO_SetText(hItem, "-", 2);
    /* Init button widget */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
    WM_SetStayOnTop(hItem, 1);
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);      /* Id of widget */
    NCode = pMsg->Data.v;                 /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_CLICKED:
      switch (Id) {
      case GUI_ID_BUTTON0:
        _ToggleFullScreenMode(hDlg);
        break;
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED:
      switch (Id) {
      case GUI_ID_CHECK1:
        /* Toggle grid */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        GRAPH_SetGridVis(hItem, CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK1)));
        break;
      case GUI_ID_CHECK2:
      case GUI_ID_CHECK3:
      case GUI_ID_CHECK4:
      case GUI_ID_CHECK5:
        /* Toggle border */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        GRAPH_SetBorder(hItem, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK2)) * 40, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK3)) * 5, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK4)) * 5, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK5)) * 5);
        break;
      case GUI_ID_SLIDER0:
        /* Set horizontal grid spacing */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        Value = SLIDER_GetValue(pMsg->hWinSrc) * 10;
        GRAPH_SetGridDistX(hItem, Value);
        GRAPH_SCALE_SetTickDist(_hScaleH, Value);
        if (Value != 50) {
          GRAPH_SCALE_SetNumDecs(_hScaleH, 1);
        } else {
          GRAPH_SCALE_SetNumDecs(_hScaleH, 0);
        }
        break;
      case GUI_ID_SLIDER1:
        /* Set vertical grid spacing */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        Value = SLIDER_GetValue(pMsg->hWinSrc) * 5;
        GRAPH_SetGridDistY(hItem, Value);
        GRAPH_SCALE_SetTickDist(_hScaleV, Value);
        if (Value != 25) {
          GRAPH_SCALE_SetNumDecs(_hScaleV, 1);
        } else {
          GRAPH_SCALE_SetNumDecs(_hScaleV, 0);
        }
        break;
      case GUI_ID_RADIO0:
        /* Set the widget effect */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        switch (RADIO_GetValue(pMsg->hWinSrc)) {
        case 0:
          WIDGET_SetEffect(hItem, &WIDGET_Effect_3D);
          break;
        case 1:
          WIDGET_SetEffect(hItem, &WIDGET_Effect_Simple);
          break;
        case 2:
          WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
          break;
        }
        break;
      case GUI_ID_CHECK6:
        /* Toggle horizontal scroll bar */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK6))) {
          GRAPH_SetVSizeX(hItem, 500);
        } else {
          GRAPH_SetVSizeX(hItem, 0);
        }
        break;
      case GUI_ID_CHECK7:
        /* Toggle vertical scroll bar */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK7))) {
          GRAPH_SetVSizeY(hItem, 300);
        } else {
          GRAPH_SetVSizeY(hItem, 0);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
Esempio n. 6
0
static void _cbDialog(WM_MESSAGE * pMsg) {
    WM_HWIN hItem;
    int     NCode;
    int     Id;
    int led;
    static int i;
    int led_num;
    
    switch (pMsg->MsgId)
    {
        case WM_TIMER:

            rt_device_control(dev_led, RT_DEVICE_GET_LED_NUM, &led_num);
            rt_device_control(dev_led, RT_DEVICE_CTRL_LED_TOGGLE, &i);
            i++; i%= led_num;
            if(_gMode == LED_WATERLAMP)
            {
                WM_RestartTimer(pMsg->Data.v, _gFreq);
            }
            break;
      case WM_INIT_DIALOG:

        _gMode = 0;
        _LedInit();

        hItem = pMsg->hWin;
        FRAMEWIN_SetText(hItem, "led");
      
        hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
        RADIO_SetText(hItem, "control", 0);
        RADIO_SetText(hItem, "Water lamp", 1);
        RADIO_SetFont(hItem, GUI_FONT_13B_1);
      
        hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0);
        SLIDER_SetRange(hItem, 50, 1000);
      
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
        BUTTON_SetText(hItem, "led1");

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
        BUTTON_SetText(hItem, "led2");

        hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
        TEXT_SetText(hItem, "freuqency");

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
        BUTTON_SetText(hItem, "led3");

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
        BUTTON_SetText(hItem, "led4");

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4);
        BUTTON_SetText(hItem, "Cancel");
        break;
      case WM_NOTIFY_PARENT:
        Id    = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        switch(Id) {
        case ID_SLIDER_0: // Notifications sent by 'Slider'
            switch(NCode)
            {
                case WM_NOTIFICATION_VALUE_CHANGED:
                    _gFreq = SLIDER_GetValue(WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0));
                break;
            }
            break;
        case ID_RADIO_0:
          switch(NCode) {
          case WM_NOTIFICATION_CLICKED:
            break;
          case WM_NOTIFICATION_RELEASED:
            break;
          case WM_NOTIFICATION_VALUE_CHANGED:
              _gMode = RADIO_GetValue(WM_GetDialogItem(pMsg->hWin, ID_RADIO_0));
              if(_gMode == LED_WATERLAMP)
              {
                  WM_CreateTimer(WM_GetClientWindow(pMsg->hWin), 0, 200, 0);
              }
              
            break;
          }
          break;
          
        case ID_BUTTON_0:
          switch(NCode) {
          case WM_NOTIFICATION_CLICKED:
                if(_gMode == LED_CONTROL)
                {
                    led = 0;
                    rt_device_control(dev_led, RT_DEVICE_CTRL_LED_TOGGLE, &led); 
                }
                break;
          }
          break;

        case ID_BUTTON_1:
          switch(NCode) {
          case WM_NOTIFICATION_CLICKED:
                if(_gMode == LED_CONTROL)
                {
                    led = 1;
                    rt_device_control(dev_led, RT_DEVICE_CTRL_LED_TOGGLE, &led); 
                }
            break;
          }
          break;
        case ID_BUTTON_2:
          switch(NCode) {
          case WM_NOTIFICATION_CLICKED:
                if(_gMode == LED_CONTROL)
                {
                    led = 2;
                    rt_device_control(dev_led, RT_DEVICE_CTRL_LED_TOGGLE, &led); 
                }
            break;
          }
          break;
        case ID_BUTTON_3:
          switch(NCode) {
          case WM_NOTIFICATION_CLICKED:
                if(_gMode == LED_CONTROL)
                {
                    led = 3;
                    rt_device_control(dev_led, RT_DEVICE_CTRL_LED_TOGGLE, &led); 
                }
            break;
          }
          break;
        case ID_BUTTON_4: // Notifications sent by 'Button'
          switch(NCode) {
          case WM_NOTIFICATION_RELEASED:
                    GUI_EndDialog(pMsg->hWin, 0);
            break;

          }
          break;
        }
        break;

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/*********************************************************************
*
*       _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);
  }
}
Esempio n. 8
0
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg)
{
  WM_HWIN  hItem, Hint;
  GUI_RECT r;
  int NCode, Id;
  uint32_t tmp_param = 0;
  
  switch (pMsg->MsgId)
  {
  case WM_INIT_DIALOG:
  
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    CameraSettings.d32 = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP);
    
    /* Initialization of 'Image' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE);
    IMAGE_SetBitmap(hItem, &bmwizard);
    
    /* Initialization of 'Effects' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT);
    TEXT_SetFont(hItem, GUI_FONT_16B_1);
    
    /* Initialization of 'Radio' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO);
    RADIO_SetText(hItem, "None", 0);
    RADIO_SetText(hItem, "B&W", 1);
    RADIO_SetText(hItem, "Negative", 2);
    RADIO_SetText(hItem, "Antique", 3);
    RADIO_SetText(hItem, "Blue", 4);
    RADIO_SetText(hItem, "Green", 5);
    RADIO_SetText(hItem, "Red", 6);
    
    /* Camera frame initialization */
    hItem = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hItem, &r);
    hCameraFrame = WM_CreateWindowAsChild(r.x0 + 79, 
                                          r.y0 + 49, r.x1 - 159, 
                                          r.y1 - 93, 
                                          hItem, 
                                          WM_CF_SHOW | WM_CF_LATE_CLIP, 
                                          _cbCameraWindow, 
                                          0);
    
    /* Buttons initialization */
    hItem = BUTTON_CreateEx(266, 175, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CLOSE);
    WM_SetCallback(hItem, _cbButton_close);
    
    hItem = BUTTON_CreateEx(256, 79, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CAPTURE);
    WM_SetCallback(hItem, _cbButton_capture);
    
    hItem = BUTTON_CreateEx(266, 14, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_SETTINGS);
    WM_SetCallback(hItem, _cbButton_settings);
    
    _Check_DefaultPath (capture_folder);
    FrameAvailable = 0;
    break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    
    if(hSettings == 0)
    {
      switch(Id)
      {
      case ID_RADIO:
        if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
        {
          hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO);
          if(CAMERA_GetState() != CAMERA_ERROR)
          {
            CAMERA_SelectEffect(RADIO_GetValue(hItem));
          }
        }
        break;
      case ID_BUTTON_CLOSE: /* Notifications sent by 'Close' */
        switch(NCode)
        {
        case WM_NOTIFICATION_RELEASED:
          k_free(pFileInfo);
          CAMERA_Stop();
          GUI_EndDialog(pMsg->hWin, 0);
          break;
        }
        break;
      case ID_BUTTON_CAPTURE: /* Notifications sent by 'OK' */
        switch(NCode)
        {
        case WM_NOTIFICATION_RELEASED:
          /* Show Hint */
          if(CAMERA_GetState() == CAMERA_OK)
          {
            
            Hint = WM_CreateWindowAsChild(100,
                                          90,
                                          120, 32,
                                          pMsg->hWin,
                                          WM_CF_SHOW , 
                                          _cbHint, 
                                          0);
            
            GUI_Exec();
            if(CAMERA_GetState() == CAMERA_OK)
            {             
              CAMERA_SaveToFile(capture_folder);
            }
            WM_DeleteWindow(Hint);
          }
          break;
        }
        break;
      case ID_BUTTON_SETTINGS: /* Notifications sent by 'Settings' */
        switch(NCode)
        {
        case WM_NOTIFICATION_RELEASED:
          camera_disabled = 1;
          hSettings = GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, CAMERA_hWin, 0, 0);
          break;
        }
        break;
      }
    }
    break;
  case WM_DELETE:
    tmp_param = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP);
    
    /* check if new settings have to be saved */
    if(CameraSettings.d32 != tmp_param)
    {
      k_BkupSaveParameter(CALIBRATION_CAMERA_SETTING_BKP, CameraSettings.d32); 
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/*********************************************************************
*
*       _cbPage0
*
* Purpose:
*   Callback routine for the first page of the multipage widget
*/
static void _cbPage0(WM_MESSAGE * pMsg) {
  WM_HWIN hItem, hDlg, hTree;
  int Sel, NCode, Id;
  hDlg  = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_NOTIFY_PARENT:
    hTree = WM_GetDialogItem(WM_GetFirstChild(WM_HBKWIN), GUI_ID_TREEVIEW0);
    Id    = WM_GetId(pMsg->hWinSrc);      /* Id of widget */
    NCode = pMsg->Data.v;                 /* Notification code */
    hItem = WM_GetDialogItem(hDlg, Id);
    switch (Id) {
    case GUI_ID_RADIO0: /* Select the selection mode */
      switch (NCode) {
      case WM_NOTIFICATION_VALUE_CHANGED:
        Sel = RADIO_GetValue(hItem);
        TREEVIEW_SetSelMode(hTree, (Sel == 1) ? TREEVIEW_SELMODE_ROW : TREEVIEW_SELMODE_TEXT);
        break;
      }
      break;
    case GUI_ID_RADIO1: /* Set the visibility of the lines */
      switch (NCode) {
      case WM_NOTIFICATION_VALUE_CHANGED:
        Sel = RADIO_GetValue(hItem);
        TREEVIEW_SetHasLines(hTree, (Sel == 1) ? 1 : 0);
        break;
      }
      break;
    case GUI_ID_RADIO2: /* Manage horizontal scrollbar */
      switch (NCode) {
      case WM_NOTIFICATION_VALUE_CHANGED:
        Sel = RADIO_GetValue(hItem);
        if (Sel == 1) {
          WM_SetScrollbarH(hTree, 0);
        }
        TREEVIEW_SetAutoScrollH(hTree, (Sel == 0) ? 1 : 0);
        if (Sel == 2) {
          SCROLLBAR_CreateAttached(hTree, 0);
        }
        break;
      }
      break;
    case GUI_ID_RADIO3: /* Manage vertical scrollbar */
      switch (NCode) {
      case WM_NOTIFICATION_VALUE_CHANGED:
        Sel = RADIO_GetValue(hItem);
        if (Sel == 1) {
          WM_SetScrollbarV(hTree, 0);
        }
        TREEVIEW_SetAutoScrollV(hTree, (Sel == 0) ? 1 : 0);
        if (Sel == 2) {
          SCROLLBAR_CreateAttached(hTree, WIDGET_CF_VERTICAL);
        }
        break;
      }
      break;
    case GUI_ID_RADIO4: /* Manage font */
      switch (NCode) {
      case WM_NOTIFICATION_VALUE_CHANGED:
        Sel = RADIO_GetValue(hItem);
        TREEVIEW_SetFont(hTree, (Sel == 1) ? &GUI_Font24B_1: &GUI_Font13_1);
        break;
      }
      break;
    }
    break;
  case WM_INIT_DIALOG: /* Initialize the items of the dialog */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
    RADIO_SetText(hItem, "Text select", 0);
    RADIO_SetText(hItem, "Row select",  1);
    RADIO_SetValue(hItem, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO1);
    RADIO_SetText(hItem, "Off", 0);
    RADIO_SetText(hItem, "On",  1);
    RADIO_SetValue(hItem, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO4);
    RADIO_SetText(hItem, "Small font", 0);
    RADIO_SetText(hItem, "Large font",  1);
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  int i;
  int j;
  int k;
  int slave_column;
  char buffer[10];

  new_GUI_value.BUTTON_value.send_button= FALSE;
  
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'id_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "slave id:");
    //
    // Initialization of 'function_radio'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
    RADIO_SetText(hItem, "read holding registers", 0);
    RADIO_SetText(hItem, "write single register", 1);
    RADIO_SetText(hItem, "read single coil", 2);
    RADIO_SetText(hItem, "write single coil", 3);
    RADIO_SetText(hItem, "read multiple coils", 4);
    //
    // Initialization of 'multiple_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetText(hItem, "MULTIPLE REGISTER REQUEST");
    //
    // Initialization of 'from_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetText(hItem, "from:");
    //
    // Initialization of 'to_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetText(hItem, "to:");
    //
    // Initialization of 'single_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
    TEXT_SetText(hItem, "SINGLE REGISTER REQUEST");
    //
    // Initialization of 'number_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
    TEXT_SetText(hItem, "number:");
    //
    // Initialization of 'send_button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "SEND");
    //
    // Initialization of 'response_view'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    LISTVIEW_AddColumn(hItem, 60, "address", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 80, "slave 1", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 80, "slave 2", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddRow(hItem, NULL);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_AddColumn(hItem, 30, "Col", GUI_TA_LEFT | GUI_TA_VCENTER);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    //
    // Initialization of 'status_view'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
    LISTVIEW_AddColumn(hItem, 129, "status", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_SetItemText(hItem, 0, 0, "0");
    LISTVIEW_SetItemText(hItem, 0, 0, "0");
    LISTVIEW_SetRowHeight(hItem, 20);
    LISTVIEW_SetHeaderHeight(hItem, 20);
    //
    // Initialization of 'exit_button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, " X");
    //
    // Initialization of 'write_req_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
    TEXT_SetText(hItem, "WRITE REGISTER REQUEST");
    //
    // Initialization of 'value_txt'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
    TEXT_SetText(hItem, "value:");
    // USER START (Optionally insert additional code for further widget initialization)

    //aggiungo casella Status
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
    LISTVIEW_AddRow(hItem, NULL);
    LISTVIEW_SetItemText(hItem, 0, 0, "Ready");

    //aggiungo caselle di risposta
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    for (i = 0; i < 60; i++)
       LISTVIEW_AddRow(hItem, NULL);


    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_RADIO_0: // Notifications sent by 'function_radio'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // 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_RADIO_0);
          new_GUI_value.RADIO_value.radio_selection = RADIO_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_0: // Notifications sent by 'send_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(600, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)

        modbus_task();

        hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);

        if (modbus_rx.error != 0)
        {
					GUI_Delay(100);
					modbus_task();
				}
				
				hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
					
				if (modbus_rx.error != 0)
				{

					LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_RED);
					GUI_Delay(100);
					LISTVIEW_SetItemText(hItem, 0, 0, "No Response");
					PlayAudio(50, 60);				
					PlayAudio(0, 20);				
					PlayAudio(50, 100);				
				}
					
				 else if (modbus_rx.func & 0x80)
				{
					LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_YELLOW);
					GUI_Delay(100);
					LISTVIEW_SetItemText(hItem, 0, 0, "R: Wrong Message");
					PlayAudio(90, 60);				
					PlayAudio(90, 20);				
					PlayAudio(90, 100);				

				}

				else
				{
					//cancello vecchi valori
					hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
					LISTVIEW_DeleteAllRows(hItem);
					GUI_Delay(100);
					for (i = 0; i < 60; i++)
						LISTVIEW_AddRow(hItem, NULL);
					GUI_Delay(100);
					
					hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);

					LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_GREEN);
					GUI_Delay(100);
					LISTVIEW_SetItemText(hItem, 0, 0, "R: Message Accepted");
					PlayAudio(600, 20);				
					PlayAudio(600, 20);				
					PlayAudio(200, 20);
					
					
					//se ho fatto una richiesta read
					if(new_GUI_value.RADIO_value.radio_selection == 0 || new_GUI_value.RADIO_value.radio_selection == 2 || new_GUI_value.RADIO_value.radio_selection == 4)
					{
						if(new_GUI_value.SPINBOX_value.slave_id == 1)
							slave_column = 1;
						else
							slave_column = 2;

						//scrivo sul listview 0
						hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);

						
						//mi prendo la sezione dati effettivi

						//ho chiesto gli holding?
						if(new_GUI_value.RADIO_value.radio_selection == 0){
							for(i = 0; i < modbus_rx.len; i++)
							{
								//se leggo holdings
								sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i +2000);
								
								LISTVIEW_SetItemText(hItem, 0, i, buffer);
				
								sprintf(buffer, "%d", modbus_rx.data_converted[i]);
								LISTVIEW_SetItemText(hItem, slave_column, i, buffer);

							}
						}							


						//ho chiesto i coils?
						else if(new_GUI_value.RADIO_value.radio_selection == 4 ){
							for(i = 0; i < modbus_rx.len; i++)
							{
								sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i );
								
								LISTVIEW_SetItemText(hItem, 0, i, buffer);

								if(modbus_rx.data_converted[i] != 0)
									sprintf(buffer, "%s", "ON");
								else
									sprintf(buffer, "%s", "OFF");
								
								LISTVIEW_SetItemText(hItem, slave_column, i, buffer);

							}							
						}	

						//ho chiesto 1 coil?
						else if(new_GUI_value.RADIO_value.radio_selection == 2){
							
								sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.single_register_number);
								LISTVIEW_SetItemText(hItem, 0, 0, buffer);
							
								if(modbus_rx.data_converted[0] != 0)
									sprintf(buffer, "%s", "ON");
								else
									sprintf(buffer, "%s", "OFF");
								
								LISTVIEW_SetItemText(hItem, slave_column, 0, buffer);
							
							
						}
						
					}						
				}

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_LISTVIEW_0: // Notifications sent by 'response_view'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_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_LISTVIEW_1: // Notifications sent by 'status_view'
      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_SEL_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_BUTTON_1: // 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)
        new_GUI_value.SPINBOX_value.slave_id = 0;
        new_GUI_value.SPINBOX_value.multiple_register_from = 0;
        new_GUI_value.SPINBOX_value.multiple_register_to = 0;
        new_GUI_value.SPINBOX_value.single_register_number = 0;
        new_GUI_value.SPINBOX_value.write_value = 0;
        new_GUI_value.RADIO_value.radio_selection = 0;

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

        hItem = pMsg->hWin;
        GUI_EndDialog(hItem, 0);


        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_0: // Notifications sent by 'slave_id_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // 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);
        new_GUI_value.SPINBOX_value.slave_id = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_1: // Notifications sent by 'from_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // 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_1);
        new_GUI_value.SPINBOX_value.multiple_register_from = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_2: // Notifications sent by 'to_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // 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_2);
        new_GUI_value.SPINBOX_value.multiple_register_to = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_3: // Notifications sent by 'number_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // 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_3);
        new_GUI_value.SPINBOX_value.single_register_number = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_4: // Notifications sent by 'write_value_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // 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_4);
        new_GUI_value.SPINBOX_value.write_value = SPINBOX_GetValue(pMsg->hWinSrc);

        // 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)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 11
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE *pMsg)
{
    WM_HWIN hItem;
    WM_HWIN const hEdit = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    int     NCode;
    int     Id;
    float 	fre;
    int 		tab = 0;
    static int ratio[] = { 1, 1000, 1000000};
    static const char *sel[] = {"Hz", "kHz", "MHz"};
    // USER START (Optionally insert additional variables)
    // USER END

    switch (pMsg->MsgId)
    {
    case WM_PAINT:
        WM_SetFocus(hEdit);
        break;
    case WM_INIT_DIALOG:
        //
        // Initialization of 'MeasureSet'
        //
        hItem = pMsg->hWin;
        FRAMEWIN_SetText(hItem, "Set Frequency");
        FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
        //
        // Initialization of 'Edit'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
        EDIT_SetText(hItem, "");
        EDIT_SetFont(hItem, GUI_FONT_20B_1);
        EDIT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER);
        fre = ptrDDS->GetFrequency();
        while(fre > 999.99)
        {
            fre /= 1000;
            tab++;
        }
        EDIT_SetFloatMode(hItem, fre, 0.00, 999.99, 2, GUI_EDIT_NORMAL);
        //
        // Initialization of 'Button'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
        BUTTON_SetFont(hItem, GUI_FONT_16_1);
        BUTTON_SetText(hItem, "Set");
        //
        // Initialization of 'Radio'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
        RADIO_SetFont(hItem, GUI_FONT_20_1);
        RADIO_SetText(hItem, sel[0], 0);
        RADIO_SetText(hItem, sel[1], 1);
        RADIO_SetText(hItem, sel[2], 2);
        RADIO_SetValue(hItem, tab);
        //
        // Initialization of 'Button'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
        BUTTON_SetFont(hItem, GUI_FONT_16_1);
        BUTTON_SetText(hItem, "Cancel");
        //
        // Initialization of 'btn1'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
        BUTTON_SetText(hItem, "1");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn2'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
        BUTTON_SetText(hItem, "2");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn3'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4);
        BUTTON_SetText(hItem, "3");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn4'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_5);
        BUTTON_SetText(hItem, "4");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn5'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_6);
        BUTTON_SetText(hItem, "5");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn6'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_7);
        BUTTON_SetText(hItem, "6");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn7'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_8);
        BUTTON_SetText(hItem, "7");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn8'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_9);
        BUTTON_SetText(hItem, "8");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn9'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_10);
        BUTTON_SetText(hItem, "9");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btn0'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_11);
        BUTTON_SetText(hItem, "0");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btnBS'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_12);
        BUTTON_SetText(hItem, "<--");
        BUTTON_SetFocussable(hItem, 0);
        //
        // Initialization of 'btnC'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_13);
        BUTTON_SetText(hItem, "-->");
        BUTTON_SetFocussable(hItem, 0);
        // USER START (Optionally insert additional code for further widget initialization)
        // USER END
        break;
    case WM_NOTIFY_PARENT:
        Id    = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        switch(Id)
        {
        case ID_EDIT_0: // Notifications sent by '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_BUTTON_0: // Notifications sent by 'Button'
            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)
                fre = EDIT_GetFloatValue(hEdit);
                tab = RADIO_GetValue(WM_GetDialogItem(pMsg->hWin, ID_RADIO_0));
                ptrDDS->SetFrequency(fre * ratio[tab]);
                GUI_EndDialog(pMsg->hWin, 0);
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_RADIO_0: // Notifications sent by 'Radio'
            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_BUTTON_1: // Notifications sent by 'Button'
            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)
                GUI_EndDialog(pMsg->hWin, 0);
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_2: // Notifications sent by 'btn1'
            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)
                EDIT_AddKey(hEdit, '1');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_3: // Notifications sent by 'btn2'
            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)
                EDIT_AddKey(hEdit, '2');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_4: // Notifications sent by 'btn3'
            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)
                EDIT_AddKey(hEdit, '3');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_5: // Notifications sent by 'btn4'
            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)
                EDIT_AddKey(hEdit, '4');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_6: // Notifications sent by 'btn5'
            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)
                EDIT_AddKey(hEdit, '5');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_7: // Notifications sent by 'btn6'
            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)
                EDIT_AddKey(hEdit, '6');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_8: // Notifications sent by 'btn7'
            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)
                EDIT_AddKey(hEdit, '7');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_9: // Notifications sent by 'btn8'
            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)
                EDIT_AddKey(hEdit, '8');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_10: // Notifications sent by 'btn9'
            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)
                EDIT_AddKey(hEdit, '9');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_11: // Notifications sent by 'btn0'
            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)
                EDIT_AddKey(hEdit, '0');
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_12: // Notifications sent by 'btnBS'
            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)
                EDIT_AddKey(hEdit, GUI_KEY_LEFT);
                // USER END
                break;
                // USER START (Optionally insert additional code for further notification handling)
                // USER END
            }
            break;
        case ID_BUTTON_13: // Notifications sent by 'btnC'
            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)
                EDIT_AddKey(hEdit, GUI_KEY_RIGHT);
                // 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)
    // USER END
    default:
        WM_DefaultProc(pMsg);
        break;
    }
}