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/.
10 #include "LimitBox.hxx"
11 #include "dbu_qry.hrc"
12 #include "moduledbu.hxx"
14 #define ALL_STRING ModuleRes(STR_QUERY_LIMIT_ALL).toString()
20 sal_Int64 aDefLimitAry
[] =
34 LimitBox::LimitBox( Window
* pParent
, WinBits nStyle
)
35 : NumericBox( pParent
, nStyle
)
37 SetShowTrailingZeros( sal_False
);
38 SetDecimalDigits( 0 );
40 SetMax( SAL_MAX_INT64
);
44 GetSizePixel().Width(),
45 CalcWindowSizePixel(GetEntryCount() + 1) );
53 OUString
LimitBox::CreateFieldText( sal_Int64 nValue
) const
55 if( nValue
== ALL_INT
)
58 return NumericBox::CreateFieldText( nValue
);
61 void LimitBox::Reformat()
64 if( GetText() == ALL_STRING
)
68 ///Reformat only when text is not All
71 ///Not allow user to type in -1
72 if( GetText() == "-1" )
77 NumericBox::Reformat();
81 void LimitBox::ReformatAll()
83 ///First entry is All, which do not need numeric reformat
84 if ( GetEntryCount() > 0 )
87 NumericBox::ReformatAll();
88 InsertValue( ALL_INT
, 0);
92 NumericBox::ReformatAll();
96 Size
LimitBox::GetOptimalSize() const
98 return CalcSize(10,1);
101 ///Initialize entries
102 void LimitBox::LoadDefaultLimits()
104 InsertValue( ALL_INT
);
106 const unsigned nSize
=
107 sizeof(global::aDefLimitAry
)/sizeof(global::aDefLimitAry
[0]);
108 for( unsigned nIndex
= 0; nIndex
< nSize
; ++nIndex
)
110 InsertValue( global::aDefLimitAry
[nIndex
] );
114 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeLimitBox( Window
*pParent
)
116 LimitBox
* pBox
= new LimitBox( pParent
, WB_DROPDOWN
| WB_VSCROLL
);
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */