Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

gadget_SysBar.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_bar.c
00026  *
00027  *  Author            : Gergely Gáti
00028  *  Date              :
00029  *  Description       :
00030  *
00031  */
00032 #include <stdlib.h>
00033 
00034 #include "gadgets/gadget_SysBar.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 
00045 struct _sys_bar
00046 {
00047   Gadget_t gadget;
00048 };
00049 
00050 static bases_Modules_t *api;
00051 VERSION("SysBar.gadget",1,0,"Gergely Gati","g.gati@freemail.hu");
00052 
00053 
00054 /*
00055  *  This function is always called after the Gadget_t has been created and
00056  *  attached to the Gadget_t tree, but before the call to sys_bar_layout(). It may be
00057  *  called more than once. It must fill in the Gadget_t's minimum and maximum
00058  *  sizes into the supplied extent structures.
00059  */
00060 static void sys_bar_get_extent(Gadget_t *this, Extent_t *min, Extent_t *max)
00061 {
00062   debug_Begin();
00063 
00064   min->width=2;
00065   min->height=16;
00066   max->width=GADGET_MAXIMUM_SIZE;
00067   max->height=16;
00068 
00069   debug_End();
00070 }
00071 
00072 
00073 /*
00074  *  This function is called always after sys_bar_get_extent() has been called at
00075  *  least once. It receives a position and an extent which determine the
00076  *  position and the size of the Gadget_t on the screen. This extent is always
00077  *  between the minimum and maximum sizes which were returned by
00078  *  sys_bar_get_extent() of the same gadget. After this call the Gadget_t is made
00079  *  visible.
00080  */
00081 static void sys_bar_layout(Gadget_t *this, Rect_t *rect)
00082 {
00083 
00084 /*
00085   windowtitle = 0x6182ae
00086   white = 0xefefef
00087   black = 0x000000
00088 */
00089 
00090   debug_Begin();
00091 
00092   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,0x6182ae,TAG_DONE);
00093   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);
00094   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,0xefefef,TAG_DONE);
00095   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);
00096   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);
00097   api->glw_Call(GLW_SETCOLOR,TAG_GLW_WINDOW,this->window->handle, TAG_GLW_RGB,0x000000,TAG_DONE);
00098   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);
00099   api->glw_Call(GLW_DRAWLINE,TAG_GLW_WINDOW,this->window->handle,TAG_GLW_X1,rect->left+rect->width-1,TAG_GLW_Y1,rect->top,TAG_GLW_X2,rect->left+rect->width-1,TAG_GLW_Y2,rect->top+rect->height-1,TAG_DONE);
00100 
00101   debug_End();
00102 }
00103 
00104 
00105 #if 0
00106   static int sys_bar_input_event_handler(Gadget_t *gad, struct glw_Event *event)
00107   {
00108     return(0);
00109   }
00110 #endif
00111 
00112 
00113 int sys_bar_init_gadget(Gadget_t *this, tag *taglist)
00114 {
00115   debug_Begin();
00116   debug_End();
00117   return(0);
00118 }
00119 
00120 
00121 static int sys_bar_gadget_event_handler(Gadget_t *this, int event, tag *taglist)
00122 {
00123   int ret=-1;
00124 
00125   debug_Begin();
00126 
00127   if(this!=NULL&&event>=0)
00128   {
00129     switch(event)
00130     {
00131       case GADEV_INIT_GADGET:
00132       {
00133         ret=sys_bar_init_gadget(this,taglist);
00134         break;
00135       }
00136       case GADEV_DELETE_GADGET:
00137       {
00138         ret=0;
00139         break;
00140       }
00141       case GADEV_GET_EXTENT:
00142       {
00143         Extent_t *min,*max,n,x;
00144         min=(Extent_t *)tag_GetTagData(taglist,TAG_GAD_EXTMIN,(u32)&n);
00145         max=(Extent_t *)tag_GetTagData(taglist,TAG_GAD_EXTMAX,(u32)&x);
00146         sys_bar_get_extent(this,min,max);
00147         ret=0;
00148         break;
00149       }
00150       case GADEV_LAYOUT:
00151       case GADEV_DAMAGE:
00152       {
00153         Rect_t *rect,r;
00154         rect=(Rect_t *)tag_GetTagData(taglist,TAG_GAD_RECT,(u32)&r);
00155         sys_bar_layout(this,rect);
00156         ret=0;
00157         break;
00158       }
00159     }
00160   }
00161 
00162   debug_End();
00163 
00164   return(ret);
00165 }
00166 
00167 
00168 /*
00169  *  This function is called once before the creation of any Gadget_t of this
00170  *  class. Gadgets can be created only after this function has been called.
00171  */
00172 static void init_sys_bar_class(u32 module)
00173 {
00174   api->gadget_Call(GADGET_REGISTER_CLASS,
00175                             TAG_GADGET_CLASS_ID,CLASS_SYS_BAR_ID,
00176                             TAG_GADGET_NAME,CLASS_SYS_BAR_NAME,
00177                 TAG_GADGET_BINDING,NULL,
00178                 TAG_GADGET_COLOR_NAMES,NULL,
00179                 TAG_GADGET_CUSTOM_NAMES,NULL,
00180                 TAG_GADGET_STATE_MASK,GADSTF_NORMAL,
00181                 TAG_GADGET_MODULE,module,
00182                 TAG_GADGET_GADGET_SIZE,sizeof(sys_bar),
00183                 TAG_GADGET_METHODS,NULL,
00184                 TAG_GADGET_INPUT_EVENT_HANDLER,NULL,
00185                 TAG_GADGET_EVENT_HANDLER,NULL,
00186                 TAG_GADGET_GADGET_EVENT_HANDLER,sys_bar_gadget_event_handler,
00187                 TAG_DONE);
00188 }
00189 
00190 
00191 EXPORT int module_Init(u32 module, bases_Modules_t *bases)
00192 {
00193     api=bases;
00194     init_sys_bar_class(module);  return(0);
00195 }

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