include/liqcell.h

00001 
00002 
00003 #ifndef liqcell_H
00004 #define liqcell_H
00005 
00006 #include "liqbase.h"
00007 //#include "liqcell_easyrun.h"
00008 //#include "liqcell_prop.h"
00009 
00010 
00011 //#########################################################################
00012 //#########################################################################
00013 //######################################################################### cell type definition
00014 //#########################################################################
00015 //#########################################################################
00016 
00017 typedef
00018 struct liqcell
00019 {
00020         unsigned int usagecount;
00021         //struct liqcell *linkcontent;                  // this gives me a shiver..
00022         struct liqcell *linkparent;
00023         struct liqcell *linkprev;
00024         struct liqcell *linknext;
00025         struct liqcell *linkchild;
00026         //int childcount;
00027 
00028         int    kind;                                            // see cellkind_ enumeration
00029 
00030 
00031                                                                                 // 1=prop               - a none visual property
00032                                                                                 // 2=visual             - a user interface element
00033                                                                                 // 4=widget         - a core widget component, the "base"
00034 
00035         char * name;
00036         char * classname;
00037         char * context;
00038         void * data;                                            // YOU are in charge of allocation, perhaps I Should enforce rigidity
00039 
00040         // todo: VVV maybe fold these up into a single uint bitmask VVV
00041 
00042         int deleted;                                            // marked as deleted (recoverable), will decide on this later
00043         int visible;
00044         int enabled;
00045         int selected;
00046 
00047 
00048         int x;                                                          // these are our dimensions according to the parent
00049         int y;
00050         int w;
00051         int h;
00052 
00053         int kineticx;                                           // this is how fast we are travelling relative to our parent
00054         int kineticy;                                           // this will be moved shortly
00055 
00056         int overlapx;                                           // amount of overlap (just to keep the algo in place)
00057         int overlapy;
00058 
00059 
00060         int innerw;                                                     // these are our total required dimensions according to our contents
00061         int innerh;                                                     // all children are expected to exist within this area
00062 
00063         // another
00064         struct liqcell *content;                                // contained cell :)
00065 
00066         liqsketch *sketch;                                      // one of each of the media types are required.  i need to be able to write paint or draw directly :)
00067         liqimage  *image;
00068         liqfont   *font;
00069         int dirty;                                                      // the dirty flag is important, and should really be automatic
00070         int tag;
00071         int dirtyhold;
00072         char *caption;
00073 
00074         unsigned int unused[8];
00075 
00076 }       liqcell;
00077 
00078 #define cellkind_prop      1
00079 #define cellkind_visual    2
00080 #define cellkind_widget    4
00081 #define cellkind_shown     8
00082 
00083 
00084 int liqcell_iskind(liqcell *self,int cellkind);
00085 /*
00086         // old style iter code
00087         liqcell *c=self->linkchild;
00088         while(c)
00089         {
00090                 // do action
00091                 c=c->linknext;
00092         }
00093 
00094         // newer OO method, aim to not touch the ->members directly
00095         liqcell *c=liqcell_getlinkchild(self);
00096         while(c)
00097         {
00098                 // do action
00099                 c=liqcell_getlinknext(c);
00100         }
00101  */
00102 
00103 //#########################################################################
00104 //#########################################################################
00105 //######################################################################### cell construction and reference counting
00106 //#########################################################################
00107 //#########################################################################
00108 liqcell * liqcell_new();
00109 liqcell * liqcell_hold(liqcell *self);
00110 void    liqcell_release(liqcell *self);
00111 void    liqcell_free(liqcell *self);
00112 
00113 //######################################################################### standard constructors
00114 
00115 liqcell*  liqcell_quickcreatewidget(char *name,char *classname,int innerw,int innerh);
00116 liqcell*  liqcell_quickcreatevis(char *name,char *classname,int x,int y,int w,int h);
00117 liqcell*  liqcell_quickcreatedata(char *name,char *classname,void *data);
00118 liqcell*  liqcell_quickcreatenameclass(char *name,char *classname);
00119 //liqcell * liqcell_quickcreatefull(char *name,char *classname,char *context,void *data);
00120 
00121 //######################################################################### children and tree management
00122 
00123 liqcell*  liqcell_child_append(liqcell *self,liqcell *child);
00124 liqcell*  liqcell_child_insert(liqcell *self,liqcell *child);
00125 liqcell*  liqcell_child_insertsorted(liqcell *self, liqcell * ch);
00126 liqcell*  liqcell_child_insertsortedbyname(liqcell *self, liqcell * ch,int sortpositive);
00127 int liqcell_child_remove(liqcell *self,liqcell *child);
00128 
00129 liqcell*  liqcell_child_lookup(liqcell *self,char *name);
00130 liqcell*  liqcell_child_lookup_nameclass(liqcell *self,char *name,char *classname);
00131 
00132 
00133 
00134 liqcell *       liqcell_getlinkparent(liqcell *self);
00135 liqcell *       liqcell_getlinkprev(liqcell *self);
00136 liqcell *       liqcell_getlinknext(liqcell *self);
00137 liqcell *       liqcell_getlinkchild(liqcell *self);
00138 
00139 
00140 //######################################################################### searching
00141 
00142 //liqcell*  liqcell_findfirst(liqcell *self,char *query);
00143 liqcell*  liqcell_findnext(liqcell *self,char *query);
00144 
00145 
00146 
00147 liqcell*  liqcell_local_lookup(liqcell *self,char *name);
00148 liqcell*  liqcell_local_lookup_nameclass(liqcell *self,char *name,char *classname);
00149 liqcell*  liqcell_global_lookup(liqcell *self,char *name);
00150 liqcell*  liqcell_global_lookup_nameclass(liqcell *self,char *name,char *classname);
00151 
00152 void *  liqcell_handlerfind(liqcell *self,char *handlername);
00153 liqcell*  liqcell_handleradd( liqcell *self,char *handlername, void *handler);
00154 // add a handler but pass in some context data
00155 // the context is passed into the handler through an additional 3rd parameter
00156 liqcell*  liqcell_handleradd_withcontext( liqcell *self,char *handlername, void *handler,void *context);
00157 int     liqcell_handlerrun( liqcell *self,char *handlername,void *args);
00158 
00159 
00160 
00161 // example handler prototype
00162 // context will be NULL unless explicitely set at the time of configuring the handler
00163 //int   handler(liqcell *self,void *eventargs,void *context);
00164 
00165 
00166 char*  liqcell_local_lookup_getname(liqcell *self,char *name);
00167 char*  liqcell_local_lookup_getcaption(liqcell *self,char *name);
00168 
00169 
00170 //######################################################################### standard control properties
00171 
00172 void    liqcell_setname(liqcell *self,char *name);                              // symbolic identifier
00173 char *  liqcell_getname(liqcell *self);
00174 
00175 
00176 
00177 void    liqcell_setcaption(liqcell *self,char *caption);                // easy translatable label
00178 char *  liqcell_getcaption(liqcell *self);
00179 
00180 
00181 
00182 void    liqcell_setclassname(liqcell *self,char *classname);    // class name used to construct
00183 char *  liqcell_getclassname(liqcell *self);
00184 
00185 
00186 
00187 void    liqcell_setcontext(liqcell *self,char *context);                // variation used (if applicable)
00188 char *  liqcell_getcontext(liqcell *self);
00189 
00190 
00191 
00192 
00193 
00194 void    liqcell_setcontent(liqcell *self,liqcell *content);
00195 liqcell *       liqcell_getcontent(liqcell *content);
00196 
00197 int     liqcell_getqualifiedname(liqcell *self, char *buff, int buffmax);
00198 
00199 void    liqcell_setdata(liqcell *self,void *data);
00200 void *  liqcell_getdata(liqcell *self);
00201 
00202 
00203 void    liqcell_settag(liqcell *self,void *tag);
00204 void *  liqcell_gettag(liqcell *self);
00205 
00206 
00207 //liqcell *     liqcell_getlinkcontent(liqcell *self);
00208 
00209 
00210 
00211 //######################################################################### ui/interaction
00212 void    liqcell_setvisible(liqcell *self,int arg);                              // set the visible indicator
00213 int     liqcell_getvisible(liqcell *self);
00214 
00215 void    liqcell_setenabled(liqcell *self,int arg);                              // set the enabled indicator
00216 int     liqcell_getenabled(liqcell *self);
00217 
00218 void    liqcell_setselected(liqcell *self,int arg);                             // set the selected indicator
00219 int     liqcell_getselected(liqcell *self);
00220 
00221 void    liqcell_setdirty(liqcell *self,int dirty);                              // set the dirty flag :)  this cascades through parents as well
00222 int     liqcell_getdirty(liqcell *self);
00223 
00224 void    liqcell_setdirtyhold(liqcell *self,int dirtyhold);              // hold off on telling parent (useful if there are multiple changes due)
00225 int     liqcell_getdirtyhold(liqcell *self);
00226 
00227 
00228 void    liqcell_setshown(liqcell *self,int arg);                                // set the shown indicator flag
00229 int     liqcell_getshown(liqcell *self);
00230 
00231 int     liqcell_getflagvisual(liqcell *self);
00232 int     liqcell_getflagwidget(liqcell *self);
00233 //######################################################################### style attributes
00234 
00235 void    liqcell_setsketch(liqcell *self,liqsketch *sketch);
00236 liqsketch*liqcell_getsketch(liqcell *self);
00237 
00238 
00239 void    liqcell_setimage(liqcell *self,liqimage *image);
00240 liqimage *liqcell_getimage(liqcell *self);
00241 
00242 void    liqcell_setfont(liqcell *self,liqfont *font);
00243 liqfont *liqcell_getfont(liqcell *self);
00244 
00245 
00246 void    liqcell_sketch_autoload(liqcell *self);
00247 
00248 //######################################################################### rectangle boundary handlers
00249 
00250 void    liqcell_setpos(liqcell *self,int x,int y);
00251 void    liqcell_setsize(liqcell *self,int w,int h);
00252 void    liqcell_adjustpos(liqcell *self,int dx,int dy);
00253 void    liqcell_adjustsize(liqcell *self,int dw,int dh);
00254 void    liqcell_setkinetic(liqcell *self,int kx,int ky);
00255 void    liqcell_setrect(liqcell *self,int x,int y,int w,int h);
00256 
00257 int     liqcell_movetowardsrect(liqcell *self,int x,int y,int w,int h, float fraction); // return 0 if at target coords already, 1 if not yet there
00258 
00259 
00260 void liqcell_setrect_autoscale(liqcell *self,int x,int y,int w,int h,float sx,float sy);
00261 
00262 int     liqcell_getx(liqcell *self);
00263 int     liqcell_gety(liqcell *self);
00264 int     liqcell_getw(liqcell *self);
00265 int     liqcell_geth(liqcell *self);
00266 int     liqcell_getinnerw(liqcell *self);
00267 int     liqcell_getinnerh(liqcell *self);
00268 int     liqcell_getkineticx(liqcell *self);
00269 int     liqcell_getkineticy(liqcell *self);
00270 
00271 void    liqcell_forceinboundparent(liqcell *self);
00272 
00273 //######################################################################### Misc Functions
00274 
00275 void    liqcell_zorder_totop(liqcell *self);  // moves the cell to the top of the zorder, NULL function at present
00276 liqcell * liqcell_getbasewidget(liqcell *self); // called from within an event steps backwards until it finds the base widget this item was created by
00277 
00278 //######################################################################### Arrangement and Layout tools
00279 
00280 
00281 int     liqcell_child_countvisible(liqcell *self);
00282 
00283 int     liqcell_child_arrange_easytile(liqcell *self);                  // make sure all contents are bound within the area
00284 int     liqcell_child_arrange_easyrow(liqcell *self);                   // split into Left|Centre|Right boxes (newspaper panels)
00285 int     liqcell_child_arrange_easycol(liqcell *self);                   // split into Top|Middle|Bottom boxes (sections)
00286 
00287 
00288 int     liqcell_child_arrange_autoflow(liqcell *self);                  // flowing document: like text does;
00289 int     liqcell_child_arrange_nooverlap(liqcell *self,liqcell *currentselection);
00290 int     liqcell_child_arrange_makegrid(liqcell *self,int viscolcount,int visrowcount);
00291 
00292 
00293 
00294 //######################################################################### special handlers
00295 
00296 
00297 
00298 
00299 #endif

Generated on Sat May 23 23:03:13 2009 for libliqbase by  doxygen 1.5.1