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 #ifndef _EXTENSIONS_DBP_GROUPBOXWIZ_HXX_
29 #define _EXTENSIONS_DBP_GROUPBOXWIZ_HXX_
30 
31 #include "controlwizard.hxx"
32 #include "commonpagesdbp.hxx"
33 
34 //.........................................................................
35 namespace dbp
36 {
37 //.........................................................................
38 
39 	//=====================================================================
40 	//= OOptionGroupSettings
41 	//=====================================================================
42 	struct OOptionGroupSettings : public OControlWizardSettings
43 	{
44 		StringArray		aLabels;
45 		StringArray		aValues;
46 		String			sDefaultField;
47 		String			sDBField;
48 		String			sName;
49 	};
50 
51 	//=====================================================================
52 	//= OGroupBoxWizard
53 	//=====================================================================
54 	class OGroupBoxWizard : public OControlWizard
55 	{
56 	protected:
57 		OOptionGroupSettings		m_aSettings;
58 
59 		sal_Bool		m_bVisitedDefault	: 1;
60 		sal_Bool		m_bVisitedDB		: 1;
61 
62 	public:
63 		OGroupBoxWizard(
64 			Window* _pParent,
65 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
66 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
67 		);
68 
69 		OOptionGroupSettings& getSettings() { return m_aSettings; }
70 
71 	protected:
72 		// OWizardMachine overridables
73 		virtual ::svt::OWizardPage*	createPage( WizardState _nState );
74 		virtual WizardState	        determineNextState( WizardState _nCurrentState ) const;
75 		virtual	void			    enterState( WizardState _nState );
76 		virtual sal_Bool            onFinish();
77 
78 		virtual sal_Bool approveControl(sal_Int16 _nClassId);
79 
80 	protected:
81 		void createRadios();
82 	};
83 
84 	//=====================================================================
85 	//= OGBWPage
86 	//=====================================================================
87 	class OGBWPage : public OControlWizardPage
88 	{
89 	public:
90 		OGBWPage( OControlWizard* _pParent, const ResId& _rId ) : OControlWizardPage(_pParent, _rId) { }
91 
92 	protected:
93 		OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); }
94 	};
95 
96 	//=====================================================================
97 	//= ORadioSelectionPage
98 	//=====================================================================
99 	class ORadioSelectionPage : public OGBWPage
100 	{
101 	protected:
102 		FixedLine		m_aFrame;
103 		FixedText		m_aRadioNameLabel;
104 		Edit			m_aRadioName;
105 		PushButton		m_aMoveRight;
106 		PushButton		m_aMoveLeft;
107 		FixedText		m_aExistingRadiosLabel;
108 		ListBox			m_aExistingRadios;
109 
110 	public:
111 		ORadioSelectionPage( OControlWizard* _pParent );
112 
113 	protected:
114 		// TabPage overridables
115 		void ActivatePage();
116 
117 		// OWizardPage overridables
118 		virtual void		initializePage();
119 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
120 		virtual bool        canAdvance() const;
121 
122 		DECL_LINK( OnMoveEntry, PushButton* );
123 		DECL_LINK( OnEntrySelected, ListBox* );
124 		DECL_LINK( OnNameModified, Edit* );
125 
126 		void implCheckMoveButtons();
127 	};
128 
129 	//=====================================================================
130 	//= ODefaultFieldSelectionPage
131 	//=====================================================================
132 	class ODefaultFieldSelectionPage : public OMaybeListSelectionPage
133 	{
134 	protected:
135 		FixedLine		m_aFrame;
136 		FixedText		m_aDefaultSelectionLabel;
137 		RadioButton		m_aDefSelYes;
138 		RadioButton		m_aDefSelNo;
139 		ListBox			m_aDefSelection;
140 
141 	public:
142 		ODefaultFieldSelectionPage( OControlWizard* _pParent );
143 
144 	protected:
145 		// OWizardPage overridables
146 		virtual void		initializePage();
147 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
148 
149 		OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); }
150 	};
151 
152 	//=====================================================================
153 	//= OOptionValuesPage
154 	//=====================================================================
155 	class OOptionValuesPage : public OGBWPage
156 	{
157 	protected:
158 		FixedLine		m_aFrame;
159 		FixedText		m_aDescription;
160 		FixedText		m_aValueLabel;
161 		Edit			m_aValue;
162 		FixedText		m_aOptionsLabel;
163 		ListBox			m_aOptions;
164 
165 		StringArray		m_aUncommittedValues;
166 		::svt::WizardTypes::WizardState
167                         m_nLastSelection;
168 
169 	public:
170 		OOptionValuesPage( OControlWizard* _pParent );
171 
172 	protected:
173 		// TabPage overridables
174 		void ActivatePage();
175 
176 		// OWizardPage overridables
177 		virtual void		initializePage();
178 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
179 
180 		void implTraveledOptions();
181 
182 		DECL_LINK( OnOptionSelected, ListBox* );
183 	};
184 
185 	//=====================================================================
186 	//= OOptionDBFieldPage
187 	//=====================================================================
188 	class OOptionDBFieldPage : public ODBFieldPage
189 	{
190 	public:
191 		OOptionDBFieldPage( OControlWizard* _pParent );
192 
193 	protected:
194 		OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); }
195 
196 		// ODBFieldPage overridables
197 		virtual String& getDBFieldSetting();
198 	};
199 
200 	//=====================================================================
201 	//= OFinalizeGBWPage
202 	//=====================================================================
203 	class OFinalizeGBWPage : public OGBWPage
204 	{
205 	protected:
206 		FixedLine		m_aFrame;
207 		FixedText		m_aNameLabel;
208 		Edit			m_aName;
209 		FixedText		m_aThatsAll;
210 
211 	public:
212 		OFinalizeGBWPage( OControlWizard* _pParent );
213 
214 	protected:
215 		// TabPage overridables
216 		void ActivatePage();
217 
218 		// OWizardPage overridables
219 		virtual void		initializePage();
220 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
221 		virtual bool        canAdvance() const;
222 	};
223 
224 //.........................................................................
225 }	// namespace dbp
226 //.........................................................................
227 
228 #endif // _EXTENSIONS_DBP_GROUPBOXWIZ_HXX_
229 
230