GCC Middle and Back End API Reference
text_art::table Class Reference

#include <table.h>

Collaboration diagram for text_art::table:

Data Structures

class  cell_placement

Public Types

typedef size< class tablesize_t
typedef coord< class tablecoord_t
typedef range< class tablerange_t
typedef rect< class tablerect_t

Public Member Functions

 table (size_t size)
 ~table ()=default
 table (table &&)=default
 table (const table &)=delete
tableoperator= (const table &)=delete
const size_tget_size () const
int add_rows (unsigned num)
int add_row ()
void set_cell (coord_t coord, table_cell_content &&content, enum x_align x_align=x_align::CENTER, enum y_align y_align=y_align::CENTER)
void set_cell_span (rect_t span, table_cell_content &&content, enum x_align x_align=x_align::CENTER, enum y_align y_align=y_align::CENTER)
void maybe_set_cell_span (rect_t span, table_cell_content &&content, enum x_align x_align=x_align::CENTER, enum y_align y_align=y_align::CENTER)
canvas to_canvas (const theme &theme, const style_manager &sm) const
void paint_to_canvas (canvas &canvas, canvas::coord_t offset, const table_geometry &tg, const theme &theme) const
void debug () const
void add_other_table (table &&other, table::coord_t offset)
const cell_placementget_placement_at (coord_t coord) const

Private Member Functions

int get_occupancy_safe (coord_t coord) const
directions get_connections (int table_x, int table_y) const
void paint_cell_borders_to_canvas (canvas &canvas, canvas::coord_t offset, const table_geometry &tg, const theme &theme) const
void paint_cell_contents_to_canvas (canvas &canvas, canvas::coord_t offset, const table_geometry &tg) const

Private Attributes

size_t m_size
std::vector< cell_placementm_placements
array2< int, size_t, coord_tm_occupancy

Friends

class table_cell_sizes

Detailed Description

A 2D grid of cells.  Instances of table_cell_content can be assigned
to individual table cells, and to rectangular spans of cells.  Such
assignments do not have to fully cover the 2D grid, but they must not
overlap.   

Member Typedef Documentation

◆ coord_t

◆ range_t

◆ rect_t

◆ size_t

Constructor & Destructor Documentation

◆ table() [1/3]

table::table ( size_t size)
class text_art::table.   

References m_occupancy, m_placements, and m_size.

Referenced by add_other_table(), operator=(), table(), and table().

◆ ~table()

text_art::table::~table ( )
default

◆ table() [2/3]

text_art::table::table ( table && )
default

References table().

◆ table() [3/3]

text_art::table::table ( const table & )
delete

References table().

Member Function Documentation

◆ add_other_table()

void table::add_other_table ( table && other,
table::coord_t offset )
Move OTHER's content this table, starting at OFFSET.   

References set_cell_span(), and table().

◆ add_row()

int text_art::table::add_row ( )
inline

References add_rows().

◆ add_rows()

int text_art::table::add_rows ( unsigned num)
inline

References i, m_occupancy, and m_size.

Referenced by add_row().

◆ debug()

DEBUG_FUNCTION void table::debug ( ) const
Print this table to stderr.   

References text_art::canvas::debug(), and to_canvas().

◆ get_connections()

directions table::get_connections ( int table_x,
int table_y ) const
private
Determine if the "?" edges need borders for table cell D
  in the following, for the directions relative to "X", based
  on whether each of table cell boundaries AB, CD, AC, and BD
  are boundaries between cell spans:

  #            up?
  #      +-----+-----+
  #      |           |
  #      |     ?     |
  #      |  A  ?  B  |
  #      |     ?     |
  #      |           |
  # left?+ ??? X ??? + right?
  #      |           |
  #      |     ?     |
  #      |  C  ?  D  |
  #      |     ?     |
  #      |           |
  #      +-----+-----+
  #          down?

References get_occupancy_safe().

Referenced by paint_cell_borders_to_canvas().

◆ get_occupancy_safe()

int table::get_occupancy_safe ( coord_t coord) const
private

◆ get_placement_at()

