[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: UrShape: Definition by controversy



Ok, well here is my take on the UrShape.  I rearanged the structures to be
a bit more object oriented.  I havent put in the behaviors yet.  This is
just a skeleton.  The gist of it is that everything is a UrShape with
global ur functions to manipulate the tree.  UrContainers inherit from
UrShape and are the only structures allowed to have children (this is only
partialy true since SVG defines its own parent child relationships.)
UrContainer can hold UrShapes hence they can hold anything inherited from
UrShapes.  We could define classes for each type of container but the bulk
of this will be handled by the dynamicly binded behavors and some sort of
attribute hash that hasn't been worked out yet.  Can we create a hash that
can hold both text and numerical data so that we don't have to convert
each time we want access to an attribute?  Hard coding these means classes
for each type of container, SVG shape and widget.

-J5

Andre Kloss wrote:

> Hi again.
>
> I'm running out of time as well as motivation and, worst of all,
> ideas. Ok, let's see, what we have now:
>
> I need some Callback that a dragged UrShape can perform in order to
> interact somehow with the UrContainer. The source for the UrShape
> side of this functionality should read like this:
>
> if (IS_IN(myself, container->bounding_box) && !isOver) {
>   isOver = TRUE; /* Perform this once */
>   container->behaviour->isOver(container, myself); /* interact */
> }
>
> Same goes for isOut and isDropped. I'm not sure yet if the select
> callback belongs to the container or the UrShape, but well, here we
> are - for now.
>
> I still have no clue about the "normal" UrContainer Behaviour. If
> someone could enlighten this to me, I would be able to think further
> in that direction.
>
> cu Andre
>
> 8<-----------------------------UrShape.h--------------------->8
>
> /* urshape.h : defining the generic UrShape */
> #ifndef URSHAPE_H
> #define URSHAPE_H
>
> #include "element.h"
> /* What else has to be included? */
>
> typedef enum _UrContainerType UrContainerType;
> typedef struct _UrContainerBehaviour UrContainerBehaviour;
> typedef struct _UrContainer UrContainer;
> typedef struct _UrShape UrShape;
>
> enum _UrContainerType {
>   SINGLE,
>   HORIZANTAL_ARRAY,
>   VERTICAL_ARRAY,
>   TABLE
> };
>
> struct _UrContainerBehaviour {
>   void (isOver)(UrContainer *myself, UrShape *other);
>   void (isOut)(UrContainer *myself, UrShape *other);
>   void (isDropped)(UrContainer *myself, UrShape *other);
>   void (select)(UrContainer *myself);
> /* YOUR PROPOSAL GOES HERE */
> }
>
> struct _UrContainer {
>   UrContainerType type; /* Is it a Simple-/Array- or
>                            Table-Container? */
>   UrContainerBehaviour behaviour; /* To discriminate behaviour */
>
>   /* (Dynamic) geometry stuff */
>   Rectangle *bounding_box;
>   GList *rows;          /* The left border of rows */
>   GList *columns;       /* The upper border of columns */
> }
>
> struct _UrShape {
>   Element element;      /* Inheritance (C sometimes sucks ;) */
>
>   /* UrShape container stuff */
>   UrContainer *embedding; /* NULL if free,
>                              "parent's" container else */
>   int row,column; /* For all but SINGLE, it'll be nice to know in what
>                      row/column the UrShape is embedded. */
>   GList *childrenContainers; /* The containers I have */
>
>   /* The miniDOM. Thanx to Cyrille, now it _is_ mini. */
>   UrShape *parent_shape;
>   GList *self; /* this->self->data == this */
>   GList *children; /* (this->children->data->parent_shape == this ||
>                        this->children == NULL) */
> };
>
> #endif
>
> _______________________________________________
> Dia-list mailing list
> Dia-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/dia-list
/* urshape.h : defining the generic UrShape */
#ifndef URSHAPE_H
#define URSHAPE_H

#include "element.h"
/* What else has to be included? */
/*prototypes for UrShape*/
UrShape *ur_document; /*root node of urshape*/
UrShape *ur_current_node;

/*this is just some functional programming to make processing a document easyer.
  Similar to the map function in scheme ur_foreach takes a tree of UrShapes,
  interates through every node and runs a user defined function on each node */

/*hey if we are using OO why not functional(generic) programming too? hehe*/ 
  
typedef gint (*node_proc)(UrShape*); /*function that takes UrShape * as an argument
                                       should return 1 to continue and 0 to stop*/

void ur_foreach( UrShape *document,node_proc func );
void ur_foreach_back( UrShape *document,node_proc func ); /*same as foreach but
                                                            iterates backwards
                                                            to propigate events*/ 

typedef enum _UrShapeType UrShapeType;
typedef enum _UrContainerType UrContainerType;
typedef enum _UrSVGType UrSVGType;
typedef enum _UrWidgetType UrWidgetType;
typedef struct _UrContainerBehaviour UrContainerBehaviour;
typedef struct _UrContainer UrContainer;
typedef struct _UrShapeBehaviour UrShapeBehaviour;
typedef struct _UrShape UrShape;

enum _UrShapeType {
  CONTAINER,
  SVG,
  WIDGET,
  CONNECTOR
}

enum _UrContainerType {
  SINGLE,
  HBOX,
  VBOX,
  TABLE
};

/*more to come but for now this is fine*/
enum _UrSVGType UrSVGType {
  LINE,
  BOX
};

enum _UrWidgetType{
  TEXTBOX
};

/*UrShape -- inherits from element*/
struct _UrShape {
  
  Element deceased_rich_uncle; /*yay, inheritence*/

  UrShapeType type;
  UrShapeBehavior *behaviour; 

  gint x; /*relative to container*/
  gint y; /*height and width already defined by element*/

  char *id; /*should we use GTK+ strings? Every node can have a hash ID
              for use with scripting*/

  int row,column; /* For all but SINGLE, it'll be nice to know in what
                     row/column the UrShape is embedded. 
                     *J5* shouldn't this be queried (parent->getRow(self)) instead of 
                     holding it itself?*/
  
  UrShape *parent;
  UrShape *peer;
  UrShape *self; /*only containers can have children*/
  
}; 

/*UrContainer -- inherits from  UrShape*/
struct _UrContainer {

  UrShape deceased_rich_uncle; 

  UrContainerType type;
  /*Now you may be asking yourself why no behavior?  
    Because, it is inherited as a pointer from UrShape.
    A simple cast (UrContainerBehavior *)(deceased_rich_uncle->behavior)
    will do the trick.  Funny C OO */ 

  gint canDnD : 1;

  UrShape *child; /* I don't think lists are in order here. Should 
                     Lists be used instead of peer pointers?*/

  Rectangle *bounding_box;
  GList *rows;          /* The left border of rows */
  GList *columns;       /* The upper border of columns */
};

/*UrSVG -- inherits from  UrShape*/
struct _UrSVG {
  UrShape deceased_rich_uncle; 

  UrSVGType type;
};

/*UrWidget -- inherits from  UrShape*/
struct _UrWidget {
  UrShape deceased_rich_uncle; 

  UrWidgetType type;
};




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK