git-svn-id: svn://db.shs.com.ru/pip@249 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -48,11 +48,11 @@ void TileSimple::drawEvent(PIScreenDrawer * d) {
|
||||
Row & r(content[i]);
|
||||
int rx = 0;
|
||||
switch (alignment) {
|
||||
case Left: rx = x; break;
|
||||
case Center: rx = x + (width - r.first.size_s()) / 2; break;
|
||||
case Right: rx = x + width - r.first.size_s(); break;
|
||||
case Left: rx = x_; break;
|
||||
case Center: rx = x_ + (width_ - r.first.size_s()) / 2; break;
|
||||
case Right: rx = x_ + width_ - r.first.size_s(); break;
|
||||
};
|
||||
d->drawText(rx, y + i, r.first, (Color)r.second.color_char, (Color)r.second.color_back, r.second.flags);
|
||||
d->drawText(rx, y_ + i, r.first, (Color)r.second.color_char, (Color)r.second.color_back, r.second.flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,23 +77,23 @@ void TileList::sizeHint(int & w, int & h) const {
|
||||
|
||||
void TileList::drawEvent(PIScreenDrawer * d) {
|
||||
vert_line = d->artChar(PIScreenDrawer::LineVertical);
|
||||
lhei = height - 2;
|
||||
lhei = height_ - 2;
|
||||
//int osp = piMini(3, lhei / 4);
|
||||
int is = piClampi(offset, 0, piMaxi(0, content.size_s() - 1)), ie = piClampi(offset + lhei, 0, content.size_s());
|
||||
if (is > 0) d->drawText(x, y, PIString(" /\\ ").repeat(width / 4), Green, Default, Bold);
|
||||
if (is > 0) d->drawText(x_, y_, PIString(" /\\ ").repeat(width_ / 4), Green, Default, Bold);
|
||||
//piCout << is << ie << offset << lhei << content.size_s();
|
||||
for (int i = is; i < ie; ++i) {
|
||||
Row & r(content[i]);
|
||||
bool sel = i == cur && has_focus;
|
||||
if (sel) {
|
||||
int cy = y + i - is + 1;
|
||||
d->drawLine(x, cy, x + width - 2, cy, ' ', Default, Blue);
|
||||
int cy = y_ + i - is + 1;
|
||||
d->drawLine(x_, cy, x_ + width_ - 2, cy, ' ', Default, Blue);
|
||||
}
|
||||
int rx(0);
|
||||
switch (alignment) {
|
||||
case Left: rx = x; break;
|
||||
case Center: rx = x + (width - 1 - r.first.size_s()) / 2; break;
|
||||
case Right: rx = x + width - 1 - r.first.size_s(); break;
|
||||
case Left: rx = x_; break;
|
||||
case Center: rx = x_ + (width_ - 1 - r.first.size_s()) / 2; break;
|
||||
case Right: rx = x_ + width_ - 1 - r.first.size_s(); break;
|
||||
};
|
||||
CharFlags cf = r.second.flags;
|
||||
Color cc = (Color)r.second.color_char;
|
||||
@@ -101,18 +101,18 @@ void TileList::drawEvent(PIScreenDrawer * d) {
|
||||
cf |= Bold;
|
||||
cc = Yellow;
|
||||
}
|
||||
d->drawText(rx, y + i - is + 1, r.first, cc, sel ? Blue : Default, cf);
|
||||
d->drawText(rx, y_ + i - is + 1, r.first, cc, sel ? Blue : Default, cf);
|
||||
}
|
||||
int cx = x + width - 1;
|
||||
d->drawLine(cx, y + 1, cx, y + height - 2, vert_line, Green);
|
||||
int cx = x_ + width_ - 1;
|
||||
d->drawLine(cx, y_ + 1, cx, y_ + height_ - 2, vert_line, Green);
|
||||
if (content.size_s() > 1)
|
||||
d->drawPixel(cx, y + piRound(float(cur) / (content.size_s() - 1) * (lhei - 1)) + 1, ' ', Green, Green);
|
||||
if (ie < content.size_s()) d->drawText(x, y + height - 1, PIString(" \\/ ").repeat(width / 4), Green, Default, Bold);
|
||||
d->drawPixel(cx, y_ + piRound(float(cur) / (content.size_s() - 1) * (lhei - 1)) + 1, ' ', Green, Green);
|
||||
if (ie < content.size_s()) d->drawText(x_, y_ + height_ - 1, PIString(" \\/ ").repeat(width_ / 4), Green, Default, Bold);
|
||||
}
|
||||
|
||||
|
||||
bool TileList::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
lhei = height - 2;
|
||||
lhei = height_ - 2;
|
||||
int oo(0), osp = piMini(3, lhei / 4);
|
||||
switch (key.key) {
|
||||
case PIKbdListener::PageUp:
|
||||
@@ -216,10 +216,10 @@ 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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -259,12 +259,12 @@ void TileButtons::sizeHint(int & w, int & h) const {
|
||||
|
||||
|
||||
void TileButtons::drawEvent(PIScreenDrawer * d) {
|
||||
int cx = x, cy = y, shw, shh;
|
||||
int cx = x_, cy = y_, shw, shh;
|
||||
sizeHint(shw, shh);
|
||||
int dx = 0;
|
||||
switch (alignment) {
|
||||
case PIScreenTypes::Center: dx = (width - shw) / 2; break;
|
||||
case PIScreenTypes::Right: dx = width - shw; break;
|
||||
case PIScreenTypes::Center: dx = (width_ - shw) / 2; break;
|
||||
case PIScreenTypes::Right: dx = width_ - shw; break;
|
||||
default: break;
|
||||
}
|
||||
if (direction == PIScreenTypes::Horizontal)
|
||||
@@ -281,7 +281,7 @@ void TileButtons::drawEvent(PIScreenDrawer * d) {
|
||||
Button & b(content[i]);
|
||||
int cw = b.first.size_s() + 2, xo(0);
|
||||
if (direction == Vertical) {
|
||||
cw = width - 2;
|
||||
cw = width_ - 2;
|
||||
xo = (cw - b.first.size_s()) / 2 - 1;
|
||||
}
|
||||
d->fillRect(cx, cy, cx + cw + 2, cy + 1, ' ', Default, cb);
|
||||
@@ -337,9 +337,9 @@ void TileCheck::drawEvent(PIScreenDrawer * d) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -371,17 +371,17 @@ void TileProgress::sizeHint(int & w, int & h) const {
|
||||
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);
|
||||
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);
|
||||
d->drawText(x_ + sx, y_, s, Black, Transparent);
|
||||
else if (w >= sx + s.size_s())
|
||||
d->drawText(x + sx, y, s, White, Transparent);
|
||||
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);
|
||||
d->drawText(x_ + sx, y_, s.left(fw), White, Transparent);
|
||||
d->drawText(x_ + sx + fw, y_, s.cutLeft(fw), Black, Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,12 +443,12 @@ void TileInput::sizeHint(int & w, int & h) const {
|
||||
|
||||
|
||||
void TileInput::drawEvent(PIScreenDrawer * d) {
|
||||
PIString ps = text.mid(offset, width - 2);
|
||||
d->drawText(x + 1, y, ps, (Color)format.color_char, Transparent, (CharFlags)format.flags);
|
||||
PIString ps = text.mid(offset, width_ - 2);
|
||||
d->drawText(x_ + 1, y_, ps, (Color)format.color_char, Transparent, (CharFlags)format.flags);
|
||||
if (offset > 0)
|
||||
d->drawText(x, y, "<", Green, Black, Bold);
|
||||
if (text.size_s() - offset >= width - 2)
|
||||
d->drawText(x + width - 1, y, ">", Green, Black, Bold);
|
||||
d->drawText(x_, y_, "<", Green, Black, Bold);
|
||||
if (text.size_s() - offset >= width_ - 2)
|
||||
d->drawText(x_ + width_ - 1, y_, ">", Green, Black, Bold);
|
||||
if (!has_focus) return;
|
||||
Color cb = (Color)format.color_char, cc = (Color)format.color_back;
|
||||
if (tm_blink.elapsed_m() >= 650) {
|
||||
@@ -456,12 +456,12 @@ void TileInput::drawEvent(PIScreenDrawer * d) {
|
||||
inv = !inv;
|
||||
}
|
||||
if (inv) piSwap(cb, cc);
|
||||
d->drawText(x + 1 + cur - offset, y, text.mid(cur, 1).expandLeftTo(1, ' '), cc, cb, (CharFlags)format.flags);
|
||||
d->drawText(x_ + 1 + cur - offset, y_, text.mid(cur, 1).expandLeftTo(1, ' '), cc, cb, (CharFlags)format.flags);
|
||||
}
|
||||
|
||||
|
||||
bool TileInput::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
int lwid = piMaxi(0, width - 2);
|
||||
int lwid = piMaxi(0, width_ - 2);
|
||||
int oo(0), osp = piMini(3, lwid / 4);
|
||||
lwid--;
|
||||
switch (key.key) {
|
||||
|
||||
Reference in New Issue
Block a user