From 7667dac8423ac275d8290014647fb27903865c6f Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 23 Mar 2024 22:50:14 +0100 Subject: You may no longer attempt to join server with mismatched version --- StarsEx/ListBox.cpp | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'StarsEx/ListBox.cpp') diff --git a/StarsEx/ListBox.cpp b/StarsEx/ListBox.cpp index 8d52cfe..1f6fbed 100644 --- a/StarsEx/ListBox.cpp +++ b/StarsEx/ListBox.cpp @@ -27,10 +27,12 @@ class ListBoxCell public: static const char* TYPENAME() { return "ListBoxCell"; } - ListBoxCell() : data(0), image(0) { } + ListBoxCell() : data(0), color(Color::White), use_color(false), image(0) { } Text text; DWORD data; + Color color; + bool use_color; Bitmap* image; }; @@ -330,7 +332,7 @@ ListBox::DrawContent(const Rect& ctrl_rect) item_rect.h = h - item_rect.y - 1; } - Color item_color = GetItemColor(index-1, 0); + Color item_color = GetItemColor(index-1); if (item->selected) { font->SetColor(selected_color); @@ -521,6 +523,23 @@ Color ListBox::GetItemColor(int index) return Color::White; } +Color ListBox::GetItemColor(int index, int column) +{ + if (column == 0) + return GetItemColor(index); + column--; + if (0 > index || index >= items.size()) + return Color::White; + const auto* item = items[index]; + if (0 > column || column >= item->subitems.size()) + return Color::White; + if (item->subitems[column]->use_color) + return item->subitems[column]->color; + if (columns[column]->use_color) + return columns[column]->color; + return item->color; +} + void ListBox::SetItemColor(int index, Color c) { if (index >= 0 && index < items.size()) { @@ -528,6 +547,20 @@ void ListBox::SetItemColor(int index, Color c) } } +void ListBox::SetItemColor(int index, int column, Color c) +{ + if (column == 0) + return SetItemColor(index, c); + column--; + if (0 < index || index >= items.size()) + return; + auto* item = items[index]; + if (0 < column || column >= item->subitems.size()) + return; + item->subitems[column]->color = c; + item->subitems[column]->use_color = true; +} + Text ListBox::GetItemText(int index, int column) { if (column == 0) { @@ -862,21 +895,6 @@ void ListBox::SetColumnColor(int index, Color c) } } -Color ListBox::GetItemColor(int index, int column) -{ - Color c = Color::White; - - if (index >= 0 && index < items.size()) - c = items[index]->color; - - if (column >= 0 && column < columns.size()) { - if (columns[column]->use_color) - c = columns[column]->color; - } - - return c; -} - int ListBox::GetMultiSelect() { return multiselect; -- cgit v1.1