[code] Created DoubleBufferTextView for functions/variables toolbox.

Change-Id: I8fb8d12463de44f244230eca36d4b0404343f57d
This commit is contained in:
Léa Saviot
2017-11-24 15:49:25 +01:00
parent bc4d2768d0
commit 2015bcce89
3 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#include "double_buffer_text_cell.h"
#include <escher/palette.h>
#include <assert.h>
DoubleBufferTextCell::DoubleBufferTextCell(KDText::FontSize size, float horizontalAlignment, float verticalAlignment) :
TableCell(TableCell::Layout::Vertical),
m_firstBufferTextView(size, horizontalAlignment, verticalAlignment),
m_secondBufferTextView(size, horizontalAlignment, verticalAlignment)
{
}
const char * DoubleBufferTextCell::firstText() {
return m_firstBufferTextView.text();
}
const char * DoubleBufferTextCell::secondText() {
return m_secondBufferTextView.text();
}
void DoubleBufferTextCell::setFirstText(const char * textContent) {
m_firstBufferTextView.setText(textContent);
}
void DoubleBufferTextCell::setSecondText(const char * textContent) {
m_secondBufferTextView.setText(textContent);
}
void DoubleBufferTextCell::setFirstTextColor(KDColor textColor) {
m_firstBufferTextView.setTextColor(textColor);
}
void DoubleBufferTextCell::setSecondTextColor(KDColor textColor) {
m_secondBufferTextView.setTextColor(textColor);
}
void DoubleBufferTextCell::setHighlighted(bool highlight) {
HighlightCell::setHighlighted(highlight);
KDColor background = isHighlighted() ? Palette::Select : KDColorWhite;
m_firstBufferTextView.setBackgroundColor(background);
m_secondBufferTextView.setBackgroundColor(background);
}
View * DoubleBufferTextCell::subviewAtIndex(int index) {
assert(index >= 0 && index <= 1);
if (index == 0) {
return &m_firstBufferTextView;
}
return &m_secondBufferTextView;
}
void DoubleBufferTextCell::layoutSubviews() {
TableCell::layoutSubviews();
}