/**
  * @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;
  }
}
/*********************************************************************
*
*       DROPDOWN_InsertString
*/
void DROPDOWN_InsertString(DROPDOWN_Handle hObj, const char * s, unsigned int Index) {
  if (hObj && s) {
    DROPDOWN_Obj* pObj;
    unsigned int NumItems;
    WM_LOCK();
    pObj = DROPDOWN_H2P(hObj);
    NumItems = DROPDOWN_GetNumItems(hObj);
    if (Index < NumItems) {
      WM_HMEM hItem;
      hItem = GUI_ARRAY_InsertItem(&pObj->Handles, Index, strlen(s) + 1);
      if (hItem) {
        char * pBuffer = (char *)GUI_ALLOC_h2p(hItem);
        strcpy(pBuffer, s);
      }
      WM_InvalidateWindow(hObj);
      if (pObj->hListWin) {
        LISTBOX_InsertString(pObj->hListWin, s, Index);
      }
    } else {
      DROPDOWN_AddString(hObj, s);
      if (pObj->hListWin) {
        LISTBOX_AddString(pObj->hListWin, s);
      }
    }
    WM_UNLOCK();
  }
}
Пример #3
0
/*********************************************************************
*
*       _InitDialogOrder
*/
static void _InitDialogOrder(WM_HWIN hWin) {
  WM_HWIN hItem;

  //
  // Init framewindow
  //
  FRAMEWIN_SetFont(hWin, &GUI_Font10_ASCII);
  FRAMEWIN_SetTitleHeight(hWin, 14);
  FRAMEWIN_SetMoveable(hWin, 1);
  //
  // Init edit widget
  //
  hItem = WM_GetDialogItem(hWin, GUI_ID_EDIT0);
  WM_DisableWindow(hItem);
  //
  // Init dropdown box color
  //
  hItem = WM_GetDialogItem(hWin, GUI_ID_DROPDOWN0);
  DROPDOWN_AddString(hItem, "Blue");
  DROPDOWN_AddString(hItem, "Green");
  DROPDOWN_AddString(hItem, "Red");
  DROPDOWN_SetBkColor(hItem, 1, GUI_WHITE);
  DROPDOWN_SetTextColor(hItem, 1, GUI_BLACK);
  //
  // Init dropdown box model
  //
  hItem = WM_GetDialogItem(hWin, GUI_ID_DROPDOWN1);
  DROPDOWN_AddString(hItem, "Navigation system");
  DROPDOWN_AddString(hItem, "CD Player");
  DROPDOWN_AddString(hItem, "Other ...");
  DROPDOWN_SetBkColor(hItem, 1, GUI_WHITE);
  DROPDOWN_SetTextColor(hItem, 1, GUI_BLACK);
}
Пример #4
0
/*******************************************************************
*
*       _ShowSeveralFunctions
*/
static void _ShowSeveralFunctions(DROPDOWN_Handle hDropDown) {
  int NumEntries, i, Key = 0, Cnt = 15;
  char ac[] = "-- sec to play with dropdown control";
  /* Set focus */
  GUI_DispStringAtCEOL("WM_SetFocus", 5, 55);
  GUI_Delay(SPEED * 0.9);
  WM_SetFocus(hDropDown);
  GUI_Delay(SPEED * 0.7);
  /* Add strings */
  GUI_DispStringAtCEOL("DROPDOWN_AddString", 5, 55);
  GUI_Delay(SPEED * 0.8);
  DROPDOWN_AddString(hDropDown, "English");
  DROPDOWN_AddString(hDropDown, "Deutsch");
  DROPDOWN_AddString(hDropDown, "Fran鏰is");
  DROPDOWN_AddString(hDropDown, "Japanese");
  DROPDOWN_AddString(hDropDown, "Italiano");
  DROPDOWN_AddString(hDropDown, "Espa駉l");
  DROPDOWN_AddString(hDropDown, "Other language ...");
  GUI_Delay(SPEED * 0.6);
  /* Increment selection */
  GUI_DispStringAtCEOL("DROPDOWN_IncSel", 5, 55);
  GUI_Delay(SPEED);
  NumEntries = DROPDOWN_GetNumItems(hDropDown);
  for (i = 0; i < (NumEntries - 2); i++) {
    DROPDOWN_IncSel(hDropDown);
    GUI_Delay(SPEED / 6);
	}
  GUI_Delay(SPEED / 4);
  /* Expand dropdown */
  GUI_DispStringAtCEOL("DROPDOWN_Expand", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_Expand(hDropDown);
  GUI_Delay(SPEED * 0.75);
  /* Add scrollbar */
  GUI_DispStringAtCEOL("DROPDOWN_SetAutoScroll", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetAutoScroll(hDropDown, 1);
  GUI_Delay(SPEED * 0.75);
  /* Set font */
  GUI_DispStringAtCEOL("DROPDOWN_SetFont", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetFont(hDropDown, &GUI_Font16B_1);
  GUI_Delay(SPEED * 0.75);
  /* Set text color */
  GUI_DispStringAtCEOL("DROPDOWN_SetTextColor", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetTextColor(hDropDown, 0, 0x00BB00);
  DROPDOWN_SetTextColor(hDropDown, 2, GUI_BLACK);
  GUI_Delay(SPEED * 0.75);
  /* Set background color */
  GUI_DispStringAtCEOL("DROPDOWN_SetBkColor", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetBkColor(hDropDown, 0, GUI_YELLOW);
  DROPDOWN_SetBkColor(hDropDown, 2, GUI_RED);
  GUI_Delay(SPEED * 0.75);
  /* Delete item */
  GUI_DispStringAtCEOL("DROPDOWN_DeleteItem", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_DeleteItem(hDropDown, 5);
  GUI_Delay(SPEED * 0.75);
  /* Collapse dropdown */
  GUI_DispStringAtCEOL("DROPDOWN_Collapse", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_Collapse(hDropDown);
  GUI_Delay(SPEED * 0.75);
  /* Decrement selection */
  GUI_DispStringAtCEOL("DROPDOWN_DecSel", 5, 55);
  GUI_Delay(SPEED);
  NumEntries = DROPDOWN_GetNumItems(hDropDown);
  for (i = 0; i < (NumEntries - 2); i++) {
    DROPDOWN_DecSel(hDropDown);
    GUI_Delay(SPEED / 6);
	}
  GUI_Delay(SPEED / 4);
  /* Let user play with dropdown control */
  GUI_DispStringAtCEOL("", 5, 55);
  while (!Key && (Cnt > 0)) {
    ac[0] = '0' + (Cnt / 10);
    ac[1] = '0' + (Cnt-- % 10);
    GUI_DispStringAtCEOL(ac, 5, 40);
    GUI_Delay(1000);
    Key = GUI_GetKey();
  }
  /* Delete dropdown widget */
  GUI_DispStringAtCEOL("DROPDOWN_Delete", 5, 55);
  GUI_Delay(SPEED * 1.1);
  DROPDOWN_Delete(hDropDown);
  GUI_Delay(SPEED * 0.75);
}
Пример #5
0
/*********************************************************************
 *
 *       _cbDialog
 */
static void _cbDialog(WM_MESSAGE * pMsg) {
	WM_HWIN hItem;
	int NCode;
	int Id;

	switch (pMsg->MsgId) {
	case WM_INIT_DIALOG:
		//
		// Initialization of 'Dropdown'
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_LIGHTS);
		DROPDOWN_AddString(hItem, "Light 2");
		DROPDOWN_AddString(hItem, "Light 1");
		DROPDOWN_AddString(hItem, "Item");
		DROPDOWN_IncSel(hItem);
		//
		// Initialization of 'Address' Text
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_ADDRESS);
		TEXT_SetText(hItem, "Address: <address>");
		//
		// Initialization of 'Status' Text
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_ONOFF);
		TEXT_SetText(hItem, "Status: ON");
		//
		// Initialization of 'On/Off' Button
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ONOFF);
		BUTTON_SetText(hItem, "Toggle On/Off");
		//
		// Initialization of 'Mode' Text
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_MODE);
		TEXT_SetText(hItem, "Mode: Auto");
		//
		// Initialization of 'Mode' Button
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_MODE);
		BUTTON_SetText(hItem, "Trigger SOS");
		//
		// Initialization of 'Add' Button
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ADD);
		BUTTON_SetText(hItem, "Add new...");
		//
		// Initialization of 'Reconfigure' Button
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_RECONFIGURE);
		BUTTON_SetText(hItem, "Reconfigure...");
		//
		// Initialization of 'Remove' Button
		//
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_REMOVE);
		BUTTON_SetText(hItem, "Remove...");

		WM_MakeModal(pMsg->hWin);
		break;
	case WM_NOTIFY_PARENT:
		Id = WM_GetId(pMsg->hWinSrc);
		NCode = pMsg->Data.v;
		switch (Id) {
		case ID_DROPDOWN_LIGHTS: // Notifications sent by 'Dropdown'
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			case WM_NOTIFICATION_SEL_CHANGED:
				break;
			}
			break;
		case ID_BUTTON_ONOFF:
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				ToggleLightN(1, WM_GetDialogItem(pMsg->hWin, ID_TEXT_ONOFF));
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			}
			break;
		case ID_BUTTON_MODE:
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				TriggerSOS(1, WM_GetDialogItem(pMsg->hWin, ID_TEXT_MODE));
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			}
			break;
		case ID_BUTTON_ADD:
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				AddNewLight(0);
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			}
			break;
		case ID_BUTTON_RECONFIGURE:
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				ReconfigureLight(0);
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			}
			break;
		case ID_BUTTON_REMOVE:
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				RemoveLight(0);
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			}
			break;
		case ID_BUTTON_OK:
			switch (NCode) {
			case WM_NOTIFICATION_CLICKED:
				GUI_EndDialog(pMsg->hWin, 0);
				break;
			case WM_NOTIFICATION_RELEASED:
				break;
			}
			break;
		}
		break;
	default:
		WM_DefaultProc(pMsg);
		break;
	}
}
Пример #6
0
/*********************************************************************
*
*       _cbCallback
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  int NCode, Id;
  WM_HWIN hEdit0, hEdit1, hEdit2, hEdit3, hListBox, hDropd0, hDropd1;
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      /* Get window handles for all widgets */
      hEdit0   = WM_GetDialogItem(hWin, GUI_ID_EDIT0);
      hEdit1   = WM_GetDialogItem(hWin, GUI_ID_EDIT1);
      hEdit2   = WM_GetDialogItem(hWin, GUI_ID_EDIT2);
      hEdit3   = WM_GetDialogItem(hWin, GUI_ID_EDIT3);
      hListBox = WM_GetDialogItem(hWin, GUI_ID_LISTBOX0);
      hDropd0  = WM_GetDialogItem(hWin, GUI_ID_DROPDOWN0);
      hDropd1  = WM_GetDialogItem(hWin, GUI_ID_DROPDOWN1);
      /* Initialize all widgets */
      EDIT_SetText(hEdit0, "EDIT widget 0");
      EDIT_SetText(hEdit1, "EDIT widget 1");
      EDIT_SetTextAlign(hEdit1, GUI_TA_LEFT);
      EDIT_SetHexMode(hEdit2, 0x1234, 0, 0xffffff);
      EDIT_SetBinMode(hEdit3, 0x1234, 0, 0xffff);
      LISTBOX_SetText(hListBox, _apListBox);
      WM_DisableWindow (WM_GetDialogItem(hWin, GUI_ID_CHECK1));
      CHECKBOX_Check(  WM_GetDialogItem(hWin, GUI_ID_CHECK0));
      CHECKBOX_Check(  WM_GetDialogItem(hWin, GUI_ID_CHECK1));
      SLIDER_SetWidth( WM_GetDialogItem(hWin, GUI_ID_SLIDER0), 5);
      SLIDER_SetValue( WM_GetDialogItem(hWin, GUI_ID_SLIDER1), 50);
      SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL);
      DROPDOWN_AddString(hDropd0, "Item 0");
      DROPDOWN_AddString(hDropd0, "Item 1");
      DROPDOWN_AddString(hDropd0, "Item 2");
      DROPDOWN_AddString(hDropd1, "Item 0");
      DROPDOWN_AddString(hDropd1, "Item 1");
      DROPDOWN_AddString(hDropd1, "Item 2");
      DROPDOWN_AddString(hDropd1, "Item 3");
      DROPDOWN_AddString(hDropd1, "Item 4");
      break;
    case WM_KEY:
      switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) {
      case GUI_KEY_ESCAPE:
        GUI_EndDialog(hWin, 1);
        break;
      case GUI_KEY_ENTER:
        GUI_EndDialog(hWin, 0);
        break;
      }
      break;
    case WM_NOTIFY_PARENT:
      Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
      NCode = pMsg->Data.v;               /* Notification code */
      switch (NCode) {
        case WM_NOTIFICATION_RELEASED:    /* React only if released */
          if (Id == GUI_ID_OK) {          /* OK Button */
            GUI_EndDialog(hWin, 0);
          }
          if (Id == GUI_ID_CANCEL) {      /* Cancel Button */
            GUI_EndDialog(hWin, 1);
          }
          break;
      }
      break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Пример #7
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;
	WM_MESSAGE             Msg;
	WM_HWIN                hIteminfo;
	int 									  i;
	int 	     					sel;
	uint8_t     					items;
	FRESULT res;
 // FILINFO fno;
  //DIR dir;
  // USER START (Optionally insert additional variables)
  // USER END
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
	hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
	//WM_SetFocus(hItem);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
    TEXT_SetText(hItem, "自学习文件选择");  
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"打开文件……");
		WM_HideWindow(hIteminfo);
	  //
    // Initialization of 'Dropdown'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12);
    DROPDOWN_AddString(hItem, "U盘");
    DROPDOWN_AddString(hItem, "SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
	//
    // Initialization of 'Treeview'
    //
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestFolder_Init();
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		for(i=0;i<TestFolder.number_TotalFile;i++)
		{
			LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
		}
		LISTBOX_SetFont(hItem,GUI_FONT_20_1);
		LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile);
    
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		break;
	case MY_MESSAGE_DOWN:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_IncSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,0);		
			}	

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

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

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

		break;
	case MY_MESSAGE_BUTTONDELETE:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		if(store_dev==0) //usb
		strcpy(filename,path_testfile);
		//f_opendir(&dir, path_testfile);
		if(store_dev==1) //sd
		strcpy(filename,path_testfile_sd);
		//f_opendir(&dir, path_testfile_sd);
		//res = f_opendir(&dir, "1:/LZY_WireTester/Test Files");
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		strcat(filename,"/");
		sel = LISTBOX_GetSel(hItem);
		if(sel < 0) break;
		strcat(filename,(char *)TestFolder.FilesName[LISTBOX_GetSel(hItem)]);
		res=f_unlink((const TCHAR*)filename);
		if(res == FR_OK)
		{
			hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
			WM_SetFocus(hItem);
			if(sel > 0) LISTBOX_SetSel(hItem,sel - 1);
			else LISTBOX_SetSel(hItem,0);
		}
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,380,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(8);
		GUI_DrawRect(0,0,378,220);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Пример #8
