TilePICoutix
git-svn-id: svn://db.shs.com.ru/pip@45 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2
main.cpp
2
main.cpp
@@ -19,7 +19,7 @@ class Catcher: public PIObject {
|
|||||||
PIOBJECT(Catcher)
|
PIOBJECT(Catcher)
|
||||||
public:
|
public:
|
||||||
EVENT_HANDLER2(void, event, PIScreenTile *, t, PIScreenTypes::TileEvent, e) {
|
EVENT_HANDLER2(void, event, PIScreenTile *, t, PIScreenTypes::TileEvent, e) {
|
||||||
piCout << "event from" << t->name << "type" << e.type << e.data;
|
piCout << "event from" << t->name() << "type" << e.type << e.data;
|
||||||
if (e.data == 2)
|
if (e.data == 2)
|
||||||
delete t->parentTile();
|
delete t->parentTile();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ void PIScreen::end() {
|
|||||||
PIScreenTile * PIScreen::tileByName(const PIString & name) {
|
PIScreenTile * PIScreen::tileByName(const PIString & name) {
|
||||||
PIVector<PIScreenTile*> tl(tiles());
|
PIVector<PIScreenTile*> tl(tiles());
|
||||||
piForeach (PIScreenTile * t, tl)
|
piForeach (PIScreenTile * t, tl)
|
||||||
if (t->name == name)
|
if (t->name() == name)
|
||||||
return t;
|
return t;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,7 @@
|
|||||||
using namespace PIScreenTypes;
|
using namespace PIScreenTypes;
|
||||||
|
|
||||||
|
|
||||||
PIScreenTile::PIScreenTile(const PIString & n, Direction d, SizePolicy p) {
|
PIScreenTile::PIScreenTile(const PIString & n, Direction d, SizePolicy p): PIObject(n) {
|
||||||
name = n;
|
|
||||||
direction = d;
|
direction = d;
|
||||||
size_policy = p;
|
size_policy = p;
|
||||||
focus_flags = 0;
|
focus_flags = 0;
|
||||||
|
|||||||
@@ -28,8 +28,9 @@
|
|||||||
|
|
||||||
class PIScreenDrawer;
|
class PIScreenDrawer;
|
||||||
|
|
||||||
class PIScreenTile {
|
class PIScreenTile: public PIObject {
|
||||||
friend class PIScreen;
|
friend class PIScreen;
|
||||||
|
PIOBJECT_SUBCLASS(PIScreenTile, PIObject)
|
||||||
public:
|
public:
|
||||||
PIScreenTile(const PIString & n = PIString(), PIScreenTypes::Direction d = PIScreenTypes::Vertical, PIScreenTypes::SizePolicy p = PIScreenTypes::Preferred);
|
PIScreenTile(const PIString & n = PIString(), PIScreenTypes::Direction d = PIScreenTypes::Vertical, PIScreenTypes::SizePolicy p = PIScreenTypes::Preferred);
|
||||||
virtual ~PIScreenTile();
|
virtual ~PIScreenTile();
|
||||||
@@ -45,7 +46,6 @@ public:
|
|||||||
void setMargins(int m) {marginLeft = marginRight = marginTop = marginBottom = m;}
|
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;}
|
void setMargins(int l, int r, int t, int b) {marginLeft = l; marginRight = r; marginTop = t; marginBottom = b;}
|
||||||
|
|
||||||
PIString name;
|
|
||||||
PIScreenTypes::Direction direction;
|
PIScreenTypes::Direction direction;
|
||||||
PIScreenTypes::SizePolicy size_policy;
|
PIScreenTypes::SizePolicy size_policy;
|
||||||
PIScreenTypes::FocusFlags focus_flags;
|
PIScreenTypes::FocusFlags focus_flags;
|
||||||
|
|||||||
@@ -383,3 +383,40 @@ void TileProgress::drawEvent(PIScreenDrawer * d) {
|
|||||||
d->drawText(x + sx + fw, y, s.cutLeft(fw), Black, Transparent);
|
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
|
RowPressed
|
||||||
};
|
};
|
||||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
||||||
PIVector<Row> content;
|
PIDeque<Row> content;
|
||||||
PIScreenTypes::Alignment alignment;
|
PIScreenTypes::Alignment alignment;
|
||||||
SelectionMode selection_mode;
|
SelectionMode selection_mode;
|
||||||
PISet<int> selected;
|
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
|
#endif // PISCREENTILES_H
|
||||||
|
|||||||
@@ -181,6 +181,9 @@ public:
|
|||||||
//! Returns if %PIEthernet connected to TCP server. Use only for TCP_Client
|
//! Returns if %PIEthernet connected to TCP server. Use only for TCP_Client
|
||||||
bool isConnected() const {return connected_;}
|
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
|
//! Start listen for incoming TCP connections on address \a readAddress(). Use only for TCP_Server
|
||||||
bool listen(bool threaded = false);
|
bool listen(bool threaded = false);
|
||||||
|
|||||||
@@ -314,12 +314,12 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
|||||||
if (type != 4) return true;
|
if (type != 4) return true;
|
||||||
diag_d.received(size);
|
diag_d.received(size);
|
||||||
ba >> from >> to >> cnt >> rec_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 (type == 4) { // data packet
|
||||||
if (to == self_info.name) { // my packet
|
if (to == self_info.name) { // my packet
|
||||||
int msg_count, cmsg;
|
int msg_count, cmsg;
|
||||||
ba >> 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) {
|
if (cmsg == 0 && msg_count == 1) {
|
||||||
dataReceived(from, ba);
|
dataReceived(from, ba);
|
||||||
dataReceivedEvent(from, ba);
|
dataReceivedEvent(from, ba);
|
||||||
@@ -333,11 +333,11 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
|||||||
}
|
}
|
||||||
PeerData & pd(fp->_data);
|
PeerData & pd(fp->_data);
|
||||||
if (cmsg == 0) {
|
if (cmsg == 0) {
|
||||||
//piCout << "[PIPeer \"" + name_ + "\"] Packet clear" << rec_size;
|
piCoutObj << "Packet clear" << rec_size;
|
||||||
pd.clear();
|
pd.clear();
|
||||||
pd.msg_count = msg_count;
|
pd.msg_count = msg_count;
|
||||||
}
|
}
|
||||||
//piCout << "[PIPeer \"" + name_ + "\"] Packet add" << cmsg << ba.size_s();
|
piCoutObj << "Packet add" << cmsg << ba.size_s();
|
||||||
pd.addData(ba);
|
pd.addData(ba);
|
||||||
bool frec = pd.isFullReceived();
|
bool frec = pd.isFullReceived();
|
||||||
PIByteArray rba(pd.data);
|
PIByteArray rba(pd.data);
|
||||||
@@ -345,7 +345,7 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
|||||||
if (frec) {
|
if (frec) {
|
||||||
dataReceived(from, rba);
|
dataReceived(from, rba);
|
||||||
dataReceivedEvent(from, rba);
|
dataReceivedEvent(from, rba);
|
||||||
//piCout << "[PIPeer \"" + name_ + "\"] Packet received" << pd.data.size_s();
|
piCoutObj << "Packet received" << pd.data.size_s();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
Remote * r(0);
|
Remote * r(0);
|
||||||
PIString dir;
|
PIString dir;
|
||||||
int type; ba >> type;
|
int type; ba >> type;
|
||||||
//std::cout << "rec from " << from << type;
|
//piCout << "rec from " << from << type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RequestHostInfo:
|
case RequestHostInfo:
|
||||||
makeMyHostInfo();
|
makeMyHostInfo();
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ FileManager::FileManager(Daemon * d) {
|
|||||||
panels[i] = new TileDir();
|
panels[i] = new TileDir();
|
||||||
panels[i]->fm = this;
|
panels[i]->fm = this;
|
||||||
panels[i]->key_func = (void*)tileKey_s;
|
panels[i]->key_func = (void*)tileKey_s;
|
||||||
panels[i]->name = "file panel " + PIString(i);
|
panels[i]->setName("file panel " + PIString(i));
|
||||||
panels[i]->label_path = plabel;
|
panels[i]->label_path = plabel;
|
||||||
panel->addTile(plabel);
|
panel->addTile(plabel);
|
||||||
panel->addTile(panels[i]);
|
panel->addTile(panels[i]);
|
||||||
|
|||||||
@@ -55,25 +55,29 @@ public:
|
|||||||
screen.rootTile()->addTile(center);
|
screen.rootTile()->addTile(center);
|
||||||
|
|
||||||
PIScreenTile * mt = tmenu = menuTile();
|
PIScreenTile * mt = tmenu = menuTile();
|
||||||
mt->show(); mt->name = "main menu";
|
mt->show(); mt->name() = "main menu";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
mt = tinfo = infoTile();
|
mt = tinfo = infoTile();
|
||||||
mt->hide(); mt->name = "local info";
|
mt->hide(); mt->name() = "local info";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
mt = tfm = file_manager.tile();
|
mt = tfm = file_manager.tile();
|
||||||
mt->hide(); mt->name = "file manager";
|
mt->hide(); mt->name() = "file manager";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
mt = tdaemon = daemon_.tile();
|
mt = tdaemon = daemon_.tile();
|
||||||
mt->hide(); mt->name = "daemon";
|
mt->hide(); mt->name() = "daemon";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
mt = tpeer = peerTile();
|
mt = tpeer = peerTile();
|
||||||
mt->hide(); mt->name = "peer info";
|
mt->hide(); mt->name() = "peer info";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
|
TilePICout * outt = new TilePICout();
|
||||||
|
outt->size_policy = PIScreenTypes::Expanding;
|
||||||
|
screen.rootTile()->addTile(outt);
|
||||||
|
|
||||||
CONNECTU(&screen, tileEvent, this, tileEvent)
|
CONNECTU(&screen, tileEvent, this, tileEvent)
|
||||||
CONNECTU(&screen, keyPressed, this, keyEvent)
|
CONNECTU(&screen, keyPressed, this, keyEvent)
|
||||||
CONNECTU(&file_manager, menuRequest, this, menuRequest)
|
CONNECTU(&file_manager, menuRequest, this, menuRequest)
|
||||||
|
|||||||
Reference in New Issue
Block a user