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 <vcl/builderfactory.hxx>
11 #include "LimitBox.hxx"
12 #include "dbu_qry.hrc"
13 #include "moduledbu.hxx"
15 #define ALL_STRING ModuleRes(STR_QUERY_LIMIT_ALL).toString()
21 sal_Int64 aDefLimitAry
[] =
35 LimitBox::LimitBox( vcl::Window
* pParent
, WinBits nStyle
)
36 : NumericBox( pParent
, nStyle
)
38 SetShowTrailingZeros( false );
39 SetDecimalDigits( 0 );
41 SetMax( SAL_MAX_INT64
);
45 GetSizePixel().Width(),
46 CalcWindowSizePixel(GetEntryCount() + 1) );
50 OUString
LimitBox::CreateFieldText( sal_Int64 nValue
) const
52 if( nValue
== ALL_INT
)
55 return NumericBox::CreateFieldText( nValue
);
58 void LimitBox::Reformat()
61 if( GetText() == ALL_STRING
)
65 ///Reformat only when text is not All
68 ///Not allow user to type in -1
69 if( GetText() == "-1" )
74 NumericBox::Reformat();
78 void LimitBox::ReformatAll()
80 ///First entry is All, which do not need numeric reformat
81 if ( GetEntryCount() > 0 )
84 NumericBox::ReformatAll();
85 InsertValue( ALL_INT
, 0);
89 NumericBox::ReformatAll();
93 Size
LimitBox::GetOptimalSize() const
95 return CalcBlockSize(10,1);
99 void LimitBox::LoadDefaultLimits()
101 InsertValue( ALL_INT
);
103 for(long nIndex
: global::aDefLimitAry
)
105 InsertValue( nIndex
);
109 VCL_BUILDER_FACTORY_ARGS( LimitBox
, WB_DROPDOWN
| WB_VSCROLL
)
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */