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 "piconnection.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[]) {
PIChunkStream cs;
S s;
s.i = 99; s.f = 0.01; s.s = "SSS";
PIVector<float> f;
f << -1. << 2.5 << 11.;
cs << cs.chunk(1, 10) << cs.chunk(2, PIString("text")) << cs.chunk(4, f) << cs.chunk(3, s);
f.clear();
PIByteArray ba(cs.data());
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;
PIScreen screen;
TileSimple window;
window.back_format.color_back = PIScreenTypes::Red;
window.content << TileSimple::Row("label", PIScreenTypes::CellFormat(PIScreenTypes::Black, PIScreenTypes::Transparent));
screen.rootTile()->addTile(&window);
screen.enableExitCapture(PIKbdListener::F10);
screen.start();
screen.waitForFinish();
return 0;
}

View File

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

View File

@@ -69,7 +69,15 @@ namespace PIScreenTypes {
Horizontal /** Horizontal */ ,
Vertical /** Vertical */
};
//! Position
enum Position {
//Left /** Left */ ,
//Right /** Right */ ,
//Top /** Top */ ,
//Bottom /** Bottom */
};
//! Focus flags
enum FocusFlag {
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> l;
if (!isExists()) return l;
@@ -251,6 +258,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
memset(&fd, 0, sizeof(fd));
} while (FindNextFile(hf, &fd) != 0);
FindClose(hf);
l.sort(sort_compare);
if (!hdd) {
PIFile::FileInfo fi;
fi.path = "..";
@@ -258,6 +266,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
l.push_front(fi);
}
}
#else
dirent ** list;
int cnt = scandir(