OpenTTD Source: src/widget.cpp File Reference

OpenTTD Source 14.0-beta1

Functions | Variables
widget.cpp File Reference
`#include "stdafx.h"`
`#include "core/backup_type.hpp"`
`#include "company_func.h"`
`#include "window_gui.h"`
`#include "viewport_func.h"`
`#include "zoom_func.h"`
`#include "strings_func.h"`
`#include "transparency.h"`
`#include "core/geometry_func.hpp"`
`#include "settings_type.h"`
`#include "querystring_gui.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`
`#include "table/string_colours.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
static RectPadding | ScaleGUITrad (const RectPadding &r)
| Scale a RectPadding to GUI zoom level. More...
static Dimension | ScaleGUITrad (const Dimension &dim)
| Scale a Dimension to GUI zoom level. More...
Dimension | GetScaledSpriteSize (SpriteID sprid)
| Scale sprite size for GUI. More...
void | SetupWidgetDimensions ()
| Set up pre-scaled versions of Widget Dimensions.
static Point | GetAlignedPosition (const Rect &r, const Dimension &d, StringAlignment align)
| Calculate x and y coordinates for an aligned object within a window. More...
static Point | HandleScrollbarHittest (const Scrollbar *sb, int top, int bottom, bool horizontal)
| Compute the vertical position of the draggable part of scrollbar. More...
static void | ScrollbarClickPositioning (Window *w, NWidgetScrollbar *sb, int x, int y, int mi, int ma)
| Compute new position of the scrollbar after a click and updates the window flags. More...
void | ScrollbarClickHandler (Window *w, NWidgetCore *nw, int x, int y)
| Special handling for the scrollbar widget type. More...
WidgetID | GetWidgetFromPos (const Window *w, int x, int y)
| Returns the index for the widget located at the given position relative to the window. More...
void | DrawFrameRect (int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
| Draw frame rectangle. More...
void | DrawSpriteIgnorePadding (SpriteID img, PaletteID pal, const Rect &r, StringAlignment align)
static void | DrawImageButtons (const Rect &r, WidgetType type, Colours colour, bool clicked, SpriteID img, StringAlignment align)
| Draw an image button. More...
static void | DrawLabel (const Rect &r, WidgetType type, bool clicked, TextColour colour, StringID str, StringAlignment align, FontSize fs)
| Draw the label-part of a widget. More...
static void | DrawText (const Rect &r, TextColour colour, StringID str, StringAlignment align, FontSize fs)
| Draw text. More...
static void | DrawInset (const Rect &r, Colours colour, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
| Draw an inset widget. More...
static void | DrawMatrix (const Rect &r, Colours colour, bool clicked, uint16_t data, uint resize_x, uint resize_y)
| Draw a matrix widget. More...
static void | DrawVerticalScrollbar (const Rect &r, Colours colour, bool up_clicked, bool bar_dragged, bool down_clicked, const Scrollbar *scrollbar)
| Draw a vertical scrollbar. More...
static void | DrawHorizontalScrollbar (const Rect &r, Colours colour, bool left_clicked, bool bar_dragged, bool right_clicked, const Scrollbar *scrollbar)
| Draw a horizontal scrollbar. More...
static void | DrawFrame (const Rect &r, Colours colour, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
| Draw a frame widget. More...
static void | DrawShadeBox (const Rect &r, Colours colour, bool clicked)
| Draw a shade box. More...
static void | DrawStickyBox (const Rect &r, Colours colour, bool clicked)
| Draw a sticky box. More...
static void | DrawDefSizeBox (const Rect &r, Colours colour, bool clicked)
| Draw a defsize box. More...
static void | DrawDebugBox (const Rect &r, Colours colour, bool clicked)
| Draw a NewGRF debug box. More...
static void | DrawResizeBox (const Rect &r, Colours colour, bool at_left, bool clicked, bool bevel)
| Draw a resize box. More...
static void | DrawCloseBox (const Rect &r, Colours colour)
| Draw a close box. More...
void | DrawCaption (const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
| Draw a caption bar. More...
static void | DrawButtonDropdown (const Rect &r, Colours colour, bool clicked_button, bool clicked_dropdown, StringID str, StringAlignment align)
| Draw a button with a dropdown (WWT_DROPDOWN and NWID_BUTTON_DROPDOWN). More...
static void | DrawOutline (const Window *, const NWidgetBase *wid)
static const NWidgetPart * | MakeNWidget (const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr< NWidgetBase > &dest, bool *fill_dest)
| Construct a single nested widget in *dest from its parts. More...
bool | IsContainerWidgetType (WidgetType tp)
| Test if WidgetType is a container widget. More...
static const NWidgetPart * | MakeWidgetTree (const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr< NWidgetBase > &parent)
| Build a nested widget tree by recursively filling containers with nested widgets read from their parts. More...
std::unique_ptr< NWidgetBase > | MakeNWidgets (const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr< NWidgetBase > &&container)
| Construct a nested widget tree from an array of parts. More...
std::unique_ptr< NWidgetBase > | MakeWindowNWidgetTree (const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select)
| Make a nested widget tree for a window from a parts array. More...
std::unique_ptr< NWidgetBase > | MakeCompanyButtonRows (WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip, bool resizable)
| Make a number of rows with button-like graphics, for enabling/disabling each company. More...

## Variables
bool | _draw_widget_outlines

## Detailed Description

Handling of the default/simple widgets.

Definition in file widget.cpp.

## Function Documentation

## ◆ DrawButtonDropdown()

static void DrawButtonDropdown | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | clicked_button,
|  | bool | clicked_dropdown,
|  | StringID | str,
|  | StringAlignment | align
| ) |  |
| inlinestatic

Draw a button with a dropdown (WWT_DROPDOWN and NWID_BUTTON_DROPDOWN).

Parameters

  r | Rectangle containing the widget.
  colour | Background colour of the widget.
  clicked_button | The button-part is clicked.
  clicked_dropdown | The drop-down part is clicked.
  str | Text of the button.
  align | Alignment of the text within the dropdown.

Note
  Magic constants are also used in NWidgetLeaf::ButtonHit.

Definition at line 709 of file widget.cpp.

References _current_text_dir, DrawFrameRect(), NWidgetLeaf::dropdown_dimension, FR_LOWERED, and TD_LTR.

## ◆ DrawCaption()

void DrawCaption | ( | const Rect & | r,
|  | Colours | colour,
|  | Owner | owner,
|  | TextColour | text_colour,
|  | StringID | str,
|  | StringAlignment | align,
|  | FontSize | fs
| ) |  |

Draw a caption bar.

Parameters

  r | Rectangle of the bar.
  colour | Colour of the window.
  owner | 'Owner' of the window.
  text_colour | Colour of the text.
  str | Text to draw in the bar.
  align | Alignment of the text.
  fs | Font size of the text.

Definition at line 679 of file widget.cpp.

References _colour_gradient, _company_colours, WidgetDimensions::bevel, WidgetDimensions::captiontext, DrawFrameRect(), DrawString(), FR_BORDERONLY, FR_DARKENED, FR_LOWERED, GetAlignedPosition(), GetStringBoundingBox(), GfxFillRect(), MAX_COMPANIES, WidgetDimensions::scaled, and Rect::Shrink().

## ◆ DrawCloseBox()

static void DrawCloseBox | ( | const Rect & | r,
|  | Colours | colour
| ) |  |
| inlinestatic

Draw a close box.

Parameters

  r | Rectangle of the box.`
  colour | Colour of the close box.

