Update git submodules
[LibreOffice.git] / include / formula / funcutl.hxx
bloba41f9c09a60a35f90f33bea873e166791a488554
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 <vcl/idle.hxx>
27 #include <vcl/weld.hxx>
29 class KeyEvent;
30 struct ImplSVEvent;
32 namespace formula {
34 class IControlReferenceHandler;
36 class FORMULA_DLLPUBLIC RefEdit
38 protected:
39 std::unique_ptr<weld::Entry> xEntry;
41 private:
42 Idle aIdle;
43 IControlReferenceHandler* pAnyRefDlg; // parent dialog
44 weld::Label* pLabelWidget;
45 ImplSVEvent* mpFocusInEvent;
46 ImplSVEvent* mpFocusOutEvent;
48 Link<RefEdit&,void> maGetFocusHdl;
49 Link<RefEdit&,void> maLoseFocusHdl;
50 Link<RefEdit&,void> maModifyHdl;
51 Link<weld::Widget&,bool> maActivateHdl;
53 DECL_DLLPRIVATE_LINK( UpdateHdl, Timer*, void );
55 DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool);
56 DECL_DLLPRIVATE_LINK(GetFocusHdl, weld::Widget&, void);
57 DECL_DLLPRIVATE_LINK(LoseFocusHdl, weld::Widget&, void);
58 DECL_DLLPRIVATE_LINK(AsyncFocusInHdl, void*, void);
59 DECL_DLLPRIVATE_LINK(AsyncFocusOutHdl, void*, void);
60 DECL_DLLPRIVATE_LINK(Modify, weld::Entry&, void);
62 void GetFocus();
63 void LoseFocus();
65 protected:
66 virtual bool KeyInput(const KeyEvent& rKEvt);
68 public:
69 RefEdit(std::unique_ptr<weld::Entry> xControl);
70 weld::Entry* GetWidget() const { return xEntry.get(); }
71 virtual ~RefEdit();
73 void SetRefString( const OUString& rStr );
75 /**
76 * Flag reference valid or invalid, which in turn changes the visual
77 * appearance of the control accordingly.
79 void SetRefValid(bool bValid);
81 void SetText(const OUString& rStr);
82 OUString GetText() const
84 return xEntry->get_text();
87 void StartUpdateData();
89 void SetReferences( IControlReferenceHandler* pDlg, weld::Label *pLabelWidget );
91 void DoModify()
93 Modify(*xEntry);
96 void GrabFocus()
98 xEntry->grab_focus();
101 void SelectAll()
103 xEntry->select_region(0, -1);
106 void SetSelection(const Selection& rSelection)
108 xEntry->select_region(rSelection.Min(), rSelection.Max());
111 void SetCursorAtLast()
113 xEntry->set_position(-1);
116 Selection GetSelection() const
118 int nStartPos, nEndPos;
119 xEntry->get_selection_bounds(nStartPos, nEndPos);
120 return Selection(nStartPos, nEndPos);
123 weld::Label* GetLabelWidgetForShrinkMode()
125 return pLabelWidget;
128 void SaveValue()
130 xEntry->save_value();
133 bool IsValueChangedFromSaved() const
135 return xEntry->get_value_changed_from_saved();
138 void SetGetFocusHdl(const Link<RefEdit&,void>& rLink) { maGetFocusHdl = rLink; }
139 void SetLoseFocusHdl(const Link<RefEdit&,void>& rLink) { maLoseFocusHdl = rLink; }
140 void SetModifyHdl(const Link<RefEdit&,void>& rLink) { maModifyHdl = rLink; }
141 const Link<RefEdit&,void>& GetModifyHdl() const { return maModifyHdl; }
142 void SetActivateHdl(const Link<weld::Widget&,bool>& rLink) { maActivateHdl = rLink; }
145 class FORMULA_DLLPUBLIC RefButton
147 private:
148 std::unique_ptr<weld::Button> xButton;
149 IControlReferenceHandler* pAnyRefDlg; // parent dialog
150 RefEdit* pRefEdit; // associated Edit-Control
151 Link<RefButton&,void> maGetFocusHdl;
152 Link<RefButton&,void> maLoseFocusHdl;
153 Link<weld::Widget&,bool> maActivateHdl;
154 Link<RefButton&,void> maClickHdl;
156 DECL_LINK(Click, weld::Button&, void);
157 DECL_DLLPRIVATE_LINK(KeyInput, const KeyEvent&, bool);
158 DECL_DLLPRIVATE_LINK(GetFocus, weld::Widget&, void);
159 DECL_DLLPRIVATE_LINK(LoseFocus, weld::Widget&, void);
161 public:
162 RefButton(std::unique_ptr<weld::Button> xControl);
163 weld::Button* GetWidget() const { return xButton.get(); }
164 ~RefButton();
165 void SetReferences(IControlReferenceHandler* pDlg, RefEdit* pEdit);
166 void SetStartImage();
167 void SetEndImage();
168 void DoRef()
170 Click(*xButton);
172 void SetGetFocusHdl(const Link<RefButton&,void>& rLink) { maGetFocusHdl = rLink; }
173 void SetLoseFocusHdl(const Link<RefButton&,void>& rLink) { maLoseFocusHdl = rLink; }
174 void SetActivateHdl(const Link<weld::Widget&,bool>& rLink) { maActivateHdl = rLink; }
175 void SetClickHdl(const Link<RefButton&,void>& rLink) { maClickHdl = rLink; }
178 } // formula
180 #endif // INCLUDED_FORMULA_FUNCUTL_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */