Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

gadget_SysSize.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  *  sys_size.c
00026  *
00027  *  Author            : Gergely Gáti
00028  *  Date              :
00029  *  Description       :
00030  *
00031  */
00032 #include <stdlib.h>
00033 
00034 #include "gadgets/gadget_SysSize.h"
00035 
00036 #include "debug.h"
00037 #include "classes.h"
00038 #include "Bases.h"
00039 #include "Module.h"
00040 #include "Common.h"
00041 #include "Window.h"
00042 
00043 
00044 struct _sys_size
00045 {
00046   Gadget_t gadget;
00047   int position;
00048 /*
00049   u32 col_title;
00050   u32 col_white;
00051   u32 col_black;
00052 */
00053 };
00054 
00055 
00056 static bases_Modules_t *api;
00057 VERSION("SysSize.gadget",1,1,"Gergely Gati","g.gati@freemail.hu");
00058 
00059 static gadget_Binding_t binding[]=
00060 {
00061   {"position",  TAG_SSZ_POSITION,     GADGET_INT,     NULL},
00062   GADGET_BINDING_DONE
00063 };
00064 
00065 
00066 
00067 /*
00068  *  This function is always called after the Gadget_t has been created and
00069  *  attached to the Gadget_t tree, but before the call to sys_size_layout(). It may be
00070  *  called more than once. It must fill in the Gadget_t's minimum and maximum
00071  *  sizes into the supplied extent structures.
00072  */
00073 static void sys_size_get_extent(Gadget_t *this, Extent_t *min, Extent_t *max)
00074 {
00075   debug_Begin();
00076 
00077   min->width=1;
00078   min->height=1;
00079   max->width=GADGET_MAXIMUM_SIZE;
00080   max->height=GADGET_MAXIMUM_SIZE;
00081 
00082   debug_End();
00083 }
00084 
00085 
00086 /*
00087  *  This function is called always after sys_size_get_extent() has been called at
00088  *  least once. It receives a position and an extent which determine the
00089  *  position and the size of the Gadget_t on the screen. This extent is always
00090  *  between the minimum and maximum sizes which were returned by
00091  *  sys_size_get_extent() of the same gadget. After this call the Gadget_t is made
00092  *  visible.
00093  */
00094 static void sys_size_layout(Gadget_t *this, Rect_t *rect)
00095 {
00096 //  int iw,ih,il,it;
00097 
00098   debug_Begin();
00099 
00100 /*
00101   iw=rect->width-(rect->width/3);
00102   ih=rect->height-(rect->height/3);
00103   il=rect->left+((rect->width-iw)>>1);
00104   it=rect->top+((rect->height-ih)>>1);
00105   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,((sys_size *)this)->col_title,TAG_DONE);
00106   api->glw_Call(GLW_DRAWFILLEDRECT,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_LEFT,rect->left,TAG_GLW_TOP,rect->top,TAG_GLW_WIDTH,rect->width,TAG_GLW_HEIGHT,rect->height,TAG_DONE);
00107   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,((sys_size *)this)->col_black,TAG_DONE);
00108   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,rect->left,TAG_GLW_Y1,rect->top+rect->height-1,TAG_GLW_X2,rect->left+rect->width-1,TAG_GLW_Y2,rect->top+rect->height-1,TAG_DONE);
00109   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,rect->left+rect->width-1,TAG_GLW_Y1,rect->top+rect->height-1,TAG_GLW_X2,rect->left+rect->width-1,TAG_GLW_Y2,rect->top,TAG_DONE);
00110   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,((sys_size *)this)->col_white,TAG_DONE);
00111   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,rect->left,TAG_GLW_Y1,rect->top,TAG_GLW_X2,rect->left,TAG_GLW_Y2,rect->top+rect->height-1,TAG_DONE);
00112   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,rect->left,TAG_GLW_Y1,rect->top,TAG_GLW_X2,rect->left+rect->width-1,TAG_GLW_Y2,rect->top,TAG_DONE);
00113 
00114   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,((sys_size *)this)->col_black,TAG_DONE);
00115   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,il,TAG_GLW_Y1,it+ih-1,TAG_GLW_X2,il+iw-1,TAG_GLW_Y2,it+ih-1,TAG_DONE);
00116   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,il+iw-1,TAG_GLW_Y1,it+ih-1,TAG_GLW_X2,il+iw-1,TAG_GLW_Y2,it,TAG_DONE);
00117   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,((sys_size *)this)->col_white,TAG_DONE);
00118   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,il,TAG_GLW_Y1,it+ih-1,TAG_GLW_X2,il+iw-1,TAG_GLW_Y2,it,TAG_DONE);
00119 */
00120 
00121   debug_End();
00122 }
00123 
00124 
00125 static void sys_size_suggest_extent(Gadget_t *this, Rect_t *rect)
00126 {
00127   debug_Begin();
00128 
00129   debug_End();
00130 }
00131 
00132 
00133 static int sys_size_input_event_handler(Gadget_t *gad, struct glw_Event *event)
00134 {
00135   int ret=0;
00136 
00137   debug_Begin();
00138 
00139   switch(event->event)
00140   {
00141     case GLWEV_MOUSEMOVE:
00142     {
00143       break;
00144     }
00145     case GLWEV_MOUSEBUTTONS:
00146     {
00147       switch(event->data)
00148       {
00149         case GLWEVD_LEFTDOWN:
00150         {
00151           api->gadget_Call(GADGET_REFRESH,TAG_GADGET_OBJECT,gad,TAG_DONE);
00152           api->glw_Call(GLW_RESIZEWINDOW,TAG_GLW_WINDOW,gad->window->handle, TAG_GLW_TYPE,((sys_size *)gad)->position,TAG_DONE);
00153           ret=api->gadget_Call(GADGET_CALLBACK,TAG_GADGET_OBJECT,gad,TAG_GADGET_EVENT,CBK_WINDOW_SIZE,TAG_GADGET_EVENT_DATA,0L,TAG_DONE);
00154           break;
00155         }
00156         case GLWEVD_LEFTUP:
00157         {
00158           break;
00159         }
00160       }
00161       break;
00162     }
00163   }
00164 
00165   debug_End();
00166 
00167   return(ret);
00168 }
00169 
00170 
00171 int sys_size_init_gadget(Gadget_t *this, tag *taglist)
00172 {
00173   sys_size *gad=(sys_size *)this;
00174 
00175   debug_Begin();
00176 
00177   gad->position=(int)tag_GetTagData(taglist,TAG_SSZ_POSITION,8L);
00178 /*
00179   ((sys_size *)this)->col_title=0x6182ae;
00180   ((sys_size *)this)->col_white=0xefefef;
00181   ((sys_size *)this)->col_black=0x000000;
00182 */
00183   debug_End();
00184 
00185   return(0);
00186 }
00187 
00188 
00189 static int sys_size_gadget_event_handler(Gadget_t *this, int event, tag *taglist)
00190 {
00191   int ret=-1;
00192 
00193   debug_Begin();
00194 
00195   if(this!=NULL&&event>=0)
00196   {
00197     switch(event)
00198     {
00199       case GADEV_INIT_GADGET:
00200       {
00201         ret=sys_size_init_gadget(this,taglist);
00202         break;
00203       }
00204       case GADEV_DELETE_GADGET:
00205       {
00206         ret=0;
00207         break;
00208       }
00209       case GADEV_GET_EXTENT:
00210       {
00211         Extent_t *min,*max,n,x;
00212         min=(Extent_t *)tag_GetTagData(taglist,TAG_GAD_EXTMIN,(u32)&n);
00213         max=(Extent_t *)tag_GetTagData(taglist,TAG_GAD_EXTMAX,(u32)&x);
00214         sys_size_get_extent(this,min,max);
00215         ret=0;
00216         break;
00217       }
00218       case GADEV_SUGGEST_EXTENT:
00219       {
00220         Rect_t *rect,r;
00221         rect=(Rect_t *)tag_GetTagData(taglist,TAG_GAD_RECT,(u32)&r);
00222         sys_size_suggest_extent(this,rect);
00223         ret=0;
00224         break;
00225       }
00226       case GADEV_LAYOUT:
00227       case GADEV_DAMAGE:
00228       {
00229         Rect_t *rect,r;
00230         rect=(Rect_t *)tag_GetTagData(taglist,TAG_GAD_RECT,(u32)&r);
00231         sys_size_layout(this,rect);
00232         ret=0;
00233         break;
00234       }
00235     }
00236   }
00237 
00238   debug_End();
00239 
00240   return(ret);
00241 }
00242 
00243 
00244 /*
00245  *  This function is called once before the creation of any Gadget_t of this
00246  *  class. Gadgets can be created only after this function has been called.
00247  */
00248 static void init_sys_size_class(u32 module)
00249 {
00250   api->gadget_Call(GADGET_REGISTER_CLASS,
00251                             TAG_GADGET_CLASS_ID,CLASS_SYS_SIZE_ID,
00252                             TAG_GADGET_NAME,CLASS_SYS_SIZE_NAME,
00253                 TAG_GADGET_BINDING,binding,
00254                 TAG_GADGET_COLOR_NAMES,NULL,
00255                 TAG_GADGET_CUSTOM_NAMES,NULL,
00256                 TAG_GADGET_STATE_MASK,GADSTF_NORMAL,
00257                 TAG_GADGET_MODULE,module,
00258                 TAG_GADGET_GADGET_SIZE,sizeof(sys_size),
00259                 TAG_GADGET_METHODS,NULL,
00260                 TAG_GADGET_INPUT_EVENT_HANDLER,sys_size_input_event_handler,
00261                 TAG_GADGET_EVENT_HANDLER,NULL,
00262                 TAG_GADGET_GADGET_EVENT_HANDLER,sys_size_gadget_event_handler,
00263                 TAG_DONE);
00264 }
00265 
00266 
00267 
00268 EXPORT int module_Init(u32 module, bases_Modules_t *bases)
00269 {
00270     api=bases;
00271     init_sys_size_class(module);  return(0);
00272 }

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