fltk_builder/extensions/builder/
table.rs

1use fltk::{
2    enums::{Color, FrameType},
3    prelude::TableExt,
4};
5/// Adds builder pattern friendly versions of several setter functions
6pub trait TableBuilderExt {
7    /// Sets the table frame
8    fn with_table_frame(self, frame: FrameType) -> Self;
9    /// Sets the number of rows
10    fn with_rows(self, val: i32) -> Self;
11    /// Sets the number of columns
12    fn with_cols(self, val: i32) -> Self;
13    /// Sets a row to be resizable
14    fn with_row_resize(self, flag: bool) -> Self;
15    /// Sets a column to be resizable
16    fn with_col_resize(self, flag: bool) -> Self;
17    /// Sets the current column minimum resize value.
18    fn with_col_resize_min(self, val: i32) -> Self;
19    /// Sets the current row minimum resize value.
20    fn with_row_resize_min(self, val: i32) -> Self;
21    /// Sets whether a row headers are enabled or not
22    fn with_row_header(self, flag: bool) -> Self;
23    /// Sets whether a column headers are enabled or not
24    fn with_col_header(self, flag: bool) -> Self;
25    /// Sets the column header height
26    fn with_col_header_height(self, height: i32) -> Self;
27    /// Sets the row header width
28    fn with_row_header_width(self, width: i32) -> Self;
29    /// Sets the row header color
30    fn with_row_header_color(self, val: Color) -> Self;
31    /// Sets the column header color
32    fn with_col_header_color(self, val: Color) -> Self;
33    /// Sets the row's height
34    fn with_row_height(self, row: i32, height: i32) -> Self;
35    /// Sets the column's width
36    fn with_col_width(self, col: i32, width: i32) -> Self;
37    /// Sets all rows height
38    fn with_row_height_all(self, height: i32) -> Self;
39    /// Sets all column's width
40    fn with_col_width_all(self, width: i32) -> Self;
41    /// Sets the row's position
42    fn with_row_position(self, row: i32) -> Self;
43    /// Sets the column's position
44    fn with_col_position(self, col: i32) -> Self;
45    /// Sets the top row
46    fn with_top_row(self, row: i32) -> Self;
47    /// Sets the scrollbar size
48    fn with_scrollbar_size(self, new_size: i32) -> Self;
49    /// Sets whether tab key cell navigation is enabled
50    fn with_tab_cell_nav(self, val: bool) -> Self;
51}
52
53impl<T> TableBuilderExt for T
54where
55    T: TableExt,
56{
57    fn with_table_frame(mut self, frame: FrameType) -> Self {
58        self.set_table_frame(frame);
59        self
60    }
61
62    fn with_rows(mut self, val: i32) -> Self {
63        self.set_rows(val);
64        self
65    }
66
67    fn with_cols(mut self, val: i32) -> Self {
68        self.set_cols(val);
69        self
70    }
71
72    fn with_row_resize(mut self, flag: bool) -> Self {
73        self.set_row_resize(flag);
74        self
75    }
76
77    fn with_col_resize(mut self, flag: bool) -> Self {
78        self.set_col_resize(flag);
79        self
80    }
81
82    fn with_col_resize_min(mut self, val: i32) -> Self {
83        self.set_col_resize_min(val);
84        self
85    }
86
87    fn with_row_resize_min(mut self, val: i32) -> Self {
88        self.set_row_resize_min(val);
89        self
90    }
91
92    fn with_row_header(mut self, flag: bool) -> Self {
93        self.set_row_header(flag);
94        self
95    }
96
97    fn with_col_header(mut self, flag: bool) -> Self {
98        self.set_col_header(flag);
99        self
100    }
101
102    fn with_col_header_height(mut self, height: i32) -> Self {
103        self.set_col_header_height(height);
104        self
105    }
106
107    fn with_row_header_width(mut self, width: i32) -> Self {
108        self.set_row_header_width(width);
109        self
110    }
111
112    fn with_row_header_color(mut self, val: Color) -> Self {
113        self.set_row_header_color(val);
114        self
115    }
116
117    fn with_col_header_color(mut self, val: Color) -> Self {
118        self.set_col_header_color(val);
119        self
120    }
121
122    fn with_row_height(mut self, row: i32, height: i32) -> Self {
123        self.set_row_height(row, height);
124        self
125    }
126
127    fn with_col_width(mut self, col: i32, width: i32) -> Self {
128        self.set_col_width(col, width);
129        self
130    }
131
132    fn with_row_height_all(mut self, height: i32) -> Self {
133        self.set_row_height_all(height);
134        self
135    }
136
137    fn with_col_width_all(mut self, width: i32) -> Self {
138        self.set_col_width_all(width);
139        self
140    }
141
142    fn with_row_position(mut self, row: i32) -> Self {
143        self.set_row_position(row);
144        self
145    }
146
147    fn with_col_position(mut self, col: i32) -> Self {
148        self.set_col_position(col);
149        self
150    }
151
152    fn with_top_row(mut self, row: i32) -> Self {
153        self.set_top_row(row);
154        self
155    }
156
157    fn with_scrollbar_size(mut self, new_size: i32) -> Self {
158        self.set_scrollbar_size(new_size);
159        self
160    }
161
162    fn with_tab_cell_nav(mut self, val: bool) -> Self {
163        self.set_tab_cell_nav(val);
164        self
165    }
166}