1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
30 #define _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
32 #include "commoncontrol.hxx"
33 #include "pcrcommon.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/inspection/XNumericControl.hpp>
37 #include <com/sun/star/inspection/XStringListControl.hpp>
38 #include <com/sun/star/inspection/XHyperlinkControl.hpp>
39 #include <com/sun/star/uno/Sequence.hxx>
40 /** === end UNO includes === **/
41 #include <vcl/field.hxx>
42 #include <vcl/longcurr.hxx>
43 #include <svtools/ctrlbox.hxx>
44 #include <vcl/lstbox.hxx>
45 #include <vcl/combobox.hxx>
46 #include <svtools/calendar.hxx>
47 #include <svtools/fmtfield.hxx>
53 //............................................................................
56 //............................................................................
58 //========================================================================
59 //= ListLikeControlWithModifyHandler
60 //========================================================================
61 /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
62 thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
65 template< class LISTBOX_WINDOW
>
66 class ListLikeControlWithModifyHandler
: public ControlWindow
< LISTBOX_WINDOW
>
69 typedef ControlWindow
< LISTBOX_WINDOW
> ListBoxType
;
72 ListLikeControlWithModifyHandler( Window
* _pParent
, WinBits _nStyle
)
73 :ListBoxType( _pParent
, _nStyle
)
77 void SetModifyHdl( const Link
& _rLink
) { ListBoxType::SetSelectHdl( _rLink
); }
80 long PreNotify( NotifyEvent
& _rNEvt
);
83 //------------------------------------------------------------------------
84 template< class LISTBOX_WINDOW
>
85 long ListLikeControlWithModifyHandler
< LISTBOX_WINDOW
>::PreNotify( NotifyEvent
& _rNEvt
)
87 if ( _rNEvt
.GetType() == EVENT_KEYINPUT
)
89 const ::KeyEvent
* pKeyEvent
= _rNEvt
.GetKeyEvent();
90 if ( ( pKeyEvent
->GetKeyCode().GetModifier() == 0 )
91 && ( ( pKeyEvent
->GetKeyCode().GetCode() == KEY_PAGEUP
)
92 || ( pKeyEvent
->GetKeyCode().GetCode() == KEY_PAGEDOWN
)
96 if ( !ListBoxType::IsInDropDown() )
98 // don't give the base class a chance to consume the event, in the property browser, it is
99 // intended to scroll the complete property page
100 return ListBoxType::GetParent()->PreNotify( _rNEvt
);
104 return ListBoxType::PreNotify( _rNEvt
);
107 //========================================================================
109 //========================================================================
110 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< TimeField
> > OTimeControl_Base
;
111 class OTimeControl
: public OTimeControl_Base
114 OTimeControl( Window
* pParent
, WinBits nWinStyle
);
117 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
119 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
122 //========================================================================
124 //========================================================================
125 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< CalendarField
> > ODateControl_Base
;
126 class ODateControl
: public ODateControl_Base
129 ODateControl( Window
* pParent
, WinBits nWinStyle
);
132 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
133 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
134 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
137 //========================================================================
139 //========================================================================
140 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< Edit
> > OEditControl_Base
;
141 class OEditControl
: public OEditControl_Base
144 sal_Bool m_bIsPassword
: 1;
147 OEditControl( Window
* _pParent
, sal_Bool _bPassWord
, WinBits nWinStyle
);
150 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
151 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
152 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
155 virtual void modified();
158 //========================================================================
160 //========================================================================
161 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< FormattedField
> > ODateTimeControl_Base
;
162 class ODateTimeControl
: public ODateTimeControl_Base
165 ODateTimeControl( Window
* pParent
,WinBits nWinStyle
);
168 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
169 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
170 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
173 //========================================================================
175 //========================================================================
176 class HyperlinkInput
: public Edit
179 Point m_aMouseButtonDownPos
;
180 Link m_aClickHandler
;
183 HyperlinkInput( Window
* _pParent
, WinBits _nWinStyle
);
185 /** sets the handler which will (asynchronously, with locked SolarMutex) be called
186 when the hyperlink has been clicked by the user
188 void SetClickHdl( const Link
& _rHdl
) { m_aClickHandler
= _rHdl
; }
189 const Link
& GetClickHdl( ) const { return m_aClickHandler
; }
192 virtual void MouseMove( const MouseEvent
& rMEvt
);
193 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
194 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
195 virtual void Tracking( const TrackingEvent
& rTEvt
);
198 void impl_checkEndClick( const MouseEvent rMEvt
);
199 bool impl_textHitTest( const Point
& _rWindowPos
);
202 //========================================================================
203 //= OHyperlinkControl
204 //========================================================================
205 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XHyperlinkControl
, ControlWindow
< HyperlinkInput
> > OHyperlinkControl_Base
;
206 class OHyperlinkControl
: public OHyperlinkControl_Base
209 ::cppu::OInterfaceContainerHelper m_aActionListeners
;
212 OHyperlinkControl( Window
* _pParent
, WinBits _nWinStyle
);
215 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
216 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
217 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
220 virtual void SAL_CALL
addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& listener
) throw (::com::sun::star::uno::RuntimeException
);
221 virtual void SAL_CALL
removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& listener
) throw (::com::sun::star::uno::RuntimeException
);
225 virtual void SAL_CALL
disposing();
228 DECL_LINK( OnHyperlinkClicked
, void* );
231 //========================================================================
232 //= CustomConvertibleNumericField
233 //========================================================================
234 class CustomConvertibleNumericField
: public ControlWindow
< MetricField
>
236 typedef ControlWindow
< MetricField
> BaseClass
;
239 CustomConvertibleNumericField( Window
* _pParent
, WinBits _nStyle
)
240 :BaseClass( _pParent
, _nStyle
)
244 sal_Int64
GetLastValue() const { return mnLastValue
; }
247 //========================================================================
249 //========================================================================
250 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XNumericControl
, CustomConvertibleNumericField
> ONumericControl_Base
;
251 class ONumericControl
: public ONumericControl_Base
254 FieldUnit m_eValueUnit
;
255 sal_Int16 m_nFieldToUNOValueFactor
;
258 ONumericControl( Window
* pParent
, WinBits nWinStyle
);
261 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
262 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
263 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
266 virtual ::sal_Int16 SAL_CALL
getDecimalDigits() throw (::com::sun::star::uno::RuntimeException
);
267 virtual void SAL_CALL
setDecimalDigits( ::sal_Int16 _decimaldigits
) throw (::com::sun::star::uno::RuntimeException
);
268 virtual ::com::sun::star::beans::Optional
< double > SAL_CALL
getMinValue() throw (::com::sun::star::uno::RuntimeException
);
269 virtual void SAL_CALL
setMinValue( const ::com::sun::star::beans::Optional
< double >& _minvalue
) throw (::com::sun::star::uno::RuntimeException
);
270 virtual ::com::sun::star::beans::Optional
< double > SAL_CALL
getMaxValue() throw (::com::sun::star::uno::RuntimeException
);
271 virtual void SAL_CALL
setMaxValue( const ::com::sun::star::beans::Optional
< double >& _maxvalue
) throw (::com::sun::star::uno::RuntimeException
);
272 virtual ::sal_Int16 SAL_CALL
getDisplayUnit() throw (::com::sun::star::uno::RuntimeException
);
273 virtual void SAL_CALL
setDisplayUnit( ::sal_Int16 _displayunit
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
274 virtual ::sal_Int16 SAL_CALL
getValueUnit() throw (::com::sun::star::uno::RuntimeException
);
275 virtual void SAL_CALL
setValueUnit( ::sal_Int16 _valueunit
) throw (::com::sun::star::uno::RuntimeException
);
278 /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
279 a <code>long</code> value which can be passed to our NumericField.
281 The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
283 long impl_apiValueToFieldValue_nothrow( double _nApiValue
) const;
285 /** converts a control value, as obtained from our Numeric field, into a value which can passed
286 to outer callers via our UNO API.
288 double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue
) const;
291 //========================================================================
293 //========================================================================
294 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
295 , ListLikeControlWithModifyHandler
< ColorListBox
>
296 > OColorControl_Base
;
297 class OColorControl
: public OColorControl_Base
300 ::std::set
< ::rtl::OUString
> m_aNonColorEntries
;
303 OColorControl( 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
324 , ListLikeControlWithModifyHandler
< ListBox
>
325 > OListboxControl_Base
;
326 class OListboxControl
: public OListboxControl_Base
329 OListboxControl( Window
* pParent
, WinBits nWinStyle
);
332 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
333 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
334 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
336 // XStringListControl
337 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
338 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
339 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
340 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
343 virtual void modified();
346 //========================================================================
348 //========================================================================
349 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
, ControlWindow
< ComboBox
> > OComboboxControl_Base
;
350 class OComboboxControl
: public OComboboxControl_Base
353 OComboboxControl( Window
* pParent
, WinBits nWinStyle
);
356 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
357 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
358 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
360 // XStringListControl
361 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
362 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
363 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
364 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
367 DECL_LINK( OnEntrySelected
, void* );
370 //========================================================================
371 //= DropDownEditControl
372 //========================================================================
373 enum MultiLineOperationMode
378 //========================================================================
379 //= DropDownEditControl
380 //========================================================================
381 class OMultilineFloatingEdit
;
382 typedef ControlWindow
< Edit
> DropDownEditControl_Base
;
383 /** an Edit field which can be used as ControlWindow, and has a drop-down button
385 class DropDownEditControl
: public DropDownEditControl_Base
388 OMultilineFloatingEdit
* m_pFloatingEdit
;
389 MultiLineEdit
* m_pImplEdit
;
390 PushButton
* m_pDropdownButton
;
391 MultiLineOperationMode m_nOperationMode
;
392 sal_Bool m_bDropdown
: 1;
395 DropDownEditControl( Window
* _pParent
, WinBits _nStyle
);
396 ~DropDownEditControl();
398 void setOperationMode( MultiLineOperationMode _eMode
) { m_nOperationMode
= _eMode
; }
399 MultiLineOperationMode
getOperationMode() const { return m_nOperationMode
; }
401 void SetTextValue( const ::rtl::OUString
& _rText
);
402 ::rtl::OUString
GetTextValue() const;
404 void SetStringListValue( const StlSyntaxSequence
< ::rtl::OUString
>& _rStrings
);
405 StlSyntaxSequence
< ::rtl::OUString
>
406 GetStringListValue() const;
408 // ControlWindow overridables
409 virtual void setControlHelper( ControlHelper
& _rControlHelper
);
412 // Window overridables
413 virtual long PreNotify( NotifyEvent
& rNEvt
);
414 virtual void Resize();
417 long FindPos(long nSinglePos
);
420 DECL_LINK( ReturnHdl
, OMultilineFloatingEdit
* );
421 DECL_LINK( DropDownHdl
, PushButton
* );
423 sal_Bool
ShowDropDown( sal_Bool bShow
);
426 //========================================================================
427 //= OMultilineEditControl
428 //========================================================================
429 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, DropDownEditControl
> OMultilineEditControl_Base
;
430 class OMultilineEditControl
: public OMultilineEditControl_Base
433 OMultilineEditControl( Window
* pParent
, MultiLineOperationMode _eMode
, WinBits nWinStyle
);
436 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
437 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
438 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
441 //............................................................................
443 //............................................................................
445 #endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
447 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */