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 OnPaint ()
 The window must be repainted.
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)
 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)
 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 NewsItem * ni
 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

StringID GetCompanyMessageString () const
StringID GetNewVehicleMessageString (int widget) const

Detailed Description

Window class displaying a news item.

Definition at line 281 of file news_gui.cpp.


Member Function Documentation

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 342 of file news_gui.cpp.

References WindowDesc::default_width, DrawPixelInfo::height, max(), and DrawPixelInfo::width.

virtual void NewsWindow::OnPaint (  )  [inline, virtual]

The window must be repainted.

Note:
This method should not change any state, it should only use drawing functions.

Reimplemented from Window.

Definition at line 348 of file news_gui.cpp.

References Window::DrawWidgets().

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 353 of file news_gui.cpp.

References CopyInDParam(), GetEngineInfoString(), GetStringMultiLineBoundingBox(), Dimension::height, lengthof, maxdim(), ni, NR_ENGINE, NTW_COMPANY_MSG, NTW_MESSAGE, NTW_VEH_INFO, NTW_VEH_NAME, NTW_VEH_TITLE, and Dimension::width.

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 391 of file news_gui.cpp.

References ni, NTW_DATE, and SetDParam().

virtual void NewsWindow::DrawWidget ( const Rect r,
int  widget 
) const [inline, virtual]

Draw the contents of a nested widget.

Parameters:
r Rectangle occupied by the widget.
widget Number of the widget to draw.
Note:
This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 396 of file news_gui.cpp.

References Rect::bottom, CompanyNewsInformation::colour, CopyInDParam(), DrawCompanyManagerFace(), DrawStringMultiLine(), DrawVehicleEngine(), CompanyNewsInformation::face, FILLRECT_RECOLOUR, GetEngineInfoString(), GetEnginePalette(), GfxFillRect(), Rect::left, lengthof, ni, NR_ENGINE, NTW_COMPANY_MSG, NTW_MESSAGE, NTW_MGR_FACE, NTW_MGR_NAME, NTW_PANEL, NTW_VEH_BKGND, NTW_VEH_INFO, NTW_VEH_NAME, NTW_VEH_SPR, NTW_VEH_TITLE, CompanyNewsInformation::president_name, Rect::right, SA_CENTER, SetDParamStr(), and Rect::top.

virtual void NewsWindow::OnClick ( Point  pt,
int  widget 
) [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.

Reimplemented from Window.

Definition at line 449 of file news_gui.cpp.

References _ctrl_pressed, _forced_news, duration, GetReferenceTile(), INVALID_TILE, ni, NR_VEHICLE, NTW_CAPTION, NTW_CLOSEBOX, NTW_VIEWPORT, and ScrollMainWindowTo().

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 482 of file news_gui.cpp.

References Window::ES_HANDLED, and Window::ES_NOT_HANDLED.

virtual void NewsWindow::OnInvalidateData ( int  data  )  [inline, virtual]

Some data on this window has become invalid.

Parameters:
data information about the changed data.

Reimplemented from Window.

Definition at line 492 of file news_gui.cpp.

References chat_height.


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

Generated on Wed Dec 30 20:40:36 2009 for OpenTTD by  doxygen 1.5.6