NewsWindow Struct Reference

Window class displaying a news item. More...

Inheritance diagram for NewsWindow:
Window ZeroedMemoryAllocator

Public Member Functions

 NewsWindow (const WindowDesc *desc, const NewsItem *ni)
void DrawNewsBorder (const Rect &r) const
virtual Point OnInitialPosition (const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
 Compute the initial position of the window.
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 SetStringParameters (int widget) const
 Initialize string parameters for a widget.
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 EventState OnKeyPress (uint16 key, uint16 keycode)
 A key has been pressed.
virtual void OnInvalidateData (int data=0, bool gui_scope=true)
 Some data on this window has become invalid.
virtual void OnTick ()
 Called once per (game) tick.

Data Fields

uint16 chat_height
 Height of the chat window.
uint16 status_height
 Height of the status bar window.
const NewsItemni
 News item to display.

Static Public Attributes

static uint duration = 0
 Remaining time for showing current news message (may only be accessed while a news item is displayed).

Private Member Functions

void SetWindowTop (int newtop)
 Moves the window so newtop is new 'top' coordinate.
StringID GetCompanyMessageString () const
StringID GetNewVehicleMessageString (int widget) const

Detailed Description

Window class displaying a news item.

Definition at line 283 of file news_gui.cpp.


Member Function Documentation

virtual void NewsWindow::DrawWidget ( const Rect r,
int  widget 
) const [inline, virtual]
virtual void NewsWindow::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 452 of file news_gui.cpp.

References _ctrl_pressed, duration, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetReferenceTile(), INVALID_TILE, ni, NR_VEHICLE, NTW_CAPTION, NTW_CLOSEBOX, NTW_VIEWPORT, NewsItem::ref1, NewsItem::reftype1, NewsItem::reftype2, ScrollMainWindowTo(), ScrollMainWindowToTile(), ShowExtraViewPortWindow(), ShowVehicleViewWindow(), Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

virtual Point NewsWindow::OnInitialPosition ( const WindowDesc desc,
int16  sm_width,
int16  sm_height,
int  window_number 
) [inline, virtual]

Compute the initial position of the window.

Parameters:
*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.
Returns:
Initial position of the top-left corner of the window.

Reimplemented from Window.

Definition at line 346 of file news_gui.cpp.

virtual void NewsWindow::OnInvalidateData ( int  data = 0,
bool  gui_scope = true 
) [inline, virtual]

Some data on this window has become invalid.

Parameters:
data Information about the changed data.
gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

Reimplemented from Window.

Definition at line 506 of file news_gui.cpp.

References chat_height, SetWindowTop(), and Window::top.

virtual EventState NewsWindow::OnKeyPress ( uint16  key,
uint16  keycode 
) [inline, virtual]

A key has been pressed.

Parameters:
key the Unicode value of the key.
keycode the untranslated key code including shift state.
Returns:
ES_HANDLED if the key press has been handled and no other window should receive the event.

Reimplemented from Window.

Definition at line 491 of file news_gui.cpp.

References ES_HANDLED, and ES_NOT_HANDLED.

virtual void NewsWindow::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 390 of file news_gui.cpp.

References NewsItem::date, ni, NTW_DATE, and SetDParam().

void NewsWindow::SetWindowTop ( int  newtop  )  [inline, private]

Moves the window so newtop is new 'top' coordinate.

Makes screen dirty where needed.

Parameters:
newtop new top coordinate

Definition at line 527 of file news_gui.cpp.

References Window::height, Window::left, max(), min(), SetDirtyBlocks(), ViewPort::top, Window::top, Window::viewport, and Window::width.

Referenced by OnInvalidateData(), and OnTick().

virtual void NewsWindow::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 352 of file news_gui.cpp.

References CopyInDParam(), GetEngineInfoString(), GetStringMultiLineBoundingBox(), lengthof, maxdim(), ni, NR_ENGINE, NTW_COMPANY_MSG, NTW_MESSAGE, NTW_VEH_INFO, NTW_VEH_NAME, NTW_VEH_TITLE, NewsItem::params, NewsItem::ref1, NewsItem::reftype1, and NewsItem::string_id.


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

Generated on Fri Jun 3 05:20:09 2011 for OpenTTD by  doxygen 1.6.1