summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_gui.c42
-rw-r--r--network_gui.c11
-rw-r--r--roadveh_gui.c17
-rw-r--r--settings_gui.c4
-rw-r--r--ship_gui.c17
-rw-r--r--train_gui.c22
-rw-r--r--window.c26
-rw-r--r--window.h2
8 files changed, 74 insertions, 67 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 48a5f9c80..66f02510a 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -805,22 +805,6 @@ static void AircraftDepotClickAircraft(Window *w, int x, int y)
}
}
-static const Widget _aircraft_depot_widgets[] = {
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 318, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_STICKYBOX, RESIZE_LR, 14, 319, 330, 0, 13, 0x0, STR_STICKY_BUTTON},
-{ WWT_MATRIX, RESIZE_RB, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT},
-{ WWT_PANEL, RESIZE_LRB, 14, 296, 318, 14, 13, 0x0, STR_NULL},
-{ WWT_IMGBTN, RESIZE_LRTB, 14, 296, 318, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO},
-{ WWT_SCROLLBAR, RESIZE_LRB, 14, 319, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 159, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT},
-{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 160, 318, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR},
-{ WWT_PANEL, RESIZE_RTB, 14, 319, 318, 62, 73, 0x0, STR_NULL},
-{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 319, 330, 62, 73, 0x0, STR_RESIZE_BUTTON},
-{ WIDGETS_END},
-};
-
-
static void AircraftDepotWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
@@ -830,7 +814,7 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch(e->click.widget) {
- case 3: /* click aircraft */
+ case 5: /* click aircraft */
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y);
break;
case 7: /* show build aircraft window */
@@ -848,7 +832,7 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
case WE_DRAGDROP: {
switch(e->click.widget) {
- case 3: {
+ case 5: {
Vehicle *v;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -862,12 +846,12 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
}
} break;
- case 5:
- if (!HASBIT(w->disabled_state, 5) &&
+ case 4:
+ if (!HASBIT(w->disabled_state, 4) &&
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
Vehicle *v;
- HandleButtonClick(w, 5);
+ HandleButtonClick(w, 4);
v = GetVehicle(WP(w,traindepot_d).sel);
WP(w,traindepot_d).sel = INVALID_VEHICLE;
@@ -890,12 +874,26 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
case WE_RESIZE:
w->vscroll.cap += e->sizing.diff.y / 24;
w->hscroll.cap += e->sizing.diff.x / 74;
- w->widget[3].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
+ w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
break;
}
}
+static const Widget _aircraft_depot_widgets[] = {
+{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 318, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_STICKYBOX, RESIZE_LR, 14, 319, 330, 0, 13, 0x0, STR_STICKY_BUTTON},
+{ WWT_PANEL, RESIZE_LRB, 14, 296, 318, 14, 13, 0x0, STR_NULL},
+{ WWT_IMGBTN, RESIZE_LRTB, 14, 296, 318, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO},
+{ WWT_MATRIX, RESIZE_RB, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT},
+{ WWT_SCROLLBAR, RESIZE_LRB, 14, 319, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 159, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT},
+{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 160, 318, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR},
+{ WWT_PANEL, RESIZE_RTB, 14, 319, 318, 62, 73, 0x0, STR_NULL},
+{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 319, 330, 62, 73, 0x0, STR_RESIZE_BUTTON},
+{ WIDGETS_END},
+};
static const WindowDesc _aircraft_depot_desc = {
-1, -1, 331, 74,
diff --git a/network_gui.c b/network_gui.c
index 0e9893c5c..5a3b39eb7 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -248,7 +248,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
case 4: case 5:
ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, 5, 0, 0); // do it for widget 5
break;
- case 10: { /* Matrix to show networkgames */
+ case 9: { /* Matrix to show networkgames */
uint32 id_v = (e->click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW;
if (id_v >= w->vscroll.cap) { return;} // click out of bounds
@@ -363,11 +363,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
break;
}
- switch (HandleEditBoxKey(w, 3, e)) {
- case 1:
- HandleButtonClick(w, 10);
- break;
- }
+ if (HandleEditBoxKey(w, 3, e) == 1) break; // enter pressed
// The name is only allowed when it starts with a letter!
if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ')
@@ -399,13 +395,12 @@ static const Widget _network_game_window_widgets[] = {
{ WWT_6, RESIZE_NONE, BGC, 90, 231, 42, 53, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TIP},
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 220, 230, 43, 52, STR_0225, STR_NETWORK_CONNECTION_TIP},
-{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 220, 231, 62, 185, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-
{ WWT_IMGBTN, RESIZE_NONE, BTC, 10, 130, 62, 73, 0x0, STR_NETWORK_GAME_NAME_TIP },
{ WWT_IMGBTN, RESIZE_NONE, BTC, 131, 180, 62, 73, 0x0, STR_NETWORK_CLIENTS_CAPTION_TIP },
{ WWT_IMGBTN, RESIZE_NONE, BTC, 181, 219, 62, 73, 0x0, STR_NETWORK_INFO_ICONS_TIP },
{ WWT_MATRIX, RESIZE_NONE, BGC, 10, 219, 74, 185, 0x801, STR_NETWORK_CLICK_GAME_TO_SELECT},
+{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 220, 231, 62, 185, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 115, 195, 206, STR_NETWORK_FIND_SERVER, STR_NETWORK_FIND_SERVER_TIP},
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 125, 231, 195, 206, STR_NETWORK_ADD_SERVER, STR_NETWORK_ADD_SERVER_TIP},
diff --git a/roadveh_gui.c b/roadveh_gui.c
index d2ae1ceea..ecd9a697d 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -498,7 +498,7 @@ static void DrawRoadDepotWindow(Window *w)
tile = w->window_number;
/* setup disabled buttons */
- w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<5)|(1<<7));
+ w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7));
/* determine amount of items for scroller */
num = 0;
@@ -622,7 +622,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
case WE_CLICK: {
switch(e->click.widget) {
- case 3:
+ case 5:
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y);
break;
@@ -642,7 +642,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
case WE_DRAGDROP: {
switch(e->click.widget) {
- case 3: {
+ case 5: {
Vehicle *v;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -656,12 +656,12 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
}
} break;
- case 5:
- if (!HASBIT(w->disabled_state, 5) &&
+ case 4:
+ if (!HASBIT(w->disabled_state, 4) &&
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
Vehicle *v;
- HandleButtonClick(w, 5);
+ HandleButtonClick(w, 4);
v = GetVehicle(WP(w,traindepot_d).sel);
WP(w,traindepot_d).sel = INVALID_VEHICLE;
@@ -685,7 +685,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
/* Update the scroll + matrix */
w->vscroll.cap += e->sizing.diff.y / 14;
w->hscroll.cap += e->sizing.diff.x / 56;
- w->widget[3].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
+ w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
} break;
@@ -697,9 +697,10 @@ static const Widget _road_depot_widgets[] = {
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 302, 0, 13, STR_9003_ROAD_VEHICLE_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 303, 314, 0, 13, 0x0, STR_STICKY_BUTTON},
-{ WWT_MATRIX, RESIZE_RB, 14, 0, 279, 14, 55, 0x305, STR_9022_VEHICLES_CLICK_ON_VEHICLE},
{ WWT_PANEL, RESIZE_LRB, 14, 280, 302, 14, 13, 0x0, STR_NULL},
{ WWT_IMGBTN, RESIZE_LRTB, 14, 280, 302, 14, 55, 0x2A9, STR_9024_DRAG_ROAD_VEHICLE_TO_HERE},
+
+{ WWT_MATRIX, RESIZE_RB, 14, 0, 279, 14, 55, 0x305, STR_9022_VEHICLES_CLICK_ON_VEHICLE},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 303, 314, 14, 55, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 150, 56, 67, STR_9004_NEW_VEHICLES, STR_9023_BUILD_NEW_ROAD_VEHICLE},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 151, 302, 56, 67, STR_00E4_LOCATION, STR_9025_CENTER_MAIN_VIEW_ON_ROAD},
diff --git a/settings_gui.c b/settings_gui.c
index 7cd2d01f0..a69701170 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -1196,7 +1196,7 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch(e->click.widget) {
- case 2: { // select a grf file
+ case 3: { // select a grf file
int y = (e->click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE;
if (y >= w->vscroll.cap) { return;} // click out of bounds
@@ -1239,9 +1239,9 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
static const Widget _newgrf_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_MATRIX, RESIZE_NONE, 14, 0, 267, 14, 182, 0xC01,/*small rows*/ STR_NEWGRF_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 0, 279, 183, 276, 0x0, STR_NULL},
+{ WWT_MATRIX, RESIZE_NONE, 14, 0, 267, 14, 182, 0xC01,/*small rows*/ STR_NEWGRF_TIP},
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 268, 279, 14, 182, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 147, 158, 244, 255, STR_0188, STR_NULL},
diff --git a/ship_gui.c b/ship_gui.c
index 3495a1652..f7c54a10f 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -755,7 +755,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
case WE_CLICK:
switch(e->click.widget) {
- case 3:
+ case 5:
ShipDepotClick(w, e->click.pt.x, e->click.pt.y);
break;
@@ -775,7 +775,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
case WE_DRAGDROP: {
switch(e->click.widget) {
- case 3: {
+ case 5: {
Vehicle *v;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -789,12 +789,12 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
}
} break;
- case 5:
- if (!HASBIT(w->disabled_state, 5) &&
+ case 4:
+ if (!HASBIT(w->disabled_state, 4) &&
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
Vehicle *v;
- HandleButtonClick(w, 5);
+ HandleButtonClick(w, 4);
v = GetVehicle(WP(w,traindepot_d).sel);
WP(w,traindepot_d).sel = INVALID_VEHICLE;
@@ -817,7 +817,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
case WE_RESIZE:
w->vscroll.cap += e->sizing.diff.y / 24;
w->hscroll.cap += e->sizing.diff.x / 90;
- w->widget[3].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
+ w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
break;
}
}
@@ -826,9 +826,10 @@ static const Widget _ship_depot_widgets[] = {
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, STR_9803_SHIP_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 293, 304, 0, 13, 0x0, STR_STICKY_BUTTON},
-{ WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 61, 0x203, STR_981F_SHIPS_CLICK_ON_SHIP_FOR},
-{ WWT_PANEL, RESIZE_LRB, 14, 270, 292, 14, 13, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_LRB, 14, 270, 292, 14, 13, 0x0, STR_NULL},
{ WWT_IMGBTN, RESIZE_LRTB, 14, 270, 292, 14, 61, 0x2A9, STR_9821_DRAG_SHIP_TO_HERE_TO_SELL},
+
+{ WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 61, 0x203, STR_981F_SHIPS_CLICK_ON_SHIP_FOR},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 293, 304, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 146, 62, 73, STR_9804_NEW_SHIPS, STR_9820_BUILD_NEW_SHIP},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 147, 292, 62, 73, STR_00E4_LOCATION, STR_9822_CENTER_MAIN_VIEW_ON_SHIP},
diff --git a/train_gui.c b/train_gui.c
index 4b22c66d5..35ebbba7a 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -307,7 +307,7 @@ static void DrawTrainDepotWindow(Window *w)
tile = w->window_number;
/* setup disabled buttons */
- w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<5)|(1<<6)|(1<<8));
+ w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<5)|(1<<8));
/* determine amount of items for scroller */
num = 0;
@@ -527,7 +527,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
case 9:
ScrollMainWindowToTile(w->window_number);
break;
- case 3:
+ case 6:
TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y);
break;
}
@@ -539,8 +539,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
case WE_DRAGDROP: {
switch(e->click.widget) {
- case 5:
- case 6: {
+ case 4: case 5: {
Vehicle *v;
int sell_cmd;
@@ -558,7 +557,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
HandleButtonClick(w, e->click.widget);
- sell_cmd = (e->click.widget == 6 || _ctrl_pressed) ? 1 : 0;
+ sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0;
if (v->subtype != 0) {
DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE));
@@ -570,7 +569,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
}
} break;
- case 3: {
+ case 6: {
GetDepotVehiclePtData gdvp;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -597,20 +596,21 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
/* Update the scroll + matrix */
w->vscroll.cap += e->sizing.diff.y / 14;
w->hscroll.cap += e->sizing.diff.x / 29;
- w->widget[3].unkA = (w->vscroll.cap << 8) + 1;
+ w->widget[6].unkA = (w->vscroll.cap << 8) + 1;
} break;
}
}
static const Widget _train_depot_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 336, 0, 13, STR_8800_TRAIN_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_STICKYBOX, RESIZE_LR, 14, 337, 348, 0, 13, 0x0, STR_STICKY_BUTTON},
-{ WWT_MATRIX, RESIZE_RB, 14, 0, 313, 14, 97, 0x601, STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
+{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 336, 0, 13, STR_8800_TRAIN_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_STICKYBOX, RESIZE_LR, 14, 337, 348, 0, 13, 0x0, STR_STICKY_BUTTON},
+
{ WWT_PANEL, RESIZE_LRB, 14, 314, 336, 14, 13, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_LRTB, 14, 314, 336, 14, 54, 0x2A9, STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE},
{ WWT_PANEL, RESIZE_LRTB, 14, 314, 336, 55, 109, 0x2BF, STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP},
+{ WWT_MATRIX, RESIZE_RB, 14, 0, 313, 14, 97, 0x601, STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 337, 348, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 167, 110, 121, STR_8815_NEW_VEHICLES, STR_8840_BUILD_NEW_TRAIN_VEHICLE},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 168, 336, 110, 121, STR_00E4_LOCATION, STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},
diff --git a/window.c b/window.c
index 08604eb7e..0135fd8da 100644
--- a/window.c
+++ b/window.c
@@ -96,13 +96,25 @@ void DispatchRightClickEvent(Window *w, int x, int y) {
}
-void DispatchMouseWheelEvent(Window *w, int wheel)
+void DispatchMouseWheelEvent(Window *w, uint widget, int wheel)
{
- if (w->vscroll.count > w->vscroll.cap) {
- int pos = clamp(w->vscroll.pos + wheel, 0, w->vscroll.count - w->vscroll.cap);
- if (pos != w->vscroll.pos) {
- w->vscroll.pos = pos;
- SetWindowDirty(w);
+ const Widget *wi1 = &w->widget[widget];
+ const Widget *wi2 = &w->widget[widget + 1];
+ Scrollbar *sb;
+
+ /* The listbox can only scroll if scrolling was done on the scrollbar itself,
+ * or on the listbox (and the next item is (must be) the scrollbar)
+ * XXX - should be rewritten as a widget-dependent scroller but that's
+ * not happening until someone rewrites the whole widget-code */
+ if ((sb = &w->vscroll, wi1->type == WWT_SCROLLBAR) || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR) ||
+ (sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) {
+
+ if (sb->count > sb->cap) {
+ int pos = clamp(sb->pos + wheel, 0, sb->count - sb->cap);
+ if (pos != sb->pos) {
+ sb->pos = pos;
+ SetWindowDirty(w);
+ }
}
}
}
@@ -1356,7 +1368,7 @@ void MouseLoop()
}
} else {
if (mousewheel)
- DispatchMouseWheelEvent(w, mousewheel);
+ DispatchMouseWheelEvent(w, GetWidgetFromPos(w, x - w->left, y - w->top), mousewheel);
if (click == 1)
DispatchLeftClickEvent(w, x - w->left, y - w->top);
diff --git a/window.h b/window.h
index 89bc45364..25d34aed8 100644
--- a/window.h
+++ b/window.h
@@ -471,7 +471,7 @@ enum WindowFlags {
void DispatchLeftClickEvent(Window *w, int x, int y);
void DispatchRightClickEvent(Window *w, int x, int y);
-void DispatchMouseWheelEvent(Window *w, int wheel);
+void DispatchMouseWheelEvent(Window *w, uint widget, int wheel);
/* window.c */
void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom);