diff --git a/apps/file_manager/ui.cpp b/apps/file_manager/ui.cpp index 9fbd0fb..c8837ac 100644 --- a/apps/file_manager/ui.cpp +++ b/apps/file_manager/ui.cpp @@ -747,6 +747,23 @@ int ListCallback(EsElement *element, EsMessage *message) { EsBufferFormat(message->getContent.buffer, "%D", entry->size); } } + } else if (message->type == ES_MSG_LIST_VIEW_GET_ITEM_DATA) { + int column = message->getItemData.columnID, index = message->getItemData.index; + EsAssert(index < (int) instance->listContents.Length() && index >= 0); + ListEntry *listEntry = &instance->listContents[index]; + FolderEntry *entry = listEntry->entry; + FileType *fileType = FolderEntryGetType(instance->folder, entry); + + if (column == COLUMN_NAME) { + String name = entry->GetName(); + message->getItemData.s = name.text; + message->getItemData.sBytes = name.bytes; + } else if (column == COLUMN_TYPE) { + message->getItemData.s = fileType->name; + message->getItemData.sBytes = fileType->nameBytes; + } else if (column == COLUMN_SIZE) { + message->getItemData.i = entry->size; + } } else if (message->type == ES_MSG_LIST_VIEW_GET_SUMMARY) { int index = message->getContent.index; EsAssert(index < (int) instance->listContents.Length() && index >= 0); @@ -1097,7 +1114,8 @@ void InstanceCreateUI(Instance *instance) { instance->list->messageUser = ListCallback; EsListViewRegisterColumn(instance->list, COLUMN_NAME, INTERFACE_STRING(FileManagerColumnName), ES_LIST_VIEW_COLUMN_HAS_MENU); EsListViewRegisterColumn(instance->list, COLUMN_TYPE, INTERFACE_STRING(FileManagerColumnType), ES_LIST_VIEW_COLUMN_HAS_MENU); - EsListViewRegisterColumn(instance->list, COLUMN_SIZE, INTERFACE_STRING(FileManagerColumnSize), ES_LIST_VIEW_COLUMN_HAS_MENU | ES_TEXT_H_RIGHT); + EsListViewRegisterColumn(instance->list, COLUMN_SIZE, INTERFACE_STRING(FileManagerColumnSize), + ES_LIST_VIEW_COLUMN_HAS_MENU | ES_TEXT_H_RIGHT | ES_LIST_VIEW_COLUMN_DATA_INTEGERS | ES_LIST_VIEW_COLUMN_FORMAT_BYTES); EsListViewAddAllColumns(instance->list); EsListViewInsertGroup(instance->list, 0); diff --git a/apps/samples/list.cpp b/apps/samples/list.cpp index fee660b..827febc 100644 --- a/apps/samples/list.cpp +++ b/apps/samples/list.cpp @@ -59,24 +59,24 @@ void _start() { // Register the age column. EsListViewRegisterColumn(list, - COLUMN_AGE, // The column's ID. - "Age", -1, // Its title string. - ES_LIST_VIEW_COLUMN_HAS_MENU // Column header has a menu. - | ES_TEXT_H_RIGHT // Align the text in the column to the right. - | ES_DRAW_CONTENT_TABULAR // Use the tabular digits style, so that digits line up between rows. - | ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS // We're storing integers in this column (the default is strings). - | ES_LIST_VIEW_COLUMN_FIXED_SORT_SIZE, // The items in the column can be sorted by their size. - 100); // Initial width. + COLUMN_AGE, // The column's ID. + "Age", -1, // Its title string. + ES_LIST_VIEW_COLUMN_HAS_MENU // Column header has a menu. + | ES_TEXT_H_RIGHT // Align the text in the column to the right. + | ES_DRAW_CONTENT_TABULAR // Use the tabular digits style, so that digits line up between rows. + | ES_LIST_VIEW_COLUMN_DATA_INTEGERS // We're storing integers in this column (the default is strings). + | ES_LIST_VIEW_COLUMN_SORT_SIZE, // The items in the column can be sorted by their size. + 100); // Initial width. // Register the favorite color columns. EsListViewRegisterColumn(list, - COLUMN_FAVORITE_COLOR, // The column's ID. - "Favorite color", -1, // Its title string. - ES_LIST_VIEW_COLUMN_HAS_MENU // Column header has a menu. - | ES_DRAW_CONTENT_RICH_TEXT // Parse rich text markup in the strings. (See colorStrings above). - | ES_LIST_VIEW_COLUMN_FIXED_FORMAT_ENUM_STRING // To display an item, lookup an enum string from the array. - | ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS, // The enum values are stored as integers. - 150); // Initial widths. + COLUMN_FAVORITE_COLOR, // The column's ID. + "Favorite color", -1, // Its title string. + ES_LIST_VIEW_COLUMN_HAS_MENU // Column header has a menu. + | ES_DRAW_CONTENT_RICH_TEXT // Parse rich text markup in the strings. (See colorStrings above). + | ES_LIST_VIEW_COLUMN_FORMAT_ENUM_STRING // To display an item, lookup an enum string from the array. + | ES_LIST_VIEW_COLUMN_DATA_INTEGERS, // The enum values are stored as integers. + 150); // Initial widths. EsListViewFixedItemSetEnumStringsForColumn(list, COLUMN_FAVORITE_COLOR, // Set the enum strings for the favorite color column. colorStrings, // The strings to use for the enum items in this column. diff --git a/apps/system_monitor.cpp b/apps/system_monitor.cpp index efe9eac..cb108a2 100644 --- a/apps/system_monitor.cpp +++ b/apps/system_monitor.cpp @@ -320,8 +320,6 @@ void UpdateDisplay(Instance *instance, int index) { } } -#define GET_CONTENT(...) EsBufferFormat(message->getContent.buffer, __VA_ARGS__) - int ListViewProcessesCallback(EsElement *element, EsMessage *message) { if (message->type == ES_MSG_LIST_VIEW_IS_SELECTED) { message->selectItem.isSelected = processes[message->selectItem.index].data.pid == selectedPID; @@ -382,10 +380,10 @@ void ProcessApplicationMessage(EsMessage *message) { instance->listViewProcesses->messageUser = ListViewProcessesCallback; EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_NAME, "Name", -1, ES_LIST_VIEW_COLUMN_HAS_MENU, 150); uint32_t numericColumnFlags = ES_LIST_VIEW_COLUMN_HAS_MENU | ES_TEXT_H_RIGHT | ES_DRAW_CONTENT_TABULAR - | ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS | ES_LIST_VIEW_COLUMN_FIXED_SORT_SIZE; + | ES_LIST_VIEW_COLUMN_DATA_INTEGERS | ES_LIST_VIEW_COLUMN_SORT_SIZE; EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_PID, "PID", -1, numericColumnFlags, 120); - EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_MEMORY, "Memory", -1, numericColumnFlags | ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BYTES, 120); - EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_CPU, "CPU", -1, numericColumnFlags | ES_LIST_VIEW_COLUMN_FIXED_FORMAT_PERCENTAGE, 120); + EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_MEMORY, "Memory", -1, numericColumnFlags | ES_LIST_VIEW_COLUMN_FORMAT_BYTES, 120); + EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_CPU, "CPU", -1, numericColumnFlags | ES_LIST_VIEW_COLUMN_FORMAT_PERCENTAGE, 120); EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_HANDLES, "Handles", -1, numericColumnFlags, 120); EsListViewRegisterColumn(instance->listViewProcesses, PROCESSES_COLUMN_THREADS, "Threads", -1, numericColumnFlags, 120); EsListViewAddAllColumns(instance->listViewProcesses); diff --git a/desktop/list_view.cpp b/desktop/list_view.cpp index adcccda..d23cad4 100644 --- a/desktop/list_view.cpp +++ b/desktop/list_view.cpp @@ -1742,7 +1742,7 @@ struct EsListView : EsElement { } for (uintptr_t i = 0; i < registeredColumns.Length(); i++) { - if ((registeredColumns[i].flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK) == ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS) { + if ((registeredColumns[i].flags & ES_LIST_VIEW_COLUMN_DATA_MASK) == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { for (uintptr_t j = 0; j < registeredColumns[i].items.Length(); j++) { EsHeapFree(registeredColumns[i].items[j].s.string); } @@ -1949,79 +1949,104 @@ struct EsListView : EsElement { selectedCellStyle = GetStyle(MakeStyleKey(ES_STYLE_LIST_SELECTED_CHOICE_CELL, 0), false); EsListViewChangeStyles(this, nullptr, nullptr, nullptr, nullptr, ES_FLAGS_DEFAULT, ES_FLAGS_DEFAULT); - } else if (message->type == ES_MSG_LIST_VIEW_GET_CONTENT && (flags & ES_LIST_VIEW_FIXED_ITEMS)) { + } else if (message->type == ES_MSG_LIST_VIEW_GET_CONTENT) { uintptr_t index = message->getContent.index; - EsAssert(index < fixedItems.Length()); - index = fixedItemIndices[index]; - ListViewFixedItemData emptyData = {}; - ListViewFixedItem *item = &fixedItems[index]; - ListViewColumn *column = ®isteredColumns[(flags & ES_LIST_VIEW_COLUMNS) ? activeColumns[message->getContent.activeColumnIndex] : 0]; - ListViewFixedItemData *data = index < column->items.Length() ? &column->items[index] : &emptyData; - uint32_t format = column->flags & ES_LIST_VIEW_COLUMN_FIXED_FORMAT_MASK; - uint32_t type = column->flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK; - if (!activeColumns.Length() || message->getContent.columnID == registeredColumns[activeColumns[0]].id) { - message->getContent.icon = item->iconID; + ListViewFixedItemData data = {}; + + ListViewColumn *column = ®isteredColumns[(flags & ES_LIST_VIEW_COLUMNS) ? activeColumns[message->getContent.activeColumnIndex] : 0]; + uint32_t format = column->flags & ES_LIST_VIEW_COLUMN_FORMAT_MASK; + uint32_t type = column->flags & ES_LIST_VIEW_COLUMN_DATA_MASK; + + if (flags & ES_LIST_VIEW_FIXED_ITEMS) { + EsAssert(index < fixedItems.Length()); + index = fixedItemIndices[index]; + ListViewFixedItem *item = &fixedItems[index]; + if (index < column->items.Length()) data = column->items[index]; + + if (!activeColumns.Length() || message->getContent.columnID == registeredColumns[activeColumns[0]].id) { + message->getContent.icon = item->iconID; + } + } else { + EsMessage m = { .type = ES_MSG_LIST_VIEW_GET_ITEM_DATA }; + m.getItemData.index = message->getContent.index; + m.getItemData.group = message->getContent.group; + m.getItemData.columnID = message->getContent.columnID; + m.getItemData.activeColumnIndex = message->getContent.activeColumnIndex; + EsMessageSend(this, &m); + + if (type == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { + data.s.string = (char *) m.getItemData.s; + data.s.bytes = m.getItemData.sBytes; + } else if (type == ES_LIST_VIEW_COLUMN_DATA_DOUBLES) { + data.d = m.getItemData.d; + } else if (type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { + data.i = m.getItemData.i; + } + + if (!activeColumns.Length() || message->getContent.columnID == registeredColumns[activeColumns[0]].id) { + message->getContent.icon = m.getItemData.icon; + } } #define BOOLEAN_FORMAT(trueString, falseString) \ - if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { \ - EsBufferFormat(message->getContent.buffer, "%z", data->i ? interfaceString_ ## trueString : interfaceString_ ## falseString); \ + if (type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { \ + EsBufferFormat(message->getContent.buffer, "%z", data.i ? interfaceString_ ## trueString : interfaceString_ ## falseString); \ } else { \ EsAssert(false); \ } #define NUMBER_FORMAT(unitString) \ - if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { \ - EsBufferFormat(message->getContent.buffer, "%d%z", data->i, interfaceString_ ## unitString); \ - } else if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES) { \ - EsBufferFormat(message->getContent.buffer, "%F%z", data->d, interfaceString_ ## unitString); \ + if (type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { \ + EsBufferFormat(message->getContent.buffer, "%d%z", data.i, interfaceString_ ## unitString); \ + } else if (type == ES_LIST_VIEW_COLUMN_DATA_DOUBLES) { \ + EsBufferFormat(message->getContent.buffer, "%F%z", data.d, interfaceString_ ## unitString); \ } else { \ EsAssert(false); \ } #define UNIT_FORMAT(unitString1, unitString2, unitString3) \ - double d = type == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS ? data->i : type == ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES ? data->d : 0; \ + double d = type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS ? data.i : type == ES_LIST_VIEW_COLUMN_DATA_DOUBLES ? data.d : 0; \ if (d < 10000) EsBufferFormat(message->getContent.buffer, "%F%z", d, interfaceString_ ## unitString1); \ else if (d < 10000000) EsBufferFormat(message->getContent.buffer, "%.F%z", 1, d / 1000, interfaceString_ ## unitString2); \ else EsBufferFormat(message->getContent.buffer, "%.F%z", 1, d / 1000000, interfaceString_ ## unitString3); - if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_DEFAULT) { - if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS) { - EsBufferFormat(message->getContent.buffer, "%s", data->s.bytes, data->s.string); - } else if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES) { - EsBufferFormat(message->getContent.buffer, "%F", data->d); - } else if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { - EsBufferFormat(message->getContent.buffer, "%d", data->i); + if (format == ES_LIST_VIEW_COLUMN_FORMAT_DEFAULT) { + if (type == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { + EsBufferFormat(message->getContent.buffer, "%s", data.s.bytes, data.s.string); + } else if (type == ES_LIST_VIEW_COLUMN_DATA_DOUBLES) { + EsBufferFormat(message->getContent.buffer, "%F", data.d); + } else if (type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { + EsBufferFormat(message->getContent.buffer, "%d", data.i); } - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BYTES) { - if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { - EsBufferFormat(message->getContent.buffer, "%D", data->i); + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_BYTES) { + if (type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { + EsBufferFormat(message->getContent.buffer, "%D", data.i); } else { EsAssert(false); } - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_ENUM_STRING) { - if (type == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { - EsAssert(data->i >= 0 && (uintptr_t) data->i < column->enumStringCount); - EsBufferFormat(message->getContent.buffer, "%s", column->enumStrings[data->i].stringBytes, column->enumStrings[data->i].string); + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_ENUM_STRING) { + if (type == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { + EsAssert(data.i >= 0 && (uintptr_t) data.i < column->enumStringCount); + EsBufferFormat(message->getContent.buffer, "%s", column->enumStrings[data.i].stringBytes, column->enumStrings[data.i].string); } else { EsAssert(false); } - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_YES_NO) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_YES_NO) { BOOLEAN_FORMAT(CommonBooleanYes, CommonBooleanNo); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_ON_OFF) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_ON_OFF) { BOOLEAN_FORMAT(CommonBooleanOn, CommonBooleanOff); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_PERCENTAGE) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_PERCENTAGE) { NUMBER_FORMAT(CommonUnitPercent); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BITS) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_BITS) { NUMBER_FORMAT(CommonUnitBits); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_PIXELS) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_PIXELS) { NUMBER_FORMAT(CommonUnitPixels); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_DPI) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_DPI) { NUMBER_FORMAT(CommonUnitDPI); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_SECONDS) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_SECONDS) { NUMBER_FORMAT(CommonUnitSeconds); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_HERTZ) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_HERTZ) { UNIT_FORMAT(CommonUnitHz, CommonUnitKHz, CommonUnitMHz); - } else if (format == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BYTE_RATE) { + } else if (format == ES_LIST_VIEW_COLUMN_FORMAT_BYTE_RATE) { UNIT_FORMAT(CommonUnitBps, CommonUnitKBps, CommonUnitMBps); } else { EsAssert(false); @@ -2036,20 +2061,20 @@ struct EsListView : EsElement { menu->userData = this; ListViewColumn *column = ®isteredColumns[activeColumns[message->columnMenu.activeColumnIndex]]; - uint32_t sortMode = column->flags & ES_LIST_VIEW_COLUMN_FIXED_SORT_MASK; + uint32_t sortMode = column->flags & ES_LIST_VIEW_COLUMN_SORT_MASK; uint64_t checkAscending = (fixedItemSortDirection == LIST_SORT_DIRECTION_ASCENDING && column->id == fixedItemSortColumnID) ? ES_MENU_ITEM_CHECKED : 0; uint64_t checkDescending = (fixedItemSortDirection == LIST_SORT_DIRECTION_DESCENDING && column->id == fixedItemSortColumnID) ? ES_MENU_ITEM_CHECKED : 0; - if (sortMode != ES_LIST_VIEW_COLUMN_FIXED_SORT_NONE) { + if (sortMode != ES_LIST_VIEW_COLUMN_SORT_NONE) { EsMenuAddItem(menu, ES_MENU_ITEM_HEADER, INTERFACE_STRING(CommonSortHeader)); - if (sortMode == ES_LIST_VIEW_COLUMN_FIXED_SORT_DEFAULT) { + if (sortMode == ES_LIST_VIEW_COLUMN_SORT_DEFAULT) { EsMenuAddItem(menu, checkAscending, INTERFACE_STRING(CommonSortAToZ), ListViewSetSortAscending, column->id); EsMenuAddItem(menu, checkDescending, INTERFACE_STRING(CommonSortZToA), ListViewSetSortDescending, column->id); - } else if (sortMode == ES_LIST_VIEW_COLUMN_FIXED_SORT_TIME) { + } else if (sortMode == ES_LIST_VIEW_COLUMN_SORT_TIME) { EsMenuAddItem(menu, checkAscending, INTERFACE_STRING(CommonSortOldToNew), ListViewSetSortAscending, column->id); EsMenuAddItem(menu, checkDescending, INTERFACE_STRING(CommonSortNewToOld), ListViewSetSortDescending, column->id); - } else if (sortMode == ES_LIST_VIEW_COLUMN_FIXED_SORT_SIZE) { + } else if (sortMode == ES_LIST_VIEW_COLUMN_SORT_SIZE) { EsMenuAddItem(menu, checkAscending, INTERFACE_STRING(CommonSortSmallToLarge), ListViewSetSortAscending, column->id); EsMenuAddItem(menu, checkDescending, INTERFACE_STRING(CommonSortLargeToSmall), ListViewSetSortDescending, column->id); } @@ -2639,15 +2664,15 @@ LIST_VIEW_SORT_FUNCTION(ListViewSortByDoublesAscending, left->d > right->d ? 1 : LIST_VIEW_SORT_FUNCTION(ListViewSortByDoublesDescending, left->d < right->d ? 1 : left->d == right->d ? 0 : -1); ListViewSortFunction ListViewGetSortFunction(ListViewColumn *column, uint8_t direction) { - if ((column->flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK) == ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS) { + if ((column->flags & ES_LIST_VIEW_COLUMN_DATA_MASK) == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { return (direction == LIST_SORT_DIRECTION_DESCENDING ? ListViewSortByStringsDescending : ListViewSortByStringsAscending); - } else if ((column->flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK) == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { - if ((column->flags & ES_LIST_VIEW_COLUMN_FIXED_FORMAT_MASK) == ES_LIST_VIEW_COLUMN_FIXED_FORMAT_ENUM_STRING) { + } else if ((column->flags & ES_LIST_VIEW_COLUMN_DATA_MASK) == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { + if ((column->flags & ES_LIST_VIEW_COLUMN_FORMAT_MASK) == ES_LIST_VIEW_COLUMN_FORMAT_ENUM_STRING) { return (direction == LIST_SORT_DIRECTION_DESCENDING ? ListViewSortByEnumsDescending : ListViewSortByEnumsAscending); } else { return (direction == LIST_SORT_DIRECTION_DESCENDING ? ListViewSortByIntegersDescending : ListViewSortByIntegersAscending); } - } else if ((column->flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK) == ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES) { + } else if ((column->flags & ES_LIST_VIEW_COLUMN_DATA_MASK) == ES_LIST_VIEW_COLUMN_DATA_DOUBLES) { return (direction == LIST_SORT_DIRECTION_DESCENDING ? ListViewSortByDoublesDescending : ListViewSortByDoublesAscending); } else { EsAssert(false); @@ -2708,7 +2733,7 @@ void ListViewFixedItemSetInternal(EsListView *view, EsListViewIndex index, uint3 } EsAssert(column); - EsAssert((column->flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK) == dataType); + EsAssert((column->flags & ES_LIST_VIEW_COLUMN_DATA_MASK) == dataType); // Make sure that the column's array of items has been updated to match to the size of fixedItems. if (column->items.Length() < view->fixedItems.Length()) { @@ -2719,17 +2744,17 @@ void ListViewFixedItemSetInternal(EsListView *view, EsListViewIndex index, uint3 bool changed = false; - if (dataType == ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS) { + if (dataType == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { changed = EsStringCompareRaw(column->items[index].s.string, column->items[index].s.bytes, data.s.string, data.s.bytes); - } else if (dataType == ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES) { + } else if (dataType == ES_LIST_VIEW_COLUMN_DATA_DOUBLES) { changed = column->items[index].d != data.d; - } else if (dataType == ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS) { + } else if (dataType == ES_LIST_VIEW_COLUMN_DATA_INTEGERS) { changed = column->items[index].i != data.i; } else { EsAssert(false); } - if (dataType == ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS) { + if (dataType == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { EsHeapFree(column->items[index].s.string); } @@ -2752,16 +2777,16 @@ void EsListViewFixedItemSetString(EsListView *view, EsListViewIndex index, uint3 HeapDuplicate((void **) &fixedString, &outBytes, string, fixedString.bytes); if (outBytes == fixedString.bytes) { - ListViewFixedItemSetInternal(view, index, columnID, { .s = fixedString }, ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS); + ListViewFixedItemSetInternal(view, index, columnID, { .s = fixedString }, ES_LIST_VIEW_COLUMN_DATA_STRINGS); } } void EsListViewFixedItemSetDouble(EsListView *view, EsListViewIndex index, uint32_t columnID, double number) { - ListViewFixedItemSetInternal(view, index, columnID, { .d = number }, ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES); + ListViewFixedItemSetInternal(view, index, columnID, { .d = number }, ES_LIST_VIEW_COLUMN_DATA_DOUBLES); } void EsListViewFixedItemSetInteger(EsListView *view, EsListViewIndex index, uint32_t columnID, int64_t number) { - ListViewFixedItemSetInternal(view, index, columnID, { .i = number }, ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS); + ListViewFixedItemSetInternal(view, index, columnID, { .i = number }, ES_LIST_VIEW_COLUMN_DATA_INTEGERS); } bool EsListViewFixedItemFindIndex(EsListView *view, EsGeneric data, EsListViewIndex *index) { @@ -2809,7 +2834,7 @@ bool EsListViewFixedItemRemove(EsListView *view, EsGeneric data) { ListViewColumn *column = &view->registeredColumns[i]; if ((uintptr_t) fixedIndex < column->items.Length()) { - if ((column->flags & ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK) == ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS) { + if ((column->flags & ES_LIST_VIEW_COLUMN_DATA_MASK) == ES_LIST_VIEW_COLUMN_DATA_STRINGS) { EsHeapFree(column->items[fixedIndex].s.string); } diff --git a/desktop/os.header b/desktop/os.header index ac5bf9b..e1eb481 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -378,29 +378,29 @@ define ES_DRAW_CONTENT_MARKER_UP_ARROW (1 << 10) define ES_DRAW_CONTENT_RICH_TEXT (1 << 12) // ...plus alignment flags. -define ES_LIST_VIEW_COLUMN_HAS_MENU ( 1 << 16) // The header can be clicked to open a menu. -define ES_LIST_VIEW_COLUMN_FIXED_DATA_STRINGS ( 0 << 22) // Data types for fixed items. -define ES_LIST_VIEW_COLUMN_FIXED_DATA_INTEGERS ( 1 << 22) -define ES_LIST_VIEW_COLUMN_FIXED_DATA_DOUBLES ( 2 << 22) -define ES_LIST_VIEW_COLUMN_FIXED_DATA_MASK ( 3 << 22) -define ES_LIST_VIEW_COLUMN_FIXED_SORT_DEFAULT ( 0 << 24) // Sort types for fixed items. -define ES_LIST_VIEW_COLUMN_FIXED_SORT_TIME ( 1 << 24) -define ES_LIST_VIEW_COLUMN_FIXED_SORT_SIZE ( 2 << 24) -define ES_LIST_VIEW_COLUMN_FIXED_SORT_NONE ( 3 << 24) -define ES_LIST_VIEW_COLUMN_FIXED_SORT_MASK ( 7 << 24) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_DEFAULT ( 0 << 27) // Format types for fixed items. -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_YES_NO ( 1 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_ON_OFF ( 2 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_PERCENTAGE ( 3 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BYTES ( 4 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BITS ( 5 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_BYTE_RATE ( 6 << 27) // Bytes per second. -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_SECONDS ( 7 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_HERTZ ( 8 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_PIXELS ( 9 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_DPI (10 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_ENUM_STRING (11 << 27) -define ES_LIST_VIEW_COLUMN_FIXED_FORMAT_MASK (31 << 27) +define ES_LIST_VIEW_COLUMN_HAS_MENU ( 1 << 16) // The header can be clicked to open a menu. +define ES_LIST_VIEW_COLUMN_DATA_STRINGS ( 0 << 22) // Data types for fixed items or GET_ITEM_DATA. +define ES_LIST_VIEW_COLUMN_DATA_INTEGERS ( 1 << 22) +define ES_LIST_VIEW_COLUMN_DATA_DOUBLES ( 2 << 22) +define ES_LIST_VIEW_COLUMN_DATA_MASK ( 3 << 22) +define ES_LIST_VIEW_COLUMN_SORT_DEFAULT ( 0 << 24) // Sort types for fixed items or GET_ITEM_DATA. +define ES_LIST_VIEW_COLUMN_SORT_TIME ( 1 << 24) +define ES_LIST_VIEW_COLUMN_SORT_SIZE ( 2 << 24) +define ES_LIST_VIEW_COLUMN_SORT_NONE ( 3 << 24) +define ES_LIST_VIEW_COLUMN_SORT_MASK ( 7 << 24) +define ES_LIST_VIEW_COLUMN_FORMAT_DEFAULT ( 0 << 27) // Format types for fixed items or GET_ITEM_DATA. +define ES_LIST_VIEW_COLUMN_FORMAT_YES_NO ( 1 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_ON_OFF ( 2 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_PERCENTAGE ( 3 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_BYTES ( 4 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_BITS ( 5 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_BYTE_RATE ( 6 << 27) // Bytes per second. +define ES_LIST_VIEW_COLUMN_FORMAT_SECONDS ( 7 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_HERTZ ( 8 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_PIXELS ( 9 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_DPI (10 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_ENUM_STRING (11 << 27) +define ES_LIST_VIEW_COLUMN_FORMAT_MASK (31 << 27) // ...plus draw content flags and alignment flags. // For ES_MSG_LIST_VIEW_GET_COLUMN_SORT. @@ -1033,22 +1033,23 @@ enum EsMessageType { ES_MSG_TEXTBOX_ACTIVATE_BREADCRUMB = 0x5208 // For EsTextboxUseBreadcrumbOverlay. // List view messages: - ES_MSG_LIST_VIEW_FIND_INDEX = 0x5305 - ES_MSG_LIST_VIEW_MEASURE_RANGE = 0x5307 - ES_MSG_LIST_VIEW_MEASURE_ITEM = 0x5308 - ES_MSG_LIST_VIEW_CREATE_ITEM = 0x5309 - ES_MSG_LIST_VIEW_GET_CONTENT = 0x530A - ES_MSG_LIST_VIEW_GET_INDENT = 0x530B - ES_MSG_LIST_VIEW_FIND_POSITION = 0x530C - ES_MSG_LIST_VIEW_IS_SELECTED = 0x530D - ES_MSG_LIST_VIEW_SELECT = 0x530E - ES_MSG_LIST_VIEW_SELECT_RANGE = 0x530F - ES_MSG_LIST_VIEW_CHOOSE_ITEM = 0x5310 - ES_MSG_LIST_VIEW_SEARCH = 0x5311 - ES_MSG_LIST_VIEW_CONTEXT_MENU = 0x5312 - ES_MSG_LIST_VIEW_COLUMN_MENU = 0x5313 - ES_MSG_LIST_VIEW_GET_SUMMARY = 0x5314 - ES_MSG_LIST_VIEW_GET_COLUMN_SORT = 0x5315 + ES_MSG_LIST_VIEW_FIND_INDEX = 0x5301 + ES_MSG_LIST_VIEW_MEASURE_RANGE = 0x5302 + ES_MSG_LIST_VIEW_MEASURE_ITEM = 0x5303 + ES_MSG_LIST_VIEW_CREATE_ITEM = 0x5304 + ES_MSG_LIST_VIEW_GET_CONTENT = 0x5305 + ES_MSG_LIST_VIEW_GET_INDENT = 0x5306 + ES_MSG_LIST_VIEW_FIND_POSITION = 0x5307 + ES_MSG_LIST_VIEW_IS_SELECTED = 0x5308 + ES_MSG_LIST_VIEW_SELECT = 0x5309 + ES_MSG_LIST_VIEW_SELECT_RANGE = 0x530A + ES_MSG_LIST_VIEW_CHOOSE_ITEM = 0x530B + ES_MSG_LIST_VIEW_SEARCH = 0x530C + ES_MSG_LIST_VIEW_CONTEXT_MENU = 0x530D + ES_MSG_LIST_VIEW_COLUMN_MENU = 0x530E + ES_MSG_LIST_VIEW_GET_SUMMARY = 0x530F + ES_MSG_LIST_VIEW_GET_COLUMN_SORT = 0x5310 + ES_MSG_LIST_VIEW_GET_ITEM_DATA = 0x5311 // Reorder list messages: ES_MSG_REORDER_ITEM_TEST = 0x5400 @@ -1669,10 +1670,23 @@ struct EsMessageGetContent { uint16_t activeColumnIndex; }; +struct EsMessageGetItemData { + EsListViewIndex index; + EsListViewIndex group; + uint32_t columnID; + uint16_t activeColumnIndex; + uint32_t icon; + + union { + struct { STRING s; }; + int64_t i; + double d; + }; +}; + struct EsMessageGetIndent { EsListViewIndex group; EsListViewIndex index; - uint8_t indent; }; @@ -1866,6 +1880,7 @@ struct EsMessage { EsMessageSearchItem searchItem; EsMessageColumnMenu columnMenu; EsMessageGetColumnSort getColumnSort; + EsMessageGetItemData getItemData; // Specific element messages: EsMessageSliderMoved sliderMoved;