0
/*****************************
Initializacija paneli comunikaciji
*****************************/
void Modbus_panel_show(void)
{
  if (Modbus_FrameWin == WM_UNATTACHED)
  {
    //Stvorjujemo FrameWin
    Modbus_FrameWin = FRAMEWIN_CreateEx(X0, Y0, X_SIZE, Y_SIZE, 0, WM_CF_HIDE, 0, ID_MODBUS_FRAMEWIN, Modbus_panel_title.ptitle[sel_language], _cbProtection_FrameWin);
    FRAMEWIN_SetFont(Modbus_FrameWin, &GUI_FontArialBold14_8_Unicode);
    FRAMEWIN_SetTextAlign(Modbus_FrameWin, GUI_TA_HCENTER);
    FRAMEWIN_SetBarColor(Modbus_FrameWin, 1, GUI_GREEN);
    FRAMEWIN_SetBarColor(Modbus_FrameWin, 0, GUI_LIGHTGRAY);
    FRAMEWIN_SetTextColor(Modbus_FrameWin, GUI_BLUE);

#define COL_1_X         5
#define ROW_1_Y         10
#define HIGHT_Y         20
#define SHIFT_Y         (ROW_1_Y + HIGHT_Y)
#define WIDTH_X_T       165
#define WIDTH_X_V       60
#define SHIFT_X1        (WIDTH_X_T + 10)
#define SHIFT_X2        (SHIFT_X1 + WIDTH_X_V + 10)
    
    ScrollBar_Modbus = SCROLLBAR_CreateAttached(WM_GetClientWindow(Modbus_FrameWin), SCROLLBAR_CF_VERTICAL);
    SCROLLBAR_SetNumItems(ScrollBar_Modbus, MAX_NUMBER_ITEMS_MODBUS*SHIFT_Y);
    SCROLLBAR_SetPageSize(ScrollBar_Modbus, 6*SHIFT_Y);

    //Address
    Modbus_t[0] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 0*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_ADDRESS_TITLE,  Modbus_title[0].ptitle[sel_language]);
    TEXT_SetFont(Modbus_t[0], &GUI_FontArialStandard14_8_Unicode);
    Modbus_v[0] = EDIT_CreateUser(COL_1_X + SHIFT_X1, ROW_1_Y + 0*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, 0, ID_MODBUS_ADDRESS_VALUE, 3, sizeof(__info_data));
    EDIT_SetFont(Modbus_v[0], &GUI_FontArialStandard14_8_Unicode);

    __info_data info_data;
    int shift = 0, max = KOEF_ADDRESS_MAX, min = 0;

    info_data.extra_param =  0;
    info_data.shift =  shift;
    float _shift = 0.0f;
    for (int rozrjad = 0; rozrjad < shift; rozrjad++) 
    {
      _shift /= 10.0f;
      _shift += 0.9f;
    }

//    int max_tmp = max;
//    float _max = 10;
//    while ( abs(max_tmp /= 10) >= 1) _max *= 10.0f;
//    if (max > 0)
//    {
//      _max = _max - 1 + _shift;
//    }
//    else if (max < 0)
//    {   
//      _max = -(_max / 10);
//    }
//    else _max = 0;
//    info_data.max =  _max;
    float _max = 255; //maksymalne odnobajtne chyslo, bo adresu ob'javleno jak typ char
    info_data.max =  _max;
    
    int min_tmp = min;
    float _min = 10;
    while ( abs(min_tmp /= 10) >= 1) _min *= 10.0f;
    if (min > 0)
    {
      _min = (_min / 10);
    }
    else if (min < 0)
    {
      _min = -(_min - 1 + _shift);
    }
    else _min = 0;
    info_data.min =  _min;
    
    EDIT_SetUserData(Modbus_v[0], &info_data, sizeof(__info_data));
    EDIT_SetFloatMode(Modbus_v[0], 0, _min, _max, shift, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    //Baud Rate
    Modbus_t[1] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 1*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_BAUD_RATE_TITLE,  Modbus_title[1].ptitle[sel_language]);
    TEXT_SetFont(Modbus_t[1], &GUI_FontArialStandard14_8_Unicode);
    Modbus_v[1] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 1*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_BAUD_RATE_VALUE);
    DROPDOWN_SetFont(Modbus_v[1], &GUI_FontArialStandard14_8_Unicode);
    DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_UNSEL, GUI_GRAY);
    DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_SEL,  GUI_GRAY);
    DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_SELFOCUS, GUI_BLUE);
    DROPDOWN_AddString(Modbus_v[1], "");
    for (int i = 0; i < 7; i++) DROPDOWN_AddString(Modbus_v[1], Baud_rate_title[i]);

    //Parity
    Modbus_t[2] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 2*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_PARITY_TITLE,  Modbus_title[2].ptitle[sel_language]);
    TEXT_SetFont(Modbus_t[2], &GUI_FontArialStandard14_8_Unicode);
    Modbus_v[2] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 2*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_PARITY_VALUE);
    DROPDOWN_SetFont(Modbus_v[2], &GUI_FontArialStandard14_8_Unicode);
    DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_UNSEL, GUI_GRAY);
    DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_SEL,  GUI_GRAY);
    DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_SELFOCUS, GUI_BLUE);
    DROPDOWN_AddString(Modbus_v[2], "");
    for (int i = 0; i < 3; i++) DROPDOWN_AddString(Modbus_v[2], Parity_title[i].ptitle[sel_language]);

    //Stop bits
    Modbus_t[3] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 3*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_STOP_BITS_TITLE,  Modbus_title[3].ptitle[sel_language]);
    TEXT_SetFont(Modbus_t[3], &GUI_FontArialStandard14_8_Unicode);
    Modbus_v[3] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 3*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_STOP_BITS_VALUE);
    DROPDOWN_SetFont(Modbus_v[3], &GUI_FontArialStandard14_8_Unicode);
    DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_UNSEL, GUI_GRAY);
    DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_SEL,  GUI_GRAY);
    DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_SELFOCUS, GUI_BLUE);
    DROPDOWN_AddString(Modbus_v[3], "");
    for (int i = 0; i < 2; i++) DROPDOWN_AddString(Modbus_v[3], Stop_bits_title[i]);

    //Time-Out
    Modbus_t[4] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 4*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_TIMEOUT_TITLE,  Modbus_title[4].ptitle[sel_language]);
    TEXT_SetFont(Modbus_t[4], &GUI_FontArialStandard14_8_Unicode);
    Modbus_v[4] = EDIT_CreateUser(COL_1_X + SHIFT_X1, ROW_1_Y + 4*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, 0, ID_MODBUS_TIMEOUT_VALUE, 5, sizeof(__info_data));
    EDIT_SetFont(Modbus_v[4], &GUI_FontArialStandard14_8_Unicode);

    shift = 1;
    max = VALUE_TIME_OUT_1_INTERFACE_MAX/10;
    min = 0;

    info_data.extra_param =  0;
    info_data.shift =  shift;
    _shift = 0.0f;
    for (int rozrjad = 0; rozrjad < shift; rozrjad++) 
    {
      _shift /= 10.0f;
      _shift += 0.9f;
    }

    int max_tmp = max;
    _max = 10;
    while ( abs(max_tmp /= 10) >= 1) _max *= 10.0f;
    if (max > 0)
    {   
      _max = _max - 1 + _shift;
    }
    else if (max < 0)
    {
      _max = -(_max / 10);
    }
    else _max = 0;
    info_data.max =  _max;
    
    min_tmp = min;
    _min = 10;
    while ( abs(min_tmp /= 10) >= 1) _min *= 10.0f;
    if (min > 0)
    {
      _min = (_min / 10);
    }
    else if (min < 0)
    {
      _min = -(_min - 1 + _shift);
    }
    else _min = 0;
    info_data.min =  _min;
    
    EDIT_SetUserData(Modbus_v[4], &info_data, sizeof(__info_data));
    EDIT_SetFloatMode(Modbus_v[4], 0, _min, _max, shift, GUI_EDIT_SUPPRESS_LEADING_ZEROES);

    Modbus_d = TEXT_CreateEx(COL_1_X + SHIFT_X2 , ROW_1_Y + 4*SHIFT_Y, 40, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_TIMEOUT_DIMENSION,  Modbus_Timeout_dimention.ptitle[sel_language]);
    TEXT_SetFont(Modbus_d, &GUI_FontArialStandard14_8_Unicode);
    