const table::cell_placement * table::get_placement_at ( coord_t coord) const

References m_occupancy, and m_placements.

◆ get_size()

const size_t & text_art::table::get_size ( ) const
inline

References m_size.

◆ maybe_set_cell_span()

◆ operator=()

table & text_art::table::operator= ( const table & )
delete

References table().

◆ paint_cell_borders_to_canvas()

void table::paint_cell_borders_to_canvas ( canvas & canvas,
canvas::coord_t offset,
const table_geometry & tg,
const theme & theme ) const
private
Paint the grid lines.

Consider painting
- a grid of cells,
- plus a right-hand border
- and a bottom border

Then we need to paint to the canvas like this:

#         PER-TABLE-COLUMN     R BORDER
#      +-------------------+   +-----+
#
#             TABLE CELL WIDTH (in canvas units)
#            +-------------+
#      .     .     . .     .   .     .
#   ...+-----+-----+.+-----+...+-----+ +
#      |  U  |     |.|     |   |  U  | |
#      |  U  |     |.|     |   |  U  | |
#      |LL+RR|RRRRR|.|RRRRR|   |LL+  | |
#      |  D  |     |.|     |   |  D  | |
#      |  D  |     |.|     |   |  D  | |
#   ...+-----+-----+.+-----+...+-----+ |
#      .....................   ......  +-- PER-TABLE-ROW
#   ...+-----+-----+.+-----+...+-----+ | +
#      |  D  |     |.|     |   |  D  | | |
#      |  D  |     |.|     |   |  D  | | |
#      |  D  |     |.|     |   |  D  | | +---- TABLE CELL HEIGHT (in canvas units)
#      |  D  |     |.|     |   |  D  | | |
#      |  D  |     |.|     |   |  D  | | |
#   ...+-----+-----+.+-----+...+-----+ + +
#      .     .     .     .   .     .
#   ...+-----+-----+.+-----+...+-----+  +
#      |  D  |     |.|     |   |  U  |  |
#      |  D  |     |.|     |   |  U  |  |
#      |LL+RR|RRRRR|.|RRRRR|   |LL+  |  | BOTTOM BORDER
#      |     |     |.|     |   |     |  |
#      |     |     |.|     |   |     |  |
#   ...+-----+-----+.+-----+...+-----+  +

where each:

#    +-----+
#    |     |
#    |     |
#    |     |
#    |     |
#    |     |
#    +-----+

is a canvas cell, and the U, L, R, D express the connections
that are present with neighboring table cells.  These affect
the kinds of borders that we draw for a particular table cell.   

References text_art::table_geometry::get_canvas_size(), text_art::table_geometry::get_col_width(), get_connections(), text_art::theme::get_line_art(), text_art::size< CoordinateSystem >::h, m_size, text_art::canvas::paint(), text_art::table_geometry::table_to_canvas(), text_art::table_geometry::table_x_to_canvas_x(), text_art::table_geometry::table_y_to_canvas_y(), and text_art::coord< CoordinateSystem >::x.

Referenced by paint_to_canvas().

◆ paint_cell_contents_to_canvas()

void table::paint_cell_contents_to_canvas ( canvas & canvas,
canvas::coord_t offset,
const table_geometry & tg ) const
private

References m_placements.

Referenced by paint_to_canvas().

◆ paint_to_canvas()

void table::paint_to_canvas ( canvas & canvas,
canvas::coord_t offset,
const table_geometry & tg,
const theme & theme ) const

◆ set_cell()

void table::set_cell ( coord_t coord,
table_cell_content && content,
enum x_align x_align = x_align::CENTER,
enum y_align y_align = y_align::CENTER )

References set_cell_span().

◆ set_cell_span()

◆ to_canvas()

◆ table_cell_sizes

friend class table_cell_sizes
friend

References table_cell_sizes.

Referenced by table_cell_sizes, and to_canvas().

Field Documentation

◆ m_occupancy

array2<int, size_t, coord_t> text_art::table::m_occupancy
private

◆ m_placements

◆ m_size

size_t text_art::table::m_size
private

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