bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / formula / funcutl.hxx
blob7686181b40f28a6dd697f782734b7964ce12018c
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FORMULA_FUNCUTL_HXX
21 #define INCLUDED_FORMULA_FUNCUTL_HXX
23 #include <formula/formuladllapi.h>
24 #include <rtl/ustring.hxx>
25 #include <tools/link.hxx>
26 #include <tools/wintypes.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/edit.hxx>
29 #include <vcl/idle.hxx>
30 #include <vcl/image.hxx>
31 #include <vcl/weld.hxx>
32 #include <vcl/vclptr.hxx>
34 class KeyEvent;
36 namespace formula {
38 class IControlReferenceHandler;
40 class FORMULA_DLLPUBLIC RefEdit
42 protected:
43 std::unique_ptr<weld::Entry> xEntry;
45 private:
46 Idle aIdle;
47 IControlReferenceHandler* pAnyRefDlg; // parent dialog
48 weld::Label* pLabelWidget;
49 Link<RefEdit&,void> maGetFocusHdl;
50 Link<RefEdit&,void> maLoseFocusHdl;
51 Link<RefEdit&,void> maModifyHdl;
52 Link<weld::Widget&,bool> maActivateHdl;
54 DECL_LINK( UpdateHdl, Timer*, void );
56 protected:
57 DECL_LINK(KeyInput, const KeyEvent&, bool);
58 DECL_LINK(GetFocus, weld::Widget&, void);
59 DECL_LINK(LoseFocus, weld::Widget&, void);
60 DECL_LINK(Modify, weld::Entry&, void);
62 public:
63 RefEdit(std::unique_ptr<weld::Entry> xControl);
64 weld::Entry* GetWidget() const { return xEntry.get(); }
65 ~RefEdit();
67 void SetRefString( const OUString& rStr );
69 /**
70 * Flag reference valid or invalid, which in turn changes the visual
71 * appearance of the control accordingly.
73 void SetRefValid(bool bValid);
75 void SetText(const OUString& rStr);
76 OUString GetText() const
78 return xEntry->get_text();
81 void StartUpdateData();
83 void SetReferences( IControlReferenceHandler* pDlg, weld::Label *pLabelWidget );
85 void DoModify()
87 Modify(*xEntry);
90 void GrabFocus()
92 xEntry->grab_focus();
95 void SelectAll()
97 xEntry->select_region(0, -1);
100 void SetSelection(const Selection& rSelection)
102 xEntry->select_region(rSelection.Min(), rSelection.Max());
105 void SetCursorAtLast()
107 xEntry->set_position(-1);
110 Selection GetSelection() const
112 int nStartPos, nEndPos;
113 xEntry->get_selection_bounds(nStartPos, nEndPos);
114 return Selection(nStartPos, nEndPos);
117 weld::Label* GetLabelWidgetForShrinkMode()
119 return pLabelWidget;
122 void SaveValue()
124 xEntry->save_value();
127 bool IsValueChangedFromSaved() const
129 return xEntry->get_value_changed_from_saved();
132 void SetGetFocusHdl(const Link<RefEdit&,void>& rLink) { maGetFocusHdl = rLink; }
133 void SetLoseFocusHdl(const Link<RefEdit&,void>& rLink) { maLoseFocusHdl = rLink; }
134 void SetModifyHdl(const Link<RefEdit&,void>& rLink) { maModifyHdl = rLink; }
135 const Link<RefEdit&,void>& GetModifyHdl() const { return maModifyHdl; }
136 void SetActivateHdl(const Link<weld::Widget&,bool>& rLink) { maActivateHdl = rLink; }
139 class FORMULA_DLLPUBLIC RefButton
141 private:
142 std::unique_ptr<weld::Button> xButton;
143 IControlReferenceHandler* pAnyRefDlg; // parent dialog
144 RefEdit* pRefEdit; // associated Edit-Control
145 Link<RefButton&,void> maGetFocusHdl;
146 Link<RefButton&,void> maLoseFocusHdl;
147 Link<weld::Widget&,bool> maActivateHdl;
148 Link<RefButton&,void> maClickHdl;
150 protected:
151 DECL_LINK(Click, weld::Button&, void);
152 DECL_LINK(KeyInput, const KeyEvent&, bool);
153 DECL_LINK(GetFocus, weld::Widget&, void);
154 DECL_LINK(LoseFocus, weld::Widget&, void);
156 public:
157 RefButton(std::unique_ptr<weld::Button> xControl);
158 weld::Button* GetWidget() const { return xButton.get(); }
159 ~RefButton();
160 void SetReferences(IControlReferenceHandler* pDlg, RefEdit* pEdit);
161 void SetStartImage();
162 void SetEndImage();
163 void DoRef()
165 Click(*xButton);
167 void SetGetFocusHdl(const Link<RefButton&,void>& rLink) { maGetFocusHdl = rLink; }
168 void SetLoseFocusHdl(const Link<RefButton&,void>& rLink) { maLoseFocusHdl = rLink; }
169 void SetActivateHdl(const Link<weld::Widget&,bool>& rLink) { maActivateHdl = rLink; }
170 void SetClickHdl(const Link<RefButton&,void>& rLink) { maClickHdl = rLink; }
173 } // formula
175 #endif // INCLUDED_FORMULA_FUNCUTL_HXX
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */