git-svn-id: svn://db.shs.com.ru/pip@530 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -49,6 +49,7 @@ PRIVATE_DEFINITION_END(PIScreen::SystemConsole)
|
||||
|
||||
PIScreen::SystemConsole::SystemConsole() {
|
||||
width = height = pwidth = pheight = 0;
|
||||
mouse_x = mouse_y = -1;
|
||||
int w, h;
|
||||
#ifdef WINDOWS
|
||||
PRIVATE->ulcoord.X = 0;
|
||||
@@ -147,6 +148,9 @@ 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;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
//static int cnt = 0;
|
||||
PRIVATE->srect = PRIVATE->sbi.srWindow;
|
||||
@@ -384,10 +388,13 @@ PIScreen::PIScreen(bool startNow, PIKbdListener::KBFunc slot): PIThread(), drawe
|
||||
setName("screen");
|
||||
setPriority(piLow);
|
||||
needLockRun(true);
|
||||
mouse_ = false;
|
||||
ret_func = slot;
|
||||
tile_focus = tile_dialog = 0;
|
||||
root.screen = this;
|
||||
listener = new PIKbdListener(key_eventS, this, startNow);
|
||||
CONNECTU(listener, mouseEvent, this, mouse_event);
|
||||
CONNECTU(listener, wheelEvent, this, wheel_event);
|
||||
if (startNow) start();
|
||||
}
|
||||
|
||||
@@ -401,6 +408,14 @@ PIScreen::~PIScreen() {
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::setMouseEnabled(bool on) {
|
||||
mouse_ = on;
|
||||
//lock();
|
||||
console.mouse_x = console.mouse_y = -1;
|
||||
//unlock();
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::key_event(PIKbdListener::KeyEvent key) {
|
||||
/** DEBUG
|
||||
if (ret_func != 0) ret_func(key, t);
|
||||
@@ -423,6 +438,61 @@ void PIScreen::key_event(PIKbdListener::KeyEvent key) {
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
if (!ff) {
|
||||
if (t->focus_flags[FocusOnMouse] && (e->action == PIKbdListener::MouseButtonPress)) {
|
||||
t->setFocus();
|
||||
ff = true;
|
||||
}
|
||||
if (t->focus_flags[FocusOnWheel] && (e->action == PIKbdListener::MouseWheel)) {
|
||||
t->setFocus();
|
||||
ff = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return tl;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
while (ct) {
|
||||
if (!f) ret << ct;
|
||||
f = false;
|
||||
ct = ct->childUnderMouse(x, y);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::mouse_event(PIKbdListener::MouseEvent me) {
|
||||
PIVector<PIScreenTile * > tl = prepareMouse(&me);
|
||||
if (tl.isEmpty()) return;
|
||||
piForeachR (PIScreenTile * t, tl)
|
||||
if (t->mouseEvent(me)) piBreak;
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::wheel_event(PIKbdListener::WheelEvent we) {
|
||||
PIVector<PIScreenTile * > tl = prepareMouse(&we);
|
||||
if (tl.isEmpty()) return;
|
||||
piForeachR (PIScreenTile * t, tl)
|
||||
if (t->wheelEvent(we)) piBreak;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool PIScreen::nextFocus(PIScreenTile * rt, PIKbdListener::KeyEvent key) {
|
||||
PIVector<PIScreenTile*> vtl = rt->children(true), ftl;
|
||||
piForeach (PIScreenTile * t, vtl) {
|
||||
|
||||
Reference in New Issue
Block a user