Esempio n. 1
0
/*********************************************************************
*
*       LISTVIEW_AddColumn
*/
int LISTVIEW_AddColumn(LISTVIEW_Handle hObj, int Width, const char * s, int Align) {
  int r = 0;
  if (hObj) {
    LISTVIEW_Obj* pObj;
    LISTVIEW_COLUMN Column = {0};
    unsigned NumRows;
    WM_LOCK();
    pObj = LISTVIEW_H2P(hObj);
    HEADER_AddItem(pObj->hHeader, Width, s, Align);
    Column.Align = Align;
    GUI_ARRAY_AddItem(&pObj->ColumnArray, &Column, sizeof(LISTVIEW_COLUMN));
    pObj = LISTVIEW_H2P(hObj); /* Restore after allocating memory */
    NumRows = LISTVIEW__GetNumRows(pObj);
    if (NumRows) {
      LISTVIEW_ROW* pRow;
      unsigned i;
      for (i = 0; i < NumRows; i++) {
        pRow = (LISTVIEW_ROW*) GUI_ARRAY_GetpItem(&pObj->RowArray, i);
        if (GUI_ARRAY_AddItem(&pRow->CellArray, NULL, sizeof(LISTVIEW_CELL))) {
          r = 1;
          break;
        }
        pObj = LISTVIEW_H2P(hObj); /* Restore after allocating memory */
      }
    }
    LISTVIEW__UpdateScrollParas(hObj, pObj);
    LISTVIEW__InvalidateInsideArea(hObj, pObj);
    WM_UNLOCK();
  }
  return r;
}
/*********************************************************************
*
*       _Demo
*/
static void _Demo(void) {
  int Key = 0;
  int Cnt = 10;
  char acInfoText[] = "-- sec to play with header control";
  _ChangeInfoText("HEADER_AddItem");
  HEADER_AddItem(_hHeader, 100, "Red"  , GUI_TA_VCENTER | GUI_TA_HCENTER);
  HEADER_AddItem(_hHeader,   0, "Green", GUI_TA_VCENTER | GUI_TA_HCENTER);
  HEADER_AddItem(_hHeader,   0, ":-)"  , GUI_TA_VCENTER | GUI_TA_HCENTER);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetItemWidth");
  HEADER_SetItemWidth(_hHeader, 1, 60);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetItemText");
  HEADER_SetItemWidth(_hHeader, 2, 100);
  HEADER_SetItemText(_hHeader, 2, "Blue");
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetFont");
  HEADER_SetFont(_hHeader, &GUI_Font8x8);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetHeight");
  HEADER_SetHeight(_hHeader, 50);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetTextColor");
  HEADER_SetTextColor(_hHeader, GUI_YELLOW);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetBkColor");
  HEADER_SetBkColor(_hHeader, GUI_DARKGRAY);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetTextAlign");
  HEADER_SetTextAlign(_hHeader, 0, GUI_TA_HCENTER);
  while (!Key && (Cnt > 0)) {
    acInfoText[0] = '0' + (Cnt / 10);
    acInfoText[1] = '0' + (Cnt-- % 10);
    _ChangeInfoText(acInfoText);
    GUI_Delay(1000);
    Key = GUI_GetKey();
  }
}
Esempio n. 3
0
/*********************************************************************
*
*       LISTVIEW_AddColumn
*/
void LISTVIEW_AddColumn(LISTVIEW_Handle hObj, int Width, const char * s, int Align) {
  if (hObj) {
    LISTVIEW_Obj* pObj;
    unsigned NumRows;
    WM_LOCK();
    pObj = LISTVIEW_H2P(hObj);
    HEADER_AddItem(pObj->hHeader, Width, s, Align);   /* Modify header */
    GUI_ARRAY_AddItem(&pObj->AlignArray, &Align, sizeof(int));
    NumRows = LISTVIEW_GetNumRows(hObj);
    if (NumRows) {
      GUI_ARRAY* pRow;
      unsigned i;
      for (i = 0; i < NumRows; i++) {
        pRow = (GUI_ARRAY*) GUI_ARRAY_GetpItem(&pObj->RowArray, i);
        GUI_ARRAY_AddItem(pRow, NULL, sizeof(LISTVIEW_ITEM) + 1);
      }
    }
    LISTVIEW__UpdateScrollParas(hObj, pObj);
    LISTVIEW__InvalidateInsideArea(hObj, pObj);
    WM_UNLOCK();
  }
}
Esempio n. 4
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
		//
		//Initialization of windows
		//
		hItem = pMsg->hWin;
		WINDOW_SetBkColor(hItem, GUI_LIGHTBLUE);
    //
    // Initialization of 'HeaderTop'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_0);
    HEADER_AddItem(hItem, 80, "LeCoder", 14);
    //
    // Initialization of 'Back'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_BACK);
	  BUTTON_SetFont(hItem, &GUI_FontSongTi12);
    BUTTON_SetText(hItem, StringHZ[0]);
    //
    // Initialization of 'Multipage'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);  
		MULTIPAGE_SetFont(hItem, &GUI_FontSongTi12);
		MULTIPAGE_AddPage(hItem, hDialog_Page1, StringHZ[12]);
		MULTIPAGE_AddPage(hItem, hDialog_Page2, StringHZ[13]);
		MULTIPAGE_AddPage(hItem, hDialog_Page3, StringHZ[8]);


    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_BACK: // Notifications sent by 'Back'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
						Key_Value = WINDOW_TOP;
        break;
      }
      break;
    case ID_MULTIPAGE_0: // Notifications sent by 'Multipage'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Esempio n. 5
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
    WM_HWIN          hItem;
    int              NCode;
    int              Id;
    WM_HWIN         hNumPad;
    u8              Mb_Val;

    switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
        //
        //Initialization of Window
        //
        hItem = pMsg->hWin;
        WINDOW_SetBkColor(hItem, GUI_LIGHTBLUE);
        //
        // Initialization of 'Button'
        //
        GUI_UC_SetEncodeUTF8();
        GUI_SetFont(&GUI_FontSongTi16);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_BACK);
        BUTTON_SetFont(hItem,&GUI_FontSongTi12);
        BUTTON_SetText(hItem, _StringHZ[2]);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ENTER);
        BUTTON_SetFont(hItem,&GUI_FontSongTi12);
        BUTTON_SetText(hItem, _StringHZ[3]);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_NEW);
        BUTTON_SetFont(hItem,&GUI_FontSongTi16);
        BUTTON_SetText(hItem, _StringHZ[0]);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OPEN);
        BUTTON_SetFont(hItem,&GUI_FontSongTi16);
        BUTTON_SetText(hItem, _StringHZ[1]);
        //
        // Initialization of 'Header'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_1);
        HEADER_AddItem(hItem, 80, "LeCoder", 14);
        //
        //Initialize EDIT0
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
        MULTIEDIT_SetText(hItem, "");     //清空EDIT内容
        MULTIEDIT_SetFocussable(hItem,1); //设为捕捉光标焦点
        MULTIEDIT_SetAutoScrollV(hItem,1);//自动竖直滑块
        MULTIEDIT_SetAutoScrollH(hItem,1);//自动水平滑块
        MULTIEDIT_SetWrapWord(hItem);     //自动换行
        MULTIEDIT_SetFocussable(hItem, 1);
        WM_SetFocus(hItem);
        break;
    case WM_PAINT:
        GUI_SetColor(GUI_RED);
        GUI_SetFont(&GUI_FontSongTi12);
        GUI_DispStringAt(_StringHZ[4], 100, 25);
        break;
    case WM_NOTIFY_PARENT:
        Id    = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        switch(Id) {

        case ID_BUTTON_BACK: // Notifications sent by 'Button'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                Key_Value = WINDOW_TOP;
                break;
            }
            break;
        case ID_BUTTON_ENTER: // Notifications sent by 'ENTER'
        case ID_BUTTON_NEW: // Notifications sent by 'New'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                //get the program name in the edit
                hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
                MULTIEDIT_GetText(hItem,program_name,sizeof(program_name));
                //warning the situation of empty program name
                if(strcmp(program_name, "") == 0)
                {
                    _MessageBox(_StringHZ[4],_StringHZ[5], &Mb_Val);
                }
                else
                {
                    CreateWindow_1_1();
                }
                break;
            }
            break;
        case ID_BUTTON_OPEN: // Notifications sent by 'Open'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                CreateWindow_TreeView();
                break;
            }
            break;
        case ID_HEADER_1: // Notifications sent by 'Header'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                break;
            case WM_NOTIFICATION_MOVED_OUT:
                break;
            }
            break;
        case ID_MULTIEDIT_0: // Notifications sent by 'Edit1'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                hNumPad = Create_NumPad(pMsg->hWin);
                WM_MakeModal(hNumPad);
                GUI_ExecCreatedDialog(hNumPad);
                break;
            case WM_NOTIFICATION_VALUE_CHANGED:
                break;
            }
            break;
        }
        break;
    default:
        WM_DefaultProc(pMsg);
        break;
    }
}
Esempio n. 6
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'menu_window'
    //
    hItem = pMsg->hWin;
