BuildObjectWindow Class Reference

The window used for building objects. More...

Inheritance diagram for BuildObjectWindow:
PickerWindowBase Window ZeroedMemoryAllocator

Public Member Functions

 BuildObjectWindow (const 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)
void UpdateSelectSize ()
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.
virtual void OnDropdownSelect (int widget, int index)
 A dropdown option associated to this window has been selected.

Static Private Member Functions

static DropDownListBuildObjectClassDropDown ()
 Build a dropdown list of available object classes.

Private Attributes

int line_height
 The height of a single line.
int object_height
 The height of the object box.
int info_height
 The height of the info box.
Scrollbarvscroll
 The scollbar.

Static Private Attributes

static const int OBJECT_MARGIN = 4
 The margin (in pixels) around an object.

Detailed Description

The window used for building objects.

Definition at line 42 of file object_gui.cpp.


Member Function Documentation

virtual void BuildObjectWindow::DrawWidget ( const Rect r,
int  widget 
) const [inline, virtual]
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.

Parameters:
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 277 of file object_gui.cpp.

References _selected_object_class, _selected_object_index, _selected_object_view, BOW_CLASS_DROPDOWN, BOW_OBJECT_LIST, BOW_OBJECT_MATRIX, BOW_OBJECT_SPRITE, BuildObjectClassDropDown(), GB(), NewGRFClass< Tspec, Tid, Tmax >::Get(), Scrollbar::GetCount(), Scrollbar::GetPosition(), ObjectSpec::IsAvailable(), line_height, Window::nested_array, NWidgetBase::pos_y, Window::SetDirty(), ShowDropDownList(), and vscroll.

virtual void BuildObjectWindow::OnDropdownSelect ( int  widget,
int  index 
) [inline, virtual]

A dropdown option associated to this window has been selected.

Parameters:
widget the widget (button) that the dropdown is associated with.
index the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 336 of file object_gui.cpp.

References _selected_object_class, BOW_CLASS_DROPDOWN, NewGRFClass< Tspec, Tid, Tmax >::GetCount(), SelectFirstAvailableObject(), Scrollbar::SetCount(), and vscroll.

void BuildObjectWindow::SelectFirstAvailableObject ( bool  change_class  )  [inline]

Select the first available object.

Parameters:
change_class If true, change the class if no object in the current class is available.

Definition at line 308 of file object_gui.cpp.

References _selected_object_class, NewGRFClass< Tspec, Tid, Tmax >::Get(), NewGRFClass< Tspec, Tid, Tmax >::GetCount(), ObjectSpec::IsAvailable(), OBJECT_CLASS_BEGIN, and OBJECT_CLASS_MAX.

Referenced by OnDropdownSelect().

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.

Parameters:
widget Widget number.

Reimplemented from Window.

Definition at line 81 of file object_gui.cpp.

References _selected_object_class, _selected_object_index, _selected_object_view, BOW_CLASS_DROPDOWN, BOW_OBJECT_SIZE, GB(), NewGRFClass< Tspec, Tid, Tmax >::Get(), NewGRFClass< Tspec, Tid, Tmax >::GetName(), HasBit(), SetDParam(), and ObjectSpec::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.

Parameters:
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 100 of file object_gui.cpp.

References _selected_object_class, _selected_object_index, BOW_CLASS_DROPDOWN, BOW_INFO, BOW_OBJECT_LIST, BOW_OBJECT_MATRIX, BOW_OBJECT_SPRITE, ObjectSpec::enabled, FONT_HEIGHT_NORMAL, NewGRFClass< Tspec, Tid, Tmax >::Get(), ObjectSpec::Get(), Scrollbar::GetCapacity(), NewGRFClass< Tspec, Tid, Tmax >::GetCount(), NewGRFClass< Tspec, Tid, Tmax >::GetName(), GetStringBoundingBox(), ObjectSpec::height, Window::height, info_height, lengthof, line_height, max(), maxdim(), ObjectSpec::name, NUM_OBJECTS, OBJECT_MARGIN, SetDParam(), TILE_HEIGHT, TILE_PIXELS, ObjectSpec::views, vscroll, WD_MATRIX_BOTTOM, and WD_MATRIX_TOP.


The documentation for this class was generated from the following file:

Generated on Fri Dec 31 17:16:20 2010 for OpenTTD by  doxygen 1.6.1