Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / field.hxx
blob8d9236646e6f2d3d51abd55d4b28414884cc3e8e
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_VCL_FIELD_HXX
21 #define INCLUDED_VCL_FIELD_HXX
23 #include <vcl/dllapi.h>
24 #include <tools/link.hxx>
25 #include <tools/date.hxx>
26 #include <tools/time.hxx>
27 #include <vcl/spinfld.hxx>
28 #include <vcl/combobox.hxx>
29 #include <tools/fldunit.hxx>
31 namespace com { namespace sun { namespace star { namespace lang { struct Locale; } } } }
33 class CalendarWrapper;
34 class LocaleDataWrapper;
35 class LanguageTag;
38 // - FormatterBase -
41 class VCL_DLLPUBLIC FormatterBase
43 private:
44 VclPtr<Edit> mpField;
45 LocaleDataWrapper* mpLocaleDataWrapper;
46 Link<> maErrorLink;
47 bool mbReformat;
48 bool mbStrictFormat;
49 bool mbEmptyFieldValue;
50 bool mbEmptyFieldValueEnabled;
51 bool mbDefaultLocale;
53 protected:
54 SAL_DLLPRIVATE void ImplSetText( const OUString& rText, Selection* pNewSel = NULL );
55 SAL_DLLPRIVATE bool ImplGetEmptyFieldValue() const { return mbEmptyFieldValue; }
57 void SetEmptyFieldValueData( bool bValue ) { mbEmptyFieldValue = bValue; }
59 SAL_DLLPRIVATE LocaleDataWrapper& ImplGetLocaleDataWrapper() const;
60 bool IsDefaultLocale() const { return mbDefaultLocale; }
62 public:
63 explicit FormatterBase( Edit* pField = NULL );
64 virtual ~FormatterBase();
66 const LocaleDataWrapper& GetLocaleDataWrapper() const;
68 void SetField( Edit* pField ) { mpField = pField; }
69 Edit* GetField() const { return mpField; }
71 bool MustBeReformatted() const { return mbReformat; }
72 void MarkToBeReformatted( bool b ) { mbReformat = b; }
74 void SetStrictFormat( bool bStrict );
75 bool IsStrictFormat() const { return mbStrictFormat; }
77 virtual void Reformat();
78 virtual void ReformatAll();
80 virtual void SetLocale( const ::com::sun::star::lang::Locale& rLocale );
81 const ::com::sun::star::lang::Locale& GetLocale() const;
82 const LanguageTag& GetLanguageTag() const;
84 const AllSettings& GetFieldSettings() const;
86 void SetErrorHdl( const Link<>& rLink ) { maErrorLink = rLink; }
87 const Link<>& GetErrorHdl() const { return maErrorLink; }
89 void SetEmptyFieldValue();
90 bool IsEmptyFieldValue() const;
92 void EnableEmptyFieldValue( bool bEnable ) { mbEmptyFieldValueEnabled = bEnable; }
93 bool IsEmptyFieldValueEnabled() const { return mbEmptyFieldValueEnabled; }
98 // - PatternFormatter -
101 #define PATTERN_FORMAT_EMPTYLITERALS ((sal_uInt16)0x0001)
103 class VCL_DLLPUBLIC PatternFormatter : public FormatterBase
105 private:
106 OString m_aEditMask;
107 OUString maFieldString;
108 OUString maLiteralMask;
109 sal_uInt16 mnFormatFlags;
110 bool mbSameMask;
111 bool mbInPattKeyInput;
113 protected:
114 PatternFormatter();
116 SAL_DLLPRIVATE void ImplSetMask(const OString& rEditMask,
117 const OUString& rLiteralMask);
118 SAL_DLLPRIVATE bool ImplIsSameMask() const { return mbSameMask; }
119 SAL_DLLPRIVATE bool& ImplGetInPattKeyInput() { return mbInPattKeyInput; }
121 public:
122 virtual ~PatternFormatter();
124 virtual void Reformat() SAL_OVERRIDE;
126 void SetMask(const OString& rEditMask, const OUString& rLiteralMask );
127 const OString& GetEditMask() const { return m_aEditMask; }
128 const OUString& GetLiteralMask() const { return maLiteralMask; }
130 void SetFormatFlags( sal_uInt16 nFlags ) { mnFormatFlags = nFlags; }
131 sal_uInt16 GetFormatFlags() const { return mnFormatFlags; }
133 void SetString( const OUString& rStr );
134 OUString GetString() const;
135 bool IsStringModified() const { return !(GetString() == maFieldString ); }
139 // - NumericFormatter -
142 class VCL_DLLPUBLIC NumericFormatter : public FormatterBase
144 private:
145 SAL_DLLPRIVATE void ImplInit();
147 protected:
148 sal_Int64 mnFieldValue;
149 sal_Int64 mnLastValue;
150 sal_Int64 mnMin;
151 sal_Int64 mnMax;
152 sal_Int64 mnCorrectedValue;
153 sal_uInt16 mnType;
154 sal_uInt16 mnDecimalDigits;
155 bool mbThousandSep;
156 bool mbShowTrailingZeros;
157 bool mbWrapOnLimits;
159 // the members below are used in all derivatives of NumericFormatter
160 // not in NumericFormatter itself.
161 sal_Int64 mnSpinSize;
162 sal_Int64 mnFirst;
163 sal_Int64 mnLast;
165 protected:
166 NumericFormatter();
168 void FieldUp();
169 void FieldDown();
170 void FieldFirst();
171 void FieldLast();
173 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
174 SAL_DLLPRIVATE bool ImplNumericReformat( const OUString& rStr, sal_Int64& rValue, OUString& rOutStr );
175 SAL_DLLPRIVATE void ImplNewFieldValue( sal_Int64 nNewValue );
176 SAL_DLLPRIVATE void ImplSetUserValue( sal_Int64 nNewValue, Selection* pNewSelection = NULL );
178 public:
179 virtual ~NumericFormatter();
181 virtual void Reformat() SAL_OVERRIDE;
183 void SetMin( sal_Int64 nNewMin );
184 sal_Int64 GetMin() const { return mnMin; }
185 void SetMax( sal_Int64 nNewMax );
186 sal_Int64 GetMax() const { return mnMax; }
188 sal_Int64 ClipAgainstMinMax(sal_Int64 nValue) const;
190 void SetFirst( sal_Int64 nNewFirst ) { mnFirst = nNewFirst; }
191 sal_Int64 GetFirst() const { return mnFirst; }
192 void SetLast( sal_Int64 nNewLast ) { mnLast = nNewLast; }
193 sal_Int64 GetLast() const { return mnLast; }
194 void SetSpinSize( sal_Int64 nNewSize ) { mnSpinSize = nNewSize; }
195 sal_Int64 GetSpinSize() const { return mnSpinSize; }
197 void SetDecimalDigits( sal_uInt16 nDigits );
198 sal_uInt16 GetDecimalDigits() const { return mnDecimalDigits;}
200 void SetUseThousandSep( bool b );
201 bool IsUseThousandSep() const { return mbThousandSep; }
203 void SetShowTrailingZeros( bool bShowTrailingZeros );
204 bool IsShowTrailingZeros() const { return mbShowTrailingZeros; }
207 void SetUserValue( sal_Int64 nNewValue );
208 virtual void SetValue( sal_Int64 nNewValue );
209 virtual sal_Int64 GetValue() const;
210 virtual OUString CreateFieldText( sal_Int64 nValue ) const;
211 bool IsValueModified() const;
212 sal_Int64 GetCorrectedValue() const { return mnCorrectedValue; }
214 sal_Int64 Normalize( sal_Int64 nValue ) const;
215 sal_Int64 Denormalize( sal_Int64 nValue ) const;
219 // - MetricFormatter -
222 class VCL_DLLPUBLIC MetricFormatter : public NumericFormatter
224 private:
225 SAL_DLLPRIVATE void ImplInit();
227 protected:
228 OUString maCustomUnitText;
229 OUString maCurUnitText;
230 sal_Int64 mnBaseValue;
231 FieldUnit meUnit;
232 Link<> maCustomConvertLink;
234 protected:
235 MetricFormatter();
237 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
238 SAL_DLLPRIVATE bool ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr );
240 public:
241 virtual ~MetricFormatter();
243 virtual void CustomConvert() = 0;
244 virtual void Reformat() SAL_OVERRIDE;
246 virtual void SetUnit( FieldUnit meUnit );
247 FieldUnit GetUnit() const { return meUnit; }
248 void SetCustomUnitText( const OUString& rStr );
249 const OUString& GetCustomUnitText() const { return maCustomUnitText; }
250 const OUString& GetCurUnitText() const { return maCurUnitText; }
252 using NumericFormatter::SetMax;
253 void SetMax( sal_Int64 nNewMax, FieldUnit eInUnit );
254 using NumericFormatter::GetMax;
255 sal_Int64 GetMax( FieldUnit eOutUnit ) const;
256 using NumericFormatter::SetMin;
257 void SetMin( sal_Int64 nNewMin, FieldUnit eInUnit );
258 using NumericFormatter::GetMin;
259 sal_Int64 GetMin( FieldUnit eOutUnit ) const;
260 void SetBaseValue( sal_Int64 nNewBase, FieldUnit eInUnit = FUNIT_NONE );
261 sal_Int64 GetBaseValue( FieldUnit eOutUnit = FUNIT_NONE ) const;
263 virtual void SetValue( sal_Int64 nNewValue, FieldUnit eInUnit );
264 virtual void SetValue( sal_Int64 nValue ) SAL_OVERRIDE;
265 using NumericFormatter::SetUserValue;
266 void SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit );
267 virtual sal_Int64 GetValue( FieldUnit eOutUnit ) const;
268 virtual sal_Int64 GetValue() const SAL_OVERRIDE;
269 virtual OUString CreateFieldText( sal_Int64 nValue ) const SAL_OVERRIDE;
270 using NumericFormatter::GetCorrectedValue;
271 sal_Int64 GetCorrectedValue( FieldUnit eOutUnit ) const;
273 void SetCustomConvertHdl( const Link<>& rLink ) { maCustomConvertLink = rLink; }
274 const Link<>& GetCustomConvertHdl() const { return maCustomConvertLink; }
279 // - CurrencyFormatter -
282 class VCL_DLLPUBLIC CurrencyFormatter : public NumericFormatter
284 private:
285 SAL_DLLPRIVATE void ImplInit();
287 protected:
288 CurrencyFormatter();
289 SAL_DLLPRIVATE bool ImplCurrencyReformat( const OUString& rStr, OUString& rOutStr );
291 public:
292 virtual ~CurrencyFormatter();
294 virtual void Reformat() SAL_OVERRIDE;
296 OUString GetCurrencySymbol() const;
298 virtual void SetValue( sal_Int64 nNewValue ) SAL_OVERRIDE;
299 virtual sal_Int64 GetValue() const SAL_OVERRIDE;
300 virtual OUString CreateFieldText( sal_Int64 nValue ) const SAL_OVERRIDE;
305 // - DateFormatter -
308 class VCL_DLLPUBLIC DateFormatter : public FormatterBase
310 private:
311 CalendarWrapper* mpCalendarWrapper;
312 Date maFieldDate;
313 Date maLastDate;
314 Date maMin;
315 Date maMax;
316 Date maCorrectedDate;
317 bool mbLongFormat;
318 bool mbShowDateCentury;
319 sal_uInt16 mnDateFormat;
320 sal_uLong mnExtDateFormat;
321 bool mbEnforceValidValue;
323 SAL_DLLPRIVATE void ImplInit();
325 protected:
326 DateFormatter();
328 SAL_DLLPRIVATE const Date& ImplGetFieldDate() const { return maFieldDate; }
329 SAL_DLLPRIVATE bool ImplDateReformat( const OUString& rStr, OUString& rOutStr,
330 const AllSettings& rSettings );
331 SAL_DLLPRIVATE void ImplSetUserDate( const Date& rNewDate,
332 Selection* pNewSelection = NULL );
333 SAL_DLLPRIVATE OUString ImplGetDateAsText( const Date& rDate,
334 const AllSettings& rSettings ) const;
335 SAL_DLLPRIVATE void ImplNewFieldValue( const Date& rDate );
336 CalendarWrapper& GetCalendarWrapper() const;
338 SAL_DLLPRIVATE bool ImplAllowMalformedInput() const;
340 public:
341 virtual ~DateFormatter();
343 virtual void Reformat() SAL_OVERRIDE;
344 virtual void ReformatAll() SAL_OVERRIDE;
346 virtual void SetLocale( const ::com::sun::star::lang::Locale& rLocale ) SAL_OVERRIDE;
349 void SetExtDateFormat( ExtDateFieldFormat eFormat );
350 ExtDateFieldFormat GetExtDateFormat( bool bResolveSystemFormat = false ) const;
352 void SetMin( const Date& rNewMin );
353 const Date& GetMin() const { return maMin; }
355 void SetMax( const Date& rNewMax );
356 const Date& GetMax() const { return maMax; }
360 // MT: Remove these methods too, ExtDateFormat should be enough!
361 // What should happen if using DDMMYYYY, but ShowCentury=false?
363 void SetLongFormat( bool bLong );
364 bool IsLongFormat() const { return mbLongFormat; }
365 void SetShowDateCentury( bool bShowCentury );
366 bool IsShowDateCentury() const { return mbShowDateCentury; }
369 void SetDate( const Date& rNewDate );
370 void SetUserDate( const Date& rNewDate );
371 Date GetDate() const;
372 void SetEmptyDate();
373 bool IsEmptyDate() const;
374 Date GetCorrectedDate() const { return maCorrectedDate; }
376 void ResetLastDate() { maLastDate = Date( 0, 0, 0 ); }
378 static void ExpandCentury( Date& rDate );
379 static void ExpandCentury( Date& rDate, sal_uInt16 nTwoDigitYearStart );
381 static Date GetInvalidDate() { return Date( 0, 0, 0 ); }
383 /** enables or disables the enforcement of valid values
385 If this is set to true (which is the default), then GetDate will always return a valid
386 date, no matter whether the current text can really be interpreted as date. (Note: this
387 is the compatible bahavior).
389 If this is set to false, the GetDate will return GetInvalidDate, in case the current text
390 cannot be interpreted as date.
392 In addition, if this is set to false, the text in the field will \em not be corrected
393 when the control loses the focus - instead, the invalid input will be preserved.
395 void EnforceValidValue( bool _bEnforce ) { mbEnforceValidValue = _bEnforce; }
396 inline bool IsEnforceValidValue( ) const { return mbEnforceValidValue; }
401 // - TimeFormatter -
404 class VCL_DLLPUBLIC TimeFormatter : public FormatterBase
406 private:
407 tools::Time maLastTime;
408 tools::Time maMin;
409 tools::Time maMax;
410 tools::Time maCorrectedTime;
411 TimeFieldFormat meFormat;
412 sal_uInt16 mnTimeFormat;
413 bool mbDuration;
414 bool mbEnforceValidValue;
416 SAL_DLLPRIVATE void ImplInit();
418 protected:
419 tools::Time maFieldTime;
421 TimeFormatter();
423 SAL_DLLPRIVATE bool ImplTimeReformat( const OUString& rStr, OUString& rOutStr );
424 SAL_DLLPRIVATE void ImplNewFieldValue( const tools::Time& rTime );
425 SAL_DLLPRIVATE void ImplSetUserTime( const tools::Time& rNewTime, Selection* pNewSelection = NULL );
426 SAL_DLLPRIVATE bool ImplAllowMalformedInput() const;
428 public:
430 enum TimeFormat {
431 HOUR_12,
432 HOUR_24
435 virtual ~TimeFormatter();
437 virtual void Reformat() SAL_OVERRIDE;
438 virtual void ReformatAll() SAL_OVERRIDE;
440 void SetMin( const tools::Time& rNewMin );
441 const tools::Time& GetMin() const { return maMin; }
442 void SetMax( const tools::Time& rNewMax );
443 const tools::Time& GetMax() const { return maMax; }
445 void SetTimeFormat( TimeFormat eNewFormat );
446 TimeFormat GetTimeFormat() const { return (TimeFormat)mnTimeFormat;}
448 void SetFormat( TimeFieldFormat eNewFormat );
449 TimeFieldFormat GetFormat() const { return meFormat; }
451 void SetDuration( bool mbDuration );
452 bool IsDuration() const { return mbDuration; }
454 void SetTime( const tools::Time& rNewTime );
455 void SetUserTime( const tools::Time& rNewTime );
456 tools::Time GetTime() const;
457 void SetEmptyTime() { FormatterBase::SetEmptyFieldValue(); }
458 bool IsEmptyTime() const { return FormatterBase::IsEmptyFieldValue(); }
459 tools::Time GetCorrectedTime() const { return maCorrectedTime; }
461 static tools::Time GetInvalidTime() { return tools::Time( 99, 99, 99 ); }
463 /** enables or disables the enforcement of valid values
465 If this is set to true (which is the default), then GetTime will always return a valid
466 time, no matter whether the current text can really be interpreted as time. (Note: this
467 is the compatible bahavior).
469 If this is set to false, the GetTime will return GetInvalidTime, in case the current text
470 cannot be interpreted as time.
472 In addition, if this is set to false, the text in the field will <em>not</em> be corrected
473 when the control loses the focus - instead, the invalid input will be preserved.
475 void EnforceValidValue( bool _bEnforce ) { mbEnforceValidValue = _bEnforce; }
476 inline bool IsEnforceValidValue( ) const { return mbEnforceValidValue; }
481 // - PatternField -
484 class VCL_DLLPUBLIC PatternField : public SpinField, public PatternFormatter
486 public:
487 explicit PatternField( vcl::Window* pParent, WinBits nWinStyle );
489 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
490 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
491 virtual void Modify() SAL_OVERRIDE;
492 virtual void dispose() SAL_OVERRIDE;
497 // - NumericField -
500 class VCL_DLLPUBLIC NumericField : public SpinField, public NumericFormatter
502 protected:
503 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
505 public:
506 explicit NumericField( vcl::Window* pParent, WinBits nWinStyle );
507 explicit NumericField( vcl::Window* pParent, const ResId& );
509 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
510 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
511 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
513 virtual Size CalcMinimumSize() const SAL_OVERRIDE;
515 virtual void Modify() SAL_OVERRIDE;
517 virtual void Up() SAL_OVERRIDE;
518 virtual void Down() SAL_OVERRIDE;
519 virtual void First() SAL_OVERRIDE;
520 virtual void Last() SAL_OVERRIDE;
521 virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
522 virtual void dispose() SAL_OVERRIDE;
527 // - MetricField -
530 class VCL_DLLPUBLIC MetricField : public SpinField, public MetricFormatter
532 protected:
533 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
535 public:
536 explicit MetricField( vcl::Window* pParent, WinBits nWinStyle );
537 explicit MetricField( vcl::Window* pParent, const ResId& );
539 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
540 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
541 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
543 virtual Size CalcMinimumSize() const SAL_OVERRIDE;
545 virtual void Modify() SAL_OVERRIDE;
547 virtual void Up() SAL_OVERRIDE;
548 virtual void Down() SAL_OVERRIDE;
549 virtual void First() SAL_OVERRIDE;
550 virtual void Last() SAL_OVERRIDE;
551 virtual void CustomConvert() SAL_OVERRIDE;
553 virtual void SetUnit( FieldUnit meUnit ) SAL_OVERRIDE;
555 void SetFirst( sal_Int64 nNewFirst, FieldUnit eInUnit );
556 inline void SetFirst(sal_Int64 first) { SetFirst(first, FUNIT_NONE); }
557 sal_Int64 GetFirst( FieldUnit eOutUnit ) const;
558 inline sal_Int64 GetFirst() const { return GetFirst(FUNIT_NONE); }
559 void SetLast( sal_Int64 nNewLast, FieldUnit eInUnit );
560 inline void SetLast(sal_Int64 last) { SetLast(last, FUNIT_NONE); }
561 sal_Int64 GetLast( FieldUnit eOutUnit ) const;
562 inline sal_Int64 GetLast() const { return GetLast(FUNIT_NONE); }
564 static void SetDefaultUnit( FieldUnit eDefaultUnit );
565 static FieldUnit GetDefaultUnit();
566 static sal_Int64 ConvertValue( sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits,
567 FieldUnit eInUnit, FieldUnit eOutUnit );
568 static sal_Int64 ConvertValue( sal_Int64 nValue, sal_uInt16 nDecDigits,
569 MapUnit eInUnit, FieldUnit eOutUnit );
571 // for backwards compatibility
572 // caution: conversion to double loses precision
573 static double ConvertDoubleValue( double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits,
574 FieldUnit eInUnit, FieldUnit eOutUnit );
575 static double ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits,
576 FieldUnit eInUnit, MapUnit eOutUnit );
577 static double ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits,
578 MapUnit eInUnit, FieldUnit eOutUnit );
580 // for backwards compatibility
581 // caution: conversion to double loses precision
582 static double ConvertDoubleValue( sal_Int64 nValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits,
583 FieldUnit eInUnit, FieldUnit eOutUnit )
584 { return ConvertDoubleValue( static_cast<double>(nValue), nBaseValue, nDecDigits, eInUnit, eOutUnit ); }
585 static double ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits,
586 FieldUnit eInUnit, MapUnit eOutUnit )
587 { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); }
588 static double ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits,
589 MapUnit eInUnit, FieldUnit eOutUnit )
590 { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); }
592 virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
593 virtual void dispose() SAL_OVERRIDE;
598 // - CurrencyField -
601 class VCL_DLLPUBLIC CurrencyField : public SpinField, public CurrencyFormatter
603 public:
604 CurrencyField( vcl::Window* pParent, WinBits nWinStyle );
606 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
607 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
608 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
610 virtual void Modify() SAL_OVERRIDE;
612 virtual void Up() SAL_OVERRIDE;
613 virtual void Down() SAL_OVERRIDE;
614 virtual void First() SAL_OVERRIDE;
615 virtual void Last() SAL_OVERRIDE;
616 virtual void dispose() SAL_OVERRIDE;
621 // - DateField -
624 class VCL_DLLPUBLIC DateField : public SpinField, public DateFormatter
626 private:
627 Date maFirst;
628 Date maLast;
630 protected:
631 SAL_DLLPRIVATE void ImplDateSpinArea( bool bUp );
633 public:
634 explicit DateField( vcl::Window* pParent, WinBits nWinStyle );
636 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
637 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
638 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
640 virtual void Modify() SAL_OVERRIDE;
642 virtual void Up() SAL_OVERRIDE;
643 virtual void Down() SAL_OVERRIDE;
644 virtual void First() SAL_OVERRIDE;
645 virtual void Last() SAL_OVERRIDE;
647 void SetFirst( const Date& rNewFirst ) { maFirst = rNewFirst; }
648 Date GetFirst() const { return maFirst; }
649 void SetLast( const Date& rNewLast ) { maLast = rNewLast; }
650 Date GetLast() const { return maLast; }
651 virtual void dispose() SAL_OVERRIDE;
655 // - TimeField -
658 class VCL_DLLPUBLIC TimeField : public SpinField, public TimeFormatter
660 private:
661 tools::Time maFirst;
662 tools::Time maLast;
664 protected:
665 SAL_DLLPRIVATE void ImplTimeSpinArea( bool bUp );
667 public:
668 explicit TimeField( vcl::Window* pParent, WinBits nWinStyle );
670 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
671 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
672 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
674 virtual void Modify() SAL_OVERRIDE;
676 virtual void Up() SAL_OVERRIDE;
677 virtual void Down() SAL_OVERRIDE;
678 virtual void First() SAL_OVERRIDE;
679 virtual void Last() SAL_OVERRIDE;
681 void SetFirst( const tools::Time& rNewFirst ) { maFirst = rNewFirst; }
682 tools::Time GetFirst() const { return maFirst; }
683 void SetLast( const tools::Time& rNewLast ) { maLast = rNewLast; }
684 tools::Time GetLast() const { return maLast; }
686 void SetExtFormat( ExtTimeFieldFormat eFormat );
687 virtual void dispose() SAL_OVERRIDE;
692 // - PatternBox -
695 class VCL_DLLPUBLIC PatternBox : public ComboBox, public PatternFormatter
697 public:
698 PatternBox( vcl::Window* pParent, WinBits nWinStyle );
700 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
701 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
703 virtual void Modify() SAL_OVERRIDE;
705 virtual void ReformatAll() SAL_OVERRIDE;
706 virtual void dispose() SAL_OVERRIDE;
711 // - NumericBox -
714 class VCL_DLLPUBLIC NumericBox : public ComboBox, public NumericFormatter
716 public:
717 explicit NumericBox( vcl::Window* pParent, WinBits nWinStyle );
719 virtual Size CalcMinimumSize() const SAL_OVERRIDE;
721 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
722 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
723 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
725 virtual void Modify() SAL_OVERRIDE;
727 virtual void ReformatAll() SAL_OVERRIDE;
729 void InsertValue( sal_Int64 nValue, sal_Int32 nPos = COMBOBOX_APPEND );
730 virtual void dispose() SAL_OVERRIDE;
735 // - MetricBox -
738 class VCL_DLLPUBLIC MetricBox : public ComboBox, public MetricFormatter
740 public:
741 explicit MetricBox( vcl::Window* pParent, WinBits nWinStyle );
743 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
744 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
745 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
747 virtual Size CalcMinimumSize() const SAL_OVERRIDE;
749 virtual void Modify() SAL_OVERRIDE;
751 virtual void CustomConvert() SAL_OVERRIDE;
752 virtual void ReformatAll() SAL_OVERRIDE;
754 void InsertValue( sal_Int64 nValue, FieldUnit eInUnit = FUNIT_NONE,
755 sal_Int32 nPos = COMBOBOX_APPEND );
756 sal_Int64 GetValue( sal_Int32 nPos, FieldUnit eOutUnit = FUNIT_NONE ) const;
757 sal_Int32 GetValuePos( sal_Int64 nValue,
758 FieldUnit eInUnit = FUNIT_NONE ) const;
760 // Needed, because GetValue() with nPos hide these functions
761 virtual sal_Int64 GetValue( FieldUnit eOutUnit ) const SAL_OVERRIDE;
762 virtual sal_Int64 GetValue() const SAL_OVERRIDE;
764 virtual void dispose() SAL_OVERRIDE;
769 // - CurrencyBox -
772 class VCL_DLLPUBLIC CurrencyBox : public ComboBox, public CurrencyFormatter
774 public:
775 explicit CurrencyBox( vcl::Window* pParent, WinBits nWinStyle );
777 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
778 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
779 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
781 virtual void Modify() SAL_OVERRIDE;
783 virtual void ReformatAll() SAL_OVERRIDE;
785 virtual sal_Int64 GetValue() const SAL_OVERRIDE;
786 virtual void dispose() SAL_OVERRIDE;
790 // - DateBox -
793 class VCL_DLLPUBLIC DateBox : public ComboBox, public DateFormatter
795 public:
796 explicit DateBox( vcl::Window* pParent, WinBits nWinStyle );
798 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
799 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
800 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
802 virtual void Modify() SAL_OVERRIDE;
804 virtual void ReformatAll() SAL_OVERRIDE;
805 virtual void dispose() SAL_OVERRIDE;
810 // - TimeBox -
813 class VCL_DLLPUBLIC TimeBox : public ComboBox, public TimeFormatter
815 public:
816 explicit TimeBox( vcl::Window* pParent, WinBits nWinStyle );
818 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
819 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
820 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
822 virtual void Modify() SAL_OVERRIDE;
824 virtual void ReformatAll() SAL_OVERRIDE;
825 virtual void dispose() SAL_OVERRIDE;
828 #endif // INCLUDED_VCL_FIELD_HXX
830 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */