iiscell.h

Go to the documentation of this file.
00001 #include <qmainwindow.h>
00002 #include <qtable.h>
00003 #include <queue>
00004 #include "value.h"
00005 #include "ranges.h"
00006 #include "PetriNets/place.h"
00007 
00008 class CallMember;
00009 
00010 //---------------------------------------------------------------
00011 //                          SpreadSheet Cell
00012 //---------------------------------------------------------------
00013 
00025 class IisCell: public QTableItem
00026 {
00027   friend class CallMember;
00028  public:
00029   typedef void (IisCell::*member)();
00030  private:
00036   void link(AbstractPlace&, member);
00037   void queueCall(CallMember* m);
00038   void flushCalls();
00039  private:
00044   Place<QString> entered;       // the entered text
00045   
00051   Place<Value*>  formule;       // the underlying formule
00052   
00059   Place<Value*>  value;         // the computed value
00060 
00069   Place<QImage>  image;         // the visualized image
00070   
00079   Place<bool>    show_status;   // true when entered string should be shown
00080 
00089   Place<QString> show;        // the visualized text
00090   
00095   void image_changed();
00096   
00102   void show_changed();
00103 
00107   void visual_changed();
00108 
00115   void show_value();
00116 
00121   int     scale_xs;
00122 
00127   int     scale_ys;  // if scale_xs & ys are consistent with the width & height 
00128 
00138   QImage  scaled;    // then scaled contains the scaled image
00139   
00140  private:
00141   
00146   list<IisCell*> listeners;
00147   
00151   list<IisCell*> inputs;
00152 
00158   void gather_inputs(Value * v);
00159 
00163   void add_listener(IisCell *who);
00164 
00168   void del_listener(IisCell *who);
00169 
00176   void mark_inputs(bool add);
00177 
00181   void clear_inputs();
00182   
00187   void set_inputs();
00188 
00194   void updated();
00195 
00201   void value_changed();
00202 
00209   void formule_changed();
00210 
00215   void show_status_changed();
00216 
00221   Place<bool> needs_recalculation;
00222 
00229   void recalc_changed();
00230  public: 
00231 
00236   void mark_recalc();
00237 
00238  private:
00243   bool user_input_allowed;
00244   
00245  public:
00249   bool needs_user_input();
00250 
00254   void mark_allow_ui();
00255 
00256  protected:
00260   bool will_influence(IisCell *);
00264   bool will_loop();
00265  public:
00266 
00275   IisCell::IisCell(QTable * table, EditType et);
00276   
00280   virtual void setText ( const QString & str);
00281 
00282  private:
00283   
00289   void entered_changed();
00290 
00291  public:
00298    void recalc();
00299    
00306    bool can_be_calculated_now();
00307  public:
00312    QString getFormuleTextForCell(int x, int y);
00313 
00318    QWidget * createEditor () const;
00319 
00325    void rowsInserted(int row, int nr);
00326 
00332    void colsInserted(int col, int nr);
00333 
00347    virtual void paint (QPainter * p, const QColorGroup & cg, const QRect & cr, bool selected);
00348 
00354    Data saveFile(QString prefix);
00355 
00360    void load(Data data);
00361 
00362  private:
00367    Value * evaluate(Value * what);
00368 
00372    Value * lookup(Reference * var);
00373    
00378    Value * lookup(Range * var);
00379    
00386    Value * fetch_value();
00387 
00391    Value * apply(Expression * what);
00392 };

Generated on Mon Jun 5 22:08:42 2006 for iis by  doxygen 1.4.6