xref: /aoo41x/main/dbaccess/source/ui/dlg/dlgsize.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 #ifndef DBAUI_DLGSIZE_HRC
31 #include "dlgsize.hrc"
32 #endif
33 #ifndef _DBAUI_DLGSIZE_HXX
34 #include "dlgsize.hxx"
35 #endif
36 #ifndef _DBU_DLG_HRC_
37 #include "dbu_dlg.hrc"
38 #endif
39 #ifndef _DBAUI_MODULE_DBU_HXX_
40 #include "moduledbu.hxx"
41 #endif
42 
43 //.........................................................................
44 namespace dbaui
45 {
46 //.........................................................................
47 
48 
49 #define DEF_ROW_HEIGHT  45
50 #define DEF_COL_WIDTH   227
51 
52 DBG_NAME(DlgSize)
53 //==================================================================
54 DlgSize::DlgSize( Window* pParent, sal_Int32 nVal, sal_Bool bRow, sal_Int32 _nAlternativeStandard )
55 		:ModalDialog( pParent, ModuleRes(bRow ? DLG_ROWHEIGHT : DLG_COLWIDTH))
56 		,m_nPrevValue(nVal)
57 		,m_nStandard(bRow ? DEF_ROW_HEIGHT : DEF_COL_WIDTH)
58 		,aFT_VALUE(this,	ModuleRes( FT_VALUE))
59 		,aMF_VALUE(this,	ModuleRes( MF_VALUE))
60 		,aCB_STANDARD(this, ModuleRes(CB_STANDARD))
61 		,aPB_OK(this,		ModuleRes(PB_OK))
62 		,aPB_CANCEL(this,	ModuleRes(PB_CANCEL))
63 		,aPB_HELP(this,		ModuleRes(PB_HELP))
64 {
65     DBG_CTOR(DlgSize,NULL);
66 
67 	if ( _nAlternativeStandard > 0 )
68 		m_nStandard = _nAlternativeStandard;
69 	aCB_STANDARD.SetClickHdl(LINK(this,DlgSize,CbClickHdl));
70 
71 	aMF_VALUE.EnableEmptyFieldValue(sal_True);
72 	sal_Bool bDefault = -1 == nVal;
73 	aCB_STANDARD.Check(bDefault);
74 	if (bDefault)
75 	{
76 		SetValue(m_nStandard);
77 		m_nPrevValue = m_nStandard;
78 	}
79 	LINK(this,DlgSize,CbClickHdl).Call(&aCB_STANDARD);
80 
81 	FreeResource();
82 }
83 
84 //------------------------------------------------------------------------------
85 DlgSize::~DlgSize()
86 {
87 
88     DBG_DTOR(DlgSize,NULL);
89 }
90 
91 //------------------------------------------------------------------------------
92 void DlgSize::SetValue( sal_Int32 nVal )
93 {
94 	aMF_VALUE.SetValue(nVal, FUNIT_CM );
95 }
96 
97 //------------------------------------------------------------------------------
98 sal_Int32 DlgSize::GetValue()
99 {
100 	if (aCB_STANDARD.IsChecked())
101 		return -1;
102 	return (sal_Int32)aMF_VALUE.GetValue( FUNIT_CM );
103 }
104 
105 //------------------------------------------------------------------------------
106 IMPL_LINK( DlgSize, CbClickHdl, Button *, pButton )
107 {
108 
109 	if( pButton == &aCB_STANDARD )
110 	{
111 		aMF_VALUE.Enable(!aCB_STANDARD.IsChecked());
112 		if (aCB_STANDARD.IsChecked())
113 		{
114 			m_nPrevValue = static_cast<sal_Int32>(aMF_VALUE.GetValue(FUNIT_CM));
115 				// don't use getValue as this will use aCB_STANDARD.to determine if we're standard
116 			aMF_VALUE.SetEmptyFieldValue();
117 		}
118 		else
119 		{
120 			SetValue( m_nPrevValue );
121 		}
122 	}
123 	return 0;
124 }
125 // -----------------------------------------------------------------------------
126 //.........................................................................
127 }	// namespace dbaui
128 //.........................................................................
129 
130 
131