git-svn-id: svn://db.shs.com.ru/pip@265 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2016-09-17 12:04:46 +00:00
parent bdf3c77dcf
commit 362c6bf505
2 changed files with 72 additions and 2 deletions

View File

@@ -59,6 +59,59 @@ void TileSimple::drawEvent(PIScreenDrawer * d) {
TileScrollBar::TileScrollBar(const PIString & n) {
direction = Vertical;
thickness = 1;
minimum_ = value_ = 0;
maximum_ = 100;
}
void TileScrollBar::setMinimum(int v) {
minimum_ = v;
_check();
}
void TileScrollBar::setMaximum(int v) {
maximum_ = v;
_check();
}
void TileScrollBar::setValue(int v) {
value_ = v;
_check();
}
void TileScrollBar::_check() {
value_ = piClampi(value_, minimum_, maximum_);
}
void TileScrollBar::sizeHint(int & w, int & h) const {
w = h = 0;
if (direction == Vertical) {
w = thickness;
h = 255;
} else {
h = thickness;
w = 255;
}
}
void TileScrollBar::drawEvent(PIScreenDrawer * d) {
line_char = d->artChar(direction == Vertical ? PIScreenDrawer::LineVertical : PIScreenDrawer::LineHorizontal);
d->fillRect(x_, y_, x_ + width_, y_ + height_, line_char, Green);
if ()
d->drawPixel(cx, y_ + piRound(float(cur) / (content.size_s() - 1) * (lhei - 1)) + 1, ' ', Green, Green);
}
TileList::TileList(const PIString & n): PIScreenTile(n) {
alignment = Left;
focus_flags = CanHasFocus | NextByArrowsHorizontal | NextByTab;
@@ -76,7 +129,6 @@ void TileList::sizeHint(int & w, int & h) const {
void TileList::drawEvent(PIScreenDrawer * d) {
vert_line = d->artChar(PIScreenDrawer::LineVertical);
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());

View File

@@ -39,6 +39,25 @@ protected:
};
class PIP_EXPORT TileScrollBar: public PIScreenTile {
public:
TileScrollBar(const PIString & n = PIString());
void setMinimum(int v);
void setMaximum(int v);
void setValue(int v);
int minimum() const {return minimum_;}
int maximum() const {return maximum_;}
int value() const {return value_;}
int thickness;
protected:
void _check();
void sizeHint(int & w, int & h) const;
void drawEvent(PIScreenDrawer * d);
int minimum_, maximum_, value_;
PIChar line_char;
};
class PIP_EXPORT TileList: public PIScreenTile {
public:
TileList(const PIString & n = PIString());
@@ -62,7 +81,6 @@ protected:
void drawEvent(PIScreenDrawer * d);
bool keyEvent(PIKbdListener::KeyEvent key);
int lhei;
PIChar vert_line;
};