summaryrefslogtreecommitdiff
path: root/scratch/scsolver/source/inc/basedlg.hxx
blob: 77646b0707c4bdd13562a729328c27eb2d50b934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*************************************************************************
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Kohei Yoshida.
 *    1039 Kingsway Dr., Apex, NC 27502, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

 
#ifndef _BASEDLG_HXX_
#define _BASEDLG_HXX_

#include <tools/resmgr.hxx>
#include <unoglobal.hxx>
#include <global.hxx>
#include <memory>
#include <com/sun/star/awt/PushButtonType.hpp>

using namespace com::sun::star;
using uno::Reference;
using uno::XInterface;

namespace com { namespace sun { namespace star {

	namespace awt
	{
		class XControlModel;
	}

}}}

namespace scsolver {

class SolverImpl;
class Listener;
class FocusListener;
class MouseListener;
class ActionListener;
class ItemListener;

class BaseDialogImpl;
class ObjProperty;
class ObjPropertyImpl;
class WidgetProperty;
class WidgetPropertyImpl;

typedef std::auto_ptr<ObjProperty> apObjProp;
typedef std::auto_ptr<WidgetProperty> apWidgetProp;

//--------------------------------------------------------------------------
// BaseDialog

/** Base class for all dialog classes used in scsolver. */
class BaseDialog
{
public:
	BaseDialog( SolverImpl* );
	virtual ~BaseDialog() throw() = 0;
	
	/**
	 * Must return a unique name that identifies its dialog type.
	 * Should be deprecated and its use in a nested-if or switch
     * statement is discouraged because it is not very elegant and
     * non-safe.
	 */
	virtual const rtl::OUString getDialogName() const = 0;
	virtual void setVisible( bool ) = 0;
	
	/**
     * This method is called when a range selection is finished.  If
     * the dialog does not contain a range selection widget pair,
     * just leave this method empty.
     * 
     * @return false for signaling to the calling function that
     *  the selection is invalid and should be discarded, or true if
     *  the selection is satisfactory.
     */
	virtual bool doneRangeSelection() const = 0;

	// Widget creation methods
	
	apWidgetProp addButton( sal_Int32, sal_Int32, sal_Int32, sal_Int32,
			const rtl::OUString&, const rtl::OUString&, sal_Int16 = awt::PushButtonType_STANDARD );
		
	apWidgetProp addButtonImage( sal_Int32, sal_Int32, sal_Int32, sal_Int32,
			const rtl::OUString &, const rtl::OUString &, sal_Int16 = awt::PushButtonType_STANDARD );
		
	apWidgetProp addEdit( sal_Int32, sal_Int32, sal_Int32, sal_Int32, const rtl::OUString & );

	apWidgetProp addFixedLine( sal_Int32, sal_Int32, sal_Int32, sal_Int32,
			const rtl::OUString &, const rtl::OUString &, sal_Int32 = 0 );
		
	apWidgetProp addFixedText( sal_Int32, sal_Int32, sal_Int32, sal_Int32,
			const rtl::OUString &, const rtl::OUString & );
		
	apWidgetProp addGroupBox( sal_Int32, sal_Int32, sal_Int32, sal_Int32, const rtl::OUString & );
		
	apWidgetProp addListBox( sal_Int32, sal_Int32, sal_Int32, sal_Int32, const rtl::OUString & );
	
	apWidgetProp addRadioButton( sal_Int32, sal_Int32, sal_Int32, sal_Int32, 
			const rtl::OUString &, const rtl::OUString & );

	apWidgetProp addCheckBox( sal_Int32 x, sal_Int32 y, sal_Int32 w, sal_Int32 h,
			const rtl::OUString& name, const rtl::OUString& label );
		
	apWidgetProp addRangeEdit( sal_Int32, sal_Int32, sal_Int32, sal_Int32,
			const rtl::OUString &, const rtl::OUString & );
			
	// Widget registration methods
	
	void registerListener( FocusListener* ) const;
	void registerListener( MouseListener* ) const;
	void registerListener( const rtl::OUString&, ActionListener* ) const;
	void registerListener( const rtl::OUString&, ItemListener* ) const;

	void unregisterListener( FocusListener* ) const;
	void unregisterListener( MouseListener* ) const;
	void unregisterListener( const rtl::OUString&, ActionListener* ) const;
	void unregisterListener( const rtl::OUString&, ItemListener* ) const;

	// Other methods

	SolverImpl* getSolverImpl() const;
	const Reference < XInterface > getWidgetByName( const rtl::OUString& ) const;
	const Reference < awt::XControlModel > getWidgetModelByName( const rtl::OUString& ) const;
	void enableWidget( const rtl::OUString&, sal_Bool = true ) const;
	void toFront() const;
	void execute() const;

	ResMgr* getResMgr() const;
	rtl::OUString getResStr( int resid ) const;

protected:

	void initialize( sal_Int16, sal_Int16, const rtl::OUString& ) const;
	void setVisibleDefault( bool ) const;

private:
	std::auto_ptr<BaseDialogImpl> m_pImpl;
};

//--------------------------------------------------------------------------
// ObjProperty

class ObjProperty
{
public:
	ObjProperty( const Reference< XInterface >& );
	virtual ~ObjProperty() throw() = 0;
	
	void setPropertyValueAny( const char*, const uno::Any& );

	template<typename AnyValue>
	void setPropertyValue( const char*, const AnyValue& );
	
private:
	std::auto_ptr<ObjPropertyImpl> m_pImpl;
};

//--------------------------------------------------------------------------
// WidgetProperty

class WidgetProperty : public ObjProperty
{
public:
	WidgetProperty( const Reference< XInterface >& );
	virtual ~WidgetProperty() throw();
	
	void setPositionX( sal_Int32 ) const;
	void setPositionY( sal_Int32 ) const;
	void setWidth( sal_Int32 ) const;
	void setHeight( sal_Int32 ) const;
	void setName( const rtl::OUString& ) const;
	void setLabel( const rtl::OUString& ) const;
	
private:
	std::auto_ptr<WidgetPropertyImpl> m_pImpl;
};


// Helper function

const rtl::OUString getTextByWidget( BaseDialog*, const rtl::OUString& );
void setTextByWidget( BaseDialog*, const rtl::OUString&, const rtl::OUString& );


}

#endif // _BASEDLG_HXX_