Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / standardcontrol.hxx
blobc480b508cd25cd026879d8bc222ca386f5ae37c3
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>
49 #include <set>
51 class PushButton;
52 class MultiLineEdit;
53 //............................................................................
54 namespace pcr
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)
63 as all other windows.
65 template< class LISTBOX_WINDOW >
66 class ListLikeControlWithModifyHandler : public ControlWindow< LISTBOX_WINDOW >
68 protected:
69 typedef ControlWindow< LISTBOX_WINDOW > ListBoxType;
71 public:
72 ListLikeControlWithModifyHandler( Window* _pParent, WinBits _nStyle )
73 :ListBoxType( _pParent, _nStyle )
77 void SetModifyHdl( const Link& _rLink ) { ListBoxType::SetSelectHdl( _rLink ); }
79 protected:
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 //========================================================================
108 //= OTimeControl
109 //========================================================================
110 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< TimeField > > OTimeControl_Base;
111 class OTimeControl : public OTimeControl_Base
113 public:
114 OTimeControl( Window* pParent, WinBits nWinStyle );
116 // XPropertyControl
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 //========================================================================
123 //= ODateControl
124 //========================================================================
125 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< CalendarField > > ODateControl_Base;
126 class ODateControl : public ODateControl_Base
128 public:
129 ODateControl( Window* pParent, WinBits nWinStyle );
131 // XPropertyControl
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 //========================================================================
138 //= OEditControl
139 //========================================================================
140 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< Edit > > OEditControl_Base;
141 class OEditControl : public OEditControl_Base
143 protected:
144 sal_Bool m_bIsPassword : 1;
146 public:
147 OEditControl( Window* _pParent, sal_Bool _bPassWord, WinBits nWinStyle );
149 // XPropertyControl
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);
154 protected:
155 virtual void modified();
158 //========================================================================
159 //= ODateTimeControl
160 //========================================================================
161 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > ODateTimeControl_Base;
162 class ODateTimeControl : public ODateTimeControl_Base
164 public:
165 ODateTimeControl( Window* pParent,WinBits nWinStyle );
167 // XPropertyControl
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 //========================================================================
174 //= HyperlinkInput
175 //========================================================================
176 class HyperlinkInput : public Edit
178 private:
179 Point m_aMouseButtonDownPos;
180 Link m_aClickHandler;
182 public:
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; }
191 protected:
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 );
197 private:
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
208 private:
209 ::cppu::OInterfaceContainerHelper m_aActionListeners;
211 public:
212 OHyperlinkControl( Window* _pParent, WinBits _nWinStyle );
214 // XPropertyControl
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);
219 // XHyperlinkControl
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);
223 protected:
224 // XComponent
225 virtual void SAL_CALL disposing();
227 protected:
228 DECL_LINK( OnHyperlinkClicked, void* );
231 //========================================================================
232 //= CustomConvertibleNumericField
233 //========================================================================
234 class CustomConvertibleNumericField : public ControlWindow< MetricField >
236 typedef ControlWindow< MetricField > BaseClass;
238 public:
239 CustomConvertibleNumericField( Window* _pParent, WinBits _nStyle )
240 :BaseClass( _pParent, _nStyle )
244 sal_Int64 GetLastValue() const { return mnLastValue; }
247 //========================================================================
248 //= ONumericControl
249 //========================================================================
250 typedef CommonBehaviourControl< ::com::sun::star::inspection::XNumericControl, CustomConvertibleNumericField > ONumericControl_Base;
251 class ONumericControl : public ONumericControl_Base
253 private:
254 FieldUnit m_eValueUnit;
255 sal_Int16 m_nFieldToUNOValueFactor;
257 public:
258 ONumericControl( Window* pParent, WinBits nWinStyle );
260 // XPropertyControl
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);
265 // XNumericControl
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);
277 private:
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 //========================================================================
292 //= OColorControl
293 //========================================================================
294 typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
295 , ListLikeControlWithModifyHandler< ColorListBox >
296 > OColorControl_Base;
297 class OColorControl : public OColorControl_Base
299 private:
300 ::std::set< ::rtl::OUString > m_aNonColorEntries;
302 public:
303 OColorControl( Window* pParent, WinBits nWinStyle );
305 // XPropertyControl
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);
316 protected:
317 virtual void modified();
320 //========================================================================
321 //= OListboxControl
322 //========================================================================
323 typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
324 , ListLikeControlWithModifyHandler< ListBox >
325 > OListboxControl_Base;
326 class OListboxControl : public OListboxControl_Base
328 public:
329 OListboxControl( Window* pParent, WinBits nWinStyle );
331 // XPropertyControl
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);
342 protected:
343 virtual void modified();
346 //========================================================================
347 //= OComboboxControl
348 //========================================================================
349 typedef CommonBehaviourControl< ::com::sun::star::inspection::XStringListControl, ControlWindow< ComboBox > > OComboboxControl_Base;
350 class OComboboxControl : public OComboboxControl_Base
352 public:
353 OComboboxControl( Window* pParent, WinBits nWinStyle );
355 // XPropertyControl
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);
366 protected:
367 DECL_LINK( OnEntrySelected, void* );
370 //========================================================================
371 //= DropDownEditControl
372 //========================================================================
373 enum MultiLineOperationMode
375 eStringList,
376 eMultiLineText
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
387 private:
388 OMultilineFloatingEdit* m_pFloatingEdit;
389 MultiLineEdit* m_pImplEdit;
390 PushButton* m_pDropdownButton;
391 MultiLineOperationMode m_nOperationMode;
392 sal_Bool m_bDropdown : 1;
394 public:
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 );
411 protected:
412 // Window overridables
413 virtual long PreNotify( NotifyEvent& rNEvt );
414 virtual void Resize();
416 protected:
417 long FindPos(long nSinglePos);
419 private:
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
432 public:
433 OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle );
435 // XPropertyControl
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 //............................................................................
442 } // namespace pcr
443 //............................................................................
445 #endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
447 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */