# NWidgetScrollbar Class Reference
[Hierarchical widgets]

Nested widget to display and control a scrollbar in a window. More...

`#include <widget_type.h>`

Inheritance diagram for NWidgetScrollbar:

## Public Member Functions
| NWidgetScrollbar (WidgetType tp, Colours colour, int index)
| Scrollbar widget.
void | SetupSmallestSize (Window *w, bool init_array)
| Compute smallest size needed by the widget.
void | Draw (const Window *w)
| Draw the widgets of the tree.

## Detailed Description

Nested widget to display and control a scrollbar in a window.

Also assign the scrollbar to other widgets using SetScrollbar() to make the mousewheel work.

Definition at line 714 of file widget_type.h.

## Constructor & Destructor Documentation

NWidgetScrollbar::NWidgetScrollbar | ( | WidgetType | tp,
|  | Colours | colour,
|  | int | index |
| ) |  |  |

Scrollbar widget.

Parameters:

  | tp | Scrollbar type. (horizontal/vertical)
  | colour | Colour of the scrollbar.
  | index | Index in the widget array used by the window system.

Definition at line 1871 of file widget.cpp.

References NWID_HSCROLLBAR, NWID_VSCROLLBAR, NWidgetCore::SetDataTip(), NWidgetResizeBase::SetFill(), NWidgetCore::SetIndex(), NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetResize(), NWidgetBase::type, WD_HSCROLLBAR_HEIGHT, and WD_VSCROLLBAR_WIDTH.

## Member Function Documentation

void NWidgetScrollbar::Draw | ( | const Window * | w | ) | `[virtual]`

Draw the widgets of the tree.

The function calls Window::DrawWidget for each widget with a non-negative index, after the widget itself is painted.

Parameters:

  | w | Window that owns the tree.

Implements NWidgetBase.

Definition at line 1905 of file widget.cpp.

References _colour_gradient, NWidgetCore::colour, NWidgetBase::current_x, NWidgetBase::current_y, NWidgetCore::disp_flags, DrawHorizontalScrollbar(), DrawVerticalScrollbar(), FILLRECT_CHECKER, GfxFillRect(), HasBit(), NWidgetCore::IsDisabled(), ND_SCROLLBAR_BTN, NDB_SCROLLBAR_DOWN, NDB_SCROLLBAR_UP, NWID_HSCROLLBAR, NWidgetBase::pos_x, NWidgetBase::pos_y, Window::scrolling_scrollbar, and NWidgetBase::type.

void NWidgetScrollbar::SetupSmallestSize | ( | Window * | w,
|  | bool | init_array |
| ) |  |  | `[virtual]`

Compute smallest size needed by the widget.

The smallest size of a widget is the smallest size that a widget needs to display itself properly. In addition, filling and resizing of the widget are computed. The function calls Window::UpdateWidgetSize for each leaf widget and background widget without child with a non-negative index.

Parameters:

  | w | Window owning the widget.
  | init_array | Initialize the `w->nested_array`.

Note:
  After the computation, the results can be queried by accessing the smallest_x and smallest_y data members of the widget.

Implements NWidgetBase.

Definition at line 1895 of file widget.cpp.

References NWidgetCore::index, NWidgetResizeBase::min_x, NWidgetResizeBase::min_y, Window::nested_array, Window::nested_array_size, NWidgetBase::smallest_x, and NWidgetBase::smallest_y.

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

- src/widget_type.h
- src/widget.cpp