1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #include <vcl/dllapi.h>
25 #include <tools/link.hxx>
26 #include <tools/date.hxx>
27 #include <tools/time.hxx>
28 #include <vcl/spinfld.hxx>
29 #include <vcl/combobox.hxx>
30 #include <tools/fldunit.hxx>
32 namespace com
{ namespace sun
{ namespace star
{ namespace lang
{ struct Locale
; } } } }
34 class CalendarWrapper
;
35 class LocaleDataWrapper
;
39 class VCL_DLLPUBLIC FormatterBase
43 std::unique_ptr
<LocaleDataWrapper
>
47 bool mbEmptyFieldValue
;
48 bool mbEmptyFieldValueEnabled
;
51 SAL_DLLPRIVATE
void ImplSetText( const OUString
& rText
, Selection
const * pNewSel
= nullptr );
52 SAL_DLLPRIVATE
bool ImplGetEmptyFieldValue() const { return mbEmptyFieldValue
; }
54 void SetEmptyFieldValueData( bool bValue
) { mbEmptyFieldValue
= bValue
; }
56 SAL_DLLPRIVATE LocaleDataWrapper
& ImplGetLocaleDataWrapper() const;
58 Edit
* GetField() const { return mpField
; }
59 void ClearField() { mpField
.clear(); }
62 explicit FormatterBase(Edit
* pField
);
63 virtual ~FormatterBase();
65 const LocaleDataWrapper
& GetLocaleDataWrapper() const;
67 bool MustBeReformatted() const { return mbReformat
; }
68 void MarkToBeReformatted( bool b
) { mbReformat
= b
; }
70 void SetStrictFormat( bool bStrict
);
71 bool IsStrictFormat() const { return mbStrictFormat
; }
73 virtual void Reformat();
74 virtual void ReformatAll();
76 const css::lang::Locale
& GetLocale() const;
77 const LanguageTag
& GetLanguageTag() const;
79 void SetEmptyFieldValue();
80 bool IsEmptyFieldValue() const;
82 void EnableEmptyFieldValue( bool bEnable
) { mbEmptyFieldValueEnabled
= bEnable
; }
83 bool IsEmptyFieldValueEnabled() const { return mbEmptyFieldValueEnabled
; }
86 #define PATTERN_FORMAT_EMPTYLITERALS (sal_uInt16(0x0001))
88 class VCL_DLLPUBLIC PatternFormatter
: public FormatterBase
92 OUString maLiteralMask
;
94 bool mbInPattKeyInput
;
97 PatternFormatter(Edit
* pEdit
);
99 SAL_DLLPRIVATE
void ImplSetMask(const OString
& rEditMask
,
100 const OUString
& rLiteralMask
);
101 SAL_DLLPRIVATE
bool ImplIsSameMask() const { return mbSameMask
; }
102 SAL_DLLPRIVATE
bool& ImplGetInPattKeyInput() { return mbInPattKeyInput
; }
105 virtual ~PatternFormatter() override
;
107 virtual void Reformat() override
;
109 void SetMask(const OString
& rEditMask
, const OUString
& rLiteralMask
);
110 const OString
& GetEditMask() const { return m_aEditMask
; }
111 const OUString
& GetLiteralMask() const { return maLiteralMask
; }
113 void SetString( const OUString
& rStr
);
114 OUString
GetString() const;
118 class VCL_DLLPUBLIC NumericFormatter
: public FormatterBase
121 virtual ~NumericFormatter() override
;
123 virtual void Reformat() override
;
125 void SetMin( sal_Int64 nNewMin
);
126 sal_Int64
GetMin() const { return mnMin
; }
127 void SetMax( sal_Int64 nNewMax
);
128 sal_Int64
GetMax() const { return mnMax
; }
130 sal_Int64
ClipAgainstMinMax(sal_Int64 nValue
) const;
132 void SetFirst( sal_Int64 nNewFirst
) { mnFirst
= nNewFirst
; }
133 sal_Int64
GetFirst() const { return mnFirst
; }
134 void SetLast( sal_Int64 nNewLast
) { mnLast
= nNewLast
; }
135 sal_Int64
GetLast() const { return mnLast
; }
136 void SetSpinSize( sal_Int64 nNewSize
) { mnSpinSize
= nNewSize
; }
137 sal_Int64
GetSpinSize() const { return mnSpinSize
; }
139 void SetDecimalDigits( sal_uInt16 nDigits
);
140 sal_uInt16
GetDecimalDigits() const { return mnDecimalDigits
;}
142 void SetUseThousandSep( bool b
);
143 bool IsUseThousandSep() const { return mbThousandSep
; }
145 void SetShowTrailingZeros( bool bShowTrailingZeros
);
146 bool IsShowTrailingZeros() const { return mbShowTrailingZeros
; }
148 void SetUserValue( sal_Int64 nNewValue
);
149 virtual void SetValue( sal_Int64 nNewValue
);
150 sal_Int64
GetValue() const;
151 virtual OUString
CreateFieldText( sal_Int64 nValue
) const;
152 bool IsValueModified() const;
154 sal_Int64
Normalize( sal_Int64 nValue
) const;
155 sal_Int64
Denormalize( sal_Int64 nValue
) const;
158 sal_Int64 mnFieldValue
;
159 sal_Int64 mnLastValue
;
165 // the members below are used in all derivatives of NumericFormatter
166 // not in NumericFormatter itself.
167 sal_Int64 mnSpinSize
;
171 NumericFormatter(Edit
* pEdit
);
177 void FormatValue(Selection
const * pNewSelection
= nullptr);
179 SAL_DLLPRIVATE
void ImplNumericReformat();
180 SAL_DLLPRIVATE
void ImplNewFieldValue( sal_Int64 nNewValue
);
181 SAL_DLLPRIVATE
void ImplSetUserValue( sal_Int64 nNewValue
, Selection
const * pNewSelection
= nullptr );
183 virtual sal_Int64
GetValueFromString(const OUString
& rStr
) const;
186 SAL_DLLPRIVATE
void ImplInit();
188 sal_uInt16 mnDecimalDigits
;
190 bool mbShowTrailingZeros
;
195 class VCL_DLLPUBLIC MetricFormatter
: public NumericFormatter
198 virtual ~MetricFormatter() override
;
200 virtual void CustomConvert() = 0;
201 virtual void Reformat() override
;
203 virtual void SetUnit( FieldUnit meUnit
);
204 FieldUnit
GetUnit() const { return meUnit
; }
205 void SetCustomUnitText( const OUString
& rStr
);
206 const OUString
& GetCustomUnitText() const { return maCustomUnitText
; }
207 const OUString
& GetCurUnitText() const { return maCurUnitText
; }
209 using NumericFormatter::SetMax
;
210 void SetMax( sal_Int64 nNewMax
, FieldUnit eInUnit
);
211 using NumericFormatter::GetMax
;
212 sal_Int64
GetMax( FieldUnit eOutUnit
) const;
213 using NumericFormatter::SetMin
;
214 void SetMin( sal_Int64 nNewMin
, FieldUnit eInUnit
);
215 using NumericFormatter::GetMin
;
216 sal_Int64
GetMin( FieldUnit eOutUnit
) const;
217 void SetBaseValue( sal_Int64 nNewBase
, FieldUnit eInUnit
= FieldUnit::NONE
);
218 sal_Int64
GetBaseValue() const;
220 virtual void SetValue( sal_Int64 nNewValue
, FieldUnit eInUnit
);
221 virtual void SetValue( sal_Int64 nValue
) override
;
222 using NumericFormatter::SetUserValue
;
223 void SetUserValue( sal_Int64 nNewValue
, FieldUnit eInUnit
);
224 using NumericFormatter::GetValue
;
225 sal_Int64
GetValue( FieldUnit eOutUnit
) const;
226 virtual OUString
CreateFieldText( sal_Int64 nValue
) const override
;
227 sal_Int64
GetCorrectedValue( FieldUnit eOutUnit
) const;
229 void SetCustomConvertHdl( const Link
<MetricFormatter
&,void>& rLink
) { maCustomConvertLink
= rLink
; }
231 static FieldUnit
StringToMetric(const OUString
&rMetricString
);
232 static bool TextToValue(const OUString
& rStr
, double& rValue
, sal_Int64 nBaseValue
, sal_uInt16 nDecDigits
, const LocaleDataWrapper
& rLocaleDataWrapper
, FieldUnit eUnit
);
235 sal_Int64 mnBaseValue
;
237 Link
<MetricFormatter
&,void> maCustomConvertLink
;
239 MetricFormatter(Edit
* pEdit
);
241 SAL_DLLPRIVATE
void ImplMetricReformat( const OUString
& rStr
, double& rValue
, OUString
& rOutStr
);
243 virtual sal_Int64
GetValueFromString(const OUString
& rStr
) const override
;
244 virtual sal_Int64
GetValueFromStringUnit(const OUString
& rStr
, FieldUnit eOutUnit
) const;
247 SAL_DLLPRIVATE
void ImplInit();
249 OUString maCustomUnitText
;
250 OUString maCurUnitText
;
254 class VCL_DLLPUBLIC CurrencyFormatter
: public NumericFormatter
257 CurrencyFormatter(Edit
* pEdit
);
258 SAL_DLLPRIVATE
void ImplCurrencyReformat( const OUString
& rStr
, OUString
& rOutStr
);
259 virtual sal_Int64
GetValueFromString(const OUString
& rStr
) const override
;
262 virtual ~CurrencyFormatter() override
;
264 virtual void Reformat() override
;
266 virtual void SetValue( sal_Int64 nNewValue
) override
;
267 virtual OUString
CreateFieldText( sal_Int64 nValue
) const override
;
271 class VCL_DLLPUBLIC DateFormatter
: public FormatterBase
274 std::unique_ptr
<CalendarWrapper
> mpCalendarWrapper
;
280 bool mbShowDateCentury
;
281 ExtDateFieldFormat mnExtDateFormat
;
282 bool mbEnforceValidValue
;
284 SAL_DLLPRIVATE
void ImplInit();
287 DateFormatter(Edit
* pEdit
);
289 SAL_DLLPRIVATE
const Date
& ImplGetFieldDate() const { return maFieldDate
; }
290 SAL_DLLPRIVATE
void ImplDateReformat( const OUString
& rStr
, OUString
& rOutStr
);
291 SAL_DLLPRIVATE
void ImplSetUserDate( const Date
& rNewDate
,
292 Selection
const * pNewSelection
= nullptr );
293 SAL_DLLPRIVATE OUString
ImplGetDateAsText( const Date
& rDate
) const;
294 SAL_DLLPRIVATE
void ImplNewFieldValue( const Date
& rDate
);
295 CalendarWrapper
& GetCalendarWrapper() const;
297 SAL_DLLPRIVATE
bool ImplAllowMalformedInput() const;
300 virtual ~DateFormatter() override
;
302 virtual void Reformat() override
;
303 virtual void ReformatAll() override
;
305 void SetExtDateFormat( ExtDateFieldFormat eFormat
);
306 ExtDateFieldFormat
GetExtDateFormat( bool bResolveSystemFormat
= false ) const;
308 void SetMin( const Date
& rNewMin
);
309 const Date
& GetMin() const { return maMin
; }
311 void SetMax( const Date
& rNewMax
);
312 const Date
& GetMax() const { return maMax
; }
315 // MT: Remove these methods too, ExtDateFormat should be enough!
316 // What should happen if using DDMMYYYY, but ShowCentury=false?
318 void SetLongFormat( bool bLong
);
319 bool IsLongFormat() const { return mbLongFormat
; }
320 void SetShowDateCentury( bool bShowCentury
);
321 bool IsShowDateCentury() const { return mbShowDateCentury
; }
324 void SetDate( const Date
& rNewDate
);
325 Date
GetDate() const;
327 bool IsEmptyDate() const;
329 void ResetLastDate() { maLastDate
= Date( Date::EMPTY
); }
331 static void ExpandCentury( Date
& rDate
);
332 static void ExpandCentury( Date
& rDate
, sal_uInt16 nTwoDigitYearStart
);
334 /** enables or disables the enforcement of valid values
336 If this is set to true (which is the default), then GetDate will always return a valid
337 date, no matter whether the current text can really be interpreted as date. (Note: this
338 is the compatible behavior).
340 If this is set to false, the GetDate will return GetInvalidDate, in case the current text
341 cannot be interpreted as date.
343 In addition, if this is set to false, the text in the field will \em not be corrected
344 when the control loses the focus - instead, the invalid input will be preserved.
346 void EnforceValidValue( bool _bEnforce
) { mbEnforceValidValue
= _bEnforce
; }
347 bool IsEnforceValidValue( ) const { return mbEnforceValidValue
; }
351 class VCL_DLLPUBLIC TimeFormatter
: public FormatterBase
354 tools::Time maLastTime
;
357 TimeFieldFormat meFormat
;
358 TimeFormat mnTimeFormat
;
360 bool mbEnforceValidValue
;
362 SAL_DLLPRIVATE
void ImplInit();
365 tools::Time maFieldTime
;
367 TimeFormatter(Edit
* pEdit
);
369 SAL_DLLPRIVATE
void ImplTimeReformat( const OUString
& rStr
, OUString
& rOutStr
);
370 SAL_DLLPRIVATE
void ImplNewFieldValue( const tools::Time
& rTime
);
371 SAL_DLLPRIVATE
void ImplSetUserTime( const tools::Time
& rNewTime
, Selection
const * pNewSelection
= nullptr );
372 SAL_DLLPRIVATE
bool ImplAllowMalformedInput() const;
375 static OUString
FormatTime(const tools::Time
& rNewTime
, TimeFieldFormat eFormat
, TimeFormat eHourFormat
, bool bDuration
, const LocaleDataWrapper
& rLocaleData
);
376 static bool TextToTime(const OUString
& rStr
, tools::Time
& rTime
, TimeFieldFormat eFormat
, bool bDuration
, const LocaleDataWrapper
& rLocaleDataWrapper
, bool _bSkipInvalidCharacters
= true);
377 static int GetTimeArea(TimeFieldFormat eFormat
, const OUString
& rText
, int nCursor
,
378 const LocaleDataWrapper
& rLocaleDataWrapper
);
379 static tools::Time
SpinTime(bool bUp
, const tools::Time
& rTime
, TimeFieldFormat eFormat
,
380 bool bDuration
, const OUString
& rText
, int nCursor
,
381 const LocaleDataWrapper
& rLocaleDataWrapper
);
383 virtual ~TimeFormatter() override
;
385 virtual void Reformat() override
;
386 virtual void ReformatAll() override
;
388 void SetMin( const tools::Time
& rNewMin
);
389 const tools::Time
& GetMin() const { return maMin
; }
390 void SetMax( const tools::Time
& rNewMax
);
391 const tools::Time
& GetMax() const { return maMax
; }
393 void SetTimeFormat( TimeFormat eNewFormat
);
394 TimeFormat
GetTimeFormat() const { return mnTimeFormat
;}
396 void SetFormat( TimeFieldFormat eNewFormat
);
397 TimeFieldFormat
GetFormat() const { return meFormat
; }
399 void SetDuration( bool mbDuration
);
400 bool IsDuration() const { return mbDuration
; }
402 void SetTime( const tools::Time
& rNewTime
);
403 void SetUserTime( const tools::Time
& rNewTime
);
404 tools::Time
GetTime() const;
405 void SetEmptyTime() { FormatterBase::SetEmptyFieldValue(); }
406 bool IsEmptyTime() const { return FormatterBase::IsEmptyFieldValue(); }
408 /** enables or disables the enforcement of valid values
410 If this is set to true (which is the default), then GetTime will always return a valid
411 time, no matter whether the current text can really be interpreted as time. (Note: this
412 is the compatible behavior).
414 If this is set to false, the GetTime will return GetInvalidTime, in case the current text
415 cannot be interpreted as time.
417 In addition, if this is set to false, the text in the field will <em>not</em> be corrected
418 when the control loses the focus - instead, the invalid input will be preserved.
420 void EnforceValidValue( bool _bEnforce
) { mbEnforceValidValue
= _bEnforce
; }
421 bool IsEnforceValidValue( ) const { return mbEnforceValidValue
; }
425 class VCL_DLLPUBLIC PatternField
: public SpinField
, public PatternFormatter
428 explicit PatternField( vcl::Window
* pParent
, WinBits nWinStyle
);
430 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
431 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
432 virtual void Modify() override
;
433 virtual void dispose() override
;
437 class VCL_DLLPUBLIC NumericField
: public SpinField
, public NumericFormatter
440 explicit NumericField( vcl::Window
* pParent
, WinBits nWinStyle
);
442 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
443 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
444 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
446 virtual Size
CalcMinimumSize() const override
;
448 virtual void Modify() override
;
450 virtual void Up() override
;
451 virtual void Down() override
;
452 virtual void First() override
;
453 virtual void Last() override
;
454 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
455 virtual void dispose() override
;
459 class VCL_DLLPUBLIC MetricField
: public SpinField
, public MetricFormatter
462 explicit MetricField( vcl::Window
* pParent
, WinBits nWinStyle
);
464 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
465 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
466 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
468 virtual Size
CalcMinimumSize() const override
;
470 virtual void Modify() override
;
472 virtual void Up() override
;
473 virtual void Down() override
;
474 virtual void First() override
;
475 virtual void Last() override
;
476 virtual void CustomConvert() override
;
478 virtual void SetUnit( FieldUnit meUnit
) override
;
480 void SetFirst( sal_Int64 nNewFirst
, FieldUnit eInUnit
);
481 void SetFirst(sal_Int64 first
) { SetFirst(first
, FieldUnit::NONE
); }
482 sal_Int64
GetFirst( FieldUnit eOutUnit
) const;
483 void SetLast( sal_Int64 nNewLast
, FieldUnit eInUnit
);
484 void SetLast(sal_Int64 last
) { SetLast(last
, FieldUnit::NONE
); }
485 sal_Int64
GetLast( FieldUnit eOutUnit
) const;
487 static void SetDefaultUnit( FieldUnit eDefaultUnit
);
488 static FieldUnit
GetDefaultUnit();
489 static sal_Int64
ConvertValue( sal_Int64 nValue
, sal_Int64 mnBaseValue
, sal_uInt16 nDecDigits
,
490 FieldUnit eInUnit
, FieldUnit eOutUnit
);
491 static sal_Int64
ConvertValue( sal_Int64 nValue
, sal_uInt16 nDecDigits
,
492 MapUnit eInUnit
, FieldUnit eOutUnit
);
494 // for backwards compatibility
495 // caution: conversion to double loses precision
496 static double ConvertDoubleValue( double nValue
, sal_Int64 mnBaseValue
, sal_uInt16 nDecDigits
,
497 FieldUnit eInUnit
, FieldUnit eOutUnit
);
498 static double ConvertDoubleValue( double nValue
, sal_uInt16 nDecDigits
,
499 FieldUnit eInUnit
, MapUnit eOutUnit
);
500 static double ConvertDoubleValue( double nValue
, sal_uInt16 nDecDigits
,
501 MapUnit eInUnit
, FieldUnit eOutUnit
);
503 // for backwards compatibility
504 // caution: conversion to double loses precision
505 static double ConvertDoubleValue( sal_Int64 nValue
, sal_Int64 nBaseValue
, sal_uInt16 nDecDigits
,
506 FieldUnit eInUnit
, FieldUnit eOutUnit
)
507 { return ConvertDoubleValue( static_cast<double>(nValue
), nBaseValue
, nDecDigits
, eInUnit
, eOutUnit
); }
508 static double ConvertDoubleValue( sal_Int64 nValue
, sal_uInt16 nDecDigits
,
509 FieldUnit eInUnit
, MapUnit eOutUnit
)
510 { return ConvertDoubleValue( static_cast<double>(nValue
), nDecDigits
, eInUnit
, eOutUnit
); }
511 static double ConvertDoubleValue( sal_Int64 nValue
, sal_uInt16 nDecDigits
,
512 MapUnit eInUnit
, FieldUnit eOutUnit
)
513 { return ConvertDoubleValue( static_cast<double>(nValue
), nDecDigits
, eInUnit
, eOutUnit
); }
515 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
516 virtual void dispose() override
;
520 class VCL_DLLPUBLIC CurrencyField
: public SpinField
, public CurrencyFormatter
523 CurrencyField( vcl::Window
* pParent
, WinBits nWinStyle
);
525 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
526 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
527 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
529 virtual void Modify() override
;
531 virtual void Up() override
;
532 virtual void Down() override
;
533 virtual void First() override
;
534 virtual void Last() override
;
535 virtual void dispose() override
;
539 class VCL_DLLPUBLIC DateField
: public SpinField
, public DateFormatter
546 SAL_DLLPRIVATE
void ImplDateSpinArea( bool bUp
);
549 explicit DateField( vcl::Window
* pParent
, WinBits nWinStyle
);
551 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
552 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
553 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
555 virtual void Modify() override
;
557 virtual void Up() override
;
558 virtual void Down() override
;
559 virtual void First() override
;
560 virtual void Last() override
;
562 void SetFirst( const Date
& rNewFirst
) { maFirst
= rNewFirst
; }
563 const Date
& GetFirst() const { return maFirst
; }
564 void SetLast( const Date
& rNewLast
) { maLast
= rNewLast
; }
565 const Date
& GetLast() const { return maLast
; }
566 virtual void dispose() override
;
570 class VCL_DLLPUBLIC TimeField
: public SpinField
, public TimeFormatter
577 SAL_DLLPRIVATE
void ImplTimeSpinArea( bool bUp
);
580 explicit TimeField( vcl::Window
* pParent
, WinBits nWinStyle
);
582 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
583 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
584 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
586 virtual void Modify() override
;
588 virtual void Up() override
;
589 virtual void Down() override
;
590 virtual void First() override
;
591 virtual void Last() override
;
593 void SetFirst( const tools::Time
& rNewFirst
) { maFirst
= rNewFirst
; }
594 const tools::Time
& GetFirst() const { return maFirst
; }
595 void SetLast( const tools::Time
& rNewLast
) { maLast
= rNewLast
; }
596 const tools::Time
& GetLast() const { return maLast
; }
598 void SetExtFormat( ExtTimeFieldFormat eFormat
);
599 virtual void dispose() override
;
603 class VCL_DLLPUBLIC PatternBox
: public ComboBox
, public PatternFormatter
606 PatternBox( vcl::Window
* pParent
, WinBits nWinStyle
);
608 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
609 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
611 virtual void Modify() override
;
613 virtual void ReformatAll() override
;
614 virtual void dispose() override
;
618 class VCL_DLLPUBLIC NumericBox
: public ComboBox
, public NumericFormatter
620 SAL_DLLPRIVATE
void ImplNumericReformat( const OUString
& rStr
, sal_Int64
& rValue
, OUString
& rOutStr
);
622 explicit NumericBox( vcl::Window
* pParent
, WinBits nWinStyle
);
624 virtual Size
CalcMinimumSize() const override
;
626 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
627 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
628 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
630 virtual void Modify() override
;
632 virtual void ReformatAll() override
;
634 void InsertValue( sal_Int64 nValue
, sal_Int32 nPos
= COMBOBOX_APPEND
);
635 virtual void dispose() override
;
639 class VCL_DLLPUBLIC MetricBox
: public ComboBox
, public MetricFormatter
642 explicit MetricBox( vcl::Window
* pParent
, WinBits nWinStyle
);
644 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
645 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
646 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
648 virtual Size
CalcMinimumSize() const override
;
650 virtual void Modify() override
;
652 virtual void CustomConvert() override
;
653 virtual void ReformatAll() override
;
655 void InsertValue( sal_Int64 nValue
, FieldUnit eInUnit
= FieldUnit::NONE
,
656 sal_Int32 nPos
= COMBOBOX_APPEND
);
658 // Needed, because GetValue() with nPos hide these functions
659 using MetricFormatter::GetValue
;
661 virtual void dispose() override
;
665 class VCL_DLLPUBLIC CurrencyBox
: public ComboBox
, public CurrencyFormatter
668 explicit CurrencyBox( vcl::Window
* pParent
, WinBits nWinStyle
);
670 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
671 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
672 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
674 virtual void Modify() override
;
676 virtual void ReformatAll() override
;
678 virtual void dispose() override
;
682 class VCL_DLLPUBLIC DateBox
: public ComboBox
, public DateFormatter
685 explicit DateBox( vcl::Window
* pParent
, WinBits nWinStyle
);
687 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
688 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
689 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
691 virtual void Modify() override
;
693 virtual void ReformatAll() override
;
694 virtual void dispose() override
;
698 class VCL_DLLPUBLIC TimeBox
: public ComboBox
, public TimeFormatter
701 explicit TimeBox( vcl::Window
* pParent
, WinBits nWinStyle
);
703 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
704 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
705 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
707 virtual void Modify() override
;
709 virtual void ReformatAll() override
;
710 virtual void dispose() override
;
713 #endif // INCLUDED_VCL_FIELD_HXX
715 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */