1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: standardcontrol.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
32 #define _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
34 #include "commoncontrol.hxx"
35 #include "pcrcommon.hxx"
37 /** === begin UNO includes === **/
38 #include <com/sun/star/inspection/XNumericControl.hpp>
39 #include <com/sun/star/inspection/XStringListControl.hpp>
40 #include <com/sun/star/inspection/XHyperlinkControl.hpp>
41 #include <com/sun/star/uno/Sequence.hxx>
42 /** === end UNO includes === **/
43 #include <vcl/field.hxx>
44 #include <vcl/longcurr.hxx>
45 #include <svtools/ctrlbox.hxx>
46 #include <vcl/lstbox.hxx>
47 #include <vcl/combobox.hxx>
48 #include <svtools/calendar.hxx>
49 #include <svtools/fmtfield.hxx>
55 //............................................................................
58 //............................................................................
60 //========================================================================
61 //= ListLikeControlWithModifyHandler
62 //========================================================================
63 /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
64 thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
67 template< class LISTBOX_WINDOW
>
68 class ListLikeControlWithModifyHandler
: public ControlWindow
< LISTBOX_WINDOW
>
71 typedef ControlWindow
< LISTBOX_WINDOW
> ListBoxType
;
73 ListLikeControlWithModifyHandler( Window
* _pParent
, WinBits _nStyle
)
74 :ListBoxType( _pParent
, _nStyle
)
78 void SetModifyHdl( const Link
& _rLink
) { ListBoxType::SetSelectHdl( _rLink
); }
81 //========================================================================
83 //========================================================================
84 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< TimeField
> > OTimeControl_Base
;
85 class OTimeControl
: public OTimeControl_Base
88 OTimeControl( Window
* pParent
, WinBits nWinStyle
);
91 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
92 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
93 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
96 //========================================================================
98 //========================================================================
99 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< CalendarField
> > ODateControl_Base
;
100 class ODateControl
: public ODateControl_Base
103 ODateControl( Window
* pParent
, WinBits nWinStyle
);
106 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
107 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
108 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
111 //========================================================================
113 //========================================================================
114 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< Edit
> > OEditControl_Base
;
115 class OEditControl
: public OEditControl_Base
118 sal_Bool m_bIsPassword
: 1;
121 OEditControl( Window
* _pParent
, sal_Bool _bPassWord
, WinBits nWinStyle
);
124 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
125 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
126 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
129 virtual void modified();
132 //========================================================================
134 //========================================================================
135 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< FormattedField
> > ODateTimeControl_Base
;
136 class ODateTimeControl
: public ODateTimeControl_Base
139 ODateTimeControl( Window
* pParent
,WinBits nWinStyle
);
142 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
143 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
144 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
147 //========================================================================
149 //========================================================================
150 class HyperlinkInput
: public Edit
153 Point m_aMouseButtonDownPos
;
154 Link m_aClickHandler
;
157 HyperlinkInput( Window
* _pParent
, WinBits _nWinStyle
);
159 /** sets the handler which will (asynchronously, with locked SolarMutex) be called
160 when the hyperlink has been clicked by the user
162 void SetClickHdl( const Link
& _rHdl
) { m_aClickHandler
= _rHdl
; }
163 const Link
& GetClickHdl( ) const { return m_aClickHandler
; }
166 virtual void MouseMove( const MouseEvent
& rMEvt
);
167 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
168 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
169 virtual void Tracking( const TrackingEvent
& rTEvt
);
172 void impl_checkEndClick( const MouseEvent rMEvt
);
173 bool impl_textHitTest( const Point
& _rWindowPos
);
176 //========================================================================
177 //= OHyperlinkControl
178 //========================================================================
179 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XHyperlinkControl
, ControlWindow
< HyperlinkInput
> > OHyperlinkControl_Base
;
180 class OHyperlinkControl
: public OHyperlinkControl_Base
183 ::cppu::OInterfaceContainerHelper m_aActionListeners
;
186 OHyperlinkControl( Window
* _pParent
, WinBits _nWinStyle
);
189 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
190 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
191 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
194 virtual void SAL_CALL
addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& listener
) throw (::com::sun::star::uno::RuntimeException
);
195 virtual void SAL_CALL
removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& listener
) throw (::com::sun::star::uno::RuntimeException
);
199 virtual void SAL_CALL
disposing();
202 DECL_LINK( OnHyperlinkClicked
, void* );
205 //========================================================================
206 //= CustomConvertibleNumericField
207 //========================================================================
208 class CustomConvertibleNumericField
: public ControlWindow
< MetricField
>
210 typedef ControlWindow
< MetricField
> BaseClass
;
213 CustomConvertibleNumericField( Window
* _pParent
, WinBits _nStyle
)
214 :BaseClass( _pParent
, _nStyle
)
218 sal_Int64
GetLastValue() const { return mnLastValue
; }
221 //========================================================================
223 //========================================================================
224 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XNumericControl
, CustomConvertibleNumericField
> ONumericControl_Base
;
225 class ONumericControl
: public ONumericControl_Base
228 FieldUnit m_eValueUnit
;
229 sal_Int16 m_nFieldToUNOValueFactor
;
232 ONumericControl( Window
* pParent
, WinBits nWinStyle
);
235 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
236 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
237 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
240 virtual ::sal_Int16 SAL_CALL
getDecimalDigits() throw (::com::sun::star::uno::RuntimeException
);
241 virtual void SAL_CALL
setDecimalDigits( ::sal_Int16 _decimaldigits
) throw (::com::sun::star::uno::RuntimeException
);
242 virtual ::com::sun::star::beans::Optional
< double > SAL_CALL
getMinValue() throw (::com::sun::star::uno::RuntimeException
);
243 virtual void SAL_CALL
setMinValue( const ::com::sun::star::beans::Optional
< double >& _minvalue
) throw (::com::sun::star::uno::RuntimeException
);
244 virtual ::com::sun::star::beans::Optional
< double > SAL_CALL
getMaxValue() throw (::com::sun::star::uno::RuntimeException
);
245 virtual void SAL_CALL
setMaxValue( const ::com::sun::star::beans::Optional
< double >& _maxvalue
) throw (::com::sun::star::uno::RuntimeException
);
246 virtual ::sal_Int16 SAL_CALL
getDisplayUnit() throw (::com::sun::star::uno::RuntimeException
);
247 virtual void SAL_CALL
setDisplayUnit( ::sal_Int16 _displayunit
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
248 virtual ::sal_Int16 SAL_CALL
getValueUnit() throw (::com::sun::star::uno::RuntimeException
);
249 virtual void SAL_CALL
setValueUnit( ::sal_Int16 _valueunit
) throw (::com::sun::star::uno::RuntimeException
);
252 /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
253 a <code>long</code> value which can be passed to our NumericField.
255 The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
257 long impl_apiValueToFieldValue_nothrow( double _nApiValue
) const;
259 /** converts a control value, as obtained from our Numeric field, into a value which can passed
260 to outer callers via our UNO API.
262 double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue
) const;
265 //========================================================================
267 //========================================================================
268 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
269 , ListLikeControlWithModifyHandler
< ColorListBox
>
270 > OColorControl_Base
;
271 class OColorControl
: public OColorControl_Base
274 ::std::set
< ::rtl::OUString
> m_aNonColorEntries
;
277 OColorControl( Window
* pParent
, WinBits nWinStyle
);
280 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
281 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
282 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
284 // XStringListControl
285 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
286 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
287 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
288 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
291 virtual void modified();
294 //========================================================================
296 //========================================================================
297 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
298 , ListLikeControlWithModifyHandler
< ListBox
>
299 > OListboxControl_Base
;
300 class OListboxControl
: public OListboxControl_Base
303 OListboxControl( Window
* pParent
, WinBits nWinStyle
);
306 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
307 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
308 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
310 // XStringListControl
311 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
312 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
313 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
314 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
317 virtual void modified();
320 //========================================================================
322 //========================================================================
323 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
, ControlWindow
< ComboBox
> > OComboboxControl_Base
;
324 class OComboboxControl
: public OComboboxControl_Base
327 OComboboxControl( Window
* pParent
, WinBits nWinStyle
);
330 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
331 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
332 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
334 // XStringListControl
335 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
336 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
337 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
338 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
341 DECL_LINK( OnEntrySelected
, void* );
344 //========================================================================
345 //= DropDownEditControl
346 //========================================================================
347 enum MultiLineOperationMode
352 //========================================================================
353 //= DropDownEditControl
354 //========================================================================
355 class OMultilineFloatingEdit
;
356 typedef ControlWindow
< Edit
> DropDownEditControl_Base
;
357 /** an Edit field which can be used as ControlWindow, and has a drop-down button
359 class DropDownEditControl
: public DropDownEditControl_Base
362 OMultilineFloatingEdit
* m_pFloatingEdit
;
363 MultiLineEdit
* m_pImplEdit
;
364 PushButton
* m_pDropdownButton
;
365 MultiLineOperationMode m_nOperationMode
;
366 sal_Bool m_bDropdown
: 1;
369 DropDownEditControl( Window
* _pParent
, WinBits _nStyle
);
370 ~DropDownEditControl();
372 void setOperationMode( MultiLineOperationMode _eMode
) { m_nOperationMode
= _eMode
; }
373 MultiLineOperationMode
getOperationMode() const { return m_nOperationMode
; }
375 void SetTextValue( const ::rtl::OUString
& _rText
);
376 ::rtl::OUString
GetTextValue() const;
378 void SetStringListValue( const StlSyntaxSequence
< ::rtl::OUString
>& _rStrings
);
379 StlSyntaxSequence
< ::rtl::OUString
>
380 GetStringListValue() const;
382 // ControlWindow overridables
383 virtual void setControlHelper( ControlHelper
& _rControlHelper
);
386 // Window overridables
387 virtual long PreNotify( NotifyEvent
& rNEvt
);
388 virtual void Resize();
391 long FindPos(long nSinglePos
);
394 DECL_LINK( ReturnHdl
, OMultilineFloatingEdit
* );
395 DECL_LINK( DropDownHdl
, PushButton
* );
397 sal_Bool
ShowDropDown( sal_Bool bShow
);
400 //========================================================================
401 //= OMultilineEditControl
402 //========================================================================
403 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, DropDownEditControl
> OMultilineEditControl_Base
;
404 class OMultilineEditControl
: public OMultilineEditControl_Base
407 OMultilineEditControl( Window
* pParent
, MultiLineOperationMode _eMode
, WinBits nWinStyle
);
410 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
411 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
412 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
415 //............................................................................
417 //............................................................................
419 #endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_