#undef COL_1_X
#undef ROW_1_Y
#undef HIGHT_Y
#undef SHIFT_Y
#undef WIDTH_X_T
#undef WIDTH_X_V
#undef SHIFT_X1
#undef SHIFT_X2
  }
  
  WM_BringToTop(Modbus_FrameWin);
  WM_ShowWindow(Modbus_FrameWin);
  
}
Пример #9
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of '_dFileType'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
    DROPDOWN_AddString(hItem, "(.Prj) Project");
    //
    // Initialization of 'Name'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER);
    //
    // Initialization of '_bOK'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "Conform");
    //
    // Initialization of '_bDiscard'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, "Discard");
    //
    // Initialization of 'Listview'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_AddColumn(hItem, 50, "Date", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 100, "FileName", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 80, "Type", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddRow(hItem, NULL);
    LISTVIEW_SetItemText(hItem, 0, 0, "13/12/21");
    LISTVIEW_SetItemText(hItem, 1, 0, "Default.Prj");
    LISTVIEW_SetItemText(hItem, 2, 0, ".Prj Project");
    //
    // Initialization of '_eFilename'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "Default.prj");
    // 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_DROPDOWN_0: // Notifications sent by '_dFileType'
      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_0: // Notifications sent by '_bOK'
      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;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by '_bDiscard'
      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;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_LISTVIEW_0: // Notifications sent by 'Listview'
      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_EDIT_0: // Notifications sent by '_eFilename'
      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;
    // 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;
  }
}
Пример #10
0
/*********************************************************************
*
*       _cbDialogColor
*
* Function description
*   Callback routine of DialogColor
*/
static void _cbDialogColor(WM_MESSAGE * pMsg) {
  GUI_COLOR Color;
  WM_HWIN   hDlg;
  WM_HWIN   hItem;
  int       i;
  int       NCode;
  int       Id;

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

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Framewin'
    //
    hItem = pMsg->hWin;
    FRAMEWIN_SetTitleVis(hItem, 0);
    //
    // Initialization of 'Dropdown'
    //
    hItem_Drop_Years = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
	  DROPDOWN_SetListHeight(hItem_Drop_Years, 100);
	  DROPDOWN_SetItemSpacing(hItem_Drop_Years,10);
	  DROPDOWN_SetAutoScroll(hItem_Drop_Years,1);
	  DROPDOWN_SetFont(hItem_Drop_Years, GUI_FONT_13B_1);
	  DROPDOWN_AddString(hItem_Drop_Years, "2016");
	  DROPDOWN_AddString(hItem_Drop_Years, "2017");
	  DROPDOWN_AddString(hItem_Drop_Years, "2018");
		DROPDOWN_AddString(hItem_Drop_Years, "2019");
		DROPDOWN_AddString(hItem_Drop_Years, "2020");
		DROPDOWN_AddString(hItem_Drop_Years, "2021");
		DROPDOWN_AddString(hItem_Drop_Years, "2022");
		DROPDOWN_AddString(hItem_Drop_Years, "2023");
		DROPDOWN_AddString(hItem_Drop_Years, "2024");
		DROPDOWN_AddString(hItem_Drop_Years, "2025");
		DROPDOWN_AddString(hItem_Drop_Years, "2026");
		DROPDOWN_AddString(hItem_Drop_Years, "2027");
		DROPDOWN_AddString(hItem_Drop_Years, "2028");
		DROPDOWN_AddString(hItem_Drop_Years, "2029");
		DROPDOWN_AddString(hItem_Drop_Years, "2030");
		DROPDOWN_SetScrollbarWidth(hItem_Drop_Years,10);

    //
    // Initialization of 'Dropdown'
    //
    hItem_Drop_Month = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_1);
		DROPDOWN_SetListHeight(hItem_Drop_Month, 100);
	  DROPDOWN_SetItemSpacing(hItem_Drop_Month,10);
	  DROPDOWN_SetAutoScroll(hItem_Drop_Month,1);
    DROPDOWN_AddString(hItem_Drop_Month, "1");
		DROPDOWN_AddString(hItem_Drop_Month, "2");
		DROPDOWN_AddString(hItem_Drop_Month, "3");
		DROPDOWN_AddString(hItem_Drop_Month, "4");
		DROPDOWN_AddString(hItem_Drop_Month, "5");
		DROPDOWN_AddString(hItem_Drop_Month, "6");
		DROPDOWN_AddString(hItem_Drop_Month, "7");
		DROPDOWN_AddString(hItem_Drop_Month, "8");
		DROPDOWN_AddString(hItem_Drop_Month, "9");
		DROPDOWN_AddString(hItem_Drop_Month, "10");
		DROPDOWN_AddString(hItem_Drop_Month, "11");
		DROPDOWN_AddString(hItem_Drop_Month, "12");
		DROPDOWN_SetScrollbarWidth(hItem_Drop_Month,10);
		
    //
    // Initialization of 'Dropdown'
    //
    hItem_Drop_day = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_2);
    DROPDOWN_SetListHeight(hItem_Drop_day, 100);
	  DROPDOWN_SetItemSpacing(hItem_Drop_day,10);
	  DROPDOWN_SetAutoScroll(hItem_Drop_day,1);
    DROPDOWN_AddString(hItem_Drop_day, "1");
		DROPDOWN_AddString(hItem_Drop_day, "2");
		DROPDOWN_AddString(hItem_Drop_day, "3");
		DROPDOWN_AddString(hItem_Drop_day, "4");
		DROPDOWN_AddString(hItem_Drop_day, "5");
		DROPDOWN_AddString(hItem_Drop_day, "6");
		DROPDOWN_AddString(hItem_Drop_day, "7");
		DROPDOWN_AddString(hItem_Drop_day, "8");
		DROPDOWN_AddString(hItem_Drop_day, "9");
		DROPDOWN_AddString(hItem_Drop_day, "10");
		DROPDOWN_AddString(hItem_Drop_day, "11");
		DROPDOWN_AddString(hItem_Drop_day, "12");
		DROPDOWN_AddString(hItem_Drop_day, "13");
		DROPDOWN_AddString(hItem_Drop_day, "14");
		DROPDOWN_AddString(hItem_Drop_day, "15");
		DROPDOWN_AddString(hItem_Drop_day, "16");
		DROPDOWN_AddString(hItem_Drop_day, "17");
		DROPDOWN_AddString(hItem_Drop_day, "18");
		DROPDOWN_AddString(hItem_Drop_day, "19");
		DROPDOWN_AddString(hItem_Drop_day, "20");
		DROPDOWN_AddString(hItem_Drop_day, "21");
		DROPDOWN_AddString(hItem_Drop_day, "22");
		DROPDOWN_AddString(hItem_Drop_day, "23");
		DROPDOWN_AddString(hItem_Drop_day, "24");
		DROPDOWN_AddString(hItem_Drop_day, "25");
		DROPDOWN_AddString(hItem_Drop_day, "26");
		DROPDOWN_AddString(hItem_Drop_day, "27");
		DROPDOWN_AddString(hItem_Drop_day, "28");
		DROPDOWN_AddString(hItem_Drop_day, "29");
		DROPDOWN_AddString(hItem_Drop_day, "30");
		DROPDOWN_AddString(hItem_Drop_day, "31");
		DROPDOWN_SetScrollbarWidth(hItem_Drop_day,10);
    //
    // Initialization of 'Button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "ok");
    BUTTON_SetFont(hItem, GUI_FONT_20_1);
    //
    // Initialization of 'Button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, "skip");
    BUTTON_SetFont(hItem, GUI_FONT_20_1);
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetFont(hItem, GUI_FONT_20_1);
    TEXT_SetText(hItem, "year");
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetText(hItem, "month");
    TEXT_SetFont(hItem, GUI_FONT_20_1);
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetFont(hItem, GUI_FONT_20_1);
    TEXT_SetText(hItem, "day");
    //
    // Initialization of 'Dropdown'
    //
    hItem_Drop_hour = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_3);
    DROPDOWN_SetListHeight(hItem_Drop_hour, 100);
	  DROPDOWN_SetItemSpacing(hItem_Drop_hour,10);
	  DROPDOWN_SetAutoScroll(hItem_Drop_hour,1);
    DROPDOWN_AddString(hItem_Drop_hour, "1");
		DROPDOWN_AddString(hItem_Drop_hour, "2");
		DROPDOWN_AddString(hItem_Drop_hour, "3");
		DROPDOWN_AddString(hItem_Drop_hour, "4");
		DROPDOWN_AddString(hItem_Drop_hour, "5");
		DROPDOWN_AddString(hItem_Drop_hour, "6");
		DROPDOWN_AddString(hItem_Drop_hour, "7");
		DROPDOWN_AddString(hItem_Drop_hour, "8");
		DROPDOWN_AddString(hItem_Drop_hour, "9");
		DROPDOWN_AddString(hItem_Drop_hour, "10");
		DROPDOWN_AddString(hItem_Drop_hour, "11");
		DROPDOWN_AddString(hItem_Drop_hour, "12");
		DROPDOWN_AddString(hItem_Drop_hour, "13");
		DROPDOWN_AddString(hItem_Drop_hour, "14");
		DROPDOWN_AddString(hItem_Drop_hour, "15");
		DROPDOWN_AddString(hItem_Drop_hour, "16");
		DROPDOWN_AddString(hItem_Drop_hour, "17");
		DROPDOWN_AddString(hItem_Drop_hour, "18");
		DROPDOWN_AddString(hItem_Drop_hour, "19");
		DROPDOWN_AddString(hItem_Drop_hour, "20");
		DROPDOWN_AddString(hItem_Drop_hour, "21");
		DROPDOWN_AddString(hItem_Drop_hour, "22");
		DROPDOWN_AddString(hItem_Drop_hour, "23");
		DROPDOWN_AddString(hItem_Drop_hour, "24");
		DROPDOWN_SetScrollbarWidth(hItem_Drop_hour,10);
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetText(hItem, "hour");
    TEXT_SetFont(hItem, GUI_FONT_20_1);
		
		
		
		
		//
		//   drop4  min
		//
		
		hItem_Drop_min = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_4);
    DROPDOWN_SetListHeight(hItem_Drop_min, 100);
	  DROPDOWN_SetItemSpacing(hItem_Drop_min,10);
	  DROPDOWN_SetAutoScroll(hItem_Drop_min,1);
    DROPDOWN_AddString(hItem_Drop_min, "1");
		DROPDOWN_AddString(hItem_Drop_min, "2");
		DROPDOWN_AddString(hItem_Drop_min, "3");
		DROPDOWN_AddString(hItem_Drop_min, "4");
		DROPDOWN_AddString(hItem_Drop_min, "5");
		DROPDOWN_AddString(hItem_Drop_min, "6");
		DROPDOWN_AddString(hItem_Drop_min, "7");
		DROPDOWN_AddString(hItem_Drop_min, "8");
		DROPDOWN_AddString(hItem_Drop_min, "9");
		DROPDOWN_AddString(hItem_Drop_min, "10");
		DROPDOWN_AddString(hItem_Drop_min, "11");
		DROPDOWN_AddString(hItem_Drop_min, "12");
		DROPDOWN_AddString(hItem_Drop_min, "13");
		DROPDOWN_AddString(hItem_Drop_min, "14");
		DROPDOWN_AddString(hItem_Drop_min, "15");
		DROPDOWN_AddString(hItem_Drop_min, "16");
		DROPDOWN_AddString(hItem_Drop_min, "17");
		DROPDOWN_AddString(hItem_Drop_min, "18");
		DROPDOWN_AddString(hItem_Drop_min, "19");
		DROPDOWN_AddString(hItem_Drop_min, "20");
		DROPDOWN_AddString(hItem_Drop_min, "21");
		DROPDOWN_AddString(hItem_Drop_min, "22");
		DROPDOWN_AddString(hItem_Drop_min, "23");
		DROPDOWN_AddString(hItem_Drop_min, "24");
    DROPDOWN_AddString(hItem_Drop_min, "25");
		DROPDOWN_AddString(hItem_Drop_min, "26");
		DROPDOWN_AddString(hItem_Drop_min, "27");
		DROPDOWN_AddString(hItem_Drop_min, "28");
		DROPDOWN_AddString(hItem_Drop_min, "29");
		DROPDOWN_AddString(hItem_Drop_min, "30");
		DROPDOWN_AddString(hItem_Drop_min, "31");
		DROPDOWN_AddString(hItem_Drop_min, "32");
		DROPDOWN_AddString(hItem_Drop_min, "33");
		DROPDOWN_AddString(hItem_Drop_min, "34");
		DROPDOWN_AddString(hItem_Drop_min, "35");
		DROPDOWN_AddString(hItem_Drop_min, "36");
		DROPDOWN_AddString(hItem_Drop_min, "37");
		DROPDOWN_AddString(hItem_Drop_min, "38");
		DROPDOWN_AddString(hItem_Drop_min, "39");
		DROPDOWN_AddString(hItem_Drop_min, "40");
		DROPDOWN_AddString(hItem_Drop_min, "41");
		DROPDOWN_AddString(hItem_Drop_min, "42");
		DROPDOWN_AddString(hItem_Drop_min, "43");
		DROPDOWN_AddString(hItem_Drop_min, "44");
		DROPDOWN_AddString(hItem_Drop_min, "45");
		DROPDOWN_AddString(hItem_Drop_min, "46");
		DROPDOWN_AddString(hItem_Drop_min, "47");
		DROPDOWN_AddString(hItem_Drop_min, "48");
    DROPDOWN_AddString(hItem_Drop_min, "49");
		DROPDOWN_AddString(hItem_Drop_min, "50");
		DROPDOWN_AddString(hItem_Drop_min, "51");
		DROPDOWN_AddString(hItem_Drop_min, "52");
		DROPDOWN_AddString(hItem_Drop_min, "53");
		DROPDOWN_AddString(hItem_Drop_min, "54");
		DROPDOWN_AddString(hItem_Drop_min, "55");
		DROPDOWN_AddString(hItem_Drop_min, "56");
		DROPDOWN_AddString(hItem_Drop_min, "57");
		DROPDOWN_AddString(hItem_Drop_min, "58");
		DROPDOWN_AddString(hItem_Drop_min, "59");
		DROPDOWN_AddString(hItem_Drop_min, "60");
		DROPDOWN_SetScrollbarWidth(hItem_Drop_min,10);
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetText(hItem, "min");
    TEXT_SetFont(hItem, GUI_FONT_20_1);
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetText(hItem, "please set current time");
    // 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_DROPDOWN_0: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

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

				//hItemIndex = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
				//in = getDropIndex;
