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

This commit is contained in:
2016-02-10 08:50:59 +00:00
parent dc7048d100
commit 697b39124c
5 changed files with 60 additions and 41 deletions

View File

@@ -1,42 +1,19 @@
#include "pikbdlistener.h" #include "pikbdlistener.h"
#include "piconnection.h" #include "piconnection.h"
#include "piconfig.h" #include "piconfig.h"
#include "pichunkstream.h" #include "piscreentiles.h"
#include "piscreen.h"
struct S {
int i;
float f;
PIString s;
};
PIByteArray & operator <<(PIByteArray & b, const S & s) {b << s.i << s.f << s.s; return b;}
PIByteArray & operator >>(PIByteArray & b, S & s) {b >> s.i >> s.f >> s.s; return b;}
int main (int argc, char * argv[]) { int main (int argc, char * argv[]) {
PIChunkStream cs; PIScreen screen;
S s; TileSimple window;
s.i = 99; s.f = 0.01; s.s = "SSS"; window.back_format.color_back = PIScreenTypes::Red;
PIVector<float> f; window.content << TileSimple::Row("label", PIScreenTypes::CellFormat(PIScreenTypes::Black, PIScreenTypes::Transparent));
f << -1. << 2.5 << 11.; screen.rootTile()->addTile(&window);
cs << cs.chunk(1, 10) << cs.chunk(2, PIString("text")) << cs.chunk(4, f) << cs.chunk(3, s); screen.enableExitCapture(PIKbdListener::F10);
f.clear(); screen.start();
PIByteArray ba(cs.data()); screen.waitForFinish();
piCout << ba;
PIChunkStream cs2(ba);
s.i = 0; s.f = 0; s.s = "";
int i(0);
PIString str;
piCout << i << str << f << s.i << s.f << s.s;
while (!cs2.atEnd()) {
switch (cs2.read()) {
case 1: i = cs2.getData<int>(); break;
case 2: str = cs2.getData<PIString>(); break;
case 3: s = cs2.getData<S>(); break;
case 4: f = cs2.getData<PIVector<float> >(); break;
}
}
piCout << i << str << f << s.i << s.f << s.s;
return 0; return 0;
} }

View File

@@ -1,5 +1,6 @@
#ifndef PISCREENCONSOLE_H #ifndef PISCREENCONSOLE_H
#define PISCREENCONSOLE_H #define PISCREENCONSOLE_H
#include "piscreentiles.h" #include "piscreentiles.h"
class PIP_EXPORT TileVars: public PIScreenTile { class PIP_EXPORT TileVars: public PIScreenTile {
@@ -7,7 +8,7 @@ public:
TileVars(const PIString & n = PIString()); TileVars(const PIString & n = PIString());
protected: protected:
struct Variable { struct Variable {
Variable() {nx = ny = type = offset = bitFrom = bitCount = size = 0; format = PIScreenTypes::CellFormat(); ptr = 0; id = 1;} Variable() {nx = ny = type = offset = bitFrom = bitCount = size = 0; format = PIScreenTypes::CellFormat(); ptr = 0;}
bool isEmpty() const {return (ptr == 0);} bool isEmpty() const {return (ptr == 0);}
PIString name; PIString name;
PIScreenTypes::CellFormat format; PIScreenTypes::CellFormat format;
@@ -18,10 +19,8 @@ protected:
int bitFrom; int bitFrom;
int bitCount; int bitCount;
int size; int size;
int id;
const void * ptr; const void * ptr;
PIByteArray rdata; /*void operator =(const Variable & src) {
void operator =(const Variable & src) {
name = src.name; name = src.name;
format = src.format; format = src.format;
nx = src.nx; nx = src.nx;
@@ -31,10 +30,8 @@ protected:
bitFrom = src.bitFrom; bitFrom = src.bitFrom;
bitCount = src.bitCount; bitCount = src.bitCount;
size = src.size; size = src.size;
id = src.id;
ptr = src.ptr; ptr = src.ptr;
rdata = src.rdata; }*/
}
}; };
PIVector<Variable> variables; PIVector<Variable> variables;
PIScreenTypes::Alignment alignment; PIScreenTypes::Alignment alignment;

View File

@@ -161,4 +161,32 @@ protected:
}; };
class PIP_EXPORT TileTabs: public PIScreenTile {
public:
TileTabs(const PIString & n = PIString());
enum EventType {
TabChanged
};
struct Tab {
Tab(const PIString & l = PIString(), int k = 0, PIScreenTile * t = 0) {
label = l;
key = k;
tile = t;
}
PIString label;
int key;
PIScreenTile * tile;
};
PIScreenTypes::CellFormat format_tab;
PIScreenTypes::CellFormat format_tab_selected;
PIDeque<Tab> tabs;
protected:
void sizeHint(int & w, int & h) const;
void drawEvent(PIScreenDrawer * d);
bool keyEvent(PIKbdListener::KeyEvent key);
void selectTab(int index);
int cur;
};
#endif // PISCREENTILES_H #endif // PISCREENTILES_H

View File

@@ -69,7 +69,15 @@ namespace PIScreenTypes {
Horizontal /** Horizontal */ , Horizontal /** Horizontal */ ,
Vertical /** Vertical */ Vertical /** Vertical */
}; };
//! Position
enum Position {
//Left /** Left */ ,
//Right /** Right */ ,
//Top /** Top */ ,
//Bottom /** Bottom */
};
//! Focus flags //! Focus flags
enum FocusFlag { enum FocusFlag {
CanHasFocus /** Tile can has focus */ = 0x1, CanHasFocus /** Tile can has focus */ = 0x1,

View File

@@ -214,6 +214,13 @@ bool PIDir::make(bool withParents) {
} }
#ifdef WINDOWS
int sort_compare(const PIFile::FileInfo * v0, const PIFile::FileInfo * v1) {
return strcoll(v0->path.data(), v1->path.data());
}
#endif
PIVector<PIFile::FileInfo> PIDir::entries() { PIVector<PIFile::FileInfo> PIDir::entries() {
PIVector<PIFile::FileInfo> l; PIVector<PIFile::FileInfo> l;
if (!isExists()) return l; if (!isExists()) return l;
@@ -251,6 +258,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
memset(&fd, 0, sizeof(fd)); memset(&fd, 0, sizeof(fd));
} while (FindNextFile(hf, &fd) != 0); } while (FindNextFile(hf, &fd) != 0);
FindClose(hf); FindClose(hf);
l.sort(sort_compare);
if (!hdd) { if (!hdd) {
PIFile::FileInfo fi; PIFile::FileInfo fi;
fi.path = ".."; fi.path = "..";
@@ -258,6 +266,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
l.push_front(fi); l.push_front(fi);
} }
} }
#else #else
dirent ** list; dirent ** list;
int cnt = scandir( int cnt = scandir(