Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / querydesign / LimitBox.cxx
blob445d0380a91fe2b26c2c1875eaa7ef77c66d9e94
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/.
8 */
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()
16 #define ALL_INT -1
18 namespace global{
20 /// Default values
21 sal_Int64 aDefLimitAry[] =
24 10,
25 20,
31 namespace dbaui
35 LimitBox::LimitBox( vcl::Window* pParent, WinBits nStyle )
36 : NumericBox( pParent, nStyle )
38 SetShowTrailingZeros( false );
39 SetDecimalDigits( 0 );
40 SetMin( -1 );
41 SetMax( SAL_MAX_INT64 );
42 LoadDefaultLimits();
44 Size aSize(
45 GetSizePixel().Width(),
46 CalcWindowSizePixel(GetEntryCount() + 1) );
47 SetSizePixel(aSize);
50 OUString LimitBox::CreateFieldText( sal_Int64 nValue ) const
52 if( nValue == ALL_INT )
53 return ALL_STRING;
54 else
55 return NumericBox::CreateFieldText( nValue );
58 void LimitBox::Reformat()
61 if( GetText() == ALL_STRING )
63 SetValue( ALL_INT );
65 ///Reformat only when text is not All
66 else
68 ///Not allow user to type in -1
69 if( GetText() == "-1" )
71 Undo();
73 else
74 NumericBox::Reformat();
78 void LimitBox::ReformatAll()
80 ///First entry is All, which do not need numeric reformat
81 if ( GetEntryCount() > 0 )
83 RemoveEntryAt( 0 );
84 NumericBox::ReformatAll();
85 InsertValue( ALL_INT, 0);
87 else
89 NumericBox::ReformatAll();
93 Size LimitBox::GetOptimalSize() const
95 return CalcBlockSize(10,1);
98 ///Initialize entries
99 void LimitBox::LoadDefaultLimits()
101 InsertValue( ALL_INT );
103 const unsigned nSize =
104 sizeof(global::aDefLimitAry)/sizeof(global::aDefLimitAry[0]);
105 for( unsigned nIndex = 0; nIndex< nSize; ++nIndex)
107 InsertValue( global::aDefLimitAry[nIndex] );
111 VCL_BUILDER_FACTORY_ARGS( LimitBox, WB_DROPDOWN | WB_VSCROLL )
113 } ///dbaui namespace
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */