summaryrefslogtreecommitdiff
path: root/scratch/scsolver/source/inc/dialog.hxx
blob: 61157ee0300e761344baefe9f2d179d10732a0ec (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 _DIALOG_HXX_
#define _DIALOG_HXX_

#include <type.hxx>
#include <basedlg.hxx>
#include <unoglobal.hxx>
#include <numeric/type.hxx>
#include <memory>
#include <com/sun/star/awt/PushButtonType.hpp>
#include <com/sun/star/awt/Rectangle.hpp>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using scsolver::numeric::opres::Equality;
using scsolver::numeric::opres::Goal;

namespace com { namespace sun { namespace star { namespace awt {

	class XTextComponent;

}}}}

namespace scsolver {

class SolverImpl;

class Listener;
class RngBtnListener;
class BaseDialog;
class WidgetProperty;
class MessageDialog;
class OptionDialog;

class SolverDialog;
class SolveBtnListener;
class CloseBtnListener;
class SaveBtnListener;
class LoadBtnListener;
class ResetBtnListener;
class OptionBtnListener;
class MaxRadioBtnListener;
class ConstEditBtnListener;
class WindowFocusListener;
class WindowMouseListener;
class ConstListBoxListener;
	
class OKCancelBtnListener;


//---------------------------------------------------------------------------
// Class ConstEditDialog


class ConstEditDialog : public BaseDialog
{
public:
	ConstEditDialog( SolverImpl* );
	virtual ~ConstEditDialog() throw();
	virtual const rtl::OUString getDialogName() const { return ascii( "ConstEditDialog" ); }
	virtual void setVisible( bool );
	virtual bool doneRangeSelection() const;

	void initialize();
	void reset();
	
	sal_uInt32 getConstraintId() const { return m_nConstraintId; }
	rtl::OUString getLeftCellReference();
	rtl::OUString getRightCellReference();
	Equality getEquality();

	void setChangeMode( sal_Bool b ) { m_bIsChangeMode = b; }
	void setConstraintId( sal_uInt32 );
	
	const rtl::OUString getLeftCellReference() const;
	const rtl::OUString getRightCellReference() const;
	void setLeftCellReference( const rtl::OUString& );
	void setRightCellReference( const rtl::OUString& );

	void setEquality( const Equality );
	
	bool isChangeMode() const { return m_bIsChangeMode; }
	bool isCellRangeGeometryEqual() const;
	
protected:
	virtual void registerListeners();
	virtual void unregisterListeners();

private:
	bool m_bIsChangeMode;
	sal_uInt32 m_nConstraintId;

	OKCancelBtnListener* m_pOKListener;
	OKCancelBtnListener* m_pCancelListener;
	RngBtnListener* m_pLeftRngListener;
	RngBtnListener* m_pRightRngListener;
};

//---------------------------------------------------------------------------
// Class SolverDialog

class SolverDialog : public BaseDialog
{

public:
	
	SolverDialog( SolverImpl* );
	virtual ~SolverDialog() throw();
	virtual const rtl::OUString getDialogName() const { return ascii( "SolverDialog" ); }
	virtual void setVisible( bool );
	virtual bool doneRangeSelection() const { return true; }

	void initialize();
	

	ConstEditDialog* getConstEditDialog();
	OptionDialog* getOptionDialog();

	sal_Int16 getSelectedConstraintPos();
	
	Reference< awt::XTextComponent > getXTextComponentFromWidget( const rtl::OUString& ) const;
	
	rtl::OUString getTargetCellAddress() const;
	void setTargetCellAddress( const rtl::OUString& );
	
	rtl::OUString getVarCellAddress();
	void setVarCellAddress( const rtl::OUString& );
	
	Goal getGoal() const;
	void setGoal( Goal );
	
	void output();
	
	void editConstraint( const sal_uInt32, const rtl::OUString&, const rtl::OUString&, 
			const Equality );
	void getConstraint( const sal_uInt32, rtl::OUString&, rtl::OUString&, Equality& );
	std::vector< ConstraintString > getAllConstraints() const;
	void removeConstraint( const sal_uInt32 );
	void clearConstraints();
	
	void setConstraint( const rtl::OUString&, const rtl::OUString&, const Equality );

	void showSolveError( const rtl::OUString& );
	void showSolutionInfeasible();
	void showSolutionFound();
	
	void reset();
	void saveModelToDocument();
	void loadModelFromDocument();

	ResMgr& GetResMgr();

protected:
	
	virtual void registerListeners();
	virtual void unregisterListeners();
	
private:
	
	void removeConstraintsFromListBox( sal_Int16 = 0, sal_Int16 = 0 );
	void setConstraintImpl( const rtl::OUString&, const rtl::OUString&, const Equality,
			const sal_Bool, const sal_uInt32 = 0 );

	std::auto_ptr<ConstEditDialog> m_pConstEditDialog;
	std::auto_ptr<OptionDialog>  m_pOptionDialog;
	std::auto_ptr<MessageDialog> m_pSolveErrorDlg;
	std::auto_ptr<MessageDialog> m_pSolInfeasibleDlg;
	std::auto_ptr<MessageDialog> m_pSolFoundDlg;

	// Action Listeners
	RngBtnListener* m_pTargetRngListener;
	RngBtnListener* m_pVarCellsRngListener;
	WindowMouseListener* m_pWindowMouseListener;
	SolveBtnListener* m_pSolveListener;
	CloseBtnListener* m_pOKListener;
	SaveBtnListener* m_pSaveListener;
	LoadBtnListener* m_pLoadListener;
	ResetBtnListener* m_pResetListener;
	OptionBtnListener* m_pOptionListener;
	MaxRadioBtnListener* m_pMaxListener;
	ConstEditBtnListener* m_pConstAddListener;
	ConstEditBtnListener* m_pConstChangeListener;
	ConstEditBtnListener* m_pConstDeleteListener;
	WindowFocusListener* m_pWindowFocusListener;
	ConstListBoxListener* m_pConstListBoxListener;

	// Constraint
	std::vector< ConstraintString > m_aConstraint;
};

//--------------------------------------------------------------------------


}


#endif //_DIALOG_HXX_