tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / condformatdlgentry.hxx
blob33b218b181e6719dff737c3c7f7419ee64fe909a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include <conditio.hxx>
13 #include <formula/funcutl.hxx>
14 #include <vcl/weld.hxx>
15 #include <svl/lstner.hxx>
16 #include <svx/fntctrl.hxx>
18 class ScIconSetFrmtDataEntry;
19 class ScCondFormatDlg;
20 class ScCondFormatList;
21 class ColorListBox;
22 class ScColorScaleFormat;
23 class ScDataBarFormat;
24 class ScIconSetFormat;
25 struct ScDataBarFormatData;
27 namespace condformat::entry {
29 enum ScCondFrmtEntryType
31 CONDITION,
32 FORMULA,
33 COLORSCALE2,
34 COLORSCALE3,
35 DATABAR,
36 ICONSET,
37 DATE
42 class ScCondFrmtEntry
44 protected:
45 ScCondFormatList* mpParent;
46 std::unique_ptr<weld::Builder> mxBuilder;
48 private:
49 //general ui elements
50 std::unique_ptr<weld::Widget> mxBorder;
51 std::unique_ptr<weld::Container> mxGrid;
52 std::unique_ptr<weld::Label> mxFtCondNr;
53 std::unique_ptr<weld::Label> mxFtCondition;
55 bool mbActive;
56 OUString const maStrCondition;
57 Link<ScCondFrmtEntry&,void> maClickHdl;
59 DECL_LINK( EntrySelectHdl, const MouseEvent&, bool );
61 protected:
62 std::unique_ptr<weld::ComboBox> mxLbType;
64 ScDocument& mrDoc;
65 ScAddress maPos;
67 virtual void Select();
68 virtual void Deselect();
70 virtual OUString GetExpressionString() = 0;
72 public:
73 ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, const ScAddress& rPos);
74 virtual ~ScCondFrmtEntry();
76 void Show() { mxGrid->show(); }
78 void set_grid_top_attach(int nAttach) { mxBorder->set_grid_top_attach(nAttach); }
79 int get_preferred_height() const { return mxBorder->get_preferred_size().Height(); }
81 void SetPos(const ScAddress& rPos) { maPos = rPos; };
82 bool IsSelected() const { return mbActive;}
83 void SetIndex(sal_Int32 nIndex);
85 virtual ScFormatEntry* GetEntry() const = 0;
86 virtual void SetActive() = 0;
87 virtual void SetInactive() = 0;
89 virtual condformat::entry::ScCondFrmtEntryType GetType() = 0;
92 class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener
94 //cond format ui elements
95 SvxFontPrevWindow maWdPreview;
96 std::unique_ptr<weld::ComboBox> mxLbCondType;
97 std::unique_ptr<formula::RefEdit> mxEdVal1;
98 std::unique_ptr<formula::RefEdit> mxEdVal2;
99 std::unique_ptr<weld::Label> mxFtVal;
100 std::unique_ptr<weld::Label> mxFtStyle;
101 std::unique_ptr<weld::ComboBox> mxLbStyle;
102 std::unique_ptr<weld::Widget> mxWdPreviewWin;
103 std::unique_ptr<weld::CustomWeld> mxWdPreview;
104 bool mbIsInStyleCreate;
106 static const sal_Int32 NUM_COND_ENTRIES = 24;
107 // Lookup table from positions in maLbCondType to the condition mode enum
108 static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES];
110 ScFormatEntry* createConditionEntry() const;
112 virtual OUString GetExpressionString() override;
113 void Init(ScCondFormatDlg* pDialogParent);
114 DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
115 DECL_LINK( ConditionTypeSelectHdl, weld::ComboBox&, void );
116 DECL_LINK( OnEdChanged, formula::RefEdit&, void );
118 // Searches the lookup table for the entry position, given condition mode
119 static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode );
120 // Accesses the lookup table for the condition mode, given entry position
121 static ScConditionMode EntryPosToConditionMode( sal_Int32 aEntryPos );
122 // Returns the number of edit fields used for a given condition mode
123 static sal_Int32 GetNumberEditFields( ScConditionMode eMode );
125 protected:
126 virtual void Select() override;
127 virtual void Deselect() override;
129 public:
130 ScConditionFrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, ScCondFormatDlg* pDialogParent,
131 const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
132 virtual ~ScConditionFrmtEntry() override;
134 virtual ScFormatEntry* GetEntry() const override;
135 virtual void SetActive() override;
136 virtual void SetInactive() override;
138 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
140 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::CONDITION; }
143 class ScFormulaFrmtEntry : public ScCondFrmtEntry
145 SvxFontPrevWindow maWdPreview;
146 std::unique_ptr<weld::Label> mxFtStyle;
147 std::unique_ptr<weld::ComboBox> mxLbStyle;
148 std::unique_ptr<weld::Widget> mxWdPreviewWin;
149 std::unique_ptr<weld::CustomWeld> mxWdPreview;
150 std::unique_ptr<formula::RefEdit> mxEdFormula;
152 ScFormatEntry* createFormulaEntry() const;
153 virtual OUString GetExpressionString() override;
154 void Init(ScCondFormatDlg* pDialogParent);
156 DECL_LINK(StyleSelectHdl, weld::ComboBox&, void);
158 public:
159 ScFormulaFrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
160 virtual ~ScFormulaFrmtEntry() override;
162 virtual ScFormatEntry* GetEntry() const override;
163 virtual void SetActive() override;
164 virtual void SetInactive() override;
165 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::FORMULA; }
168 class ScColorScale2FrmtEntry : public ScCondFrmtEntry
171 //color format ui elements
172 std::unique_ptr<weld::ComboBox> mxLbColorFormat;
174 //color scale ui elements
175 std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
176 std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;
178 std::unique_ptr<weld::Entry> mxEdMin;
179 std::unique_ptr<weld::Entry> mxEdMax;
181 std::unique_ptr<ColorListBox> mxLbColMin;
182 std::unique_ptr<ColorListBox> mxLbColMax;
184 std::unique_ptr<weld::Label> mxFtMin;
185 std::unique_ptr<weld::Label> mxFtMax;
187 ScFormatEntry* createColorscaleEntry() const;
189 virtual OUString GetExpressionString() override;
190 void Init();
192 DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
193 public:
194 ScColorScale2FrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
195 virtual ~ScColorScale2FrmtEntry() override;
196 virtual ScFormatEntry* GetEntry() const override;
197 virtual void SetActive() override;
198 virtual void SetInactive() override;
199 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE2; }
202 class ScColorScale3FrmtEntry : public ScCondFrmtEntry
205 //color format ui elements
206 std::unique_ptr<weld::ComboBox> mxLbColorFormat;
208 //color scale ui elements
209 std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
210 std::unique_ptr<weld::ComboBox> mxLbEntryTypeMiddle;
211 std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;
213 std::unique_ptr<weld::Entry> mxEdMin;
214 std::unique_ptr<weld::Entry> mxEdMiddle;
215 std::unique_ptr<weld::Entry> mxEdMax;
217 std::unique_ptr<ColorListBox> mxLbColMin;
218 std::unique_ptr<ColorListBox> mxLbColMiddle;
219 std::unique_ptr<ColorListBox> mxLbColMax;
221 std::unique_ptr<weld::Label> mxFtMin;
222 std::unique_ptr<weld::Label> mxFtMax;
224 ScFormatEntry* createColorscaleEntry() const;
226 virtual OUString GetExpressionString() override;
227 void Init();
229 DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
230 public:
231 ScColorScale3FrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
232 virtual ~ScColorScale3FrmtEntry() override;
233 virtual ScFormatEntry* GetEntry() const override;
234 virtual void SetActive() override;
235 virtual void SetInactive() override;
236 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE3; }
239 class ScDataBarFrmtEntry : public ScCondFrmtEntry
241 //color format ui elements
242 std::unique_ptr<weld::ComboBox> mxLbColorFormat;
244 //data bar ui elements
245 std::unique_ptr<weld::ComboBox> mxLbDataBarMinType;
246 std::unique_ptr<weld::ComboBox> mxLbDataBarMaxType;
247 std::unique_ptr<weld::Entry> mxEdDataBarMin;
248 std::unique_ptr<weld::Entry> mxEdDataBarMax;
249 std::unique_ptr<weld::Button> mxBtOptions;
251 std::unique_ptr<weld::Label> mxFtMin;
252 std::unique_ptr<weld::Label> mxFtMax;
254 std::unique_ptr<ScDataBarFormatData> mpDataBarData;
256 ScFormatEntry* createDatabarEntry() const;
258 virtual OUString GetExpressionString() override;
259 void Init();
261 DECL_LINK( OptionBtnHdl, weld::Button&, void );
262 DECL_LINK( DataBarTypeSelectHdl, weld::ComboBox&, void );
263 public:
264 ScDataBarFrmtEntry(ScCondFormatList* pParemt, ScDocument& rDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr);
265 virtual ~ScDataBarFrmtEntry() override;
266 virtual ScFormatEntry* GetEntry() const override;
267 virtual void SetActive() override;
268 virtual void SetInactive() override;
270 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATABAR; }
273 class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener
275 public:
276 ScDateFrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, const ScCondDateFormatEntry* pFormat = nullptr);
277 virtual ~ScDateFrmtEntry() override;
278 virtual ScFormatEntry* GetEntry() const override;
279 virtual void SetActive() override;
280 virtual void SetInactive() override;
281 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATE; }
283 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
285 protected:
286 virtual OUString GetExpressionString() override;
288 private:
289 void Init();
291 DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
293 SvxFontPrevWindow maWdPreview;
294 std::unique_ptr<weld::ComboBox> mxLbDateEntry;
295 std::unique_ptr<weld::Label> mxFtStyle;
296 std::unique_ptr<weld::ComboBox> mxLbStyle;
297 std::unique_ptr<weld::Widget> mxWdPreviewWin;
298 std::unique_ptr<weld::CustomWeld> mxWdPreview;
300 bool mbIsInStyleCreate;
303 class ScIconSetFrmtEntry : public ScCondFrmtEntry
305 //color format ui elements
306 std::unique_ptr<weld::ComboBox> mxLbColorFormat;
308 // icon set ui elements
309 std::unique_ptr<weld::ComboBox> mxLbIconSetType;
311 std::unique_ptr<weld::Container> mxIconParent;
313 typedef std::vector<std::unique_ptr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType;
314 ScIconSetFrmtDataEntriesType maEntries;
316 virtual OUString GetExpressionString() override;
318 void Init();
320 DECL_LINK(IconSetTypeHdl, weld::ComboBox&, void);
322 public:
323 ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument& rDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr);
324 virtual ~ScIconSetFrmtEntry() override;
325 virtual ScFormatEntry* GetEntry() const override;
326 virtual void SetActive() override;
327 virtual void SetInactive() override;
328 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::ICONSET; }
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */