bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / standardcontrol.hxx
blob6da36353c28e05737921b6f0dc143653353e4af1
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_EXTENSIONS_SOURCE_PROPCTRLR_STANDARDCONTROL_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_STANDARDCONTROL_HXX
23 #include "commoncontrol.hxx"
24 #include "pcrcommon.hxx"
26 #include <com/sun/star/inspection/XNumericControl.hpp>
27 #include <com/sun/star/inspection/XStringListControl.hpp>
28 #include <com/sun/star/inspection/XHyperlinkControl.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <vcl/field.hxx>
31 #include <vcl/longcurr.hxx>
32 #include <svtools/ctrlbox.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <vcl/combobox.hxx>
35 #include <svtools/calendar.hxx>
36 #include <vcl/fmtfield.hxx>
37 #include <svx/colorbox.hxx>
39 #include <set>
41 class PushButton;
42 class MultiLineEdit;
44 namespace pcr
48 //= ListLikeControlWithModifyHandler
50 /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
51 thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
52 as all other windows.
54 template< class TListboxWindow >
55 class ListLikeControlWithModifyHandler : public TListboxWindow
57 public:
58 ListLikeControlWithModifyHandler( vcl::Window* _pParent, WinBits _nStyle )
59 : TListboxWindow( _pParent, _nStyle )
61 TListboxWindow::SetSelectHdl( LINK(this, ListLikeControlWithModifyHandler, OnSelect) );
64 void SetModifyHdl( const Link<TListboxWindow&,void>& _rLink ) { aModifyHdl = _rLink; }
65 private:
66 DECL_LINK(OnSelect, TListboxWindow&, void);
67 Link<TListboxWindow&,void> aModifyHdl;
70 template< class LISTBOX_WINDOW >
71 void ListLikeControlWithModifyHandler< LISTBOX_WINDOW >::LinkStubOnSelect(void * instance, LISTBOX_WINDOW& data) {
72 return static_cast<ListLikeControlWithModifyHandler< LISTBOX_WINDOW > *>(instance)->OnSelect(data);
74 template< class LISTBOX_WINDOW >
75 void ListLikeControlWithModifyHandler< LISTBOX_WINDOW >::OnSelect(LISTBOX_WINDOW& rListBox)
77 aModifyHdl.Call(rListBox);
80 //= OTimeControl
82 typedef CommonBehaviourControl< css::inspection::XPropertyControl, TimeField > OTimeControl_Base;
83 class OTimeControl : public OTimeControl_Base
85 public:
86 OTimeControl( vcl::Window* pParent, WinBits nWinStyle );
88 // XPropertyControl
89 virtual css::uno::Any SAL_CALL getValue() override;
90 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
91 virtual css::uno::Type SAL_CALL getValueType() override;
95 //= ODateControl
97 typedef CommonBehaviourControl< css::inspection::XPropertyControl, CalendarField > ODateControl_Base;
98 class ODateControl : public ODateControl_Base
100 public:
101 ODateControl( vcl::Window* pParent, WinBits nWinStyle );
103 // XPropertyControl
104 virtual css::uno::Any SAL_CALL getValue() override;
105 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
106 virtual css::uno::Type SAL_CALL getValueType() override;
110 //= OEditControl
112 typedef CommonBehaviourControl< css::inspection::XPropertyControl, Edit > OEditControl_Base;
113 class OEditControl final : public OEditControl_Base
115 bool m_bIsPassword : 1;
117 public:
118 OEditControl( vcl::Window* _pParent, bool _bPassWord, WinBits nWinStyle );
120 // XPropertyControl
121 virtual css::uno::Any SAL_CALL getValue() override;
122 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
123 virtual css::uno::Type SAL_CALL getValueType() override;
125 private:
126 // CommonBehaviourControlHelper::modified
127 virtual void setModified() override;
131 //= ODateTimeControl
133 typedef CommonBehaviourControl< css::inspection::XPropertyControl, FormattedField > ODateTimeControl_Base;
134 class ODateTimeControl : public ODateTimeControl_Base
136 public:
137 ODateTimeControl( vcl::Window* pParent,WinBits nWinStyle );
139 // XPropertyControl
140 virtual css::uno::Any SAL_CALL getValue() override;
141 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
142 virtual css::uno::Type SAL_CALL getValueType() override;
146 //= HyperlinkInput
148 class HyperlinkInput : public Edit
150 private:
151 Point m_aMouseButtonDownPos;
152 Link<void*,void> m_aClickHandler;
154 public:
155 HyperlinkInput( vcl::Window* _pParent, WinBits _nWinStyle );
157 /** sets the handler which will (asynchronously, with locked SolarMutex) be called
158 when the hyperlink has been clicked by the user
160 void SetClickHdl( const Link<void*,void>& _rHdl ) { m_aClickHandler = _rHdl; }
162 protected:
163 virtual void MouseMove( const MouseEvent& rMEvt ) override;
164 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
165 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
166 virtual void Tracking( const TrackingEvent& rTEvt ) override;
168 private:
169 void impl_checkEndClick( const MouseEvent& rMEvt );
170 bool impl_textHitTest( const Point& rWindowPos );
174 //= OHyperlinkControl
176 typedef CommonBehaviourControl< css::inspection::XHyperlinkControl, HyperlinkInput > OHyperlinkControl_Base;
177 class OHyperlinkControl final : public OHyperlinkControl_Base
179 ::comphelper::OInterfaceContainerHelper2 m_aActionListeners;
181 public:
182 OHyperlinkControl( vcl::Window* _pParent, WinBits _nWinStyle );
184 // XPropertyControl
185 virtual css::uno::Any SAL_CALL getValue() override;
186 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
187 virtual css::uno::Type SAL_CALL getValueType() override;
189 // XHyperlinkControl
190 virtual void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& listener ) override;
191 virtual void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& listener ) override;
193 private:
194 // XComponent
195 virtual void SAL_CALL disposing() override;
197 DECL_LINK( OnHyperlinkClicked, void*, void );
201 //= CustomConvertibleNumericField
203 class CustomConvertibleNumericField : public MetricField
205 public:
206 CustomConvertibleNumericField( vcl::Window* _pParent, WinBits _nStyle )
207 :MetricField( _pParent, _nStyle )
211 sal_Int64 GetLastValue() const { return mnLastValue; }
215 //= ONumericControl
217 typedef CommonBehaviourControl< css::inspection::XNumericControl, CustomConvertibleNumericField > ONumericControl_Base;
218 class ONumericControl : public ONumericControl_Base
220 private:
221 FieldUnit m_eValueUnit;
222 sal_Int16 m_nFieldToUNOValueFactor;
224 public:
225 ONumericControl( vcl::Window* pParent, WinBits nWinStyle );
227 // XPropertyControl
228 virtual css::uno::Any SAL_CALL getValue() override;
229 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
230 virtual css::uno::Type SAL_CALL getValueType() override;
232 // XNumericControl
233 virtual ::sal_Int16 SAL_CALL getDecimalDigits() override;
234 virtual void SAL_CALL setDecimalDigits( ::sal_Int16 _decimaldigits ) override;
235 virtual css::beans::Optional< double > SAL_CALL getMinValue() override;
236 virtual void SAL_CALL setMinValue( const css::beans::Optional< double >& _minvalue ) override;
237 virtual css::beans::Optional< double > SAL_CALL getMaxValue() override;
238 virtual void SAL_CALL setMaxValue( const css::beans::Optional< double >& _maxvalue ) override;
239 virtual ::sal_Int16 SAL_CALL getDisplayUnit() override;
240 virtual void SAL_CALL setDisplayUnit( ::sal_Int16 _displayunit ) override;
241 virtual ::sal_Int16 SAL_CALL getValueUnit() override;
242 virtual void SAL_CALL setValueUnit( ::sal_Int16 _valueunit ) override;
244 private:
245 /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
246 a <code>long</code> value which can be passed to our NumericField.
248 The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
250 long impl_apiValueToFieldValue_nothrow( double _nApiValue ) const;
252 /** converts a control value, as obtained from our Numeric field, into a value which can passed
253 to outer callers via our UNO API.
255 double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const;
259 //= OColorControl
261 typedef CommonBehaviourControl < css::inspection::XPropertyControl
262 , ListLikeControlWithModifyHandler<SvxColorListBox>
263 > OColorControl_Base;
264 class OColorControl : public OColorControl_Base
266 public:
267 OColorControl( vcl::Window* pParent, WinBits nWinStyle );
269 // XPropertyControl
270 virtual css::uno::Any SAL_CALL getValue() override;
271 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
272 virtual css::uno::Type SAL_CALL getValueType() override;
274 protected:
275 // CommonBehaviourControlHelper::setModified
276 virtual void setModified() override;
280 //= OListboxControl
282 typedef CommonBehaviourControl < css::inspection::XStringListControl
283 , ListLikeControlWithModifyHandler< ListBox >
284 > OListboxControl_Base;
285 class OListboxControl : public OListboxControl_Base
287 public:
288 OListboxControl( vcl::Window* pParent, WinBits nWinStyle );
290 // XPropertyControl
291 virtual css::uno::Any SAL_CALL getValue() override;
292 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
293 virtual css::uno::Type SAL_CALL getValueType() override;
295 // XStringListControl
296 virtual void SAL_CALL clearList( ) override;
297 virtual void SAL_CALL prependListEntry( const OUString& NewEntry ) override;
298 virtual void SAL_CALL appendListEntry( const OUString& NewEntry ) override;
299 virtual css::uno::Sequence< OUString > SAL_CALL getListEntries( ) override;
301 protected:
302 // CommonBehaviourControlHelper::setModified
303 virtual void setModified() override;
307 //= OComboboxControl
309 typedef CommonBehaviourControl< css::inspection::XStringListControl, ComboBox > OComboboxControl_Base;
310 class OComboboxControl final : public OComboboxControl_Base
312 public:
313 OComboboxControl( vcl::Window* pParent, WinBits nWinStyle );
315 // XPropertyControl
316 virtual css::uno::Any SAL_CALL getValue() override;
317 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
318 virtual css::uno::Type SAL_CALL getValueType() override;
320 // XStringListControl
321 virtual void SAL_CALL clearList( ) override;
322 virtual void SAL_CALL prependListEntry( const OUString& NewEntry ) override;
323 virtual void SAL_CALL appendListEntry( const OUString& NewEntry ) override;
324 virtual css::uno::Sequence< OUString > SAL_CALL getListEntries( ) override;
326 private:
327 DECL_LINK( OnEntrySelected, ComboBox&, void );
331 //= DropDownEditControl
333 enum MultiLineOperationMode
335 eStringList,
336 eMultiLineText
339 //= DropDownEditControl
341 class OMultilineFloatingEdit;
342 /** an Edit field which can be used as ControlWindow, and has a drop-down button
344 class DropDownEditControl final : public Edit
346 VclPtr<OMultilineFloatingEdit> m_pFloatingEdit;
347 VclPtr<MultiLineEdit> m_pImplEdit;
348 VclPtr<PushButton> m_pDropdownButton;
349 MultiLineOperationMode m_nOperationMode;
350 bool m_bDropdown : 1;
351 CommonBehaviourControlHelper* m_pHelper;
353 public:
354 DropDownEditControl( vcl::Window* _pParent, WinBits _nStyle );
355 virtual ~DropDownEditControl() override;
356 virtual void dispose() override;
358 void setControlHelper( CommonBehaviourControlHelper& _rControlHelper );
359 void setOperationMode( MultiLineOperationMode _eMode ) { m_nOperationMode = _eMode; }
360 MultiLineOperationMode getOperationMode() const { return m_nOperationMode; }
362 void SetTextValue( const OUString& _rText );
363 OUString GetTextValue() const;
365 void SetStringListValue( const StlSyntaxSequence< OUString >& _rStrings );
366 StlSyntaxSequence< OUString >
367 GetStringListValue() const;
369 private:
370 // Window overridables
371 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
372 virtual void Resize() override;
374 long FindPos(long nSinglePos);
376 DECL_LINK( ReturnHdl, FloatingWindow*, void );
377 DECL_LINK( DropDownHdl, Button*, void );
379 void ShowDropDown( bool bShow );
383 //= OMultilineEditControl
385 typedef CommonBehaviourControl< css::inspection::XPropertyControl, DropDownEditControl > OMultilineEditControl_Base;
386 class OMultilineEditControl : public OMultilineEditControl_Base
388 public:
389 OMultilineEditControl( vcl::Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle );
391 // XPropertyControl
392 virtual css::uno::Any SAL_CALL getValue() override;
393 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
394 virtual css::uno::Type SAL_CALL getValueType() override;
398 } // namespace pcr
401 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_STANDARDCONTROL_HXX
403 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */