Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_LONGCURR_HXX
21 : #define INCLUDED_VCL_LONGCURR_HXX
22 :
23 : #include <vcl/dllapi.h>
24 : #include <tools/bigint.hxx>
25 : #include <vcl/field.hxx>
26 :
27 : class LocaleDataWrapper;
28 :
29 :
30 : // - LongCurrencyFormatter -
31 :
32 :
33 : class VCL_DLLPUBLIC LongCurrencyFormatter : public FormatterBase
34 : {
35 : private:
36 : SAL_DLLPRIVATE friend bool ImplLongCurrencyReformat( const OUString&, BigInt, BigInt, sal_uInt16, const LocaleDataWrapper&, OUString&, LongCurrencyFormatter& );
37 : SAL_DLLPRIVATE void ImpInit();
38 :
39 : protected:
40 : BigInt mnFieldValue;
41 : BigInt mnLastValue;
42 : BigInt mnMin;
43 : BigInt mnMax;
44 : BigInt mnCorrectedValue;
45 : OUString maCurrencySymbol;
46 : sal_uInt16 mnType;
47 : sal_uInt16 mnDecimalDigits;
48 : bool mbThousandSep;
49 :
50 : LongCurrencyFormatter();
51 : public:
52 : virtual ~LongCurrencyFormatter();
53 :
54 : virtual void Reformat() SAL_OVERRIDE;
55 : virtual void ReformatAll() SAL_OVERRIDE;
56 :
57 : void SetUseThousandSep( bool b );
58 0 : bool IsUseThousandSep() const { return mbThousandSep; }
59 :
60 : void SetCurrencySymbol( const OUString& rStr );
61 : OUString GetCurrencySymbol() const;
62 :
63 : void SetMin( BigInt nNewMin );
64 0 : BigInt GetMin() const { return mnMin; }
65 : void SetMax( BigInt nNewMax );
66 0 : BigInt GetMax() const { return mnMax; }
67 :
68 : void SetDecimalDigits( sal_uInt16 nDigits );
69 0 : sal_uInt16 GetDecimalDigits() const { return mnDecimalDigits;}
70 : void SetValue( BigInt nNewValue );
71 : void SetUserValue( BigInt nNewValue );
72 : BigInt GetValue() const;
73 : bool IsEmptyValue() const { return GetField()->GetText().isEmpty(); }
74 :
75 : BigInt GetCorrectedValue() const { return mnCorrectedValue; }
76 : };
77 :
78 :
79 : // - LongCurrencyField -
80 :
81 :
82 : class VCL_DLLPUBLIC LongCurrencyField : public SpinField, public LongCurrencyFormatter
83 : {
84 : friend void ImplNewLongCurrencyFieldValue( LongCurrencyField*, BigInt );
85 :
86 : private:
87 : BigInt mnSpinSize;
88 : BigInt mnFirst;
89 : BigInt mnLast;
90 :
91 : public:
92 : LongCurrencyField( vcl::Window* pParent, WinBits nWinStyle );
93 : virtual ~LongCurrencyField();
94 :
95 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
96 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
97 :
98 : void Modify() SAL_OVERRIDE;
99 : void Up() SAL_OVERRIDE;
100 : void Down() SAL_OVERRIDE;
101 : void First() SAL_OVERRIDE;
102 : void Last() SAL_OVERRIDE;
103 :
104 0 : void SetFirst( BigInt nNewFirst ) { mnFirst = nNewFirst; }
105 0 : BigInt GetFirst() const { return mnFirst; }
106 0 : void SetLast( BigInt nNewLast ) { mnLast = nNewLast; }
107 0 : BigInt GetLast() const { return mnLast; }
108 0 : void SetSpinSize( BigInt nNewSize ) { mnSpinSize = nNewSize; }
109 0 : BigInt GetSpinSize() const { return mnSpinSize; }
110 : };
111 :
112 :
113 : // - LongCurrencyBox -
114 :
115 :
116 : class VCL_DLLPUBLIC LongCurrencyBox : public ComboBox, public LongCurrencyFormatter
117 : {
118 : public:
119 : LongCurrencyBox( vcl::Window* pParent, WinBits nWinStyle );
120 : virtual ~LongCurrencyBox();
121 :
122 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
123 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
124 :
125 : void Modify() SAL_OVERRIDE;
126 : void ReformatAll() SAL_OVERRIDE;
127 :
128 : BigInt GetValue() const
129 : { return LongCurrencyFormatter::GetValue(); }
130 : };
131 :
132 : #endif // INCLUDED_VCL_LONGCURR_HXX
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|