00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00030 #ifndef TRUTHTABLECANVAS_HPP_
00031 #define TRUTHTABLECANVAS_HPP_
00032
00033 #include <wx/wx.h>
00034 #include <wx/grid.h>
00035 #include <vector>
00036 #include "truthTable.hpp"
00037
00038 using namespace std;
00039
00040 class TruthTableCanvas : public wxGrid
00041 {
00042 public:
00043 TruthTableCanvas(wxWindow *parent, wxWindowID id, TruthTable initialTable);
00044 void setNewTable(TruthTable newTable);
00045 TruthTable getTable();
00046 virtual ~TruthTableCanvas();
00047 void setEditable(bool editable);
00048
00049 private:
00050 DECLARE_EVENT_TABLE()
00051 void setTable();
00052 vector<wxString> getInputsString(int i);
00053 vector<bool> getInputsVector(int i);
00054 void OnCellChanged(wxGridEvent& ev);
00055 vector<bool> getOutputs(int i);
00056 void initColours();
00057 wxColour *colourInputTrue;
00058 wxColour *colourInputFalse;
00059 wxColour *colourOutputTrue;
00060 wxColour *colourOutputFalse;
00062 TruthTable table;
00064 bool editable;
00065 };
00066
00067
00068
00077 class TruthTableCanvasEvent: public wxNotifyEvent
00078 {
00079 public:
00080 TruthTableCanvasEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
00081
00082 vector<bool> getInput();
00083 int getOutput();
00084 void setInput(vector<bool> newInput);
00085 void setOutput(int newOutput);
00086
00087 private:
00088 vector<bool> input;
00089 int output;
00090 };
00091
00092 BEGIN_DECLARE_EVENT_TYPES()
00093 DECLARE_EVENT_TYPE(TRUTH_TABLE_CANVAS_ACTION, -1)
00094 END_DECLARE_EVENT_TYPES()
00095
00096 typedef void (wxEvtHandler::*TruthTableCanvasEventFunction)(TruthTableCanvasEvent&);
00097
00098 #define EVT_TRUTH_TABLE_CANVAS(id, fn) \
00099 DECLARE_EVENT_TABLE_ENTRY( TRUTH_TABLE_CANVAS_ACTION, id, -1, \
00100 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) \
00101 wxStaticCastEvent( TruthTableCanvasEventFunction, & fn ), (wxObject *) NULL ),
00102
00103 #endif