TilePICoutix
git-svn-id: svn://db.shs.com.ru/pip@45 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -496,7 +496,7 @@ void PIScreen::end() {
|
||||
PIScreenTile * PIScreen::tileByName(const PIString & name) {
|
||||
PIVector<PIScreenTile*> tl(tiles());
|
||||
piForeach (PIScreenTile * t, tl)
|
||||
if (t->name == name)
|
||||
if (t->name() == name)
|
||||
return t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@
|
||||
using namespace PIScreenTypes;
|
||||
|
||||
|
||||
PIScreenTile::PIScreenTile(const PIString & n, Direction d, SizePolicy p) {
|
||||
name = n;
|
||||
PIScreenTile::PIScreenTile(const PIString & n, Direction d, SizePolicy p): PIObject(n) {
|
||||
direction = d;
|
||||
size_policy = p;
|
||||
focus_flags = 0;
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
|
||||
class PIScreenDrawer;
|
||||
|
||||
class PIScreenTile {
|
||||
class PIScreenTile: public PIObject {
|
||||
friend class PIScreen;
|
||||
PIOBJECT_SUBCLASS(PIScreenTile, PIObject)
|
||||
public:
|
||||
PIScreenTile(const PIString & n = PIString(), PIScreenTypes::Direction d = PIScreenTypes::Vertical, PIScreenTypes::SizePolicy p = PIScreenTypes::Preferred);
|
||||
virtual ~PIScreenTile();
|
||||
@@ -45,7 +46,6 @@ public:
|
||||
void setMargins(int m) {marginLeft = marginRight = marginTop = marginBottom = m;}
|
||||
void setMargins(int l, int r, int t, int b) {marginLeft = l; marginRight = r; marginTop = t; marginBottom = b;}
|
||||
|
||||
PIString name;
|
||||
PIScreenTypes::Direction direction;
|
||||
PIScreenTypes::SizePolicy size_policy;
|
||||
PIScreenTypes::FocusFlags focus_flags;
|
||||
|
||||
@@ -383,3 +383,40 @@ void TileProgress::drawEvent(PIScreenDrawer * d) {
|
||||
d->drawText(x + sx + fw, y, s.cutLeft(fw), Black, Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TilePICout::TilePICout(const PIString & n): TileList(n) {
|
||||
max_lines = 1024;
|
||||
selection_mode = TileList::SingleSelection;
|
||||
PICout::setBufferActive(true);
|
||||
}
|
||||
|
||||
|
||||
void TilePICout::drawEvent(PIScreenDrawer * d) {
|
||||
PIString out = PICout::buffer(true);
|
||||
if (!out.isEmpty()) {
|
||||
PIStringList l = out.split("\n");
|
||||
bool scroll = (cur == content.size_s() - 1) || !has_focus;
|
||||
piForeachC (PIString & s, l)
|
||||
content << TileList::Row(s, format);
|
||||
if (content.size_s() > max_lines)
|
||||
content.remove(0, content.size_s() - max_lines);
|
||||
if (scroll) {
|
||||
offset = piMaxi(0, content.size_s() - lhei);
|
||||
cur = content.size_s() - 1;
|
||||
}
|
||||
}
|
||||
TileList::drawEvent(d);
|
||||
}
|
||||
|
||||
|
||||
bool TilePICout::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
if (key.key == 'C') {
|
||||
content.clear();
|
||||
cur = offset = 0;
|
||||
return true;
|
||||
}
|
||||
return TileList::keyEvent(key);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
RowPressed
|
||||
};
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
||||
PIVector<Row> content;
|
||||
PIDeque<Row> content;
|
||||
PIScreenTypes::Alignment alignment;
|
||||
SelectionMode selection_mode;
|
||||
PISet<int> selected;
|
||||
@@ -135,4 +135,17 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class TilePICout: public TileList {
|
||||
public:
|
||||
TilePICout(const PIString & n = PIString());
|
||||
PIScreenTypes::CellFormat format;
|
||||
int max_lines;
|
||||
protected:
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
};
|
||||
|
||||
|
||||
#endif // PISCREENTILES_H
|
||||
|
||||
Reference in New Issue
Block a user