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 #include <dlgsize.hxx>
25 #define DEF_ROW_HEIGHT 45
26 #define DEF_COL_WIDTH 227
28 DlgSize::DlgSize(weld::Window
* pParent
, sal_Int32 nVal
, bool bRow
, sal_Int32 _nAlternativeStandard
)
29 : GenericDialogController(pParent
, bRow
? u
"dbaccess/ui/rowheightdialog.ui"_ustr
: u
"dbaccess/ui/colwidthdialog.ui"_ustr
,
30 bRow
? u
"RowHeightDialog"_ustr
: u
"ColWidthDialog"_ustr
)
32 , m_xMF_VALUE(m_xBuilder
->weld_metric_spin_button(u
"value"_ustr
, FieldUnit::CM
))
33 , m_xCB_STANDARD(m_xBuilder
->weld_check_button(u
"automatic"_ustr
))
35 sal_Int32
nStandard(bRow
? DEF_ROW_HEIGHT
: DEF_COL_WIDTH
);
36 if ( _nAlternativeStandard
> 0 )
37 nStandard
= _nAlternativeStandard
;
38 m_xCB_STANDARD
->connect_toggled(LINK(this,DlgSize
,CbClickHdl
));
40 bool bDefault
= -1 == nVal
;
41 m_xCB_STANDARD
->set_active(bDefault
);
45 m_nPrevValue
= nStandard
;
47 CbClickHdl(*m_xCB_STANDARD
);
54 void DlgSize::SetValue( sal_Int32 nVal
)
56 m_xMF_VALUE
->set_value(nVal
, FieldUnit::CM
);
59 sal_Int32
DlgSize::GetValue() const
61 if (m_xCB_STANDARD
->get_active())
63 return static_cast<sal_Int32
>(m_xMF_VALUE
->get_value( FieldUnit::CM
));
66 IMPL_LINK_NOARG(DlgSize
, CbClickHdl
, weld::Toggleable
&, void)
68 m_xMF_VALUE
->set_sensitive(!m_xCB_STANDARD
->get_active());
69 if (m_xCB_STANDARD
->get_active())
71 // don't use getValue as this will use m_xCB_STANDARD->to determine if we're standard
72 m_nPrevValue
= static_cast<sal_Int32
>(m_xMF_VALUE
->get_value(FieldUnit::CM
));
73 m_xMF_VALUE
->set_text(u
""_ustr
);
77 SetValue(m_nPrevValue
);
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */