コード例 #1
0
/**
  * @brief  Explores disk.
  * @param  hTree: tree view handle
  * @retval None
  */
static void ExploreDisks(WM_HWIN hTree) 
{
  TREEVIEW_ITEM_Handle hItem = 0;
  TREEVIEW_ITEM_Handle hUSBItem = 0;    
  TREEVIEW_ITEM_Handle Node = 0;
  uint32_t Position = 0;

  Node = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, 0, 0, "Local disks");
  
  
  if(k_StorageGetStatus(MSD_DISK_UNIT) == 1)
  {
    hItem = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, Node, TREEVIEW_INSERT_FIRST_CHILD, "microSD");
  }
  
  if(k_StorageGetStatus(USB_DISK_UNIT) == 1)
  {
    Position = hItem ? TREEVIEW_INSERT_BELOW : TREEVIEW_INSERT_FIRST_CHILD;
    hUSBItem = hItem ? hItem : Node;
    hUSBItem = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, hUSBItem, Position, "USB Disk");
  }

  if(k_StorageGetStatus(MSD_DISK_UNIT) == 1)
  {
    
    ShowNodeContent(hTree, hItem, mSDDISK_Drive, pFileList);    
  }
  
  if(k_StorageGetStatus(USB_DISK_UNIT) == 1)
  {
    ShowNodeContent(hTree, hUSBItem, USBDISK_Drive, pFileList);
  }
  
  TREEVIEW_SetAutoScrollH(hTree, 1);
  TREEVIEW_SetAutoScrollV(hTree, 1);
  TREEVIEW_SetIndent(hTree, 22);
  hItem = TREEVIEW_GetItem(hTree, 0, TREEVIEW_GET_FIRST);
  TREEVIEW_ITEM_Expand(hItem);
  
  hItem = TREEVIEW_GetItem(hTree, hItem, TREEVIEW_GET_FIRST_CHILD);
  if(hItem != 0)
  {
    TREEVIEW_ITEM_Expand(hItem);
    hItem = TREEVIEW_GetItem(hTree, hItem, TREEVIEW_GET_NEXT_SIBLING);
    if(hItem != 0)
    {      
      TREEVIEW_ITEM_Expand(hItem); 
    }
  }  
  
  WM_SetFocus(hTree);
}
コード例 #2
0
/**
  * @brief  Shows node content.
  * @param  hTree: Tree view handle
  * @param  hNode: Tree Node handle
  * @param  list: pointer to file list structure
  * @retval None
  */
static void ShowNodeContent(WM_HWIN hTree, TREEVIEW_ITEM_Handle hNode, char *path, FILELIST_FileTypeDef *list) 
{
  uint32_t i = 0, Position = 0;
  TREEVIEW_ITEM_Handle hItem = 0;
  FILEMGR_ParseDisks(path, list); 
  char fullpath[FILEMGR_FULL_PATH_SIZE];

  /*Create root nodes */
  if(list->ptr > 0)
  {
    for (i = 0; i < list->ptr; i++)
    {
      Position = hItem ? TREEVIEW_INSERT_BELOW : TREEVIEW_INSERT_FIRST_CHILD;
      hItem = hItem ? hItem : hNode;
      if(list->file[i].type == FILETYPE_DIR)
      {
        strcpy(fullpath, path);
        strcat (fullpath, "/");
        strcat (fullpath, (char *)list->file[i].name);        
        hItem = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, hItem, Position, (char *)list->file[i].name);
        list->next = malloc(sizeof(FILELIST_FileTypeDef));
        
        if (list->next == NULL)
        {
          break;
        }
        
        list->next->prev = list;
        list = list->next;
        if(FolderLevel++ < FILEMGR_MAX_LEVEL)
        {
          ShowNodeContent(hTree, hItem, fullpath, list);
        }
        FolderLevel--;
        list = list->prev;
        free(list->next);
      }
      else
      {
        hItem = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_LEAF, hItem, Position, (char *)list->file[i].name);
      }
    }
  }

}