//    WINDOW_SetBkColor(hItem, 0x00FF3939);
    //
    // Initialization of 'Header'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_0);
    HEADER_AddItem(hItem, 120, "LEDS CONTROL", 14);
    //
    // Initialization of 'Header'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_1);
    HEADER_AddItem(hItem, 120, "SENSORS CONTROL", 14);
    //
    // Initialization of 'Header'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_2);
    HEADER_AddItem(hItem, 120, "MODBUS DEBUG", 14);
    // USER START (Optionally insert additional code for further widget initialization)

    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
    BUTTON_SetText( hItem, "");
    BUTTON_SetBkColor (hItem, 0, GUI_RED);
    BUTTON_SetBkColor (hItem, 1, GUI_YELLOW);

    BUTTON_SetBitmapEx(hItem, 0, &bmdebug_icon, 5, 5);



    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText( hItem, "");
    BUTTON_SetBkColor (hItem, 0, GUI_GREEN);
    BUTTON_SetBkColor (hItem, 1, GUI_YELLOW);

    BUTTON_SetBitmapEx(hItem, 0, &bmled_icon, 5, 5);



    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText( hItem, "");
    BUTTON_SetBkColor (hItem, 0, GUI_BLUE);
    BUTTON_SetBkColor (hItem, 1, GUI_YELLOW);

    BUTTON_SetBitmapEx(hItem, 0, &bmsensor_icon, 5, 5);


    hItem = TEXT_CreateEx(0, 40, 640, 30, 0, WM_CF_SHOW, 0, GUI_ID_TEXT0, "House Control with MODBUS");
    TEXT_SetFont(hItem, &GUI_Font24B_ASCII);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetTextColor(hItem, GUI_BLACK);


    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'led_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
				
				BS_wrapper(SWITCH_CONTEXT_TO_LEDS_CONTROLLER, INTERNAL, NULL);
        
				// USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'sensor_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
			
				BS_wrapper(SWITCH_CONTEXT_TO_SENSORS_CONTROLLER, INTERNAL, NULL);			
			
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_2: // Notifications sent by 'debug_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)

        PlayAudio(150, 20);				

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

				BS_wrapper(SWITCH_CONTEXT_TO_DEBUG_MODBUS_CONTROLLER, INTERNAL, NULL);			

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_HEADER_0: // Notifications sent by 'Header'
      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_MOVED_OUT:
        // 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_HEADER_1: // Notifications sent by 'Header'
      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_MOVED_OUT:
        // 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_HEADER_2: // Notifications sent by 'Header'
      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_MOVED_OUT:
        // 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;
  }
}