Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

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

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