piethernet
git-svn-id: svn://db.shs.com.ru/pip@38 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -79,7 +79,7 @@ void TileSimple::drawEvent(PIScreenDrawer * d) {
|
||||
|
||||
TileList::TileList(const PIString & n): PIScreenTile(n) {
|
||||
alignment = Left;
|
||||
focus_flags = CanHasFocus | NextByArrows | NextByTab;
|
||||
focus_flags = CanHasFocus | NextByArrowsHorizontal | NextByTab;
|
||||
lhei = offset = cur = 0;
|
||||
selection_mode = NoSelection;
|
||||
}
|
||||
@@ -206,6 +206,39 @@ bool TileList::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
|
||||
|
||||
|
||||
TileButton::TileButton(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab | NextByArrowsAll;
|
||||
}
|
||||
|
||||
|
||||
void TileButton::sizeHint(int & w, int & h) const {
|
||||
w = text.size_s() + 2;
|
||||
h = 1;
|
||||
}
|
||||
|
||||
|
||||
void TileButton::drawEvent(PIScreenDrawer * d) {
|
||||
Color cb = has_focus ? Blue : Cyan;
|
||||
Color ct = has_focus ? White : Black;
|
||||
int ff = has_focus ? Bold : 0;
|
||||
d->fillRect(x, y, x + width, y + 1, ' ', Default, cb);
|
||||
d->drawText(x, y, "[", ct, Transparent, ff);
|
||||
d->drawText(x + (width - text.size_s()) / 2, y, text, ct, Transparent, ff);
|
||||
d->drawText(x + width - 1, y, "]", ct, Transparent, ff);
|
||||
}
|
||||
|
||||
|
||||
bool TileButton::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
if (key.key == PIKbdListener::Space || key.key == PIKbdListener::Return) {
|
||||
raiseEvent(TileEvent(ButtonClicked));
|
||||
return true;
|
||||
}
|
||||
return PIScreenTile::keyEvent(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileButtons::TileButtons(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab;
|
||||
direction = Horizontal;
|
||||
@@ -217,13 +250,13 @@ void TileButtons::sizeHint(int & w, int & h) const {
|
||||
w = h = 0;
|
||||
if (direction == Horizontal) {
|
||||
piForeachC (Button & b, content)
|
||||
w += b.first.size_s() + 2;
|
||||
w += b.first.size_s() + 4;
|
||||
w += piMaxi(0, content.size_s() - 1) * 2;
|
||||
h += 3;
|
||||
h += 1;
|
||||
} else {
|
||||
piForeachC (Button & b, content)
|
||||
w = piMaxi(w, b.first.size_s() + 2 + 4);
|
||||
h += content.size_s() * 3;
|
||||
w = piMaxi(w, b.first.size_s() + 4);
|
||||
h += content.size_s();
|
||||
h += piMaxi(0, content.size_s() - 1);
|
||||
}
|
||||
}
|
||||
@@ -243,15 +276,17 @@ void TileButtons::drawEvent(PIScreenDrawer * d) {
|
||||
Button & b(content[i]);
|
||||
int cw = b.first.size_s() + 2, xo(0);
|
||||
if (direction == Vertical) {
|
||||
cw = width - 4;
|
||||
cw = width - 2;
|
||||
xo = (cw - b.first.size_s()) / 2 - 1;
|
||||
}
|
||||
d->fillRect(cx, cy, cx + cw, cy + 3, ' ', Default, cb);
|
||||
d->drawText(cx + 1 + xo, cy + 1, b.first, ct, Transparent, ff);
|
||||
d->fillRect(cx, cy, cx + cw + 2, cy + 1, ' ', Default, cb);
|
||||
d->drawText(cx, cy, "[", ct, Transparent, ff);
|
||||
d->drawText(cx + xo + 2, cy, b.first, ct, Transparent, ff);
|
||||
d->drawText(cx + cw + 1, cy, "]", ct, Transparent, ff);
|
||||
if (direction == Horizontal)
|
||||
cx += b.first.size_s() + 4;
|
||||
cx += b.first.size_s() + 6;
|
||||
else
|
||||
cy += 4;
|
||||
cy += 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,3 +310,72 @@ bool TileButtons::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
};
|
||||
return PIScreenTile::keyEvent(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileCheck::TileCheck(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab | NextByArrowsAll;
|
||||
toggled = false;
|
||||
}
|
||||
|
||||
|
||||
void TileCheck::sizeHint(int & w, int & h) const {
|
||||
w = text.size_s() + 4;
|
||||
h = 1;
|
||||
}
|
||||
|
||||
|
||||
void TileCheck::drawEvent(PIScreenDrawer * d) {
|
||||
Color cb = has_focus ? Blue : Cyan;
|
||||
Color ct = has_focus ? White : Black;
|
||||
int ff = has_focus ? Bold : 0;
|
||||
PIString cs("[ ]");
|
||||
if (toggled) cs[1] = '*';
|
||||
d->fillRect(x, y, x + width, y + 1, ' ', Default, cb);
|
||||
d->drawText(x, y, cs, ct, Transparent, ff);
|
||||
d->drawText(x + 4, y, text, ct, Transparent, ff);
|
||||
}
|
||||
|
||||
|
||||
bool TileCheck::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
if (key.key == PIKbdListener::Space || key.key == PIKbdListener::Return) {
|
||||
toggled = !toggled;
|
||||
raiseEvent(TileEvent(Toggled, toggled));
|
||||
return true;
|
||||
}
|
||||
return PIScreenTile::keyEvent(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileProgress::TileProgress(const PIString & n): PIScreenTile(n) {
|
||||
maximum = 100.;
|
||||
value = 0.;
|
||||
suffix = " %";
|
||||
}
|
||||
|
||||
|
||||
void TileProgress::sizeHint(int & w, int & h) const {
|
||||
w = 20;
|
||||
h = 1;
|
||||
}
|
||||
|
||||
|
||||
void TileProgress::drawEvent(PIScreenDrawer * d) {
|
||||
int v = maximum == 0. ? 0 : piClampd(piRoundd(value / maximum * 100.), 0, 100);
|
||||
PIString s = prefix + PIString::fromNumber(piRoundd(value)) + suffix;
|
||||
int w = piRoundd(v / 100. * width), sx = (width - s.size_s()) / 2;
|
||||
d->fillRect(x, y, x + width, y + 1, ' ', Default, Cyan);
|
||||
d->fillRect(x, y, x + w, y + 1, ' ', Default, Blue);
|
||||
if (w < sx)
|
||||
d->drawText(x + sx, y, s, Black, Transparent);
|
||||
else if (w >= sx + s.size_s())
|
||||
d->drawText(x + sx, y, s, White, Transparent);
|
||||
else {
|
||||
int fw = w - sx;
|
||||
d->drawText(x + sx, y, s.left(fw), White, Transparent);
|
||||
d->drawText(x + sx + fw, y, s.cutLeft(fw), Black, Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user