equal
deleted
inserted
replaced
94 e.click.pt.y = y; |
94 e.click.pt.y = y; |
95 w->wndproc(w, &e); |
95 w->wndproc(w, &e); |
96 } |
96 } |
97 |
97 |
98 |
98 |
99 void DispatchMouseWheelEvent(Window *w, int wheel) |
99 void DispatchMouseWheelEvent(Window *w, uint widget, int wheel) |
100 { |
100 { |
101 if (w->vscroll.count > w->vscroll.cap) { |
101 const Widget *wi1 = &w->widget[widget]; |
102 int pos = clamp(w->vscroll.pos + wheel, 0, w->vscroll.count - w->vscroll.cap); |
102 const Widget *wi2 = &w->widget[widget + 1]; |
103 if (pos != w->vscroll.pos) { |
103 Scrollbar *sb; |
104 w->vscroll.pos = pos; |
104 |
105 SetWindowDirty(w); |
105 /* The listbox can only scroll if scrolling was done on the scrollbar itself, |
|
106 * or on the listbox (and the next item is (must be) the scrollbar) |
|
107 * XXX - should be rewritten as a widget-dependent scroller but that's |
|
108 * not happening until someone rewrites the whole widget-code */ |
|
109 if ((sb = &w->vscroll, wi1->type == WWT_SCROLLBAR) || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR) || |
|
110 (sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) { |
|
111 |
|
112 if (sb->count > sb->cap) { |
|
113 int pos = clamp(sb->pos + wheel, 0, sb->count - sb->cap); |
|
114 if (pos != sb->pos) { |
|
115 sb->pos = pos; |
|
116 SetWindowDirty(w); |
|
117 } |
106 } |
118 } |
107 } |
119 } |
108 } |
120 } |
109 |
121 |
110 |
122 |
1354 _cursor.fix_at = true; |
1366 _cursor.fix_at = true; |
1355 } |
1367 } |
1356 } |
1368 } |
1357 } else { |
1369 } else { |
1358 if (mousewheel) |
1370 if (mousewheel) |
1359 DispatchMouseWheelEvent(w, mousewheel); |
1371 DispatchMouseWheelEvent(w, GetWidgetFromPos(w, x - w->left, y - w->top), mousewheel); |
1360 |
1372 |
1361 if (click == 1) |
1373 if (click == 1) |
1362 DispatchLeftClickEvent(w, x - w->left, y - w->top); |
1374 DispatchLeftClickEvent(w, x - w->left, y - w->top); |
1363 else if (click == 2) |
1375 else if (click == 2) |
1364 DispatchRightClickEvent(w, x - w->left, y - w->top); |
1376 DispatchRightClickEvent(w, x - w->left, y - w->top); |