/home/enzo/treballs/fib/pfc/nanocomp/src/truthTableCanvas.hpp

Go to the documentation of this file.
00001 /*
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   This program is distributed in the hope that it will be useful,       *
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00011  *   GNU General Public License for more details.                          *
00012  *                                                                         *
00013  *   You should have received a copy of the GNU General Public License     *
00014  *   along with this program; if not, write to the                         *
00015  *   Free Software Foundation, Inc.,                                       *
00016  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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 //Custom event to send when the user changes an output
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 /*TRUTHTABLECANVAS_HPP_*/

Generated on Fri Sep 1 23:55:14 2006 for NanoComp by  doxygen 1.4.6