From 697b39124c44ed2c45aaca601d782e5a51785580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 10 Feb 2016 08:50:59 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@179 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- main.cpp | 43 ++++++++--------------------------- src/console/piscreenconsole.h | 11 ++++----- src/console/piscreentiles.h | 28 +++++++++++++++++++++++ src/console/piscreentypes.h | 10 +++++++- src/io/pidir.cpp | 9 ++++++++ 5 files changed, 60 insertions(+), 41 deletions(-) diff --git a/main.cpp b/main.cpp index c1aac375..b0105dfb 100644 --- a/main.cpp +++ b/main.cpp @@ -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 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(); break; - case 2: str = cs2.getData(); break; - case 3: s = cs2.getData(); break; - case 4: f = cs2.getData >(); 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; } diff --git a/src/console/piscreenconsole.h b/src/console/piscreenconsole.h index 79fb197a..f68a5092 100644 --- a/src/console/piscreenconsole.h +++ b/src/console/piscreenconsole.h @@ -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 variables; PIScreenTypes::Alignment alignment; diff --git a/src/console/piscreentiles.h b/src/console/piscreentiles.h index cc9e3b59..d05cefaf 100644 --- a/src/console/piscreentiles.h +++ b/src/console/piscreentiles.h @@ -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 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 diff --git a/src/console/piscreentypes.h b/src/console/piscreentypes.h index 858b5c6a..436a8333 100644 --- a/src/console/piscreentypes.h +++ b/src/console/piscreentypes.h @@ -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, diff --git a/src/io/pidir.cpp b/src/io/pidir.cpp index 990a5235..1a09d434 100755 --- a/src/io/pidir.cpp +++ b/src/io/pidir.cpp @@ -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 PIDir::entries() { PIVector l; if (!isExists()) return l; @@ -251,6 +258,7 @@ PIVector 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 PIDir::entries() { l.push_front(fi); } } + #else dirent ** list; int cnt = scandir(