Public Member Functions | Data Fields

GoalListWindow Struct Reference

Window for displaying goals. More...

Inheritance diagram for GoalListWindow:
Window ZeroedMemoryAllocator

Public Member Functions

 GoalListWindow (WindowDesc *desc, WindowNumber window_number)
void SetStringParameters (int widget) const
 Initialize string parameters for a widget.
void OnClick (Point pt, int widget, int click_count)
 A click with the left mouse button has been made on the window.
void HandleClick (const Goal *s)
 Handle clicking at a goal.
uint CountLines ()
 Count the number of lines in this window.
void UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 Update size and resize step of a widget in the window.
void DrawPartialGoalList (int &pos, const int cap, int x, int y, int right, uint progress_col_width, bool global_section, GoalColumn column) const
 Draws either the global goals or the company goal section.
void DrawListColumn (GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
 Draws a given column of the goal list.
void OnPaint ()
 The window must be repainted.
void OnResize ()
 Called after the window got resized.
void OnInvalidateData (int data=0, bool gui_scope=true)
 Some data on this window has become invalid.

Data Fields

Scrollbarvscroll
 Reference to the scrollbar widget.

Detailed Description

Window for displaying goals.

Definition at line 38 of file goal_gui.cpp.


Member Function Documentation

uint GoalListWindow::CountLines (  )  [inline]

Count the number of lines in this window.

Returns:
the number of lines.

Definition at line 155 of file goal_gui.cpp.

References Goal::company, and INVALID_COMPANY.

Referenced by OnInvalidateData().

void GoalListWindow::DrawListColumn ( GoalColumn  column,
NWidgetBase wid,
uint  progress_col_width 
) const [inline]

Draws a given column of the goal list.

Parameters:
column Which column to draw. Pointer to the goal list widget. Width of the progress column.
Returns:
max width of drawn text

Definition at line 254 of file goal_gui.cpp.

References NWidgetBase::current_x, DrawPartialGoalList(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), NWidgetBase::pos_x, NWidgetBase::pos_y, and vscroll.

Referenced by OnPaint().

void GoalListWindow::DrawPartialGoalList ( int &  pos,
const int  cap,
int  x,
int  y,
int  right,
uint  progress_col_width,
bool  global_section,
GoalColumn  column 
) const [inline]

Draws either the global goals or the company goal section.

This is a helper method for DrawWidget.

Parameters:
pos [inout] Vertical line number to draw.
cap Number of lines to draw in the window.
x Left edge of the text line to draw.
y Vertical position of the top edge of the window.
right Right edge of the text line to draw.
global_section Whether the global goals are printed.
column Which column to draw.

Definition at line 201 of file goal_gui.cpp.

References _current_text_dir, Goal::company, Goal::completed, DrawString(), FONT_HEIGHT_NORMAL, GC_GOAL, GC_PROGRESS, INVALID_COMPANY, IsInsideMM(), Goal::progress, SA_FORCE, SA_RIGHT, SetDParamStr(), Goal::text, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and Window::window_number.

Referenced by DrawListColumn().

void GoalListWindow::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 62 of file goal_gui.cpp.

References Goal::company, Scrollbar::GetScrolledRowFromWidget(), HandleClick(), INVALID_COMPANY, vscroll, WD_FRAMERECT_TOP, and WID_GOAL_LIST.

void GoalListWindow::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 307 of file goal_gui.cpp.

References CountLines(), Scrollbar::SetCount(), Window::SetWidgetDirty(), vscroll, and WID_GOAL_LIST.

void GoalListWindow::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 272 of file goal_gui.cpp.

References Goal::completed, NWidgetBase::current_x, DrawListColumn(), Window::DrawWidgets(), GC_GOAL, GC_PROGRESS, GetStringBoundingBox(), min(), Goal::progress, and SetDParamStr().

void GoalListWindow::OnResize (  )  [inline, virtual]

Called after the window got resized.

For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.

Reimplemented from Window.

Definition at line 297 of file goal_gui.cpp.

References Scrollbar::SetCapacityFromWidget(), vscroll, and WID_GOAL_LIST.

void GoalListWindow::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 50 of file goal_gui.cpp.

References INVALID_COMPANY, SetDParam(), WID_GOAL_CAPTION, and Window::window_number.

void GoalListWindow::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 177 of file goal_gui.cpp.

References GetStringBoundingBox(), maxdim(), WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and WID_GOAL_LIST.


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