Window class displaying a news item. More...
Public Member Functions | |
NewsWindow (WindowDesc *desc, const NewsItem *ni) | |
void | DrawNewsBorder (const Rect &r) const |
virtual Point | OnInitialPosition (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 (WChar 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 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 | |
void | SetWindowTop (int newtop) |
Moves the window so newtop is new 'top' coordinate. | |
StringID | GetCompanyMessageString () const |
StringID | GetNewVehicleMessageString (int widget) const |
Window class displaying a news item.
Definition at line 260 of file news_gui.cpp.
virtual void NewsWindow::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 356 of file news_gui.cpp.
References _local_company, CompanyNewsInformation::colour, CopyInDParam(), DrawCaption(), DrawCompanyManagerFace(), DrawStringMultiLine(), DrawVehicleEngine(), EIT_PREVIEW, CompanyNewsInformation::face, FILLRECT_RECOLOUR, NewsItem::free_data, GetEngineInfoString(), GetEnginePalette(), GfxFillRect(), lengthof, ni, NR_ENGINE, Window::owner, PALETTE_NEWSPAPER, NewsItem::params, PC_GREY, CompanyNewsInformation::president_name, NewsItem::ref1, NewsItem::reftype1, SA_CENTER, SetDParamStr(), WID_N_CAPTION, WID_N_COMPANY_MSG, WID_N_MESSAGE, WID_N_MGR_FACE, WID_N_MGR_NAME, WID_N_PANEL, WID_N_VEH_BKGND, WID_N_VEH_INFO, WID_N_VEH_NAME, WID_N_VEH_SPR, and WID_N_VEH_TITLE.
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.
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 413 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, NewsItem::ref1, NewsItem::reftype1, NewsItem::reftype2, ScrollMainWindowTo(), ScrollMainWindowToTile(), ShowExtraViewPortWindow(), ShowVehicleViewWindow(), WID_N_CAPTION, WID_N_CLOSEBOX, WID_N_VIEWPORT, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
virtual Point NewsWindow::OnInitialPosition | ( | int16 | sm_width, | |
int16 | sm_height, | |||
int | window_number | |||
) | [inline, virtual] |
Compute the initial position of the window.
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 307 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.
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 467 of file news_gui.cpp.
References chat_height, SetWindowTop(), and Window::top.
virtual EventState NewsWindow::OnKeyPress | ( | WChar | key, | |
uint16 | keycode | |||
) | [inline, virtual] |
A key has been pressed.
key | the Unicode value of the key. | |
keycode | the untranslated key code including shift state. |
Reimplemented from Window.
Definition at line 452 of file news_gui.cpp.
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.
widget | Widget number. |
Reimplemented from Window.
Definition at line 351 of file news_gui.cpp.
References NewsItem::date, ni, SetDParam(), and WID_N_DATE.
void NewsWindow::SetWindowTop | ( | int | newtop | ) | [inline, private] |
Moves the window so newtop is new 'top' coordinate.
Makes screen dirty where needed.
newtop | new top coordinate |
Definition at line 488 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.
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 313 of file news_gui.cpp.
References CopyInDParam(), GetEngineInfoString(), GetStringMultiLineBoundingBox(), lengthof, maxdim(), ni, NR_ENGINE, NewsItem::params, NewsItem::ref1, NewsItem::reftype1, NewsItem::string_id, WID_N_COMPANY_MSG, WID_N_MESSAGE, WID_N_VEH_INFO, WID_N_VEH_NAME, and WID_N_VEH_TITLE.