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
|
||||
|
||||
@@ -181,6 +181,9 @@ public:
|
||||
//! Returns if %PIEthernet connected to TCP server. Use only for TCP_Client
|
||||
bool isConnected() const {return connected_;}
|
||||
|
||||
//! Returns if %PIEthernet is connecting to TCP server. Use only for TCP_Client
|
||||
bool isConnecting() const {return connecting_;}
|
||||
|
||||
|
||||
//! Start listen for incoming TCP connections on address \a readAddress(). Use only for TCP_Server
|
||||
bool listen(bool threaded = false);
|
||||
|
||||
@@ -314,12 +314,12 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
||||
if (type != 4) return true;
|
||||
diag_d.received(size);
|
||||
ba >> from >> to >> cnt >> rec_size;
|
||||
//piCout << "[PIPeer \"" + name_ + "\"] Received packet" << /*type << from << to << cnt <<*/ rec_size;
|
||||
piCoutObj << "Received packet" << type << from << to << cnt << rec_size;
|
||||
if (type == 4) { // data packet
|
||||
if (to == self_info.name) { // my packet
|
||||
int msg_count, cmsg;
|
||||
ba >> msg_count >> cmsg;
|
||||
//piCout << "[PIPeer \"" + name_ + "\"] Received packet" << type << from << to << cnt << rec_size << msg_count << cmsg;
|
||||
piCoutObj << "Received packet" << type << from << to << cnt << rec_size << msg_count << cmsg;
|
||||
if (cmsg == 0 && msg_count == 1) {
|
||||
dataReceived(from, ba);
|
||||
dataReceivedEvent(from, ba);
|
||||
@@ -333,11 +333,11 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
||||
}
|
||||
PeerData & pd(fp->_data);
|
||||
if (cmsg == 0) {
|
||||
//piCout << "[PIPeer \"" + name_ + "\"] Packet clear" << rec_size;
|
||||
piCoutObj << "Packet clear" << rec_size;
|
||||
pd.clear();
|
||||
pd.msg_count = msg_count;
|
||||
}
|
||||
//piCout << "[PIPeer \"" + name_ + "\"] Packet add" << cmsg << ba.size_s();
|
||||
piCoutObj << "Packet add" << cmsg << ba.size_s();
|
||||
pd.addData(ba);
|
||||
bool frec = pd.isFullReceived();
|
||||
PIByteArray rba(pd.data);
|
||||
@@ -345,7 +345,7 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
||||
if (frec) {
|
||||
dataReceived(from, rba);
|
||||
dataReceivedEvent(from, rba);
|
||||
//piCout << "[PIPeer \"" + name_ + "\"] Packet received" << pd.data.size_s();
|
||||
piCoutObj << "Packet received" << pd.data.size_s();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user