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 #ifndef DBAUI_FIELDCONTROLS_HXX
28 #define DBAUI_FIELDCONTROLS_HXX
29 
30 #ifndef _SV_FIELD_HXX
31 #include <vcl/field.hxx>
32 #endif
33 #ifndef _SV_LSTBOX_HXX
34 #include <vcl/lstbox.hxx>
35 #endif
36 #ifndef _SV_SVAPP_HXX
37 #include <vcl/svapp.hxx>
38 #endif
39 #ifndef DBAUI_SQLNAMEEDIT_HXX
40 #include "SqlNameEdit.hxx"
41 #endif
42 #ifndef _DBAUI_MODULE_DBU_HXX_
43 #include "moduledbu.hxx"
44 #endif
45 
46 
47 namespace dbaui
48 {
49     namespace
50     {
51         void lcl_setSpecialReadOnly( sal_Bool _bReadOnly, Window* _pWin )
52         {
53 			StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
54 			const Color& rNewColor = _bReadOnly ? aSystemStyle.GetDialogColor() : aSystemStyle.GetFieldColor();
55 			_pWin->SetBackground(Wallpaper(rNewColor));
56 			_pWin->SetControlBackground(rNewColor);
57         }
58     }
59 
60 	//==================================================================
61 	class OPropColumnEditCtrl : public OSQLNameEdit
62 	{
63         OModuleClient m_aModuleClient;
64 		short	             m_nPos;
65 		String	             m_strHelpText;
66 	public:
67 		inline OPropColumnEditCtrl(Window* pParent, ::rtl::OUString& _rAllowedChars, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
68 
69 		inline sal_Bool IsModified() const { return GetText() != GetSavedValue(); }
70 
71 		short GetPos() const { return m_nPos; }
72 		String GetHelp() const { return m_strHelpText; }
73 
74 		virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
75 		{
76 			SetReadOnly(_bReadOnly);
77 			lcl_setSpecialReadOnly(_bReadOnly,this);
78 		}
79 	};
80 	inline OPropColumnEditCtrl::OPropColumnEditCtrl(Window* pParent,
81 													::rtl::OUString& _rAllowedChars,
82 													sal_uInt16 nHelpId,
83 													short nPosition,
84 													WinBits nWinStyle)
85 		:OSQLNameEdit(pParent, _rAllowedChars,nWinStyle)
86 		,m_nPos(nPosition)
87 	{
88 		m_strHelpText=String(ModuleRes(nHelpId));
89 	}
90 	//==================================================================
91 	class OPropEditCtrl :	public Edit
92 	{
93         OModuleClient m_aModuleClient;
94 		short	             m_nPos;
95 		String	             m_strHelpText;
96 
97 	public:
98 		inline OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
99 		inline OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition = -1);
100 
101 		inline sal_Bool IsModified() const { return GetText() != GetSavedValue(); }
102 
103 		short GetPos() const { return m_nPos; }
104 		String GetHelp() const { return m_strHelpText; }
105 
106 		virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
107 		{
108 			SetReadOnly(_bReadOnly);
109 			lcl_setSpecialReadOnly(_bReadOnly,this);
110 		}
111 	};
112 
113 	inline OPropEditCtrl::OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition, WinBits nWinStyle)
114 		:Edit(pParent, nWinStyle)
115 		,m_nPos(nPosition)
116 	{
117 		m_strHelpText =String(ModuleRes(nHelpId));
118 	}
119 	inline OPropEditCtrl::OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition)
120 		:Edit(pParent, _rRes)
121 		,m_nPos(nPosition)
122 	{
123 		m_strHelpText =String(ModuleRes(nHelpId));
124 	}
125 
126 	//==================================================================
127 	class OPropNumericEditCtrl : public NumericField
128     {
129 		short	m_nPos;
130 		String	m_strHelpText;
131 
132 	public:
133 		inline OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
134 		inline OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition = -1);
135 
136 		inline sal_Bool IsModified() const { return GetText() != GetSavedValue(); }
137 
138 		short GetPos() const { return m_nPos; }
139 		String GetHelp() const { return m_strHelpText; }
140 
141 		virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
142 		{
143 			SetReadOnly(_bReadOnly);
144 			lcl_setSpecialReadOnly(_bReadOnly,this);
145 		}
146 	};
147 
148 	inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition, WinBits nWinStyle)
149 		:NumericField(pParent, nWinStyle)
150 		,m_nPos(nPosition)
151 	{
152 		m_strHelpText =String(ModuleRes(nHelpId));
153 	}
154 	inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition)
155 		:NumericField(pParent, _rRes)
156 		,m_nPos(nPosition)
157 	{
158 		m_strHelpText =String(ModuleRes(nHelpId));
159 	}
160 
161 	//==================================================================
162 	class OPropListBoxCtrl : public ListBox
163 	{
164 		short	m_nPos;
165 		String	m_strHelpText;
166 
167 	public:
168 		inline OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
169 		inline OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition = -1);
170 
171 		inline sal_Bool IsModified() const { return GetSelectEntryPos() != GetSavedValue(); }
172 
173 		short GetPos() const { return m_nPos; }
174 		String GetHelp() const { return m_strHelpText; }
175 
176 		virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
177 		{
178 			SetReadOnly(_bReadOnly);
179 			lcl_setSpecialReadOnly(_bReadOnly,this);
180 		}
181 	};
182 
183 	inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition, WinBits nWinStyle)
184 		:ListBox(pParent, nWinStyle)
185 		,m_nPos(nPosition)
186 	{
187 		m_strHelpText =String(ModuleRes(nHelpId));
188 	}
189 	inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition)
190 		:ListBox(pParent, _rRes)
191 		,m_nPos(nPosition)
192 	{
193 		m_strHelpText =String(ModuleRes(nHelpId));
194 	}
195 }
196 #endif // DBAUI_FIELDCONTROLS_HXX
197 
198 
199 
200