1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
34 class IControlReferenceHandler
;
36 class FORMULA_DLLPUBLIC RefEdit
39 std::unique_ptr
<weld::Entry
> xEntry
;
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);
66 virtual bool KeyInput(const KeyEvent
& rKEvt
);
69 RefEdit(std::unique_ptr
<weld::Entry
> xControl
);
70 weld::Entry
* GetWidget() const { return xEntry
.get(); }
73 void SetRefString( const OUString
& rStr
);
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
);
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()
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
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);
162 RefButton(std::unique_ptr
<weld::Button
> xControl
);
163 weld::Button
* GetWidget() const { return xButton
.get(); }
165 void SetReferences(IControlReferenceHandler
* pDlg
, RefEdit
* pEdit
);
166 void SetStartImage();
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
; }
180 #endif // INCLUDED_FORMULA_FUNCUTL_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */