Symfield widget auto-inits

ADS-B emergency frame
This commit is contained in:
furrtek 2017-02-01 00:21:13 +00:00
parent 688a012443
commit 064e097bc3
13 changed files with 103 additions and 65 deletions

View file

@ -1160,37 +1160,36 @@ int32_t NumberField::clip_value(int32_t value) {
/* SymField **************************************************************/
SymField::SymField(
Point parent_pos,
size_t length
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
length_ { length }
{
set_focusable(true);
}
SymField::SymField(
Point parent_pos,
size_t length,
bool hex
symfield_type type
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
length_ { length },
hex_ { hex }
type_ { type }
{
uint8_t c;
uint32_t c;
// Hex field auto-init
for (c = 0; c < length; c++)
set_symbol_list(c, "0123456789ABCDEF");
// Auto-init
if (type == SYMFIELD_OCT) {
for (c = 0; c < length; c++)
set_symbol_list(c, "01234567");
} else if (type == SYMFIELD_DEC) {
for (c = 0; c < length; c++)
set_symbol_list(c, "0123456789");
} else if (type == SYMFIELD_HEX) {
for (c = 0; c < length; c++)
set_symbol_list(c, "0123456789ABCDEF");
}
set_focusable(true);
}
uint64_t SymField::value_hex_u64() {
uint8_t c;
uint32_t c;
uint64_t v = 0;
if (hex_) {
if (type_ != SYMFIELD_DEF) {
for (c = 0; c < length_; c++)
v += values_[c] << (4 * (length_ - 1 - c));
return v;