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