Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

gadget_Container.c

Go to the documentation of this file.
00001 /*
00002  *    gui - [gega user interface] the flexible solution for user interface problems
00003  *    Copyright (C) 2002  Gergely Gati
00004  *
00005  *    This program is free software; you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation; version 2 of the License.
00008  *
00009  *    This program is distributed in the hope that it will be useful,
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *    GNU General Public License for more details.
00013  *
00014  *    You should have received a copy of the GNU General Public License
00015  *    along with this program; if not, write to the Free Software
00016  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  *    Gergely Gati
00019  *      email:           g.gati@freemail.hu
00020  *      AIM screenname:  GatiGergely
00021  *      ICQ number:      93131690
00022  *
00023  */
00024 /*
00025  *  container.c
00026  */
00027 #include <stdlib.h>
00028 
00029 #include "debug.h"
00030 #include "classes.h"
00031 #include "Memory.h"
00032 #include "Bases.h"
00033 #include "Module.h"
00034 #include "Common.h"
00035 
00036 #include "gadgets/gadget_Container.h"
00037 
00038 
00039 struct _container
00040 {
00041   Gadget_t gadget;
00042   Gadget_t *child;
00043 };
00044 
00045 
00046 
00047 static bases_Modules_t *api;
00048 VERSION("Container.gadget",1,0,"Gergely Gati","g.gati@freemail.hu");
00049 
00050 
00051 static int container_gadget_event_handler(Gadget_t *this, int event, tag *taglist)
00052 {
00053   int ret=-1;
00054 
00055   debug_Begin();
00056   debug_Message("event=%d",event);
00057 
00058   if(this!=NULL&&event>=0)
00059   {
00060     switch(event)
00061     {
00062       case GADEV_INIT_GADGET:
00063       {
00064         ret=0;
00065         break;
00066       }
00067       case GADEV_DELETE_GADGET:
00068       {
00069         ret=0;
00070         break;
00071       }
00072       case GADEV_GET_EXTENT:
00073       {
00074         Extent_t *min,*max,n,x;
00075         min=(Extent_t *)tag_GetTagData(taglist,TAG_GAD_EXTMIN,(u32)&n);
00076         max=(Extent_t *)tag_GetTagData(taglist,TAG_GAD_EXTMAX,(u32)&x);
00077         if(((container *)this)->child==NULL) ((container *)this)->child=(Gadget_t *)api->gadget_Call(GADGET_FIRST_CHILD,TAG_GADGET_OBJECT,this,TAG_DONE);
00078         if(((container *)this)->child!=NULL)
00079         {
00080           api->gadget_Call(GADGET_GET_EXTENT,TAG_GADGET_OBJECT,((container *)this)->child,TAG_GADGET_MIN,min,TAG_GADGET_MAX,max,TAG_DONE);
00081           ret=0;
00082         }
00083         break;
00084       }
00085       case GADEV_SUGGEST_EXTENT:
00086       {
00087         Rect_t *rect,r;
00088         rect=(Rect_t *)tag_GetTagData(taglist,TAG_GAD_RECT,(u32)&r);
00089         if(((container *)this)->child==NULL) ((container *)this)->child=(Gadget_t *)api->gadget_Call(GADGET_FIRST_CHILD,TAG_GADGET_OBJECT,this,TAG_DONE);
00090         if(((container *)this)->child!=NULL)
00091         {
00092           api->gadget_Call(GADGET_SUGGEST_EXTENT,TAG_GADGET_OBJECT,((container *)this)->child,TAG_GADGET_RECT,rect,TAG_DONE);
00093           ret=0;
00094         }
00095         break;
00096       }
00097       case GADEV_LAYOUT:
00098       {
00099         Rect_t *rect,r;
00100         rect=(Rect_t *)tag_GetTagData(taglist,TAG_GAD_RECT,(u32)&r);
00101         if(((container *)this)->child==NULL) ((container *)this)->child=(Gadget_t *)api->gadget_Call(GADGET_FIRST_CHILD,TAG_GADGET_OBJECT,this,TAG_DONE);
00102         if(((container *)this)->child!=NULL)
00103         {
00104           api->gadget_Call(GADGET_LAYOUT,TAG_GADGET_OBJECT,((container *)this)->child,TAG_GADGET_RECT,rect,TAG_DONE);
00105           ret=0;
00106         }
00107         break;
00108       }
00109       case GADEV_DAMAGE:
00110       {
00111         Rect_t *rect,r;
00112         rect=(Rect_t *)tag_GetTagData(taglist,TAG_GAD_RECT,(u32)&r);
00113         if(((container *)this)->child==NULL) ((container *)this)->child=(Gadget_t *)api->gadget_Call(GADGET_FIRST_CHILD,TAG_GADGET_OBJECT,this,TAG_DONE);
00114         if(((container *)this)->child!=NULL)
00115         {
00116           api->gadget_Call(GADGET_DAMAGE,TAG_GADGET_OBJECT,((container *)this)->child,TAG_GADGET_RECT,rect,TAG_DONE);
00117           ret=0;
00118         }
00119         break;
00120       }
00121       case GADEV_SAVE:
00122       {
00123         ret=0;
00124         break;
00125       }
00126       case GADEV_RESTORE:
00127       {
00128         ret=0;
00129         break;
00130       }
00131     }
00132   }
00133 
00134   debug_End();
00135 
00136   return(ret);
00137 }
00138 
00139 
00140 static void init_container_class(u32 module)
00141 {
00142   api->gadget_Call(GADGET_REGISTER_CLASS,
00143                             TAG_GADGET_CLASS_ID,CLASS_CONTAINER_ID,
00144                             TAG_GADGET_NAME,CLASS_CONTAINER_NAME,
00145                 TAG_GADGET_BINDING,NULL,
00146                 TAG_GADGET_COLOR_NAMES,NULL,
00147                 TAG_GADGET_CUSTOM_NAMES,NULL,
00148                 TAG_GADGET_STATE_MASK,GADSTF_NORMAL,
00149                 TAG_GADGET_MODULE,module,
00150                 TAG_GADGET_GADGET_SIZE,sizeof(container),
00151                 TAG_GADGET_METHODS,NULL,
00152                 TAG_GADGET_INPUT_EVENT_HANDLER,NULL,
00153                 TAG_GADGET_EVENT_HANDLER,NULL,
00154                 TAG_GADGET_GADGET_EVENT_HANDLER,container_gadget_event_handler,
00155                 TAG_DONE);
00156 }
00157 
00158 
00159 EXPORT int module_Init(u32 module, bases_Modules_t *bases)
00160 {
00161     api=bases;
00162     init_container_class(module);
00163     return(0);
00164 }

Generated on Tue Jan 7 12:11:19 2003 for THEGUI by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002