Definition at line 658 of file widget.cpp.

## ◆ DrawDebugBox()

static void DrawDebugBox | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | clicked
| ) |  |
| inlinestatic

Draw a NewGRF debug box.

Parameters

  r | Rectangle of the box.
  colour | Colour of the debug box.
  clicked | Box is lowered.

Definition at line 630 of file widget.cpp.

References DrawImageButtons(), and WWT_DEBUGBOX.

## ◆ DrawDefSizeBox()

static void DrawDefSizeBox | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | clicked
| ) |  |
| inlinestatic

Draw a defsize box.

Parameters

  r | Rectangle of the box.
  colour | Colour of the defsize box.
  clicked | Box is lowered.

Definition at line 619 of file widget.cpp.

References DrawImageButtons(), and WWT_DEFSIZEBOX.

## ◆ DrawFrame()

static void DrawFrame | ( | const Rect & | r,
|  | Colours | colour,
|  | TextColour | text_colour,
|  | StringID | str,
|  | StringAlignment | align,
|  | FontSize | fs
| ) |  |
| inlinestatic

Draw a frame widget.

Parameters

  r | Rectangle of the frame.
  colour | Colour of the frame.
  text_colour | Colour of the text.
  str | Text of the frame.
  align | Alignment of the text in the frame.
  fs | Font size of the text.

