source/inc/dialog.hxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  The Contents of this file are made available subject to
00004  *  the terms of GNU Lesser General Public License Version 2.1.
00005  *
00006  *
00007  *    GNU Lesser General Public License Version 2.1
00008  *    =============================================
00009  *    Copyright 2005-2008 by Kohei Yoshida.
00010  *    1039 Kingsway Dr., Apex, NC 27502, USA
00011  *
00012  *    This library is free software; you can redistribute it and/or
00013  *    modify it under the terms of the GNU Lesser General Public
00014  *    License version 2.1, as published by the Free Software Foundation.
00015  *
00016  *    This library is distributed in the hope that it will be useful,
00017  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *    Lesser General Public License for more details.
00020  *
00021  *    You should have received a copy of the GNU Lesser General Public
00022  *    License along with this library; if not, write to the Free Software
00023  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024  *    MA  02111-1307  USA
00025  *
00026  ************************************************************************/
00027 
00028  
00029 #ifndef _DIALOG_HXX_
00030 #define _DIALOG_HXX_
00031 
00032 #include <type.hxx>
00033 #include <basedlg.hxx>
00034 #include <unoglobal.hxx>
00035 #include <numeric/type.hxx>
00036 #include <memory>
00037 #include <com/sun/star/awt/PushButtonType.hpp>
00038 #include <com/sun/star/awt/Rectangle.hpp>
00039 
00040 using namespace ::com::sun::star;
00041 using namespace ::com::sun::star::uno;
00042 using scsolver::numeric::EqualityType;
00043 using scsolver::numeric::GoalType;
00044 
00045 namespace com { namespace sun { namespace star { namespace awt {
00046 
00047         class XTextComponent;
00048 
00049 }}}}
00050 
00051 namespace scsolver {
00052 
00053 class SolverImpl;
00054 
00055 class Listener;
00056 class RngBtnListener;
00057 class BaseDialog;
00058 class WidgetProperty;
00059 class MessageDialog;
00060 class OptionDialog;
00061 
00062 class SolverDialog;
00063 class SolveBtnListener;
00064 class CloseBtnListener;
00065 class SaveBtnListener;
00066 class LoadBtnListener;
00067 class ResetBtnListener;
00068 class OptionBtnListener;
00069 class MaxRadioBtnListener;
00070 class ConstEditBtnListener;
00071 class WindowFocusListener;
00072 class WindowMouseListener;
00073 class ConstListBoxListener;
00074 class OKCancelBtnListener;
00075 class ConstDlgCloseAction;
00076 class SolverDlgCloseAction;
00077 
00081 class ConstEditDialog : public BaseDialog
00082 {
00083 public:
00084         ConstEditDialog( SolverImpl* );
00085         virtual ~ConstEditDialog() throw();
00086         virtual const rtl::OUString getDialogName() const { return ascii( "ConstEditDialog" ); }
00087         virtual void setVisible( bool );
00088         virtual bool doneRangeSelection() const;
00089         virtual void close();
00090 
00091         void initialize();
00092         void reset();
00093         
00094         sal_uInt32 getConstraintId() const { return m_nConstraintId; }
00095         rtl::OUString getLeftCellReference();
00096         rtl::OUString getRightCellReference();
00097         EqualityType getEquality();
00098 
00099         void setChangeMode( sal_Bool b ) { m_bIsChangeMode = b; }
00100         void setConstraintId( sal_uInt32 );
00101         
00102         const rtl::OUString getLeftCellReference() const;
00103         const rtl::OUString getRightCellReference() const;
00104         void setLeftCellReference( const rtl::OUString& );
00105         void setRightCellReference( const rtl::OUString& );
00106 
00107         void setEquality( const EqualityType );
00108         
00109         bool isChangeMode() const { return m_bIsChangeMode; }
00110         bool isCellRangeGeometryEqual() const;
00111         
00112 protected:
00113         virtual void registerListeners();
00114         virtual void unregisterListeners();
00115 
00116 private:
00117         bool m_bIsChangeMode;
00118         sal_uInt32 m_nConstraintId;
00119 
00120         OKCancelBtnListener* m_pOKListener;
00121         OKCancelBtnListener* m_pCancelListener;
00122         RngBtnListener* m_pLeftRngListener;
00123         RngBtnListener* m_pRightRngListener;
00124         TopWindowListener* m_pTopWindowListener;
00125         ConstDlgCloseAction* m_pCloseAction;
00126 };
00127 
00131 class SolverDialog : public BaseDialog
00132 {
00133 
00134 public:
00135         
00136         SolverDialog( SolverImpl* );
00137         virtual ~SolverDialog() throw();
00138         virtual const rtl::OUString getDialogName() const { return ascii( "SolverDialog" ); }
00139         virtual void setVisible( bool );
00140         virtual bool doneRangeSelection() const { return true; }
00141         virtual void close();
00142 
00143         void initialize();
00144 
00145         ConstEditDialog* getConstEditDialog();
00146         OptionDialog*    getOptionDialog();
00147 
00148         sal_Int16 getSelectedConstraintPos();
00149 
00150         Reference< awt::XTextComponent > getXTextComponentFromWidget( const rtl::OUString& ) const;
00151         
00152         rtl::OUString getTargetCellAddress() const;
00153         void setTargetCellAddress( const rtl::OUString& );
00154         
00155         rtl::OUString getVarCellAddress();
00156         void setVarCellAddress( const rtl::OUString& );
00157         
00158         GoalType getGoal() const;
00159         void setGoal( GoalType );
00160         
00161         void output();
00162         
00163         void editConstraint( const sal_uInt32, const rtl::OUString&, const rtl::OUString&, 
00164                         const EqualityType );
00165         void getConstraint( const sal_uInt32, rtl::OUString&, rtl::OUString&, EqualityType& );
00166         std::vector< ConstraintString > getAllConstraints() const;
00167         void removeConstraint( const sal_uInt32 );
00168         void clearConstraints();
00169         
00170         void setConstraint( const rtl::OUString&, const rtl::OUString&, const EqualityType );
00171 
00172         void showMessage( const rtl::OUString& );
00173         void showSolutionInfeasible();
00174         void showSolutionFound();
00175         
00176         void reset();
00177         void saveModelToDocument();
00178         void loadModelFromDocument();
00179 
00180         void updateWidgets();
00181 
00182 protected:
00183         
00184         virtual void registerListeners();
00185         virtual void unregisterListeners();
00186         
00187 private:
00188         
00189         void removeConstraintsFromListBox( sal_Int16 = 0, sal_Int16 = 0 );
00190         void setConstraintImpl( const rtl::OUString&, const rtl::OUString&, const EqualityType,
00191                         const sal_Bool, const sal_uInt32 = 0 );
00192 
00193         std::auto_ptr<ConstEditDialog> m_pConstEditDialog;
00194         std::auto_ptr<OptionDialog>  m_pOptionDialog;
00195 
00196         // Action Listeners
00197         TopWindowListener* m_pTopWindowListener;
00198         RngBtnListener* m_pTargetRngListener;
00199         RngBtnListener* m_pVarCellsRngListener;
00200         SolveBtnListener* m_pSolveListener;
00201         CloseBtnListener* m_pOKListener;
00202         SaveBtnListener* m_pSaveListener;
00203         LoadBtnListener* m_pLoadListener;
00204         ResetBtnListener* m_pResetListener;
00205         OptionBtnListener* m_pOptionListener;
00206         MaxRadioBtnListener* m_pMaxListener;
00207         ConstEditBtnListener* m_pConstAddListener;
00208         ConstEditBtnListener* m_pConstChangeListener;
00209         ConstEditBtnListener* m_pConstDeleteListener;
00210         ConstListBoxListener* m_pConstListBoxListener;
00211         SolverDlgCloseAction* m_pCloseAction;
00212 
00213         // Constraint
00214         std::vector< ConstraintString > m_aConstraint;
00215 };
00216 
00217 //--------------------------------------------------------------------------
00218 
00219 
00220 }
00221 
00222 
00223 #endif //_DIALOG_HXX_

Generated on Mon Jul 28 09:13:20 2008 for scsolver by  doxygen 1.5.3