Drop-down menu window. More...
Public Member Functions | |
DropdownWindow (Window *parent, DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll) | |
Create a dropdown menu. | |
virtual Point | OnInitialPosition (const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) |
Compute the initial position of the window. | |
bool | GetDropDownItem (int &value) |
Find the dropdown item under the cursor. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
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 | OnTick () |
Called once per (game) tick. | |
virtual void | OnMouseLoop () |
Called for every mouse loop run, which is at least once per (game) tick. | |
Data Fields | |
WindowClass | parent_wnd_class |
Parent window class. | |
WindowNumber | parent_wnd_num |
Parent window number. | |
byte | parent_button |
Parent widget number where the window is dropped from. | |
DropDownList * | list |
List with dropdown menu items. | |
int | selected_index |
Index of the selected item in the list. | |
byte | click_delay |
Timer to delay selection. | |
bool | drag_mode |
bool | instant_close |
Close the window when the mouse button is raised. | |
int | scrolling |
If non-zero, auto-scroll the item list (one time). | |
Point | position |
Position of the topleft corner of the window. | |
Scrollbar * | vscroll |
Drop-down menu window.
Definition at line 106 of file dropdown.cpp.
DropdownWindow::DropdownWindow | ( | Window * | parent, | |
DropDownList * | list, | |||
int | selected, | |||
int | button, | |||
bool | instant_close, | |||
const Point & | position, | |||
const Dimension & | size, | |||
Colours | wi_colour, | |||
bool | scroll | |||
) | [inline] |
Create a dropdown menu.
parent | Parent window. | |
list | Dropdown item list. | |
selected | Index of the selected item in the list. | |
button | Widget of the parent window doing the dropdown. | |
instant_close | Close the window when the mouse button is raised. | |
position | Topleft position of the dropdown menu window. | |
size | Size of the dropdown menu window. | |
wi_colour | Colour of the parent widget. | |
scroll | Dropdown menu has a scrollbar. | |
widget | Widgets of the dropdown menu window. |
Definition at line 132 of file dropdown.cpp.
References click_delay, NWidgetCore::colour, Window::CreateNestedTree(), DDM_SCROLL, Window::FinishInitNested(), Window::flags4, Window::GetScrollbar(), parent_button, parent_wnd_class, parent_wnd_num, selected_index, Scrollbar::SetCapacity(), Scrollbar::SetCount(), NWidgetResizeBase::SetMinimalSize(), SZSP_NONE, WD_VSCROLLBAR_WIDTH, Window::window_class, and Window::window_number.
virtual void DropdownWindow::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 234 of file dropdown.cpp.
References _colour_gradient, DDM_ITEMS, FILLRECT_CHECKER, Scrollbar::GetPosition(), GfxFillRect(), list, DropDownListItem::masked, PC_BLACK, DropDownListItem::result, and selected_index.
bool DropdownWindow::GetDropDownItem | ( | int & | value | ) | [inline] |
Find the dropdown item under the cursor.
value | [out] Selected item, if function returns true . |
Definition at line 204 of file dropdown.cpp.
References NWidgetBase::current_x, Scrollbar::GetPosition(), GetWidgetFromPos(), list, DropDownListItem::masked, NWidgetBase::pos_y, DropDownListItem::result, and Window::width.
Referenced by OnClick(), and OnMouseLoop().
virtual void DropdownWindow::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 263 of file dropdown.cpp.
References click_delay, DDM_ITEMS, GetDropDownItem(), selected_index, and Window::SetDirty().
virtual Point DropdownWindow::OnInitialPosition | ( | const WindowDesc * | desc, | |
int16 | sm_width, | |||
int16 | sm_height, | |||
int | window_number | |||
) | [inline, virtual] |
Compute the initial position of the window.
*desc | The pointer to the WindowDesc of the window to create. | |
sm_width | Smallest width of the window. | |
sm_height | Smallest height of the window. | |
window_number | The window number of the new window. |
Reimplemented from Window.
Definition at line 194 of file dropdown.cpp.
References position.