Definition at line 544 of file widget.cpp.

References _colour_gradient, _current_text_dir, WidgetDimensions::bevel, DrawString(), Rect::Expand(), WidgetDimensions::frametext, FS_NORMAL, GetCharacterHeight(), GfxFillRect(), WidgetDimensions::scaled, ScaleGUITrad(), Rect::Shrink(), and TD_LTR.

## ◆ DrawFrameRect()

void DrawFrameRect | ( | int | left,
|  | int | top,
|  | int | right,
|  | int | bottom,
|  | Colours | colour,
|  | FrameFlags | flags
| ) |  |

Draw frame rectangle.

Parameters

  left | Left edge of the frame
  top | Top edge of the frame
  right | Right edge of the frame
  bottom | Bottom edge of the frame
  colour | Colour table to use.

See also
  _colour_gradient

Parameters

  flags | Flags controlling how to draw the frame.

See also
  FrameFlags

Definition at line 281 of file widget.cpp.

Referenced by DrawButtonDropdown(), DrawCaption(), DrawImageButtons(), DrawInset(), DrawResizeBox(), and Window::DrawWidgets().

## ◆ DrawHorizontalScrollbar()

static void DrawHorizontalScrollbar | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | left_clicked,
|  | bool | bar_dragged,
|  | bool | right_clicked,
|  | const Scrollbar * | scrollbar
| ) |  |
| inlinestatic

Draw a horizontal scrollbar.

Parameters

  r | Rectangle of the scrollbar widget.
  colour | Colour of the scrollbar widget.
  left_clicked | Left-arrow is clicked.
  bar_dragged | Bar is dragged.
  right_clicked | Right-arrow is clicked.
  scrollbar | Scrollbar size, offset, and capacity information.

Definition at line 504 of file widget.cpp.

References DrawImageButtons(), NWID_HSCROLLBAR, and Rect::WithWidth().

## ◆ DrawImageButtons()

static void DrawImageButtons | ( | const Rect & | r,
|  | WidgetType | type,
|  | Colours | colour,
|  | bool | clicked,
|  | SpriteID | img,
|  | StringAlignment | align
| ) |  |
| inlinestatic

Draw an image button.

Parameters

  r | Rectangle of the button.
  type | Widget type (WWT_IMGBTN or WWT_IMGBTN_2).
  colour | Colour of the button.
  clicked | Button is clicked.
  img | Sprite to draw.
  align | Alignment of the sprite.

Definition at line 337 of file widget.cpp.

References DrawFrameRect(), and FR_LOWERED.

Referenced by DrawDebugBox(), DrawDefSizeBox(), DrawHorizontalScrollbar(), DrawShadeBox(), DrawStickyBox(), and DrawVerticalScrollbar().

## ◆ DrawInset()

static void DrawInset | ( | const Rect & | r,
|  | Colours | colour,
|  | TextColour | text_colour,
|  | StringID | str,
|  | StringAlignment | align,
|  | FontSize | fs
| ) |  |
| inlinestatic

Draw an inset widget.

Parameters

  r | Rectangle of the background.
  colour | Colour of the inset.
  text_colour | Colour of the text.
  str | Text to draw.
  align | Alignment of the text.
  fs | Font size of the text.

Definition at line 389 of file widget.cpp.

References DrawFrameRect(), DrawString(), FR_DARKENED, FR_LOWERED, WidgetDimensions::inset, WidgetDimensions::scaled, and Rect::Shrink().

## ◆ DrawLabel()

static void DrawLabel | ( | const Rect & | r,
|  | WidgetType | type,
|  | bool | clicked,
|  | TextColour | colour,
|  | StringID | str,
|  | StringAlignment | align,
|  | FontSize | fs
| ) |  |
| inlinestatic

