before formatting
This commit is contained in:
@@ -17,16 +17,17 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "piscreen.h"
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#ifndef WINDOWS
|
||||
# include <sys/ioctl.h>
|
||||
# include <fcntl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <termios.h>
|
||||
#else
|
||||
# include <wingdi.h>
|
||||
# include <wincon.h>
|
||||
# include <wingdi.h>
|
||||
# ifndef COMMON_LVB_UNDERSCORE
|
||||
# define COMMON_LVB_UNDERSCORE 0x8000
|
||||
# define COMMON_LVB_UNDERSCORE 0x8000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -66,11 +67,11 @@ void PIScreen::SystemConsole::begin() {
|
||||
int w, h;
|
||||
#ifdef WINDOWS
|
||||
PRIVATE->ulcoord.X = 0;
|
||||
PRIVATE->hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
PRIVATE->hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
||||
PRIVATE->dattr = PRIVATE->sbi.wAttributes;
|
||||
w = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
|
||||
h = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
|
||||
PRIVATE->dattr = PRIVATE->sbi.wAttributes;
|
||||
w = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
|
||||
h = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
|
||||
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
|
||||
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
||||
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
@@ -135,9 +136,9 @@ void PIScreen::SystemConsole::clear() {
|
||||
|
||||
void PIScreen::SystemConsole::resize(int w, int h) {
|
||||
if (w == pwidth && h == pheight) return;
|
||||
width = piMaxi(w, 0);
|
||||
height = piMaxi(h, 0);
|
||||
pwidth = width;
|
||||
width = piMaxi(w, 0);
|
||||
height = piMaxi(h, 0);
|
||||
pwidth = width;
|
||||
pheight = height;
|
||||
cells.resize(height);
|
||||
pcells.resize(height);
|
||||
@@ -158,7 +159,7 @@ void PIScreen::SystemConsole::resize(int w, int h) {
|
||||
|
||||
void PIScreen::SystemConsole::print() {
|
||||
if (mouse_x >= 0 && mouse_x < width && mouse_y >= 0 && mouse_y < height) {
|
||||
///cells[mouse_y][mouse_x].format.flags ^= Inverse;
|
||||
/// cells[mouse_y][mouse_x].format.flags ^= Inverse;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
PRIVATE->srect = PRIVATE->sbi.srWindow;
|
||||
@@ -186,10 +187,10 @@ void PIScreen::SystemConsole::print() {
|
||||
int k = j * dw + i;
|
||||
Cell & c(cells[j + dy0][i + dx0]);
|
||||
PRIVATE->chars[k].Char.UnicodeChar = 0;
|
||||
PRIVATE->chars[k].Char.AsciiChar = c.symbol.toConsole1Byte();
|
||||
PRIVATE->chars[k].Attributes = attributes(c);
|
||||
PRIVATE->chars[k].Char.AsciiChar = c.symbol.toConsole1Byte();
|
||||
PRIVATE->chars[k].Attributes = attributes(c);
|
||||
}
|
||||
//piCout << "draw" << dw << dh;
|
||||
// piCout << "draw" << dw << dh;
|
||||
PRIVATE->bs.X = dw;
|
||||
PRIVATE->bs.Y = dh;
|
||||
PRIVATE->srect.Left += dx0;
|
||||
@@ -228,7 +229,7 @@ void PIScreen::SystemConsole::print() {
|
||||
if (!s.isEmpty()) {
|
||||
moveTo(si, sj);
|
||||
PICout::stdoutPIString(s);
|
||||
//printf("%s", s.data());
|
||||
// printf("%s", s.data());
|
||||
s.clear();
|
||||
}
|
||||
}
|
||||
@@ -240,33 +241,37 @@ void PIScreen::SystemConsole::print() {
|
||||
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
#define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
||||
# define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
# define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
||||
ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
||||
WORD attr = PRIVATE->dattr;
|
||||
if (c.format.flags & Bold) attr |= FOREGROUND_INTENSITY;
|
||||
else attr &= ~FOREGROUND_INTENSITY;
|
||||
if (c.format.flags & Underline) attr |= COMMON_LVB_UNDERSCORE;
|
||||
else attr &= ~COMMON_LVB_UNDERSCORE;
|
||||
if (c.format.flags & Bold)
|
||||
attr |= FOREGROUND_INTENSITY;
|
||||
else
|
||||
attr &= ~FOREGROUND_INTENSITY;
|
||||
if (c.format.flags & Underline)
|
||||
attr |= COMMON_LVB_UNDERSCORE;
|
||||
else
|
||||
attr &= ~COMMON_LVB_UNDERSCORE;
|
||||
switch (c.format.color_char) {
|
||||
case Black: attr = (attr & ~FOREGROUND_MASK); break;
|
||||
case Red: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_RED; break;
|
||||
case Green: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_GREEN; break;
|
||||
case Blue: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_BLUE; break;
|
||||
case Cyan: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
|
||||
case Black: attr = (attr & ~FOREGROUND_MASK); break;
|
||||
case Red: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_RED; break;
|
||||
case Green: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_GREEN; break;
|
||||
case Blue: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_BLUE; break;
|
||||
case Cyan: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
|
||||
case Magenta: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_RED | FOREGROUND_BLUE; break;
|
||||
case Yellow: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_RED | FOREGROUND_GREEN; break;
|
||||
case White: attr = attr | FOREGROUND_MASK; break;
|
||||
case Yellow: attr = (attr & ~FOREGROUND_MASK) | FOREGROUND_RED | FOREGROUND_GREEN; break;
|
||||
case White: attr = attr | FOREGROUND_MASK; break;
|
||||
}
|
||||
switch (c.format.color_back) {
|
||||
case Black: attr = (attr & ~BACKGROUND_MASK); break;
|
||||
case Red: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_RED; break;
|
||||
case Green: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_GREEN; break;
|
||||
case Blue: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_BLUE; break;
|
||||
case Cyan: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE; break;
|
||||
case Black: attr = (attr & ~BACKGROUND_MASK); break;
|
||||
case Red: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_RED; break;
|
||||
case Green: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_GREEN; break;
|
||||
case Blue: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_BLUE; break;
|
||||
case Cyan: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE; break;
|
||||
case Magenta: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_RED | BACKGROUND_BLUE; break;
|
||||
case Yellow: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_RED | BACKGROUND_GREEN; break;
|
||||
case White: attr = attr | BACKGROUND_MASK; break;
|
||||
case Yellow: attr = (attr & ~BACKGROUND_MASK) | BACKGROUND_RED | BACKGROUND_GREEN; break;
|
||||
case White: attr = attr | BACKGROUND_MASK; break;
|
||||
}
|
||||
if ((c.format.flags & Inverse) == Inverse) {
|
||||
uchar f = attr & 0xFF;
|
||||
@@ -276,8 +281,8 @@ ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
#undef FOREGROUND_MASK
|
||||
#undef BACKGROUND_MASK
|
||||
# undef FOREGROUND_MASK
|
||||
# undef BACKGROUND_MASK
|
||||
|
||||
void PIScreen::SystemConsole::getWinCurCoord() {
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
|
||||
@@ -292,36 +297,37 @@ void PIScreen::SystemConsole::clearLine() {
|
||||
|
||||
void PIScreen::SystemConsole::newLine() {
|
||||
getWinCurCoord();
|
||||
PRIVATE->ccoord.X = 0; PRIVATE->ccoord.Y++;
|
||||
PRIVATE->ccoord.X = 0;
|
||||
PRIVATE->ccoord.Y++;
|
||||
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
|
||||
}
|
||||
#else // WINDOWS
|
||||
#else // WINDOWS
|
||||
PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
|
||||
PIString ts = PIStringAscii("\e[0");
|
||||
switch (c.format.color_char) {
|
||||
case Black: ts += PIStringAscii(";30"); break;
|
||||
case Red: ts += PIStringAscii(";31"); break;
|
||||
case Green: ts += PIStringAscii(";32"); break;
|
||||
case Blue: ts += PIStringAscii(";34"); break;
|
||||
case Cyan: ts += PIStringAscii(";36"); break;
|
||||
case Black: ts += PIStringAscii(";30"); break;
|
||||
case Red: ts += PIStringAscii(";31"); break;
|
||||
case Green: ts += PIStringAscii(";32"); break;
|
||||
case Blue: ts += PIStringAscii(";34"); break;
|
||||
case Cyan: ts += PIStringAscii(";36"); break;
|
||||
case Magenta: ts += PIStringAscii(";35"); break;
|
||||
case Yellow: ts += PIStringAscii(";33"); break;
|
||||
case White: ts += PIStringAscii(";37"); break;
|
||||
case Yellow: ts += PIStringAscii(";33"); break;
|
||||
case White: ts += PIStringAscii(";37"); break;
|
||||
}
|
||||
switch (c.format.color_back) {
|
||||
case Black: ts += PIStringAscii(";40"); break;
|
||||
case Red: ts += PIStringAscii(";41"); break;
|
||||
case Green: ts += PIStringAscii(";42"); break;
|
||||
case Blue: ts += PIStringAscii(";44"); break;
|
||||
case Cyan: ts += PIStringAscii(";46"); break;
|
||||
case Black: ts += PIStringAscii(";40"); break;
|
||||
case Red: ts += PIStringAscii(";41"); break;
|
||||
case Green: ts += PIStringAscii(";42"); break;
|
||||
case Blue: ts += PIStringAscii(";44"); break;
|
||||
case Cyan: ts += PIStringAscii(";46"); break;
|
||||
case Magenta: ts += PIStringAscii(";45"); break;
|
||||
case Yellow: ts += PIStringAscii(";43"); break;
|
||||
case White: ts += PIStringAscii(";47"); break;
|
||||
case Yellow: ts += PIStringAscii(";43"); break;
|
||||
case White: ts += PIStringAscii(";47"); break;
|
||||
}
|
||||
if ((c.format.flags & Bold ) == Bold ) ts += PIStringAscii(";1");
|
||||
if ((c.format.flags & Bold) == Bold) ts += PIStringAscii(";1");
|
||||
if ((c.format.flags & Underline) == Underline) ts += PIStringAscii(";4");
|
||||
if ((c.format.flags & Blink ) == Blink ) ts += PIStringAscii(";5");
|
||||
if ((c.format.flags & Inverse ) == Inverse ) ts += PIStringAscii(";7");
|
||||
if ((c.format.flags & Blink) == Blink) ts += PIStringAscii(";5");
|
||||
if ((c.format.flags & Inverse) == Inverse) ts += PIStringAscii(";7");
|
||||
return ts + 'm';
|
||||
}
|
||||
#endif // WINDOWS
|
||||
@@ -358,8 +364,16 @@ void PIScreen::SystemConsole::clearScreen() {
|
||||
void PIScreen::SystemConsole::clearScreenLower() {
|
||||
#ifdef WINDOWS
|
||||
getWinCurCoord();
|
||||
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
||||
FillConsoleOutputAttribute(PRIVATE->hOut,
|
||||
PRIVATE->dattr,
|
||||
width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X,
|
||||
PRIVATE->ccoord,
|
||||
&PRIVATE->written);
|
||||
FillConsoleOutputCharacter(PRIVATE->hOut,
|
||||
' ',
|
||||
width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X,
|
||||
PRIVATE->ccoord,
|
||||
&PRIVATE->written);
|
||||
#else
|
||||
printf("\e[0m\e[J");
|
||||
#endif
|
||||
@@ -384,17 +398,17 @@ void PIScreen::SystemConsole::showCursor() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// PIScreen
|
||||
|
||||
PIScreen::PIScreen(bool startNow, PIKbdListener::KBFunc slot): PIThread(), drawer_(console.cells), root("rootTile") {
|
||||
setName("screen");
|
||||
setPriority(piLow);
|
||||
needLockRun(true);
|
||||
mouse_ = false;
|
||||
ret_func = slot;
|
||||
mouse_ = false;
|
||||
ret_func = slot;
|
||||
tile_focus = tile_dialog = nullptr;
|
||||
root.screen = this;
|
||||
listener = new PIKbdListener(key_eventS, this, startNow);
|
||||
root.screen = this;
|
||||
listener = new PIKbdListener(key_eventS, this, startNow);
|
||||
CONNECT1(void, PIKbdListener::MouseEvent, listener, mouseEvent, this, mouse_event);
|
||||
CONNECT1(void, PIKbdListener::WheelEvent, listener, wheelEvent, this, wheel_event);
|
||||
if (startNow) start();
|
||||
@@ -410,7 +424,7 @@ PIScreen::~PIScreen() {
|
||||
|
||||
|
||||
void PIScreen::setMouseEnabled(bool on) {
|
||||
mouse_ = on;
|
||||
mouse_ = on;
|
||||
console.mouse_x = console.mouse_y = -1;
|
||||
}
|
||||
|
||||
@@ -422,14 +436,12 @@ void PIScreen::key_event(PIKbdListener::KeyEvent key) {
|
||||
return;
|
||||
*/
|
||||
PIScreenTile * rtile = rootTile();
|
||||
if (tile_dialog)
|
||||
rtile = tile_dialog;
|
||||
if (tile_dialog) rtile = tile_dialog;
|
||||
bool used = nextFocus(rtile, key);
|
||||
if (used) return;
|
||||
if (!used && tile_focus) {
|
||||
if (tile_focus->visible) {
|
||||
if (tile_focus->keyEvent(key))
|
||||
return;
|
||||
if (tile_focus->keyEvent(key)) return;
|
||||
}
|
||||
}
|
||||
if (ret_func != 0) ret_func(key, data_);
|
||||
@@ -437,14 +449,14 @@ void PIScreen::key_event(PIKbdListener::KeyEvent key) {
|
||||
}
|
||||
|
||||
|
||||
PIVector<PIScreenTile * > PIScreen::prepareMouse(PIKbdListener::MouseEvent * e) {
|
||||
PIVector<PIScreenTile * > ret;
|
||||
PIVector<PIScreenTile *> PIScreen::prepareMouse(PIKbdListener::MouseEvent * e) {
|
||||
PIVector<PIScreenTile *> ret;
|
||||
if (!mouse_ || !e) return ret;
|
||||
console.mouse_x = e->x;
|
||||
console.mouse_y = e->y;
|
||||
PIVector<PIScreenTile * > tl = tilesUnderMouse(e->x, e->y);
|
||||
bool ff = false;
|
||||
piForeachR (PIScreenTile * t, tl) {
|
||||
console.mouse_x = e->x;
|
||||
console.mouse_y = e->y;
|
||||
PIVector<PIScreenTile *> tl = tilesUnderMouse(e->x, e->y);
|
||||
bool ff = false;
|
||||
piForeachR(PIScreenTile * t, tl) {
|
||||
if (!ff) {
|
||||
if (t->focus_flags[FocusOnMouse] && (e->action == PIKbdListener::MouseButtonPress)) {
|
||||
t->setFocus();
|
||||
@@ -455,20 +467,19 @@ PIVector<PIScreenTile * > PIScreen::prepareMouse(PIKbdListener::MouseEvent * e)
|
||||
ff = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return tl;
|
||||
}
|
||||
|
||||
|
||||
PIVector<PIScreenTile * > PIScreen::tilesUnderMouse(int x, int y) {
|
||||
PIVector<PIScreenTile * > ret;
|
||||
PIVector<PIScreenTile *> PIScreen::tilesUnderMouse(int x, int y) {
|
||||
PIVector<PIScreenTile *> ret;
|
||||
if (x < 0 || x >= console.width || y < 0 || y >= console.height) return ret;
|
||||
PIScreenTile * ct = tile_dialog ? tile_dialog : rootTile();
|
||||
bool f = true;
|
||||
bool f = true;
|
||||
while (ct) {
|
||||
if (!f) ret << ct;
|
||||
f = false;
|
||||
f = false;
|
||||
ct = ct->childUnderMouse(x, y);
|
||||
}
|
||||
return ret;
|
||||
@@ -476,27 +487,25 @@ PIVector<PIScreenTile * > PIScreen::tilesUnderMouse(int x, int y) {
|
||||
|
||||
|
||||
void PIScreen::mouse_event(PIKbdListener::MouseEvent me) {
|
||||
PIVector<PIScreenTile * > tl = prepareMouse(&me);
|
||||
PIVector<PIScreenTile *> tl = prepareMouse(&me);
|
||||
if (tl.isEmpty()) return;
|
||||
piForeachR (PIScreenTile * t, tl)
|
||||
piForeachR(PIScreenTile * t, tl)
|
||||
if (t->mouseEvent(me)) break;
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::wheel_event(PIKbdListener::WheelEvent we) {
|
||||
PIVector<PIScreenTile * > tl = prepareMouse(&we);
|
||||
PIVector<PIScreenTile *> tl = prepareMouse(&we);
|
||||
if (tl.isEmpty()) return;
|
||||
piForeachR (PIScreenTile * t, tl)
|
||||
piForeachR(PIScreenTile * t, tl)
|
||||
if (t->wheelEvent(we)) break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool PIScreen::nextFocus(PIScreenTile * rt, PIKbdListener::KeyEvent key) {
|
||||
PIVector<PIScreenTile*> vtl = rt->children(true), ftl;
|
||||
piForeach (PIScreenTile * t, vtl) {
|
||||
if (t->focus_flags[CanHasFocus])
|
||||
ftl << t;
|
||||
PIVector<PIScreenTile *> vtl = rt->children(true), ftl;
|
||||
piForeach(PIScreenTile * t, vtl) {
|
||||
if (t->focus_flags[CanHasFocus]) ftl << t;
|
||||
}
|
||||
int ind = -1;
|
||||
for (int i = 0; i < ftl.size_s(); ++i)
|
||||
@@ -504,18 +513,15 @@ bool PIScreen::nextFocus(PIScreenTile * rt, PIKbdListener::KeyEvent key) {
|
||||
ind = i;
|
||||
break;
|
||||
}
|
||||
if (ind < 0)
|
||||
tile_focus = 0;
|
||||
if (ind < 0) tile_focus = 0;
|
||||
if (ftl.isEmpty())
|
||||
tile_focus = 0;
|
||||
else {
|
||||
if (tile_focus)
|
||||
if (!tile_focus->visible)
|
||||
tile_focus = 0;
|
||||
if (!tile_focus->visible) tile_focus = 0;
|
||||
int next = tile_focus ? 0 : 1;
|
||||
if (tile_focus) {
|
||||
if (tile_focus->focus_flags[NextByTab] && key.key == PIKbdListener::Tab)
|
||||
next = 1;
|
||||
if (tile_focus->focus_flags[NextByTab] && key.key == PIKbdListener::Tab) next = 1;
|
||||
if (tile_focus->focus_flags[NextByArrowsHorizontal]) {
|
||||
if (key.key == PIKbdListener::LeftArrow) next = -1;
|
||||
if (key.key == PIKbdListener::RightArrow) next = 1;
|
||||
@@ -525,16 +531,16 @@ bool PIScreen::nextFocus(PIScreenTile * rt, PIKbdListener::KeyEvent key) {
|
||||
if (key.key == PIKbdListener::DownArrow) next = 1;
|
||||
}
|
||||
}
|
||||
//piCout << ftl.size() << ind << next;
|
||||
// piCout << ftl.size() << ind << next;
|
||||
if (next != 0) {
|
||||
PIVector<PIScreenTile*> tl = rt->children();
|
||||
piForeach (PIScreenTile * t, tl)
|
||||
PIVector<PIScreenTile *> tl = rt->children();
|
||||
piForeach(PIScreenTile * t, tl)
|
||||
t->has_focus = false;
|
||||
if (!ftl.isEmpty()) {
|
||||
ind += next;
|
||||
if (ind >= ftl.size_s()) ind = 0;
|
||||
if (ind < 0) ind = ftl.size_s() - 1;
|
||||
tile_focus = ftl[ind];
|
||||
tile_focus = ftl[ind];
|
||||
tile_focus->has_focus = true;
|
||||
}
|
||||
return true;
|
||||
@@ -550,22 +556,19 @@ void PIScreen::tileEventInternal(PIScreenTile * t, TileEvent e) {
|
||||
|
||||
|
||||
void PIScreen::tileRemovedInternal(PIScreenTile * t) {
|
||||
if (tile_dialog == t)
|
||||
tile_dialog = 0;
|
||||
if (tile_dialog == t) tile_dialog = 0;
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::tileSetFocusInternal(PIScreenTile * t) {
|
||||
PIScreenTile * rt = rootTile();
|
||||
if (tile_dialog)
|
||||
rt = tile_dialog;
|
||||
PIVector<PIScreenTile*> tl = rt->children(), ftl;
|
||||
piForeach (PIScreenTile * i, tl)
|
||||
if (tile_dialog) rt = tile_dialog;
|
||||
PIVector<PIScreenTile *> tl = rt->children(), ftl;
|
||||
piForeach(PIScreenTile * i, tl)
|
||||
i->has_focus = false;
|
||||
tile_focus = t;
|
||||
if (!tile_focus) return;
|
||||
if (tile_focus->focus_flags[CanHasFocus])
|
||||
tile_focus->has_focus = true;
|
||||
if (tile_focus->focus_flags[CanHasFocus]) tile_focus->has_focus = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -612,16 +615,21 @@ void PIScreen::run() {
|
||||
if (tile_dialog) {
|
||||
int sw(0), sh(0);
|
||||
tile_dialog->sizeHint(sw, sh);
|
||||
sw = piClampi(sw, tile_dialog->minimumWidth, tile_dialog->maximumWidth);
|
||||
sh = piClampi(sh, tile_dialog->minimumHeight, tile_dialog->maximumHeight);
|
||||
tile_dialog->x_ = (console.width - sw) / 2;
|
||||
tile_dialog->y_ = (console.height - sh) / 2;
|
||||
tile_dialog->width_ = sw;
|
||||
sw = piClampi(sw, tile_dialog->minimumWidth, tile_dialog->maximumWidth);
|
||||
sh = piClampi(sh, tile_dialog->minimumHeight, tile_dialog->maximumHeight);
|
||||
tile_dialog->x_ = (console.width - sw) / 2;
|
||||
tile_dialog->y_ = (console.height - sh) / 2;
|
||||
tile_dialog->width_ = sw;
|
||||
tile_dialog->height_ = sh;
|
||||
tile_dialog->layout();
|
||||
int dx = tile_dialog->x_ - 1, dy = tile_dialog->y_ - 1, dw = tile_dialog->width_, dh = tile_dialog->height_;
|
||||
drawer_.drawFrame(dx, dy, dx + dw + 1, dy + dh + 1, (Color)tile_dialog->back_format.color_char,
|
||||
(Color)tile_dialog->back_format.color_back, (CharFlags)tile_dialog->back_format.flags);
|
||||
drawer_.drawFrame(dx,
|
||||
dy,
|
||||
dx + dw + 1,
|
||||
dy + dh + 1,
|
||||
(Color)tile_dialog->back_format.color_char,
|
||||
(Color)tile_dialog->back_format.color_back,
|
||||
(CharFlags)tile_dialog->back_format.flags);
|
||||
tile_dialog->drawEventInternal(&drawer_);
|
||||
}
|
||||
console.print();
|
||||
@@ -635,10 +643,8 @@ void PIScreen::end() {
|
||||
|
||||
|
||||
PIScreenTile * PIScreen::tileByName(const PIString & name) {
|
||||
PIVector<PIScreenTile*> tl(tiles());
|
||||
piForeach (PIScreenTile * t, tl)
|
||||
if (t->name() == name)
|
||||
return t;
|
||||
PIVector<PIScreenTile *> tl(tiles());
|
||||
piForeach(PIScreenTile * t, tl)
|
||||
if (t->name() == name) return t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user