git-svn-id: svn://db.shs.com.ru/pip@530 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -117,12 +117,18 @@ void TileScrollBar::drawEvent(PIScreenDrawer * d) {
|
||||
}
|
||||
|
||||
|
||||
bool TileScrollBar::mouseEvent(PIKbdListener::MouseEvent me) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileList::TileList(const PIString & n): PIScreenTile(n) {
|
||||
alignment = Left;
|
||||
focus_flags = CanHasFocus | NextByArrowsHorizontal | NextByTab;
|
||||
focus_flags = CanHasFocus | NextByArrowsHorizontal | NextByTab | FocusOnMouseOrWheel;
|
||||
lhei = offset = cur = 0;
|
||||
mouse_sel = false;
|
||||
selection_mode = NoSelection;
|
||||
scroll = new TileScrollBar();
|
||||
scroll->size_policy = Ignore;
|
||||
@@ -277,10 +283,50 @@ bool TileList::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
}
|
||||
|
||||
|
||||
bool TileList::mouseEvent(PIKbdListener::MouseEvent me) {
|
||||
if (me.action == PIKbdListener::MouseButtonRelease) return true;
|
||||
int mp = me.y - y() - 1 + offset;
|
||||
if (mp < 0 || mp >= content.size_s()) return true;
|
||||
cur = mp;
|
||||
switch (me.action) {
|
||||
case PIKbdListener::MouseButtonPress:
|
||||
mouse_sel = !selected.contains(cur);
|
||||
break;
|
||||
case PIKbdListener::MouseButtonDblClick:
|
||||
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
|
||||
//raiseEvent(TileEvent(RowPressed, cur));
|
||||
return true;
|
||||
default: break;
|
||||
}
|
||||
if (me.buttons[PIKbdListener::MouseRight]) {
|
||||
switch (selection_mode) {
|
||||
case SingleSelection:
|
||||
selected.clear();
|
||||
selected << cur;
|
||||
raiseEvent(TileEvent(SelectionChanged));
|
||||
break;
|
||||
case MultiSelection:
|
||||
if (mouse_sel) selected << cur;
|
||||
else selected.remove(cur);
|
||||
raiseEvent(TileEvent(SelectionChanged));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TileList::wheelEvent(PIKbdListener::WheelEvent we) {
|
||||
keyEvent(PIKbdListener::KeyEvent(we.direction ? PIKbdListener::PageUp : PIKbdListener::PageDown));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileButton::TileButton(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab | NextByArrowsAll;
|
||||
focus_flags = CanHasFocus | NextByTab | NextByArrowsAll | FocusOnMouse;
|
||||
}
|
||||
|
||||
|
||||
@@ -310,10 +356,17 @@ bool TileButton::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
}
|
||||
|
||||
|
||||
bool TileButton::mouseEvent(PIKbdListener::MouseEvent me) {
|
||||
if (me.action != PIKbdListener::MouseButtonRelease) return true;
|
||||
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileButtons::TileButtons(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab;
|
||||
focus_flags = CanHasFocus | NextByTab | FocusOnMouse;
|
||||
direction = Horizontal;
|
||||
alignment = PIScreenTypes::Center;
|
||||
cur = 0;
|
||||
@@ -339,6 +392,7 @@ void TileButtons::sizeHint(int & w, int & h) const {
|
||||
void TileButtons::drawEvent(PIScreenDrawer * d) {
|
||||
int cx = x_, cy = y_, shw, shh;
|
||||
sizeHint(shw, shh);
|
||||
btn_rects.resize(content.size());
|
||||
int dx = 0;
|
||||
switch (alignment) {
|
||||
case PIScreenTypes::Center: dx = (width_ - shw) / 2; break;
|
||||
@@ -362,6 +416,7 @@ void TileButtons::drawEvent(PIScreenDrawer * d) {
|
||||
cw = width_ - 2;
|
||||
xo = (cw - b.first.size_s()) / 2 - 1;
|
||||
}
|
||||
btn_rects[i] = (Rect){cx, cy, cx + cw + 2, cy + 1};
|
||||
d->fillRect(cx, cy, cx + cw + 2, cy + 1, ' ', Default, cb);
|
||||
d->drawText(cx, cy, "[", ct, Transparent, ff);
|
||||
d->drawText(cx + xo + 2, cy, b.first, ct, Transparent, ff);
|
||||
@@ -395,10 +450,26 @@ bool TileButtons::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
}
|
||||
|
||||
|
||||
bool TileButtons::mouseEvent(PIKbdListener::MouseEvent me) {
|
||||
if (me.action == PIKbdListener::MouseMove || me.action == PIKbdListener::MouseButtonPress) {
|
||||
for (int i = 0; i < btn_rects.size_s(); ++i)
|
||||
if (me.x >= btn_rects[i].x0 && me.x < btn_rects[i].x1 &&
|
||||
me.y >= btn_rects[i].y0 && me.y < btn_rects[i].y1) {
|
||||
cur = i;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (me.action != PIKbdListener::MouseButtonRelease) return true;
|
||||
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileCheck::TileCheck(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab | NextByArrowsAll;
|
||||
focus_flags = CanHasFocus | NextByTab | NextByArrowsAll | FocusOnMouse;
|
||||
toggled = false;
|
||||
}
|
||||
|
||||
@@ -431,6 +502,12 @@ bool TileCheck::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
}
|
||||
|
||||
|
||||
bool TileCheck::mouseEvent(PIKbdListener::MouseEvent me) {
|
||||
if (me.action == PIKbdListener::MouseButtonPress)
|
||||
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TileProgress::TileProgress(const PIString & n): PIScreenTile(n) {
|
||||
@@ -504,7 +581,7 @@ bool TilePICout::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
|
||||
|
||||
TileInput::TileInput(const PIString & n): PIScreenTile(n) {
|
||||
focus_flags = CanHasFocus | NextByTab;
|
||||
focus_flags = CanHasFocus | NextByTab | FocusOnMouse;
|
||||
back_format.color_back = White;
|
||||
format.color_char = Black;
|
||||
format.color_back = White;
|
||||
|
||||
Reference in New Issue
Block a user