Draw the label-part of a widget.

Parameters

  r | Rectangle of the label background.
  type | Widget type (WWT_TEXTBTN, WWT_TEXTBTN_2, or WWT_LABEL).
  clicked | Label is clicked.
  colour | Colour of the text.
  str | Text to draw.
  align | Alignment of the text.
  fs | Font size of the text.

Definition at line 356 of file widget.cpp.

## ◆ DrawMatrix()

static void DrawMatrix | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | clicked,
|  | uint16_t | data,
|  | uint | resize_x,
|  | uint | resize_y
| ) |  |
| inlinestatic

Draw a matrix widget.

Parameters

  r | Rectangle of the matrix background.
  colour | Colour of the background.
  clicked | Matrix is rendered lowered.
  data | Data of the widget, number of rows and columns of the widget.
  resize_x | Matrix resize unit size.
  resize_y | Matrix resize unit size.

Definition at line 404 of file widget.cpp.

## ◆ DrawResizeBox()

static void DrawResizeBox | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | at_left,
|  | bool | clicked,
|  | bool | bevel
| ) |  |
| inlinestatic

Draw a resize box.

Parameters

  r | Rectangle of the box.
  colour | Colour of the resize box.
  at_left | Resize box is at left-side of the window,
  clicked | Box is lowered.
  bevel | Draw bevel iff set.

Definition at line 643 of file widget.cpp.

References DrawFrameRect(), and FR_LOWERED.

## ◆ DrawShadeBox()

static void DrawShadeBox | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | clicked
| ) |  |
| inlinestatic

Draw a shade box.

Parameters

  r | Rectangle of the box.
  colour | Colour of the shade box.
  clicked | Box is lowered.

Definition at line 597 of file widget.cpp.

References DrawImageButtons(), and WWT_SHADEBOX.

## ◆ DrawStickyBox()

static void DrawStickyBox | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | clicked
| ) |  |
| inlinestatic

Draw a sticky box.

Parameters

  r | Rectangle of the box.
  colour | Colour of the sticky box.
  clicked | Box is lowered.

Definition at line 608 of file widget.cpp.

References DrawImageButtons(), and WWT_STICKYBOX.

## ◆ DrawText()

static void DrawText | ( | const Rect & | r,
|  | TextColour | colour,
|  | StringID | str,
|  | StringAlignment | align,
|  | FontSize | fs
| ) |  |
| inlinestatic

Draw text.

Parameters

  r | Rectangle of the background.
  colour | Colour of the text.
  str | Text to draw.
  align | Alignment of the text.
  fs | Font size of the text.

Definition at line 373 of file widget.cpp.

References DrawString(), GetAlignedPosition(), and GetStringBoundingBox().

## ◆ DrawVerticalScrollbar()

static void DrawVerticalScrollbar | ( | const Rect & | r,
|  | Colours | colour,
|  | bool | up_clicked,
|  | bool | bar_dragged,
|  | bool | down_clicked,
|  | const Scrollbar * | scrollbar
| ) |  |
| inlinestatic

Draw a vertical scrollbar.

Parameters

  r | Rectangle of the scrollbar widget.
  colour | Colour of the scrollbar widget.
  up_clicked | Up-arrow is clicked.
  bar_dragged | Bar is dragged.
  down_clicked | Down-arrow is clicked.
  scrollbar | Scrollbar size, offset, and capacity information.

Definition at line 464 of file widget.cpp.

References DrawImageButtons(), NWID_VSCROLLBAR, and Rect::WithHeight().

## ◆ GetAlignedPosition()

static Point GetAlignedPosition | ( | const Rect & | r,
|  | const Dimension & | d,
|  | StringAlignment | align
| ) |  |
| inlinestatic

Calculate x and y coordinates for an aligned object within a window.

Parameters

  r | Rectangle of the widget to be drawn in.
  d | Dimension of the object to be drawn.
  align | Alignment of the object.

Returns
  A point containing the position at which to draw.

Definition at line 106 of file widget.cpp.

References _current_text_dir, CenterBounds(), SA_FORCE, SA_HOR_CENTER, SA_HOR_MASK, SA_LEFT, SA_RIGHT, and TD_RTL.

