LibreOffice Module formula (master) 1
funcutl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_FORMULA_FUNCUTL_HXX
21#define INCLUDED_FORMULA_FUNCUTL_HXX
22
24#include <rtl/ustring.hxx>
25#include <tools/link.hxx>
26#include <vcl/idle.hxx>
27#include <vcl/weld.hxx>
28
29class KeyEvent;
30struct ImplSVEvent;
31
32namespace formula {
33
34class IControlReferenceHandler;
35
37{
38protected:
39 std::unique_ptr<weld::Entry> xEntry;
40
41private:
47
52
53 DECL_DLLPRIVATE_LINK( UpdateHdl, Timer*, void );
54
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);
61
62 void GetFocus();
63 void LoseFocus();
64
65protected:
66 virtual bool KeyInput(const KeyEvent& rKEvt);
67
68public:
69 RefEdit(std::unique_ptr<weld::Entry> xControl);
70 weld::Entry* GetWidget() const { return xEntry.get(); }
71 virtual ~RefEdit();
72
73 void SetRefString( const OUString& rStr );
74
79 void SetRefValid(bool bValid);
80
81 void SetText(const OUString& rStr);
82 OUString GetText() const
83 {
84 return xEntry->get_text();
85 }
86
87 void StartUpdateData();
88
89 void SetReferences( IControlReferenceHandler* pDlg, weld::Label *pLabelWidget );
90
91 void DoModify()
92 {
93 Modify(*xEntry);
94 }
95
96 void GrabFocus()
97 {
98 xEntry->grab_focus();
99 }
100
102 {
103 xEntry->select_region(0, -1);
104 }
105
106 void SetSelection(const Selection& rSelection)
107 {
108 xEntry->select_region(rSelection.Min(), rSelection.Max());
109 }
110
112 {
113 xEntry->set_position(-1);
114 }
115
117 {
118 int nStartPos, nEndPos;
119 xEntry->get_selection_bounds(nStartPos, nEndPos);
120 return Selection(nStartPos, nEndPos);
121 }
122
124 {
125 return pLabelWidget;
126 }
127
129 {
130 xEntry->save_value();
131 }
132
134 {
135 return xEntry->get_value_changed_from_saved();
136 }
137
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; }
142 void SetActivateHdl(const Link<weld::Widget&,bool>& rLink) { maActivateHdl = rLink; }
143};
144
146{
147private:
148 std::unique_ptr<weld::Button> xButton;
150 RefEdit* pRefEdit; // associated Edit-Control
155
156 DECL_LINK(Click, weld::Button&, void);
157 DECL_DLLPRIVATE_LINK(KeyInput, const KeyEvent&, bool);
160
161public:
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()
169 {
170 Click(*xButton);
171 }
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; }
176};
177
178} // formula
179
180#endif // INCLUDED_FORMULA_FUNCUTL_HXX
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long Min() const
tools::Long Max() const
Link< RefButton &, void > maLoseFocusHdl
Definition: funcutl.hxx:152
void SetClickHdl(const Link< RefButton &, void > &rLink)
Definition: funcutl.hxx:175
std::unique_ptr< weld::Button > xButton
Definition: funcutl.hxx:148
DECL_DLLPRIVATE_LINK(LoseFocus, weld::Widget &, void)
Link< weld::Widget &, bool > maActivateHdl
Definition: funcutl.hxx:153
void SetGetFocusHdl(const Link< RefButton &, void > &rLink)
Definition: funcutl.hxx:172
RefEdit * pRefEdit
Definition: funcutl.hxx:150
DECL_DLLPRIVATE_LINK(KeyInput, const KeyEvent &, bool)
Link< RefButton &, void > maGetFocusHdl
Definition: funcutl.hxx:151
DECL_LINK(Click, weld::Button &, void)
IControlReferenceHandler * pAnyRefDlg
Definition: funcutl.hxx:149
Link< RefButton &, void > maClickHdl
Definition: funcutl.hxx:154
void SetLoseFocusHdl(const Link< RefButton &, void > &rLink)
Definition: funcutl.hxx:173
DECL_DLLPRIVATE_LINK(GetFocus, weld::Widget &, void)
void SetActivateHdl(const Link< weld::Widget &, bool > &rLink)
Definition: funcutl.hxx:174
weld::Button * GetWidget() const
Definition: funcutl.hxx:163
DECL_DLLPRIVATE_LINK(Modify, weld::Entry &, void)
weld::Label * GetLabelWidgetForShrinkMode()
Definition: funcutl.hxx:123
void SetCursorAtLast()
Definition: funcutl.hxx:111
DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent &, bool)
ImplSVEvent * mpFocusInEvent
Definition: funcutl.hxx:45
void SelectAll()
Definition: funcutl.hxx:101
Link< RefEdit &, void > maLoseFocusHdl
Definition: funcutl.hxx:49
void SetSelection(const Selection &rSelection)
Definition: funcutl.hxx:106
ImplSVEvent * mpFocusOutEvent
Definition: funcutl.hxx:46
void GrabFocus()
Definition: funcutl.hxx:96
DECL_DLLPRIVATE_LINK(LoseFocusHdl, weld::Widget &, void)
Link< RefEdit &, void > maGetFocusHdl
Definition: funcutl.hxx:48
void SaveValue()
Definition: funcutl.hxx:128
void SetLoseFocusHdl(const Link< RefEdit &, void > &rLink)
Definition: funcutl.hxx:139
weld::Label * pLabelWidget
Definition: funcutl.hxx:44
weld::Entry * GetWidget() const
Definition: funcutl.hxx:70
Link< weld::Widget &, bool > maActivateHdl
Definition: funcutl.hxx:51
void SetModifyHdl(const Link< RefEdit &, void > &rLink)
Definition: funcutl.hxx:140
bool IsValueChangedFromSaved() const
Definition: funcutl.hxx:133
std::unique_ptr< weld::Entry > xEntry
Definition: funcutl.hxx:39
const Link< RefEdit &, void > & GetModifyHdl() const
Definition: funcutl.hxx:141
void SetActivateHdl(const Link< weld::Widget &, bool > &rLink)
Definition: funcutl.hxx:142
void DoModify()
Definition: funcutl.hxx:91
DECL_DLLPRIVATE_LINK(GetFocusHdl, weld::Widget &, void)
Selection GetSelection() const
Definition: funcutl.hxx:116
void SetGetFocusHdl(const Link< RefEdit &, void > &rLink)
Definition: funcutl.hxx:138
DECL_DLLPRIVATE_LINK(AsyncFocusInHdl, void *, void)
IControlReferenceHandler * pAnyRefDlg
Definition: funcutl.hxx:43
OUString GetText() const
Definition: funcutl.hxx:82
DECL_DLLPRIVATE_LINK(AsyncFocusOutHdl, void *, void)
Link< RefEdit &, void > maModifyHdl
Definition: funcutl.hxx:50
DECL_DLLPRIVATE_LINK(UpdateHdl, Timer *, void)
Link< ColorFieldControl &, void > maModifyHdl
virtual void SetText(const OUString &rStr) override
#define FORMULA_DLLPUBLIC
Definition: formuladllapi.h:28