|
| 1 | +use rust_xlsxwriter as xlsx; |
| 2 | +use wasm_bindgen::prelude::*; |
| 3 | + |
| 4 | +use crate::wrapper::color::Color; |
| 5 | + |
| 6 | +/// The `ChartFont` struct represents a chart font. |
| 7 | +/// |
| 8 | +/// The `ChartFont` struct is used to define the font properties for chart elements |
| 9 | +/// such as chart titles, axis labels, data labels and other text elements in a chart. |
| 10 | +/// |
| 11 | +/// It is used in conjunction with the {@link Chart} struct. |
| 12 | +#[wasm_bindgen] |
| 13 | +pub struct ChartFont { |
| 14 | + pub(crate) inner: xlsx::ChartFont, |
| 15 | +} |
| 16 | + |
| 17 | +#[wasm_bindgen] |
| 18 | +impl ChartFont { |
| 19 | + /// Create a new `ChartFont` object. |
| 20 | + #[wasm_bindgen(constructor)] |
| 21 | + pub fn new() -> ChartFont { |
| 22 | + ChartFont { |
| 23 | + inner: xlsx::ChartFont::new(), |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + /// Set the font bold property. |
| 28 | + /// |
| 29 | + /// @return {ChartFont} - The ChartFont instance. |
| 30 | + #[wasm_bindgen(js_name = "setBold")] |
| 31 | + pub fn set_bold(mut self) -> ChartFont { |
| 32 | + self.inner.set_bold(); |
| 33 | + self |
| 34 | + } |
| 35 | + |
| 36 | + /// Set the font character set value. |
| 37 | + /// |
| 38 | + /// Set the font character set value using the standard Windows values. |
| 39 | + /// This is generally only required when using non-standard fonts. |
| 40 | + /// |
| 41 | + /// @param {number} charset - The font character set value. |
| 42 | + /// @return {ChartFont} - The ChartFont instance. |
| 43 | + #[wasm_bindgen(js_name = "setCharacterSet")] |
| 44 | + pub fn set_character_set(mut self, character_set: u8) -> ChartFont { |
| 45 | + self.inner.set_character_set(character_set); |
| 46 | + self |
| 47 | + } |
| 48 | + |
| 49 | + /// Set the font color property. |
| 50 | + /// |
| 51 | + /// @param {Color} color - The font color property. |
| 52 | + /// @return {ChartFont} - The ChartFont instance. |
| 53 | + #[wasm_bindgen(js_name = "setColor")] |
| 54 | + pub fn set_color(mut self, color: &Color) -> ChartFont { |
| 55 | + self.inner.set_color(color.inner); |
| 56 | + self |
| 57 | + } |
| 58 | + |
| 59 | + /// Set the font italic property. |
| 60 | + /// |
| 61 | + /// @return {ChartFont} - The ChartFont instance. |
| 62 | + #[wasm_bindgen(js_name = "setItalic")] |
| 63 | + pub fn set_italic(mut self) -> ChartFont { |
| 64 | + self.inner.set_italic(); |
| 65 | + self |
| 66 | + } |
| 67 | + |
| 68 | + /// Set the font name/family property. |
| 69 | + /// |
| 70 | + /// Set the font name for the chart element. Excel can only display fonts that |
| 71 | + /// are installed on the system that it is running on. Therefore it is generally |
| 72 | + /// best to use standard Excel fonts. |
| 73 | + /// |
| 74 | + /// @param {string} name - The font name property. |
| 75 | + /// @return {ChartFont} - The ChartFont instance. |
| 76 | + #[wasm_bindgen(js_name = "setName")] |
| 77 | + pub fn set_name(mut self, name: &str) -> ChartFont { |
| 78 | + self.inner.set_name(name); |
| 79 | + self |
| 80 | + } |
| 81 | + |
| 82 | + /// Set the font pitch and family value. |
| 83 | + /// |
| 84 | + /// Set the font pitch and family value using the standard Windows values. |
| 85 | + /// This is generally only required when using non-standard fonts. |
| 86 | + /// |
| 87 | + /// @param {number} pitch_family - The font pitch and family value. |
| 88 | + /// @return {ChartFont} - The ChartFont instance. |
| 89 | + #[wasm_bindgen(js_name = "setPitchFamily")] |
| 90 | + pub fn set_pitch_family(mut self, pitch_family: u8) -> ChartFont { |
| 91 | + self.inner.set_pitch_family(pitch_family); |
| 92 | + self |
| 93 | + } |
| 94 | + |
| 95 | + /// Set the right to left property. |
| 96 | + /// |
| 97 | + /// Set the right to left property. This is generally only required when using |
| 98 | + /// non-standard fonts. |
| 99 | + /// |
| 100 | + /// @param {boolean} enable - Turn the property on/off. Defaults to true. |
| 101 | + /// @return {ChartFont} - The ChartFont instance. |
| 102 | + #[wasm_bindgen(js_name = "setRightToLeft")] |
| 103 | + pub fn set_right_to_left(mut self, enable: bool) -> ChartFont { |
| 104 | + self.inner.set_right_to_left(enable); |
| 105 | + self |
| 106 | + } |
| 107 | + |
| 108 | + /// Set the font rotation angle. |
| 109 | + /// |
| 110 | + /// Set the rotation angle of the font text in the range -90 to 90 degrees. |
| 111 | + /// |
| 112 | + /// @param {number} rotation - The rotation angle in degrees. |
| 113 | + /// @return {ChartFont} - The ChartFont instance. |
| 114 | + #[wasm_bindgen(js_name = "setRotation")] |
| 115 | + pub fn set_rotation(mut self, rotation: i16) -> ChartFont { |
| 116 | + self.inner.set_rotation(rotation); |
| 117 | + self |
| 118 | + } |
| 119 | + |
| 120 | + /// Set the font size property. |
| 121 | + /// |
| 122 | + /// Set the font size for the chart element. |
| 123 | + /// |
| 124 | + /// @param {number} size - The font size property. |
| 125 | + /// @return {ChartFont} - The ChartFont instance. |
| 126 | + #[wasm_bindgen(js_name = "setSize")] |
| 127 | + pub fn set_size(mut self, size: f64) -> ChartFont { |
| 128 | + self.inner.set_size(size); |
| 129 | + self |
| 130 | + } |
| 131 | + |
| 132 | + /// Set the font strikethrough property. |
| 133 | + /// |
| 134 | + /// Set the strikethrough property. This is generally only required when using |
| 135 | + /// non-standard fonts. |
| 136 | + /// |
| 137 | + /// @return {ChartFont} - The ChartFont instance. |
| 138 | + #[wasm_bindgen(js_name = "setStrikethrough")] |
| 139 | + pub fn set_strikethrough(mut self) -> ChartFont { |
| 140 | + self.inner.set_strikethrough(); |
| 141 | + self |
| 142 | + } |
| 143 | + |
| 144 | + /// Set the font underline property. |
| 145 | + /// |
| 146 | + /// Set the font underline. This is generally only required when using |
| 147 | + /// non-standard fonts. |
| 148 | + /// |
| 149 | + /// @param {number} underline - The font underline value. |
| 150 | + /// @return {ChartFont} - The ChartFont instance. |
| 151 | + #[wasm_bindgen(js_name = "setUnderline")] |
| 152 | + pub fn set_underline(mut self) -> ChartFont { |
| 153 | + self.inner.set_underline(); |
| 154 | + self |
| 155 | + } |
| 156 | + |
| 157 | + /// Unset bold property. |
| 158 | + /// |
| 159 | + /// Unset the bold property. This is generally only required when using |
| 160 | + /// non-standard fonts. |
| 161 | + /// |
| 162 | + /// @return {ChartFont} - The ChartFont instance. |
| 163 | + #[wasm_bindgen(js_name = "unsetBold")] |
| 164 | + pub fn unset_bold(mut self) -> ChartFont { |
| 165 | + self.inner.unset_bold(); |
| 166 | + self |
| 167 | + } |
| 168 | +} |
0 commit comments