Data Structures | |
struct | GetDepotVehiclePtData |
Public Types | |
enum | DepotGUIAction { MODE_ERROR, MODE_DRAG_VEHICLE, MODE_SHOW_VEHICLE, MODE_START_STOP } |
Public Member Functions | |
DepotWindow (const WindowDesc *desc, TileIndex tile, VehicleType type) | |
void | DrawVehicleInDepot (const Vehicle *v, int left, int right, int y) const |
Draw a vehicle in the depot window in the box with the top left corner at x,y. | |
void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
void | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
DepotGUIAction | GetVehicleFromDepotWndPt (int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const |
void | DepotClick (int x, int y) |
Handle click in the depot matrix. | |
void | SetupWidgetData (VehicleType type) |
Function to set up vehicle specific widgets (mainly sprites and strings). | |
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
Update size and resize step of a widget in the window. | |
virtual void | OnInvalidateData (int data) |
Some data on this window has become invalid. | |
virtual void | OnPaint () |
The window must be repainted. | |
virtual void | OnClick (Point pt, int widget, int click_count) |
A click with the left mouse button has been made on the window. | |
virtual void | OnQueryTextFinished (char *str) |
The query window opened from this window has closed. | |
virtual bool | OnRightClick (Point pt, int widget) |
A click with the right mouse button has been made on the window. | |
virtual void | OnVehicleSelect (const Vehicle *v) |
Clones a vehicle. | |
virtual void | OnPlaceObjectAbort () |
The user cancelled a tile highlight mode that has been set. | |
virtual void | OnMouseDrag (Point pt, int widget) |
An 'object' is being dragged at the provided position, highlight the target if possible. | |
virtual void | OnDragDrop (Point pt, int widget) |
A dragged 'object' has been released. | |
virtual void | OnTimeout () |
Called when this window's timeout has been reached. | |
virtual void | OnResize () |
Called after the window got resized. | |
virtual EventState | OnCTRLStateChange () |
The state of the control key has changed. | |
Data Fields | |
VehicleID | sel |
VehicleID | vehicle_over |
Rail vehicle over which another one is dragged, INVALID_VEHICLE if none. | |
VehicleType | type |
bool | generate_list |
VehicleList | vehicle_list |
VehicleList | wagon_list |
uint | num_columns |
Number of columns. | |
Scrollbar * | hscroll |
Only for trains. | |
Scrollbar * | vscroll |
uint | count_width |
uint | header_width |
uint | flag_width |
uint | flag_height |
Definition at line 221 of file depot_gui.cpp.
void DepotWindow::DepotClick | ( | int | x, | |
int | y | |||
) | [inline] |
Handle click in the depot matrix.
x | Horizontal position in the matrix widget in pixels. | |
y | Vertical position in the matrix widget in pixels. |
Definition at line 482 of file depot_gui.cpp.
References _ctrl_pressed, _current_text_dir, GroundVehicleCache::cached_veh_length, DIR_E, DIR_W, Vehicle::GetGroundVehicleCache(), Vehicle::GetImage(), GetVehiclePalette(), HT_DRAG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::IsGroundVehicle(), Window::SetDirty(), CursorVars::short_vehicle_offset, ShowVehicleViewWindow(), StartStopVehicle(), TD_RTL, VEH_TRAIN, CursorVars::vehchain, and VehicleClicked().
Referenced by OnClick().
void DepotWindow::DrawVehicleInDepot | ( | const Vehicle * | v, | |
int | left, | |||
int | right, | |||
int | y | |||
) | const [inline] |
Draw a vehicle in the depot window in the box with the top left corner at x,y.
v | Vehicle to draw. | |
left | Left side of the box to draw in. | |
right | Right side of the box to draw in. | |
y | Top of the box to draw in. |
Definition at line 270 of file depot_gui.cpp.
References _current_text_dir, Vehicle::age, GroundVehicleCache::cached_total_length, CeilDiv(), DAYS_IN_LEAP_YEAR, DIR_W, DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawSprite(), DrawString(), DrawTrainImage(), FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL, SpecializedVehicle< Train, Type >::From(), GroundVehicle< T, Type >::gcache, Vehicle::GetImage(), Scrollbar::GetPosition(), GetVehicleHeight(), Sprite::height, hscroll, GroundVehicle< T, Type >::IsFreeWagon(), Vehicle::IsGroundVehicle(), max(), Vehicle::max_age, Window::resize, SA_RIGHT, SetDParam(), ST_NORMAL, ResizeInfo::step_height, TD_RTL, BaseVehicle::type, Vehicle::unitnumber, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, vehicle_over, Vehicle::vehstatus, VS_STOPPED, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_PAR_VSEP_NORMAL, and Sprite::y_offs.
Referenced by DrawWidget().
void DepotWindow::DrawWidget | ( | const Rect & | r, | |
int | widget | |||
) | const [inline, virtual] |
Draw the contents of a nested widget.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Definition at line 329 of file depot_gui.cpp.
References _current_text_dir, DrawVehicleInDepot(), GB(), Scrollbar::GetPosition(), SmallVector< T, S >::Length(), MAT_COL_BITS, MAT_COL_START, MAT_ROW_BITS, MAT_ROW_START, min(), Window::resize, ResizeInfo::step_height, ResizeInfo::step_width, and TD_RTL.
virtual void DepotWindow::OnClick | ( | Point | pt, | |
int | widget, | |||
int | click_count | |||
) | [inline, virtual] |
A click with the left mouse button has been made on the window.
pt | the point inside the window that has been clicked. | |
widget | the clicked widget. | |
click_count | Number of fast consecutive clicks at same position |
Reimplemented from Window.
Definition at line 687 of file depot_gui.cpp.
References _ctrl_pressed, CMD_DEPOT_MASS_AUTOREPLACE, CMD_MASS_START_STOP, CS_ALPHANUMERAL, DepotClick(), DoCommandP(), GetDepotIndex(), GetStationIndex(), GetTileOwner(), HT_VEHICLE, Window::IsWidgetLowered(), SmallVector< T, S >::Length(), MAX_LENGTH_DEPOT_NAME_CHARS, MAX_LENGTH_DEPOT_NAME_PIXELS, Window::owner, VehicleListIdentifier::Pack(), NWidgetBase::pos_x, NWidgetBase::pos_y, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, ScrollMainWindowToTile(), SetDParam(), Window::SetWidgetDirty(), ShowExtraViewPortWindow(), ShowQuery(), ShowQueryString(), Window::ToggleWidgetLoweredState(), VEH_AIRCRAFT, and Window::window_number.
virtual EventState DepotWindow::OnCTRLStateChange | ( | ) | [inline, virtual] |
The state of the control key has changed.
Reimplemented from Window.
Definition at line 971 of file depot_gui.cpp.
References _ctrl_pressed, ES_HANDLED, ES_NOT_HANDLED, INVALID_VEHICLE, Window::SetWidgetDirty(), and CursorVars::vehchain.
virtual void DepotWindow::OnDragDrop | ( | Point | pt, | |
int | widget | |||
) | [inline, virtual] |
A dragged 'object' has been released.
pt | the point inside the window where the release took place. | |
widget | the widget where the release took place. |
Reimplemented from Window.
Definition at line 893 of file depot_gui.cpp.
References _ctrl_pressed, CMD_MSG, CMD_REVERSE_TRAIN_DIRECTION, DoCommandP(), SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Window::HandleButtonClick(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, GroundVehicle< T, Type >::IsFrontEngine(), Window::IsWidgetDisabled(), MAKE_ORDER_BACKUP_FLAG, NWidgetBase::pos_x, NWidgetBase::pos_y, Window::SetDirty(), ShowVehicleViewWindow(), Vehicle::tile, BaseVehicle::type, VEH_TRAIN, CursorVars::vehchain, and vehicle_over.
virtual void DepotWindow::OnInvalidateData | ( | int | data | ) | [inline, virtual] |
Some data on this window has become invalid.
data | information about the changed data. |
Reimplemented from Window.
Definition at line 638 of file depot_gui.cpp.
virtual void DepotWindow::OnMouseDrag | ( | Point | pt, | |
int | widget | |||
) | [inline, virtual] |
An 'object' is being dragged at the provided position, highlight the target if possible.
pt | The point inside the window that the mouse hovers over. | |
widget | The widget the mouse hovers over. |
Reimplemented from Window.
Definition at line 853 of file depot_gui.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::Last(), NWidgetBase::pos_x, NWidgetBase::pos_y, Vehicle::Previous(), Window::SetWidgetDirty(), VEH_TRAIN, and vehicle_over.
virtual void DepotWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 643 of file depot_gui.cpp.
References _local_company, BuildDepotVehicleList(), CeilDiv(), Window::DrawWidgets(), SpecializedVehicle< Train, Type >::From(), Train::GetDisplayImageWidth(), hscroll, IsTileOwner(), SmallVector< T, S >::Length(), max(), SpecializedVehicle< T, Type >::Next(), num_columns, Scrollbar::SetCount(), Window::SetWidgetsDisabledState(), VEH_TRAIN, WIDGET_LIST_END, Window::width, and Window::window_number.
virtual void DepotWindow::OnQueryTextFinished | ( | char * | str | ) | [inline, virtual] |
The query window opened from this window has closed.
str | the new value of the string, NULL if the window was cancelled or an empty string when the default button was pressed, i.e. StrEmpty(str). |
Reimplemented from Window.
Definition at line 766 of file depot_gui.cpp.
References CMD_MSG, CMD_RENAME_DEPOT, DoCommandP(), GetDepotIndex(), and Window::window_number.
virtual void DepotWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 958 of file depot_gui.cpp.
References NWidgetBase::current_x, Scrollbar::GetCapacity(), hscroll, MAT_COL_START, MAT_ROW_START, num_columns, NWidgetBase::resize_x, Scrollbar::SetCapacity(), Scrollbar::SetCapacityFromWidget(), VEH_TRAIN, and NWidgetCore::widget_data.
virtual bool DepotWindow::OnRightClick | ( | Point | pt, | |
int | widget | |||
) | [inline, virtual] |
A click with the right mouse button has been made on the window.
pt | the point inside the window that has been clicked. | |
widget | the clicked widget. |
Reimplemented from Window.
Definition at line 774 of file depot_gui.cpp.
References _ctrl_pressed, SpecializedVehicle< Train, Type >::From(), GuiShowTooltips(), GroundVehicle< T, Type >::HasArticulatedPart(), lastof, Vehicle::Next(), NUM_CARGO, NWidgetBase::pos_x, NWidgetBase::pos_y, SetDParam(), and VEH_TRAIN.
virtual void DepotWindow::OnVehicleSelect | ( | const Vehicle * | v | ) | [inline, virtual] |
Clones a vehicle.
v | the original vehicle to clone |
Definition at line 834 of file depot_gui.cpp.
References _ctrl_pressed, CcCloneVehicle(), CMD_CLONE_VEHICLE, CMD_MSG, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, BaseVehicle::type, and Window::window_number.
void DepotWindow::SetStringParameters | ( | int | widget | ) | const [inline, virtual] |
Initialize string parameters for a widget.
Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.
widget | Widget number. |
Reimplemented from Window.
Definition at line 365 of file depot_gui.cpp.
References GetDepotIndex(), GetStationIndex(), SetDParam(), VEH_AIRCRAFT, and Window::window_number.
void DepotWindow::SetupWidgetData | ( | VehicleType | type | ) | [inline] |
Function to set up vehicle specific widgets (mainly sprites and strings).
Only use this function to if the widget is used for several vehicle types and each has different text/sprites. If the widget is only used for a single vehicle type, or the same text/sprites are used every time, use the nested widget array to initialize the widget.
Definition at line 533 of file depot_gui.cpp.
References SetDataTip(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
virtual void DepotWindow::UpdateWidgetSize | ( | int | widget, | |
Dimension * | size, | |||
const Dimension & | padding, | |||
Dimension * | fill, | |||
Dimension * | resize | |||
) | [inline, virtual] |
Update size and resize step of a widget in the window.
After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.
widget | Widget number. | |
size | Size of the widget. | |
padding | Recommended amount of space between the widget content and the widget edge. | |
fill | Fill step of the widget. | |
resize | Resize step of the widget. |
Reimplemented from Window.
Definition at line 594 of file depot_gui.cpp.
References FONT_HEIGHT_NORMAL, GetDigitWidth(), GetStringBoundingBox(), Window::height, Sprite::height, max(), SetDParam(), ST_NORMAL, VEH_ROAD, VEH_TRAIN, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_MATRIX_BOTTOM, WD_MATRIX_TOP, WD_PAR_VSEP_NORMAL, and Sprite::width.