Exemplo n.º 1
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;
  }
}
Exemplo n.º 2
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;
    }
}