/*******************************************************************
*
*       _DemoListBox
*/
static void _DemoListBox(void) {
  int            i;
  int            Entries;
  int            ySize;
  LISTBOX_Handle hListBox;
  
  Entries = GUI_COUNTOF(_ListBox) - 1;
  ySize   = GUI_GetYDistOfFont(&GUI_Font13B_1) * Entries;
  //
  // Create the listbox
  //
  hListBox = LISTBOX_Create(_ListBox, 130, 80, 60, ySize, WM_CF_SHOW);
  //
  // Change current selection of the listbox
  //
  for (i = 0; i < Entries-1; i++) {
    GUI_Delay(500);
    LISTBOX_IncSel(hListBox);
    WM_ExecIdle();
	}
  for (i = 0; i < Entries-1; i++) {
    GUI_Delay(500);
    LISTBOX_DecSel(hListBox);
    WM_ExecIdle();
	}
  GUI_Delay(750);
  //
  // Delete listbox widget
  //
  LISTBOX_Delete(hListBox);
  GUI_ClearRect(0, 50, 319, 239);
  GUI_Delay(750);
}
/*********************************************************************
*
*       _GetNumVisItems

  Returns:
    Number of fully or partially visible items
*/
static int _GetNumVisItems(LISTBOX_Obj* pObj) {
  int FontDist = GUI_GetYDistOfFont(pObj->pFont);
  int ysize = WM__GetWindowSizeY(&pObj->Widget.Win);
  ysize -= 2*  pObj->Widget.pEffect->EffectSize;
  if (FontDist)
    return ysize  / FontDist;
  return 1;
}
Esempio n. 3
0
/*********************************************************************
*
*       DROPDOWN__AdjustHeight
*/
void DROPDOWN__AdjustHeight(DROPDOWN_Handle hObj, DROPDOWN_Obj* pObj) {
  int Height;
  Height = pObj->TextHeight;
  if (!Height) {
    Height = GUI_GetYDistOfFont(pObj->Props.pFont);
  }
  Height += pObj->Widget.pEffect->EffectSize + 2 *  pObj->Props.TextBorderSize;
  WM_SetSize(hObj, WM__GetWindowSizeX(&pObj->Widget.Win), Height);
}
Esempio n. 4
0
/*********************************************************************
*
*       LISTVIEW__GetRowDistY
*/
unsigned LISTVIEW__GetRowDistY(const LISTVIEW_Obj* pObj) {
  unsigned RowDistY;
  if (pObj->RowDistY) {
    RowDistY = pObj->RowDistY;
  } else {
    RowDistY = GUI_GetYDistOfFont(pObj->Props.pFont);
    if (pObj->ShowGrid) {
      RowDistY++;
    }
  }
  return RowDistY;
}
Esempio n. 5
0
/*********************************************************************
*
*       DROPDOWN_SetFont
*/
void DROPDOWN_SetFont(DROPDOWN_Handle hObj, const GUI_FONT GUI_UNI_PTR * pfont) {
  int OldHeight;
  DROPDOWN_Obj* pObj;
  if (hObj) {
    WM_LOCK();
    pObj = DROPDOWN_H2P(hObj);
    ASSERT_IS_VALID_PTR(pObj);
    OldHeight = GUI_GetYDistOfFont(pObj->Props.pFont);
    pObj->Props.pFont = pfont;
    DROPDOWN__AdjustHeight(hObj, pObj);
    DROPDOWN_Invalidate(hObj);
    if (pObj->hListWin) {
      if (OldHeight != GUI_GetYDistOfFont(pObj->Props.pFont)) {
        DROPDOWN_Collapse(hObj);
        DROPDOWN_Expand(hObj);
      }
      LISTBOX_SetFont(pObj->hListWin, pfont);
    }
    WM_UNLOCK();
  }
}
/*********************************************************************
*
*       _OnTouch
*/
static int _OnTouch(LISTBOX_Handle hObj, LISTBOX_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification;
  int Sel;
  GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p;
  int FontDistY = GUI_GetYDistOfFont(pObj->pFont);
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      Sel = pState->y / FontDistY + pObj->ScrollState.v; 
      WM_SetFocus(hObj);
      Notification = WM_NOTIFICATION_CLICKED;
      LISTBOX_SetSel(hObj, Sel);
    } else {
      Notification = WM_NOTIFICATION_RELEASED;
    }
  } else {     /* Mouse moved out */
    Notification = WM_NOTIFICATION_MOVED_OUT;
  }
  WM_NotifyParent(hObj, Notification);
  return 0;                        /* Message handled */
}
Esempio n. 7
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  TREEVIEW_ITEM_Handle hNode;
  WM_HWIN              hTree;
  int                  xSize;
  int                  ySize;
  int                  yPos;
  int                  r;
  int                  TimeStart;
  int                  TimeUsed;
  int                  ySizeText;
  U32                  BytesFree;
  U32                  BytesUsed;
  char                 acBuffer[(TREEVIEW_DEPTH << 1) + 1];
  char                 acNumNodes[30]  = "Nodes:  ";
  char                 acNumLeaves[30] = "Leaves: ";
  char                 acNumTotal[30]  = "Total:  ";
  char                 acTimeUsed[30]  = "Time:   ";
  char                 acBytesUsed[30] = "Memory: ";

  //
  // Initialize emWin
  //
  WM_SetCreateFlags(WM_CF_MEMDEV);
  GUI_Init();
  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  //
  // Set defaults for background and widgets
  //
  WM_SetDesktopColor(GUI_BLACK);
  SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
  SCROLLBAR_SetDefaultWidth(20);
  SCROLLBAR_SetThumbSizeMin(25);
  TEXT_SetDefaultFont(GUI_FONT_6X8);
  //
  // Draw info message before creating the widgets
  //
  GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, GUI_BLUE, GUI_BLACK);
  GUI_SetFont(GUI_FONT_20F_ASCII);
  GUI_DispStringHCenterAt("Filling TREEVIEW widget...", xSize >> 1, ySize / 3);
  GUI_X_Delay(1000);
  //
  // Create TREEVIEW
  //
  hTree = TREEVIEW_CreateEx(0, 0, xSize, ySize, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TREEVIEW0);
  TREEVIEW_SetAutoScrollV(hTree, 1);//管理自动使用垂直滚动条。
  TREEVIEW_SetSelMode(hTree, TREEVIEW_SELMODE_ROW);
  //
  // Fill TREEVIEW
  //
  hNode = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, 0, 0, "Tree");
  BytesFree = GUI_ALLOC_GetNumFreeBytes();
  TimeStart = GUI_GetTime();
  r = _FillNode(hTree, hNode, NUM_CHILD_NODES, NUM_CHILD_ITEMS, TREEVIEW_DEPTH, TREEVIEW_DEPTH, acBuffer, acBuffer);
  TimeUsed = GUI_GetTime() - TimeStart;
  BytesUsed = BytesFree - GUI_ALLOC_GetNumFreeBytes();
  if (r) {
    //
    // Error message
    //
    WM_DeleteWindow(hTree);
    GUI_MessageBox("Error", "Not enough memory available!", 0);
  } else {
    //
    // Show result
    //
    yPos = 20;
    ySizeText = GUI_GetYDistOfFont( TEXT_GetDefaultFont()) + 5;
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumNodes, _NumNodes);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumLeaves, _NumLeaves);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumTotal, _NumNodes + _NumLeaves);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acTimeUsed, TimeUsed);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acBytesUsed, BytesUsed);
    WM_SetFocus(hTree);
  }
  while (1) {
    GUI_Delay(100);
  }
}
Esempio n. 8
0
void vHeartbeatTask (void * pvParameters){

	int Key, Entries, ySize;
	uint16_t click_cnt=0;
	int8_t Item_nb;
	BUTTON_Handle hOK_Button, hTest_Key;
	LISTBOX_Handle hStationListBox;
	static enum GuiState eGuiState = SELECT;
	static const GUI_ConstString StationList[] = {"ZET", "RMFFM", "RMFMAXXX", "SKY.FM", "ESKA ROCK", "TERMINAL", NULL};

	vSemaphoreCreateBinary(xButton_pushed_Semaphore);
	if(xDMAch1_Semaphore != NULL){
		xSemaphoreTake(xButton_pushed_Semaphore, 0);
	}else{
		// The semaphore was not created
	}
	BUTTON_Config();	//INT0 Button as source of interrupt
	xSemaphoreTake(xButton_pushed_Semaphore, 0);

	xListBoxQueue = xQueueCreate(2, sizeof(int8_t));


	GUI_Init();
	if(0){
		_ExecCalibration();
	}else{
		_DefaultCalibration();
	}

	GUI_SetBkColor(GUI_BLUE);
	GUI_Clear();



	if (xSemaphoreTake(xDhcpCmplSemaphore_1, portMAX_DELAY) == pdTRUE) {
		/* OK button */
		hOK_Button = BUTTON_CreateEx(120, 210, 80, 20, 0, WM_CF_SHOW, 0, 12);
		GUI_SetFont(&GUI_Font32_ASCII);
		BUTTON_SetText(hOK_Button, "OK");

		/* Cancel button */
		hTest_Key = BUTTON_CreateEx(120, 180, 80, 20, 0, WM_CF_SHOW, 0, 13);
		GUI_SetFont(&GUI_Font16B_ASCII);
		BUTTON_SetText(hTest_Key, "CLICK");
		WM_SetStayOnTop(hTest_Key, 1);

		/* Station list */
		Entries = 6;//countof(StationList) - 1;
		ySize = GUI_GetYDistOfFont(&GUI_Font16B_ASCII)*Entries;
		hStationListBox = LISTBOX_CreateEx(100, 10, 120, ySize, 0, WM_CF_SHOW, 0, 5, StationList);
		SCROLLBAR_CreateAttached(hStationListBox, SCROLLBAR_CF_VERTICAL);

	}

	while(1){
		Key = GUI_GetKey();
		//top = WM_GetStayOnTop(hTest_Key);

		switch(eGuiState){
		case SELECT:
			switch (Key){
			case 12:
				Item_nb = LISTBOX_GetSel(hStationListBox);
				if(Item_nb >= 0){
					if(xQueueSendToBack(xListBoxQueue, &Item_nb, 50/portTICK_RATE_MS) == pdPASS){
						/* OK button delete */
						BUTTON_Delete(hOK_Button);
						GUI_SetBkColor(GUI_BLUE);
						GUI_ClearRect(120, 210, 200, 230);
						GUI_ClearKeyBuffer();

						/* Listbox delete */
						LISTBOX_Delete(hStationListBox);
						GUI_ClearRect(100, 10, 220, ySize+10);

						eGuiState = PLAYING;
					}
				}
				vTaskResume(xShoutcastTaskHandle);
				break;
			case 13:
				click_cnt++;
				GUI_SetFont(&GUI_Font16B_ASCII);
				Item_nb = LISTBOX_GetSel(hStationListBox);
				GUI_DispStringAt("CNT = ", 0, 210);
				GUI_DispDecSpace(Item_nb, 3);
				break;
			default:
				break;
			}

			break;
		case PLAYING:
			switch (Key){
			case 13:
				click_cnt++;
				GUI_SetFont(&GUI_Font16B_ASCII);
//				Item_nb = LISTBOX_GetSel(hStationListBox);
				GUI_DispStringAt("CNT = ", 0, 210);
				GUI_DispDecSpace(123, 3);
				break;
			default:
				break;
			}
		}
		vTaskDelay(20/portTICK_RATE_MS);
	}
}
Esempio n. 9
0
/*********************************************************************
*
*       LISTBOX_OwnerDraw
*/
int LISTBOX_OwnerDraw(const WIDGET_ITEM_DRAW_INFO* pDrawItemInfo) {
  switch (pDrawItemInfo->Cmd) {
    case WIDGET_ITEM_GET_XSIZE: {
      LISTBOX_Obj* pObj;
      const GUI_FONT GUI_UNI_PTR* pOldFont;
      const char* s;
      int DistX;
      pObj = LISTBOX_H2P(pDrawItemInfo->hWin);
      pOldFont = GUI_SetFont(pObj->Props.pFont);
      s = LISTBOX__GetpString(pObj, pDrawItemInfo->ItemIndex);
      DistX = GUI_GetStringDistX(s);
      GUI_SetFont(pOldFont);
      return DistX;
    }
    case WIDGET_ITEM_GET_YSIZE: {
      LISTBOX_Obj* pObj;
      pObj = LISTBOX_H2P(pDrawItemInfo->hWin);
      return GUI_GetYDistOfFont(pObj->Props.pFont) + pObj->ItemSpacing;
    }
    case WIDGET_ITEM_DRAW: {
      LISTBOX_Obj* pObj;
      LISTBOX_ITEM* pItem;
      WM_HMEM hItem;
      GUI_RECT r;
      int FontDistY;
      int ItemIndex = pDrawItemInfo->ItemIndex;
      const char* s;
      int ColorIndex;
      char IsDisabled;
      char IsSelected;
      pObj = LISTBOX_H2P(pDrawItemInfo->hWin);
      hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, ItemIndex);
      pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem);
      WM_GetInsideRect(&r);
      FontDistY = GUI_GetFontDistY();
      /* Calculate color index */
      IsDisabled = (pItem->Status & LISTBOX_ITEM_DISABLED) ? 1 : 0;
      IsSelected = (pItem->Status & LISTBOX_ITEM_SELECTED) ? 1 : 0;
      if (pObj->Flags & LISTBOX_SF_MULTISEL) {
        if (IsDisabled) {
          ColorIndex = 3;
        } else {
          ColorIndex = (IsSelected) ? 2 : 0;
        }
      } else {
        if (IsDisabled) {
          ColorIndex = 3;
        } else {
          if (ItemIndex == pObj->Sel) {
            ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1;
          } else {
            ColorIndex = 0;
          }
        }
      }
      /* Display item */
      LCD_SetBkColor(pObj->Props.aBackColor[ColorIndex]);
      LCD_SetColor  (pObj->Props.aTextColor[ColorIndex]);
      s = LISTBOX__GetpString(pObj, ItemIndex);
      GUI_SetTextMode(GUI_TM_TRANS);
      GUI_Clear();
      GUI_DispStringAt(s, pDrawItemInfo->x0 + 1, pDrawItemInfo->y0);
      /* Display focus rectangle */
      if ((pObj->Flags & LISTBOX_SF_MULTISEL) && (ItemIndex == pObj->Sel)) {
        GUI_RECT rFocus;
        rFocus.x0 = pDrawItemInfo->x0;
        rFocus.y0 = pDrawItemInfo->y0;
        rFocus.x1 = r.x1;
        rFocus.y1 = pDrawItemInfo->y0 + FontDistY - 1;
        LCD_SetColor(GUI_WHITE - pObj->Props.aBackColor[ColorIndex]);
        GUI_DrawFocusRect(&rFocus, 0);
      }
      return 0;
    }
  }
  return 0;
}