6 #include "css_length.h"
14 typedef std::vector
<table_row
> vector
;
19 std::shared_ptr
<render_item
> el_row
;
22 css_length css_height
;
37 table_row(int h
, const std::shared_ptr
<render_item
>& row
);
39 table_row(const table_row
& val
)
41 min_height
= val
.min_height
;
44 border_bottom
= val
.border_bottom
;
45 border_top
= val
.border_top
;
47 css_height
= val
.css_height
;
51 table_row(table_row
&& val
) noexcept
53 min_height
= val
.min_height
;
56 border_bottom
= val
.border_bottom
;
57 border_top
= val
.border_top
;
59 css_height
= val
.css_height
;
60 el_row
= std::move(val
.el_row
);
66 typedef std::vector
<table_column
> vector
;
89 table_column(int min_w
, int max_w
)
101 table_column(const table_column
& val
)
105 border_left
= val
.border_left
;
106 border_right
= val
.border_right
;
107 max_width
= val
.max_width
;
108 min_width
= val
.min_width
;
110 css_width
= val
.css_width
;
114 class table_column_accessor
117 virtual int& get(table_column
& col
) = 0;
120 ~table_column_accessor() = default;
123 class table_column_accessor_max_width final
: public table_column_accessor
126 int& get(table_column
& col
) override
;
129 class table_column_accessor_min_width final
: public table_column_accessor
132 int& get(table_column
& col
) override
;
135 class table_column_accessor_width final
: public table_column_accessor
138 int& get(table_column
& col
) override
;
143 std::shared_ptr
<render_item
> el
;
167 table_cell(const table_cell
& val
)
170 colspan
= val
.colspan
;
171 rowspan
= val
.rowspan
;
174 min_width
= val
.min_width
;
175 min_height
= val
.min_height
;
176 max_width
= val
.max_width
;
177 max_height
= val
.max_height
;
178 borders
= val
.borders
;
181 table_cell(table_cell
&& val
) noexcept
183 el
= std::move(val
.el
);
184 colspan
= val
.colspan
;
185 rowspan
= val
.rowspan
;
188 min_width
= val
.min_width
;
189 min_height
= val
.min_height
;
190 max_width
= val
.max_width
;
191 max_height
= val
.max_height
;
192 borders
= val
.borders
;
199 typedef std::vector
< std::vector
<table_cell
> > rows
;
204 table_column::vector m_columns
;
205 table_row::vector m_rows
;
206 std::vector
<std::shared_ptr
<render_item
>> m_captions
;
207 int m_top_captions_height
;
208 int m_bottom_captions_height
;
214 m_top_captions_height(0),
215 m_bottom_captions_height(0)
220 void begin_row(const std::shared_ptr
<render_item
>& row
);
221 void add_cell(const std::shared_ptr
<render_item
>& el
);
222 bool is_rowspanned(int r
, int c
);
224 table_cell
* cell(int t_col
, int t_row
);
225 table_column
& column(int c
) { return m_columns
[c
]; }
226 table_row
& row(int r
) { return m_rows
[r
]; }
227 std::vector
<std::shared_ptr
<render_item
>>& captions() { return m_captions
; }
229 int rows_count() const { return m_rows_count
; }
230 int cols_count() const { return m_cols_count
; }
232 void top_captions_height(int height
) { m_top_captions_height
= height
; }
233 int top_captions_height() const { return m_top_captions_height
; }
234 void bottom_captions_height(int height
) { m_bottom_captions_height
= height
; }
235 int bottom_captions_height() const { return m_bottom_captions_height
; }
237 void distribute_max_width(int width
, int start
, int end
);
238 void distribute_min_width(int width
, int start
, int end
);
239 void distribute_width(int width
, int start
, int end
);
240 void distribute_width(int width
, int start
, int end
, table_column_accessor
* acc
);
241 int calc_table_width(int block_width
, bool is_auto
, int& min_table_width
, int& max_table_width
);
242 void calc_horizontal_positions(const margins
& table_borders
, border_collapse bc
, int bdr_space_x
);
243 void calc_vertical_positions(const margins
& table_borders
, border_collapse bc
, int bdr_space_y
);
244 void calc_rows_height(int blockHeight
, int borderSpacingY
);