The window used for building objects. More...
Public Member Functions | |
BuildObjectWindow (WindowDesc *desc, Window *w) | |
virtual void | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
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 | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
void | SelectOtherObject (int object_index) |
Select the specified object in _selected_object_class class. | |
void | UpdateSelectSize () |
virtual void | OnResize () |
Called after the window got resized. | |
virtual void | OnClick (Point pt, int widget, int click_count) |
A click with the left mouse button has been made on the window. | |
void | SelectFirstAvailableObject (bool change_class) |
Select the first available object. | |
Private Member Functions | |
void | EnsureSelectedObjectClassIsVisible () |
Scroll WID_BO_CLASS_LIST so that the selected object class is visible. | |
bool | CanRestoreSelectedObject () |
Tests whether the previously selected object can be selected. | |
uint | GetMatrixColumnCount () |
Calculate the number of columns of the WID_BO_SELECT_MATRIX widget. | |
Private Attributes | |
int | line_height |
The height of a single line. | |
int | info_height |
The height of the info box. | |
Scrollbar * | vscroll |
The scrollbar. | |
Static Private Attributes | |
static const int | OBJECT_MARGIN = 4 |
The margin (in pixels) around an object. |
The window used for building objects.
Definition at line 33 of file object_gui.cpp.
bool BuildObjectWindow::CanRestoreSelectedObject | ( | ) | [inline, private] |
Tests whether the previously selected object can be selected.
true
if the selected object is available, false
otherwise. Definition at line 54 of file object_gui.cpp.
References _selected_object_class, _selected_object_index, NewGRFClass< Tspec, Tid, Tmax >::Get(), and NewGRFClass< Tspec, Tid, Tmax >::GetSpecCount().
virtual void BuildObjectWindow::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 229 of file object_gui.cpp.
References _selected_object_class, _selected_object_index, _selected_object_view, CALLBACK_FAILED, ObjectSpec::callback_mask, CBID_OBJECT_FUND_MORE_TEXT, CBM_OBJ_FUND_MORE_TEXT, DrawNewObjectTileInGUI(), DrawOrigTileSeqInGUI(), DrawString(), DrawStringMultiLine(), ErrorUnknownCallbackResult(), FillDrawPixelInfo(), FILLRECT_CHECKER, GB(), NewGRFClass< Tspec, Tid, Tmax >::Get(), GetGRFStringID(), GetObjectCallback(), NewGRFClass< Tspec, Tid, Tmax >::GetUISpecCount(), GfxFillRect(), ObjectSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), info_height, INVALID_TILE, ObjectSpec::IsAvailable(), Scrollbar::IsVisible(), line_height, GRFFilePropsBase< Tcnt >::local_id, min(), NewGRFClass< Tspec, Tid, Tmax >::name, OBJECT_MARGIN, PC_BLACK, Window::ReInit(), SetDParam(), StartTextRefStackUsage(), StopTextRefStackUsage(), TILE_PIXELS, ObjectSpec::views, vscroll, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, WD_MATRIX_TOP, WID_BO_CLASS_LIST, WID_BO_INFO, WID_BO_OBJECT_SPRITE, and WID_BO_SELECT_IMAGE.
void BuildObjectWindow::EnsureSelectedObjectClassIsVisible | ( | ) | [inline, private] |
Scroll WID_BO_CLASS_LIST so that the selected object class is visible.
Definition at line 40 of file object_gui.cpp.
References _selected_object_class, NewGRFClass< Tspec, Tid, Tmax >::Get(), Scrollbar::ScrollTowards(), and vscroll.
uint BuildObjectWindow::GetMatrixColumnCount | ( | ) | [inline, private] |
Calculate the number of columns of the WID_BO_SELECT_MATRIX widget.
Definition at line 68 of file object_gui.cpp.
References NWidgetBase::current_x, NWidgetBase::resize_x, and NWidgetBase::smallest_x.
virtual void BuildObjectWindow::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 374 of file object_gui.cpp.
References _selected_object_class, _selected_object_index, _selected_object_view, GB(), NewGRFClass< Tspec, Tid, Tmax >::Get(), Scrollbar::GetPosition(), NewGRFClass< Tspec, Tid, Tmax >::GetUISpecCount(), line_height, Window::nested_array, NWidgetBase::pos_y, SelectFirstAvailableObject(), SelectOtherObject(), Window::SetDirty(), vscroll, WID_BO_CLASS_LIST, WID_BO_OBJECT_SPRITE, and WID_BO_SELECT_IMAGE.
virtual void BuildObjectWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 368 of file object_gui.cpp.
References Scrollbar::GetCapacity(), MAT_COL_START, Scrollbar::SetCapacityFromWidget(), vscroll, and WID_BO_CLASS_LIST.
void BuildObjectWindow::SelectFirstAvailableObject | ( | bool | change_class | ) | [inline] |
Select the first available object.
change_class | If true, change the class if no object in the current class is available. |
Definition at line 410 of file object_gui.cpp.
References _selected_object_class, NewGRFClass< Tspec, Tid, Tmax >::Get(), NewGRFClass< Tspec, Tid, Tmax >::GetSpecCount(), ObjectSpec::IsAvailable(), OBJECT_CLASS_BEGIN, and SelectOtherObject().
Referenced by OnClick().
void BuildObjectWindow::SelectOtherObject | ( | int | object_index | ) | [inline] |
Select the specified object in _selected_object_class class.
object_index | Object index to select, -1 means select nothing. |
Definition at line 339 of file object_gui.cpp.
References _selected_object_class, _selected_object_index, _selected_object_view, NewGRFClass< Tspec, Tid, Tmax >::Get(), min(), Window::ReInit(), Window::SetDirty(), and ObjectSpec::views.
Referenced by OnClick(), and SelectFirstAvailableObject().
virtual void BuildObjectWindow::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 123 of file object_gui.cpp.
References _selected_object_class, _selected_object_index, _selected_object_view, GB(), NewGRFClass< Tspec, Tid, Tmax >::Get(), HasBit(), ObjectSpec::name, SetDParam(), ObjectSpec::size, WID_BO_OBJECT_NAME, and WID_BO_OBJECT_SIZE.
virtual void BuildObjectWindow::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 144 of file object_gui.cpp.
References _selected_object_class, _selected_object_index, FONT_HEIGHT_NORMAL, ObjectSpec::Get(), NewGRFClass< Tspec, Tid, Tmax >::Get(), Scrollbar::GetCapacity(), GetStringBoundingBox(), NewGRFClass< Tspec, Tid, Tmax >::GetUISpecCount(), ObjectSpec::height, Window::height, info_height, ObjectSpec::IsEverAvailable(), lengthof, line_height, max(), NewGRFClass< Tspec, Tid, Tmax >::name, NUM_OBJECTS, OBJECT_MARGIN, TILE_HEIGHT, TILE_PIXELS, ObjectSpec::views, vscroll, WD_MATRIX_TOP, WID_BO_CLASS_LIST, WID_BO_INFO, WID_BO_OBJECT_MATRIX, WID_BO_OBJECT_NAME, WID_BO_OBJECT_SIZE, WID_BO_OBJECT_SPRITE, and WID_BO_SELECT_MATRIX.