diff options
author | rubidium <rubidium@openttd.org> | 2009-09-02 07:36:39 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-09-02 07:36:39 +0000 |
commit | 78c9827000d3a3c42045798c66f8791b6b63b2cd (patch) | |
tree | 7124c3de58ec5c59485716e54ea9974cc6cc9f76 /src/depot_gui.cpp | |
parent | 1c94d98bb911be6e478947a1500eb843be478a45 (diff) | |
download | openttd-78c9827000d3a3c42045798c66f8791b6b63b2cd.tar.xz |
(svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
Diffstat (limited to 'src/depot_gui.cpp')
-rw-r--r-- | src/depot_gui.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index d2cf21c9b..ef2e9e0a8 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -278,7 +278,7 @@ struct DepotWindow : Window { free_wagon = u->IsFreeWagon(); uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0; - DrawTrainImage(u, x + 24 + x_space, sprite_y - 1, this->sel, this->hscroll.cap - x_space, this->hscroll.pos); + DrawTrainImage(u, x + 24 + x_space, sprite_y - 1, this->sel, this->hscroll.GetCapacity() - x_space, this->hscroll.GetPosition()); /* Number of wagons relative to a standard length wagon (rounded up) */ SetDParam(0, (u->tcache.cached_total_length + 7) / 8); @@ -349,10 +349,10 @@ struct DepotWindow : Window { max_width = max(max_width, width); } /* Always have 1 empty row, so people can change the setting of the train */ - SetVScrollCount(this, this->vehicle_list.Length() + this->wagon_list.Length() + 1); - SetHScrollCount(this, max_width); + this->vscroll.SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1); + this->hscroll.SetCount(max_width); } else { - SetVScrollCount(this, (this->vehicle_list.Length() + this->hscroll.cap - 1) / this->hscroll.cap); + this->vscroll.SetCount((this->vehicle_list.Length() + this->hscroll.GetCapacity() - 1) / this->hscroll.GetCapacity()); } /* locate the depot struct */ @@ -367,7 +367,7 @@ struct DepotWindow : Window { this->DrawWidgets(); - uint16 num = this->vscroll.pos * boxes_in_each_row; + uint16 num = this->vscroll.GetPosition() * boxes_in_each_row; maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row)); for (x = 2, y = 15; num < maxval; y += this->resize.step_height, x = 2) { // Draw the rows @@ -380,7 +380,7 @@ struct DepotWindow : Window { } } - maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row)); + maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll.GetPosition() * boxes_in_each_row) + (rows_in_display * boxes_in_each_row)); /* draw the train wagons, that do not have an engine in front */ for (; num < maxval; num++, y += 14) { @@ -413,15 +413,15 @@ struct DepotWindow : Window { } else { xt = x / this->resize.step_width; xm = x % this->resize.step_width; - if (xt >= this->hscroll.cap) return MODE_ERROR; + if (xt >= this->hscroll.GetCapacity()) return MODE_ERROR; ym = (y - 14) % this->resize.step_height; } row = (y - 14) / this->resize.step_height; - if (row >= this->vscroll.cap) return MODE_ERROR; + if (row >= this->vscroll.GetCapacity()) return MODE_ERROR; - pos = ((row + this->vscroll.pos) * boxes_in_each_row) + xt; + pos = ((row + this->vscroll.GetPosition()) * boxes_in_each_row) + xt; if ((int)(this->vehicle_list.Length() + this->wagon_list.Length()) <= pos) { if (this->type == VEH_TRAIN) { @@ -435,7 +435,7 @@ struct DepotWindow : Window { if ((int)this->vehicle_list.Length() > pos) { *veh = this->vehicle_list[pos]; - skip = this->hscroll.pos; + skip = this->hscroll.GetPosition(); } else { pos -= this->vehicle_list.Length(); *veh = this->wagon_list[pos]; @@ -657,8 +657,8 @@ struct DepotWindow : Window { /* Resize the window according to the vehicle type */ /* Set the number of blocks in each direction */ - this->vscroll.cap = _resize_cap[type][0]; - this->hscroll.cap = _resize_cap[type][1]; + this->vscroll.SetCapacity(_resize_cap[type][0]); + this->hscroll.SetCapacity(_resize_cap[type][1]); /* Set the block size */ this->resize.step_width = _block_sizes[type][0]; @@ -666,8 +666,8 @@ struct DepotWindow : Window { /* Enlarge the window to fit with the selected number of blocks of the selected size */ ResizeWindow(this, - _block_sizes[type][0] * this->hscroll.cap, - _block_sizes[type][1] * this->vscroll.cap); + _block_sizes[type][0] * this->hscroll.GetCapacity(), + _block_sizes[type][1] * this->vscroll.GetCapacity()); if (type == VEH_TRAIN) { /* Make space for the horizontal scrollbar vertically, and the unit @@ -684,8 +684,8 @@ struct DepotWindow : Window { this->SetupStringsForDepotWindow(type); this->widget[DEPOT_WIDGET_MATRIX].data = - (this->vscroll.cap << MAT_ROW_START) // number of rows to draw on the background - + ((type == VEH_TRAIN ? 1 : this->hscroll.cap) << MAT_COL_START); // number of boxes in each row. Trains always have just one + (this->vscroll.GetCapacity() << MAT_ROW_START) // number of rows to draw on the background + + ((type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START); // number of boxes in each row. Trains always have just one this->SetWidgetsHiddenState(type != VEH_TRAIN, @@ -945,9 +945,9 @@ struct DepotWindow : Window { virtual void OnResize(Point delta) { - this->vscroll.cap += delta.y / (int)this->resize.step_height; - this->hscroll.cap += delta.x / (int)this->resize.step_width; - this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.cap << MAT_ROW_START) + ((this->type == VEH_TRAIN ? 1 : this->hscroll.cap) << MAT_COL_START); + this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->hscroll.UpdateCapacity(delta.x / (int)this->resize.step_width); + this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + ((this->type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START); this->ResizeDepotButtons(); } |