Referenced by DrawCaption(), and DrawText().

## ◆ GetScaledSpriteSize()

Dimension GetScaledSpriteSize | ( | SpriteID | sprid | ) |

Scale sprite size for GUI.

Offset is ignored.

Definition at line 54 of file widget.cpp.

References GetSpriteSize(), ScaleGUITrad(), and ZOOM_LVL_OUT_4X.

Referenced by DepotWindow::OnInit(), and NWidgetLeaf::SetupSmallestSize().

## ◆ GetWidgetFromPos()

WidgetID GetWidgetFromPos | ( | const Window * | w,
|  | int | x,
|  | int | y
| ) |  |

Returns the index for the widget located at the given position relative to the window.

It includes all widget-corner pixels as well.

Parameters

  *w | Window to look inside
  x | The Window client X coordinate
  y | The Window client y coordinate

Returns
  A widget index, or -1 if no widget was found.

Definition at line 266 of file widget.cpp.

Referenced by DropdownWindow::GetDropDownItem(), and Window::OnDropdownClose().

## ◆ HandleScrollbarHittest()

static Point HandleScrollbarHittest | ( | const Scrollbar * | sb,
|  | int | top,
|  | int | bottom,
|  | bool | horizontal
| ) |  |
| static

Compute the vertical position of the draggable part of scrollbar.

Parameters

  sb | Scrollbar list data
  top | Top position of the scrollbar (top position of the up-button)
  bottom | Bottom position of the scrollbar (bottom position of the down-button)
  horizontal | Whether the scrollbar is horizontal or not

Returns
  A Point, with x containing the top coordinate of the draggable part, and y containing the bottom coordinate of the draggable part

Definition at line 135 of file widget.cpp.

References _current_text_dir, Scrollbar::GetCapacity(), Scrollbar::GetCount(), Scrollbar::GetPosition(), and TD_RTL.

## ◆ IsContainerWidgetType()

bool IsContainerWidgetType | ( | WidgetType | tp | ) |

Test if WidgetType is a container widget.

Parameters

  tp | WidgetType to test.

Returns
  True iff WidgetType is a container widget.

Definition at line 3079 of file widget.cpp.

References NWID_HORIZONTAL, NWID_HORIZONTAL_LTR, NWID_MATRIX, NWID_SELECTION, NWID_VERTICAL, WWT_FRAME, WWT_INSET, and WWT_PANEL.

Referenced by IsNWidgetTreeClosed(), and MakeWidgetTree().

## ◆ MakeCompanyButtonRows()

std::unique_ptr<NWidgetBase> MakeCompanyButtonRows | ( | WidgetID | widget_first,
|  | WidgetID | widget_last,
|  | Colours | button_colour,
|  | int | max_length,
|  | StringID | button_tooltip,
|  | bool | resizable
| ) |  |

Make a number of rows with button-like graphics, for enabling/disabling each company.

Parameters

  widget_first | The first widget index to use.
  widget_last | The last widget index to use.
  colour | The colour in which to draw the button.
  max_length | Maximal number of company buttons in one row.
  button_tooltip | The tooltip-string of every button.
  resizable | Whether the rows are resizable.

Returns
  Panel with rows of company buttons.

Definition at line 3196 of file widget.cpp.

References GetSpriteSize().

Referenced by MakeCompanyButtonRowsGraphGUI(), MakeCompanyButtonRowsLinkGraphGUI(), and MakeCompanyButtonRowsScriptDebug().

## ◆ MakeNWidget()

static const NWidgetPart* MakeNWidget | ( | const NWidgetPart * | nwid_begin,
|  | const NWidgetPart * | nwid_end,
|  | std::unique_ptr< NWidgetBase > & | dest,
|  | bool * | fill_dest
| ) |  |
| static

Construct a single nested widget in *dest from its parts.

Construct a NWidgetBase object from a NWidget function, and apply all settings that follow it, until encountering a EndContainer, another NWidget, or the end of the parts array.

Parameters

  nwid_begin | Pointer to beginning of nested widget parts.
  nwid_end | Pointer to ending of nested widget parts.
  dest | Address of pointer to use for returning the composed widget.
  fill_dest | Fill the composed widget with child widgets.

