00001
00002
00003 #include "../Constraint.h"
00004 #include "../CountedPtr.h"
00005 #include "../History.h"
00006 #include "../Parser.h"
00007 #include "../VariableNames.h"
00008
00009 #include "FunctionValidator.h"
00010
00011 #ifndef CONSTRAINTSPANEL_H
00012 #define CONSTRAINTSPANEL_H
00013
00014
00015
00016
00017
00018 class ConstraintsPanel: public wxPanel {
00019 public:
00020 friend class ConstraintsValidator;
00021
00022 enum {
00023
00024
00025 ID_BUTTON_EDIT = 1,
00026
00027 ID_COMBO_FUNCTION,
00028 ID_LISTBOX
00029 };
00030
00031
00032
00033
00034 ConstraintsPanel(wxWindow* parent,
00035 int id,
00036 CountedPtr<const Parser> cpParser,
00037 ProblemBase* pProblem,
00038 FunctionValidator::Type functionValidatorType,
00039 History& rFunctionHistory,
00040 History& rConstraintHistory,
00041 const wxPoint& pos=wxDefaultPosition,
00042 const wxSize& size=wxDefaultSize,
00043 long style=0);
00044
00045
00046 void OnAdd(wxCommandEvent& event);
00047 void OnEdit(wxCommandEvent& event);
00048 void OnRemove(wxCommandEvent& event);
00049 void OnTextUpdate(wxCommandEvent& event);
00050 void OnComboSelect(wxCommandEvent& event);
00051 void OnTextEnter(wxCommandEvent& event);
00052 void OnListSelect(wxCommandEvent& event);
00053 void OnConstraintsChange(wxCommandEvent& event);
00054
00057 void InitFunctionDirty();
00058 private:
00059
00060 void set_properties();
00061 void do_layout();
00062
00063
00067 void UpdateFunction();
00069 bool ParseFunction();
00071 void RefreshList();
00072
00077 wxArrayInt MarkInvalidConstraints() const;
00078
00084 void RemoveInvalidConstraints(const wxArrayInt& indexes);
00085
00086
00087 CountedPtr<const Parser> mcpParser;
00088 CountedPtr<const FunctionBase> mcpFunction;
00089 CountedPtr<const VariableNames> mcpVariables;
00090 vector<Constraint> mConstraints;
00091
00092 ProblemBase* mpProblem;
00093
00094 bool mFunctionDirty;
00095
00096 History& mrConstraintHistory;
00097
00098 protected:
00099
00100 wxStaticBox* sizer_5_staticbox;
00101 wxStaticBox* sizer_10_staticbox;
00102 wxComboBox* mpFunctionCombo;
00103 wxListBox* mpConstraintList;
00104 wxButton* mpAddButton;
00105 wxButton* mpEditButton;
00106 wxButton* mpRemoveButton;
00107
00108
00109 DECLARE_EVENT_TABLE()
00110 };
00111
00112
00113 #endif // CONSTRAINTSPANEL_H