creativity  v1.3.0
Agent-based model of creativity and piracy
Public Member Functions | List of all members
creativity::gui::BookInfoWindow Class Reference

InfoWindow subclass for displaying the details of a book. More...

#include <creativity/gui/BookInfoWindow.hpp>

Public Member Functions

 BookInfoWindow (std::shared_ptr< const state::State > state, std::shared_ptr< Gtk::Window > main_window, eris::eris_id_t book_id)
 Constructs a new InfoWindow displaying book information. More...
 
virtual void refresh (std::shared_ptr< const state::State > state) override
 Refresh the information in the dialog using the given simulation state. More...
 
- Public Member Functions inherited from creativity::gui::InfoWindow
 InfoWindow ()=delete
 No default constructor.
 

Additional Inherited Members

- Public Attributes inherited from creativity::gui::InfoWindow
const eris::eris_id_t id
 The eris_id of the simulation object about which this dialog is displaying details.
 
- Protected Member Functions inherited from creativity::gui::InfoWindow
 InfoWindow (std::shared_ptr< Gtk::Window > main_window, eris::eris_id_t id, const std::string &title)
 Creates a new InfoWindow, setting up the dialog window. More...
 
template<class T , typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
void updateValue (const std::string &code, const T &val)
 Updates a single value Gtk::Label text with the given value by passing it to std::to_string.
 
void updateValue (const std::string &code, const std::string &val)
 Updates a single value Gtk::Label text with the given string.
 
void updateMatrix (const std::string &code, const Eigen::Ref< const Eigen::MatrixXd > &m, bool lower_triangle=false)
 Updates a matrix set up with matrix_at with the values of the given matrix. More...
 
void clearMatrix (const std::string &code, const std::string &value="")
 Clears all values of a matrix set up with matrix_at, setting all values to the given value (defaulting to an empty string).
 
Gtk::Grid & new_grid ()
 Create a new grid, store it, return a reference to it (but don't add to any element)
 
Gtk::Grid & new_tab_grid (Gtk::Notebook &notebook, const std::string &title)
 Create a new grid and adds it as the content of new tab "title" on notebook, returns a reference to it.
 
void data_at (Gtk::Grid &grid, const std::string &code, const std::string &value_name, int row, int col, double label_align=1.0, double value_align=0.0)
 Creates a "value: data" label pair with labels stored in fields_ that can be updated later. More...
 
void data_append (Gtk::Grid &grid, const std::string &code, const std::string &value_name, double label_align=1.0, double value_align=0.0)
 Calls data_at to put the label at (gpos_, 0), then increments gpos_.
 
void label_at (Gtk::Grid &grid, const std::string &label, double alignment, int row, int col, int width, int height)
 Creates a label at the given location, taking up the given number of rows and columns, with horizontal alignment as given (0-1). More...
 
void labels_at (Gtk::Grid &grid, const std::string &label1, const std::string &label2, int row, int col)
 Creates a pair of single-cell labels at the given (row,col) and (row,col+1). More...
 
void labels_append (Gtk::Grid &grid, const std::string &label1, const std::string &label2)
 Creates a pair of static labels at the current (gpos_) row, first two columns.
 
void comment_append (Gtk::Grid &grid, const std::string &comment, int cols=2)
 Creates a static, wrapping, multi-column label, at the current (gpos_) row.
 
void matrix_at (Gtk::Grid &grid, const std::string &code, const std::string &name, int row, int col, int nrows, int ncols)
 Creates labels for a matrix of the given size in the grid with [0,0] element at (row+1,col+1), storing the labels in row-major order in matrix_. More...
 
- Protected Attributes inherited from creativity::gui::InfoWindow
std::unordered_map< std::string, std::pair< Gtk::Label, Gtk::Label > > fields_
 Fields containing a pair of labels: description and value.
 
std::unordered_map< std::string, std::vector< std::unique_ptr< Gtk::Label > > > matrix_
 Field containing a description and a matrix of values.
 
std::list< Gtk::Grid > grids_
 Grid for the display.
 
std::list< Gtk::Label > labels_
 Stored labels that aren't fields (i.e. single labels)
 
std::list< Gtk::Notebook > nbs_
 Notebooks for the tabs.
 
std::list< Gtk::ScrolledWindow > swins_
 Any scrolled windows used.
 
int gpos_ = 0
 The global label position, used during setup.
 
unsigned long t_ = (unsigned long) -1
 The time currently being shown (don't need to do anything in refresh() if this doesn't change.
 
bool initial_refresh_ = true
 On the initial refresh, don't replace the book model.
 

Detailed Description

InfoWindow subclass for displaying the details of a book.

Constructor & Destructor Documentation

§ BookInfoWindow()

creativity::gui::BookInfoWindow::BookInfoWindow ( std::shared_ptr< const state::State state,
std::shared_ptr< Gtk::Window >  main_window,
eris::eris_id_t  book_id 
)

Constructs a new InfoWindow displaying book information.

Parameters
statethe state at which to display the information for the initial refresh()
main_windowthe main window to which this dialog will be attached
book_idthe id of the book to display. If the book does not exist in the passed-in state, its values will be set to "N/A". (This is allowed because the book window can be refresh()ed to another state where the book may or may not exist).

Member Function Documentation

§ refresh()

virtual void creativity::gui::BookInfoWindow::refresh ( std::shared_ptr< const state::State state)
overridevirtual

Refresh the information in the dialog using the given simulation state.

Implements creativity::gui::InfoWindow.

Inheritance diagram for creativity::gui::BookInfoWindow:
[legend]
Collaboration diagram for creativity::gui::BookInfoWindow:
[legend]

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