xref: /trunk/main/dbaccess/source/ui/dlg/dlgsize.cxx (revision b63233d8)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbui.hxx"
26 #ifndef DBAUI_DLGSIZE_HRC
27 #include "dlgsize.hrc"
28 #endif
29 #ifndef _DBAUI_DLGSIZE_HXX
30 #include "dlgsize.hxx"
31 #endif
32 #ifndef _DBU_DLG_HRC_
33 #include "dbu_dlg.hrc"
34 #endif
35 #ifndef _DBAUI_MODULE_DBU_HXX_
36 #include "moduledbu.hxx"
37 #endif
38 
39 //.........................................................................
40 namespace dbaui
41 {
42 //.........................................................................
43 
44 
45 #define DEF_ROW_HEIGHT  45
46 #define DEF_COL_WIDTH   227
47 
DBG_NAME(DlgSize)48 DBG_NAME(DlgSize)
49 //==================================================================
50 DlgSize::DlgSize( Window* pParent, sal_Int32 nVal, sal_Bool bRow, sal_Int32 _nAlternativeStandard )
51 		:ModalDialog( pParent, ModuleRes(bRow ? DLG_ROWHEIGHT : DLG_COLWIDTH))
52 		,m_nPrevValue(nVal)
53 		,m_nStandard(bRow ? DEF_ROW_HEIGHT : DEF_COL_WIDTH)
54 		,aFT_VALUE(this,	ModuleRes( FT_VALUE))
55 		,aMF_VALUE(this,	ModuleRes( MF_VALUE))
56 		,aCB_STANDARD(this, ModuleRes(CB_STANDARD))
57 		,aPB_OK(this,		ModuleRes(PB_OK))
58 		,aPB_CANCEL(this,	ModuleRes(PB_CANCEL))
59 		,aPB_HELP(this,		ModuleRes(PB_HELP))
60 {
61     DBG_CTOR(DlgSize,NULL);
62 
63 	if ( _nAlternativeStandard > 0 )
64 		m_nStandard = _nAlternativeStandard;
65 	aCB_STANDARD.SetClickHdl(LINK(this,DlgSize,CbClickHdl));
66 
67 	aMF_VALUE.EnableEmptyFieldValue(sal_True);
68 	sal_Bool bDefault = -1 == nVal;
69 	aCB_STANDARD.Check(bDefault);
70 	if (bDefault)
71 	{
72 		SetValue(m_nStandard);
73 		m_nPrevValue = m_nStandard;
74 	}
75 	LINK(this,DlgSize,CbClickHdl).Call(&aCB_STANDARD);
76 
77 	FreeResource();
78 }
79 
80 //------------------------------------------------------------------------------
~DlgSize()81 DlgSize::~DlgSize()
82 {
83 
84     DBG_DTOR(DlgSize,NULL);
85 }
86 
87 //------------------------------------------------------------------------------
SetValue(sal_Int32 nVal)88 void DlgSize::SetValue( sal_Int32 nVal )
89 {
90 	aMF_VALUE.SetValue(nVal, FUNIT_CM );
91 }
92 
93 //------------------------------------------------------------------------------
GetValue()94 sal_Int32 DlgSize::GetValue()
95 {
96 	if (aCB_STANDARD.IsChecked())
97 		return -1;
98 	return (sal_Int32)aMF_VALUE.GetValue( FUNIT_CM );
99 }
100 
101 //------------------------------------------------------------------------------
IMPL_LINK(DlgSize,CbClickHdl,Button *,pButton)102 IMPL_LINK( DlgSize, CbClickHdl, Button *, pButton )
103 {
104 
105 	if( pButton == &aCB_STANDARD )
106 	{
107 		aMF_VALUE.Enable(!aCB_STANDARD.IsChecked());
108 		if (aCB_STANDARD.IsChecked())
109 		{
110 			m_nPrevValue = static_cast<sal_Int32>(aMF_VALUE.GetValue(FUNIT_CM));
111 				// don't use getValue as this will use aCB_STANDARD.to determine if we're standard
112 			aMF_VALUE.SetEmptyFieldValue();
113 		}
114 		else
115 		{
116 			SetValue( m_nPrevValue );
117 		}
118 	}
119 	return 0;
120 }
121 // -----------------------------------------------------------------------------
122 //.........................................................................
123 }	// namespace dbaui
124 //.........................................................................
125 
126 
127