Hi all..

I have an implementation of The Conway Game Of Life which i am using to
experiment with the various drawing functions.

I had it working when using fl_rectf as the shape to draw and setting the 
colour with
group->child(count)->color(n);

But with my polygons and new class designthat is not working..

My new class looks like this as I wanted to make the shape coords calculation 
internal, but now i cannot get the widget to update its colours depending on 
cell status after each generation as the algorithm runs

//excerpt from the header

#ifndef LIFE_H_INCLUDED
#define LIFE_H_INCLUDED

#include<vector>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Button.H>
#include "fluidUI.h"

using namespace std;

class DrawBox : public Fl_Widget {
public:
   DrawBox(int X, int Y, int W, int H, const char*L=0)
   : Fl_Widget(X,Y,W,H,L) {

      //assign a value to fill_colour here...
      if(fill_colour == 25) //will be consts when colours are decided..!
        line_color = 25;
      else
        line_color = 0;

    SetDims(X,Y,W,H);
    }
        void draw()
        {
            fl_color(fill_color);
            fl_polygon(x,y,x1,y1,x2,y2,x3,y3); //four sided polgon
            fl_color(line_color);
            fl_yxline(x,y,y2);
        }

    private:
    int fill_color;
    int line_color;
    int x, x1, x2, x3;
    int y, y1, y2, y3;
    void SetDims(int xpos, int ypos, int wid, int hgt)
    {
        x = xpos + (wid * 0.5);
        y = ypos;
        x1 = xpos + wid;
        y1 = ypos + (hgt * 0.75);
        x2 = x; //reuse the 'halfway accross widget' value already calculated
        y2 = ypos + hgt;
        x3 = xpos;
        y3 = y1; //reuse the '2thirds of way down widget' value }
};

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to