GCC Middle and Back End API Reference
|
#include <table.h>
Data Structures | |
class | cell_placement |
Public Types | |
typedef size< class table > | size_t |
typedef coord< class table > | coord_t |
typedef range< class table > | range_t |
typedef rect< class table > | rect_t |
Public Member Functions | |
table (size_t size) | |
~table ()=default | |
table (table &&)=default | |
table (const table &)=delete | |
table & | operator= (const table &)=delete |
const size_t & | get_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_placement * | get_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_placement > | m_placements |
array2< int, size_t, coord_t > | m_occupancy |
Friends | |
class | table_cell_sizes |
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.
typedef coord<class table> text_art::table::coord_t |
typedef range<class table> text_art::table::range_t |
typedef rect<class table> text_art::table::rect_t |
typedef size<class table> text_art::table::size_t |
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().
|
default |
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().
|
inline |
References add_rows().
|
inline |
References i, m_occupancy, and m_size.
Referenced by add_row().
DEBUG_FUNCTION void table::debug | ( | ) | const |
Print this table to stderr.
References text_art::canvas::debug(), and to_canvas().
|
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().
|
private |
References m_occupancy, m_size, text_art::coord< CoordinateSystem >::x, and text_art::coord< CoordinateSystem >::y.
Referenced by get_connections().
const table::cell_placement * table::get_placement_at | ( | coord_t | coord | ) | const |
References m_occupancy, and m_placements.
void table::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 ) |
If SPAN is unoccuped, set it to CONTENT. Otherwise, discard CONTENT.
References gcc_assert, text_art::rect< CoordinateSystem >::get_min_x(), text_art::rect< CoordinateSystem >::get_min_y(), text_art::rect< CoordinateSystem >::get_next_x(), text_art::rect< CoordinateSystem >::get_next_y(), text_art::size< CoordinateSystem >::h, m_occupancy, text_art::rect< CoordinateSystem >::m_size, set_cell_span(), text_art::size< CoordinateSystem >::w, and y.
|
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().
|
private |
References m_placements.
Referenced by paint_to_canvas().
void table::paint_to_canvas | ( | canvas & | canvas, |
canvas::coord_t | offset, | ||
const table_geometry & | tg, | ||
const theme & | theme ) const |
References text_art::canvas::fill(), text_art::table_geometry::get_canvas_size(), paint_cell_borders_to_canvas(), and paint_cell_contents_to_canvas().
Referenced by to_canvas().
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().
void table::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 ) |
References gcc_assert, text_art::rect< CoordinateSystem >::get_min_x(), text_art::rect< CoordinateSystem >::get_min_y(), text_art::rect< CoordinateSystem >::get_next_x(), text_art::rect< CoordinateSystem >::get_next_y(), text_art::size< CoordinateSystem >::h, m_occupancy, m_placements, text_art::rect< CoordinateSystem >::m_size, text_art::size< CoordinateSystem >::w, and y.
Referenced by add_other_table(), maybe_set_cell_span(), and set_cell().
canvas table::to_canvas | ( | const theme & | theme, |
const style_manager & | sm ) const |
References text_art::table_geometry::get_canvas_size(), m_size, paint_to_canvas(), text_art::table_cell_sizes::pass_1(), text_art::table_cell_sizes::pass_2(), and table_cell_sizes.
Referenced by debug().
|
friend |
References table_cell_sizes.
Referenced by table_cell_sizes, and to_canvas().
Referenced by add_rows(), get_occupancy_safe(), get_placement_at(), maybe_set_cell_span(), set_cell_span(), and table().
|
private |
|
private |
Referenced by add_rows(), get_occupancy_safe(), get_size(), paint_cell_borders_to_canvas(), table(), and to_canvas().