- protected String getLabel(int index, int width) {
- // we could use: " ", "┃", "│"...
- return card.getContacts().get(index).toString(format, " ┃ ", width);
+ protected List<TextPart> getLabel(int index, int width, boolean selected,
+ boolean focused) {
+ List<TextPart> parts = new LinkedList<TextPart>();
+
+ Contact contact = null;
+ if (index > -1 && index < contacts.size())
+ contact = contacts.get(index);
+
+ if (contact == null)
+ return parts;
+
+ Element el = (focused && selected) ? Element.CONTACT_LINE_SELECTED
+ : Element.CONTACT_LINE;
+ Element elSep = (focused && selected) ? Element.CONTACT_LINE_SEPARATOR_SELECTED
+ : Element.CONTACT_LINE_SEPARATOR;
+ Element elDirty = (focused && selected) ? Element.CONTACT_LINE_DIRTY_SELECTED
+ : Element.CONTACT_LINE_DIRTY;
+
+ width -= 2; // dirty mark space
+
+ String[] array = contact.toStringArray(format, getSeparator(), " ",
+ width, UiColors.getInstance().isUnicode());
+
+ if (contact.isDirty()) {
+ parts.add(new TextPart(" ", el));
+ parts.add(new TextPart("*", elDirty));
+ } else {
+ parts.add(new TextPart(" ", elSep));
+ }
+
+ boolean separator = false;
+ for (String str : array) {
+ parts.add(new TextPart(str, (separator ? elSep : el)));
+ separator = !separator;
+ }
+
+ return parts;
+ }
+
+ /**
+ * Return the currently selected {@link Contact}.
+ *
+ * @return the currently selected {@link Contact}
+ */
+ private Contact getSelectedContact() {
+ int index = getSelectedIndex();
+ if (index > -1 && index < contacts.size())
+ return contacts.get(index);
+ return null;