//			  Dropitem =  DROPDOWN_GetItemText(hItem,getDropIndex,"123",3);
//			  in = Dropitem;
						 //hItemIndex = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
			 // sprintf(out, " %d" , in);
//			  DROPDOWN_AddString(hItem,out);

			
        // 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_DROPDOWN_1: // Notifications sent by 'Dropdown'
      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_DROPDOWN_2: // Notifications sent by 'Dropdown'
      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_0: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
				hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
				getDropIndex = DROPDOWN_GetSel(hItem);  //获取当前选择的下表
			  getDropIndex = getDropIndex + startYear;
			  hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
				TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
				TEXT_SetFont(hItem, GUI_FONT_20_1);
			  sprintf(out," %d",getDropIndex);
				TEXT_SetText(hItem, out);
			
				hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_1);
				getDropIndexMonth = DROPDOWN_GetSel(hItem);
			  getDropIndexMonth = getDropIndexMonth + startMonth;
			
				hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_2);
				getDropIndexDay = DROPDOWN_GetSel(hItem);
			  getDropIndexDay = getDropIndexDay + startDay;
	
				hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_3);
				getDropIndexHour = DROPDOWN_GetSel(hItem);
			  getDropIndexHour = getDropIndexHour + startHour;		

				hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_4);
				getDropIndexMin = DROPDOWN_GetSel(hItem);
			  getDropIndexMin = getDropIndexMin + startMin;	
				
				
			  //Dropitem =  DROPDOWN_GetItemText(hItem,getDropIndex,"123",3);
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
				//index = 1;                //index为1时,删除界面
			
			
        // 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:
				index = 1;
        // 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_DROPDOWN_3: // Notifications sent by 'Dropdown'
      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_DROPDOWN_4: // Notifications sent by 'Dropdown'
      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;
    // 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;
  }
}
Пример #12
0
/*********************************************************************
*
*       _cbCallbackWidgets
*
* Purpose:
*   Initializes the widgets of the main dialog box
*/
static void _cbCallbackWidgets(WM_MESSAGE * pMsg) {
  GRAPH_SCALE_Handle hScaleH, hScaleV;
  int i;
  WM_HWIN hDlg, hMenu;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      /* Get handles of widgets */
      for (i = 0; i < NUM_WIDGETS; i++) {
        _ahWin[i] = WM_GetDialogItem(hDlg, _aID[i]);
      }
      /* Init dropdown widget */
      for (i = 0; i < 8; i++) {
        char acBuffer[] = {"Item x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        DROPDOWN_AddString(_ahWin[DROPDOWN0], acBuffer);
      }
      /* Init edit widget */
      EDIT_SetText(_ahWin[EDIT0], "Edit");
      /* Init listbox widget */
      LISTBOX_SetAutoScrollV(_ahWin[LISTBOX0], 1);
      for (i = 0; i < 4; i++) {
        char acBuffer[] = {"Item x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        LISTBOX_AddString(_ahWin[LISTBOX0], acBuffer);
      }
      /* Init listview widget */
      for (i = 0; i < 2; i++) {
        char acBuffer[] = {"Col. x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        LISTVIEW_AddColumn(_ahWin[LISTVIEW0], 60, acBuffer, GUI_TA_CENTER);
      }
      for (i = 0; i < 9; i++) {
        int j;
        LISTVIEW_AddRow(_ahWin[LISTVIEW0], NULL);
        for (j = 0; j < (int)LISTVIEW_GetNumColumns(_ahWin[LISTVIEW0]); j++) {
          char acBuffer[] = {"Rx/Cx"};
          acBuffer[1] = '1' + i;
          acBuffer[4] = '1' + j;
          LISTVIEW_SetItemText(_ahWin[LISTVIEW0], j, i, acBuffer);
        }
      }
      LISTVIEW_SetGridVis(_ahWin[LISTVIEW0], 1);
      SCROLLBAR_CreateAttached(_ahWin[LISTVIEW0], SCROLLBAR_CF_VERTICAL);
      /* Init multiedit widget */
      MULTIEDIT_SetText(_ahWin[MULTIEDIT0], "This text could be modified by the MULTIEDIT widget");
      MULTIEDIT_SetWrapWord(_ahWin[MULTIEDIT0]);
      MULTIEDIT_SetAutoScrollV(_ahWin[MULTIEDIT0], 1);
      /* Init progbar widget */
      WIDGET_SetEffect(_ahWin[PROGBAR0], &WIDGET_Effect_3D);
      /* Init graph widget */
      for (i = 0; i < GUI_COUNTOF(_aColor); i++) {
        _aValue[i] = rand() % 95;
        _ahData[i] = GRAPH_DATA_YT_Create(_aColor[i], 500, 0, 0);
        GRAPH_AttachData(_ahWin[GRAPH0], _ahData[i]);
      }
      GRAPH_SetGridDistY(_ahWin[GRAPH0], 25);
      GRAPH_SetGridVis(_ahWin[GRAPH0], 1);
      GRAPH_SetGridFixedX(_ahWin[GRAPH0], 1);
      GRAPH_SetBorder(_ahWin[GRAPH0], 20, 4, 5, 4);
      /* Create and add vertical scale of graph widget */
      hScaleV = GRAPH_SCALE_Create(18, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
      GRAPH_SCALE_SetTextColor(hScaleV, GUI_RED);
      GRAPH_AttachScale(_ahWin[GRAPH0], hScaleV);
      /* Create and add horizontal scale of graph widget */
      hScaleH = GRAPH_SCALE_Create(46, GUI_TA_HCENTER | GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
      GRAPH_SCALE_SetTextColor(hScaleH, GUI_DARKGREEN);
      GRAPH_AttachScale(_ahWin[GRAPH0], hScaleH);
      /* Init multipage widget */
      MULTIPAGE_AddPage(_ahWin[MULTIPAGE0],
                        GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbDialogPage, WM_UNATTACHED, 0, 0), 
                        "Page 1");
      MULTIPAGE_AddPage(_ahWin[MULTIPAGE0],
                        GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), &_cbDialogPage, WM_UNATTACHED, 0, 0), 
                        "Page 2");
      /* Create and attach menu */
      hMenu = _CreateMenu(hDlg);/**/
      break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Пример #13
0
void rank_dlg_do_init() {
  #define WIDTH_DLG     185
  #define HEIGHT_DLG    85

  #define WIDTH_B       65
  #define HEIGHT_B      20
  #define WIDTH_T       60
  #define HEIGHT_T      20
  #define WIDTH_COMP    65
  #define HEIGHT_COMP   20
  
  int x0 = (GUI_X_MAX - WIDTH_DLG) >> 1;
  int y0 = (GUI_Y_MAX - HEIGHT_DLG) >> 1;
  
  int x_b = 5;
  int y_b = HEIGHT_DLG - (HEIGHT_B + 5);
  int x_textLabel = x_b;
  int y_textLabel = 30;
  
  int x_components = WIDTH_T + 10;
  
  TEXT_Handle label;
  
  DROPDOWN_Handle typeDOListBox; //список для выбора вида дискр. выхода
  
  BUTTON_Handle ESC_Button_do_rank_dlg;
  BUTTON_Handle ENTER_Button_do_rank_dlg;
  
  rankDlgDOPg = FRAMEWIN_CreateEx(x0, y0, WIDTH_DLG, HEIGHT_DLG, 0, WM_CF_SHOW, 0, win_id_list[ID_RANK_DO_DLG], _rankDlgDOItem[0].pText[sel_language], _cbRankDlgWin);
  FRAMEWIN_SetFont(rankDlgDOPg, &GUI_FontArialBold14_8_Unicode);
  
  label = TEXT_CreateEx(x_textLabel, y_textLabel, WIDTH_T, HEIGHT_T, rankDlgDOPg, WM_CF_SHOW, 0, ID_RANK_DO_TEXT_LABEL, typeDOTextLabels[sel_language]);
  TEXT_SetFont(label, &GUI_FontArialBold14_8_Unicode);
  
  typeDOListBox = DROPDOWN_CreateEx(x_components, y_textLabel, WIDTH_COMP + 25, HEIGHT_COMP, rankDlgDOPg, WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_RANK_DO_TYPE);
  DROPDOWN_SetFont(typeDOListBox, &GUI_FontArialStandard14_8_Unicode);
  DROPDOWN_SetBkColor(typeDOListBox, DROPDOWN_CI_UNSEL, GUI_GRAY);
  DROPDOWN_SetBkColor(typeDOListBox, DROPDOWN_CI_SEL, GUI_GRAY);
  DROPDOWN_SetBkColor(typeDOListBox, DROPDOWN_CI_SELFOCUS, GUI_BLUE);
  DROPDOWN_AddString(typeDOListBox, typesDO0[sel_language]);
  DROPDOWN_AddString(typeDOListBox, typesDO1[sel_language]);
  
  ESC_Button_do_rank_dlg = BUTTON_CreateEx(x_b, y_b, WIDTH_B, HEIGHT_B, rankDlgDOPg, WM_CF_SHOW, 0, ID_RANK_DO_DLGBUT_ESC);
  BUTTON_SetFont(ESC_Button_do_rank_dlg, &GUI_FontArialBold14_8_Unicode);
  BUTTON_SetText(ESC_Button_do_rank_dlg, "ESC");
  
  x_b = WIDTH_DLG - (WIDTH_B + 5);
  ENTER_Button_do_rank_dlg = BUTTON_CreateEx(x_b, y_b, WIDTH_B, HEIGHT_B, rankDlgDOPg, WM_CF_SHOW, 0, ID_RANK_DO_DLGBUT_ENTER);
  BUTTON_SetFont(ENTER_Button_do_rank_dlg, &GUI_FontArialBold14_8_Unicode);
  BUTTON_SetText(ENTER_Button_do_rank_dlg, "ENTER");
  
  WM_BringToTop(rankDlgDOPg);

  #undef WIDTH_DLG
  #undef HEIGHT_DLG

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

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

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

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

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

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


//		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
//		if(WM_HasFocus(hItem))//取消
//		{
//			TestFolder.number_CurrentFile=0;
//			TestFile.command = 0;
//			WT_TestItem_Init(TestFolder.FilesName[0]);
//			Msg.MsgId = MY_MESSAGE_BUTTONCANCEL;
//			WM_SendMessage(pMsg->hWinSrc,&Msg);
//			GUI_EndDialog(pMsg->hWin,0);
//		}
		//GUI_EndDialog(pMsg->hWin,0);
		//Number_Windos = 0;
		break;
	case MY_MESSAGE_LOCK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		WM_HideWindow(hItem);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		TEXT_SetText(hItem, "系统被锁定,请解锁!");
		WM_ShowWindow(hItem);
		GUI_Exec();
		break;
	case MY_MESSAGE_UNLOCK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		WM_HideWindow(hItem);
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,480,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(8);
		GUI_DrawRect(0,0,478,220);
//		GUI_DrawRoundedFrame(0, 0, 480, 222, 0, 4);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Пример #15
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;

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

		GUI_EndDialog(pMsg->hWin,0);

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

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

		break;
	case MY_MESSAGE_BUTTONDELETE://删除字符
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		if(WM_HasFocus(hItem))
		{
			EDIT_AddKey(hItem,GUI_KEY_BACKSPACE);
			cursorindex=EDIT_GetCursorCharPos(hItem);
		}
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,480,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(6);
		GUI_DrawRect(0,0,480-2,222-2);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}