Returns
  Pointer to remaining nested widget parts.

Definition at line 2902 of file widget.cpp.

References NWidgetPartWidget::colour, NWidgetPart::NWidgetPartUnion::cont_flags, FS_BEGIN, NWidgetPart::NWidgetPartUnion::func_ptr, NWidgetPartWidget::index, NWID_HORIZONTAL, NWID_HORIZONTAL_LTR, NWID_MATRIX, NWID_SPACER, NWID_VERTICAL, NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetResize(), NWidgetPartTextLines::size, NWidgetPart::NWidgetPartUnion::text_lines, NWidgetPart::type, NWidgetPart::NWidgetPartUnion::widget, WPT_FUNCTION, WPT_MINSIZE, WPT_MINTEXTLINES, WPT_RESIZE, WWT_FRAME, WWT_INSET, WWT_PANEL, and NWidgetPart::NWidgetPartUnion::xy.

Referenced by MakeWidgetTree().

## ◆ MakeWidgetTree()

static const NWidgetPart* MakeWidgetTree | ( | const NWidgetPart * | nwid_begin,
|  | const NWidgetPart * | nwid_end,
|  | std::unique_ptr< NWidgetBase > & | parent
| ) |  |
| static

Build a nested widget tree by recursively filling containers with nested widgets read from their parts.

Parameters

  nwid_begin | Pointer to beginning of nested widget parts.
  nwid_end | Pointer to ending of nested widget parts.
  parent | Pointer or container to use for storing the child widgets (*parent == nullptr or *parent == container or background widget).

Returns
  Pointer to remaining nested widget parts.

Definition at line 3092 of file widget.cpp.

References NWidgetContainer::Add(), NWidgetBackground::Add(), IsContainerWidgetType(), MakeNWidget(), NWidgetPart::type, and WPT_ENDCONTAINER.

Referenced by MakeNWidgets(), and MakeWindowNWidgetTree().

## ◆ ScaleGUITrad() [1/2]

static Dimension ScaleGUITrad | ( | const Dimension & | dim | ) |
| inlinestatic

Scale a Dimension to GUI zoom level.

Parameters

  d | Dimension at ZOOM_LVL_BASE (traditional "normal" interface size).

Returns
  Dimension at #ZOOM_LVL_GUI (current interface size).

Definition at line 45 of file widget.cpp.

## ◆ ScaleGUITrad() [2/2]

static RectPadding ScaleGUITrad | ( | const RectPadding & | r | ) |
| inlinestatic

Scale a RectPadding to GUI zoom level.

Parameters

  r | RectPadding at ZOOM_LVL_BASE (traditional "normal" interface size).

Returns
  RectPadding at #ZOOM_LVL_GUI (current interface size).

Definition at line 35 of file widget.cpp.

Referenced by NWidgetLeaf::Draw(), DrawFrame(), GetScaledSpriteSize(), NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetMinimalTextLines(), NWidgetPIPContainer::SetPIP(), and SetupWidgetDimensions().

## ◆ ScrollbarClickHandler()

void ScrollbarClickHandler | ( | Window * | w,
|  | NWidgetCore * | nw,
|  | int | x,
|  | int | y
| ) |  |

Special handling for the scrollbar widget type.

Handles the special scrolling buttons and other scrolling.

Parameters

  w | Window on which a scroll was performed.
  nw | Pointer to the scrollbar widget.
  x | The X coordinate of the mouse click.
  y | The Y coordinate of the mouse click.

Definition at line 242 of file widget.cpp.

## ◆ ScrollbarClickPositioning()

static void ScrollbarClickPositioning | ( | Window * | w,
|  | NWidgetScrollbar * | sb,
|  | int | x,
|  | int | y,
|  | int | mi,
|  | int | ma
| ) |  |
| static

Compute new position of the scrollbar after a click and updates the window flags.

Parameters

  w | Window on which a scroll was performed.
  sb | Scrollbar
  mi | Minimum coordinate of the scroll bar.
  ma | Maximum coordinate of the scroll bar.
  x | The X coordinate of the mouse click.
  y | The Y coordinate of the mouse click.

Definition at line 178 of file widget.cpp.