Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

Gui.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 /* DOXYGEN section: */
00057 #include <stdlib.h>
00058 #include <string.h>
00059 
00060 #include "macros.h"
00061 #include "debug.h"
00062 #include "Bases.h"
00063 #include "Locale.h"
00064 #include "Memory.h"
00065 #include "Net.h"
00066 #include "Skin.h"
00067 #include "xml_Gui.h"
00068 #include "classes.h"
00069 #include "Image.h"
00070 #include "Prefs.h"
00071 #include "Window.h"
00072 #include "Common.h"
00073 #include "Bitmap.h"
00074 #include "Terminal.h"
00075 
00076 
00077 #define GUI_TMP_STRING_BUFFER_SIZE  64
00078 //#define GUI_SERVER_BUFFER_SIZE      8192
00079 
00080 struct gui_Timer_s
00081 {
00082   Window_t *win;
00083   int (*callback)(Window_t *,u32);
00084   int flags;
00085   u32 millisec;
00086   u32 userdata;
00087   u32 id;
00088   Node_t *node;
00089 };
00090 
00091 
00092 static int gui_TimerCanceller(Window_t *win, u32 userdata);
00093 
00094 
00095 //Declare call_vector[]
00096 static u32 (*call_vector[GUI_FUNC_DONE-GUI_FUNCBASE+1])(tag *);
00097 VERSION("gui server",1,0,"Gergely Gati","g.gati@freemail.hu");
00098 
00099 
00100 static char *langs[]=
00101 {
00102   "ro",
00103   "hu",
00104   "ru",
00105   NULL
00106 };
00107 
00108 
00109 // r1 metszi r2-t?
00114 u32 gui_IsOverlap(u32 firsttag, ...)
00115 {
00116   return(gui_IsOverlapTL((tag *)&firsttag));
00117 }
00118 u32 gui_IsOverlapTL(tag *taglist)
00119 {
00120   Rect_t *r1;
00121   Rect_t *r2;
00122 
00123   int ret=TRUE;
00124 
00125 
00126   debug_Begin();
00127 
00128   r1=(Rect_t *)tag_GetTagData(taglist,TAG_GUI_R1,0L);
00129   r2=(Rect_t *)tag_GetTagData(taglist,TAG_GUI_R2,0L);
00130 
00131   if(r1->left+r1->width<=r2->left) ret=FALSE;
00132   else if(r1->left>=r2->left+r2->width) ret=FALSE;
00133   else if(r1->top+r1->height<=r2->top) ret=FALSE;
00134   else if(r1->top>=r2->top+r2->height) ret=FALSE;
00135 
00136   debug_End();
00137 
00138   return((u32)ret);
00139 }
00140 
00141 
00142 
00143 // r1 es r2 metszetet r3-ba
00149 u32 gui_CalculateOverlap(u32 firsttag, ...)
00150 {
00151   return(gui_CalculateOverlapTL((tag *)&firsttag));
00152 }
00153 u32 gui_CalculateOverlapTL(tag *taglist)
00154 {
00155   Rect_t *r1;
00156   Rect_t *r2;
00157   Rect_t *r3;
00158 
00159   int x1,y1,x2,y2;
00160 
00161   debug_Begin();
00162 
00163   r1=(Rect_t *)tag_GetTagData(taglist,TAG_GUI_R1,0L);
00164   r2=(Rect_t *)tag_GetTagData(taglist,TAG_GUI_R2,0L);
00165   r3=(Rect_t *)tag_GetTagData(taglist,TAG_GUI_R3,0L);
00166 
00167   x1=max(r1->left,r2->left);
00168   y1=max(r1->top,r2->top);
00169   x2=min(r1->left+r1->width,r2->left+r2->width);
00170   y2=min(r1->top+r1->height,r2->top+r2->height);
00171   r3->left=x1;
00172   r3->top=y1;
00173   r3->width=x2-x1;
00174   r3->height=y2-y1;
00175 
00176   debug_End();
00177   return(0L);
00178 }
00179 
00180 
00185 u32 gui_LoadFile(u32 firsttag, ...)
00186 {
00187   return(gui_LoadFileTL((tag *)&firsttag));
00188 }
00189 u32 gui_LoadFileTL(tag *taglist)
00190 {
00191   char *name;
00192   int *len;
00193 
00194   char *ret=NULL;
00195   int file_len;
00196   FILE *f;
00197 
00198 
00199   debug_Begin();
00200 
00201   name=(char *)tag_GetTagData(taglist,TAG_GUI_NAME,0L);
00202   len=(int *)tag_GetTagData(taglist,TAG_GUI_LEN,0L);
00203 
00204   if(name!=NULL&&NULL!=(f=fopen(name,"rb")))
00205   {
00206     fseek(f,0L,SEEK_END);
00207     file_len=ftell(f);
00208     fseek(f,0L,SEEK_SET);
00209     if(NULL!=(ret=mem_malloc(file_len+1)))
00210     {
00211       ret[0]='\0';
00212       fread(ret,file_len,1,f);
00213       if(len!=NULL) *len=file_len;
00214       ret[file_len]='\0';
00215     }
00216     fclose(f);
00217   }
00218   else debug_Warning("BAD file req name='%s'",name);
00219 
00220   debug_End();
00221 
00222   return((u32)ret);
00223 }
00224 
00225 
00230 u32 gui_LoadSubgadgetDescriptor(u32 firsttag, ...)
00231 {
00232   return(gui_LoadSubgadgetDescriptorTL((tag *)&firsttag));
00233 }
00234 u32 gui_LoadSubgadgetDescriptorTL(tag *taglist)
00235 {
00236   Window_t *win;
00237   char *class_name;
00238 
00239 static char ext[]=".xml";
00240 static char pre[]="gadget_";
00241   char *ret=NULL;
00242   char *fname;
00243 
00244   debug_Begin();
00245 
00246   win=(Window_t *)tag_GetTagData(taglist,TAG_GUI_WIN,0L);
00247   class_name=(char *)tag_GetTagData(taglist,TAG_GUI_CLASS_NAME,0L);
00248 
00249   if(class_name!=NULL&&NULL!=(fname=mem_malloc(sizeof(pre)-1+strlen(class_name)+sizeof(ext)-1+1)))
00250   {
00251     strcpy(fname,pre);
00252     strcat(fname,class_name);
00253     strcat(fname,ext);
00254 //    ret=(char *)net_LoadFile(TAG_NET_CONN,glw_GetConnection(window_GetHandle(win)),TAG_NET_NAME,fname,TAG_DONE);
00255     ret=(char *)net_LoadFile(TAG_NET_CONN,window_GetConnection(win),TAG_NET_NAME,fname,TAG_DONE);
00256     mem_free(fname);
00257   }
00258 
00259   debug_End();
00260 
00261   return((u32)ret);
00262 }
00263 
00264 
00268 u32 gui_UnLoadSubgadgetDescriptor(u32 firsttag, ...)
00269 {
00270   return(gui_UnLoadSubgadgetDescriptorTL((tag *)&firsttag));
00271 }
00272 u32 gui_UnLoadSubgadgetDescriptorTL(tag *taglist)
00273 {
00274   char *gui_file;
00275 
00276   debug_Begin();
00277 
00278   gui_file=(char *)tag_GetTagData(taglist,TAG_GUI_FILE,0L);
00279 
00280   if(gui_file!=NULL) mem_free(gui_file);
00281 
00282   debug_End();
00283 
00284   return(0L);
00285 }
00286 
00287 
00293 u32 gui_IsInside(u32 firsttag, ...)
00294 {
00295   return(gui_IsInsideTL((tag *)&firsttag));
00296 }
00297 u32 gui_IsInsideTL(tag *taglist)
00298 {
00299   Rect_t *rect;
00300   int x;
00301   int y;
00302 
00303   int ret=TRUE;
00304 
00305 
00306   debug_Begin();
00307 
00308   rect=(Rect_t *)tag_GetTagData(taglist,TAG_GUI_RECT,0L);
00309   x=(int )tag_GetTagData(taglist,TAG_GUI_X,0L);
00310   y=(int )tag_GetTagData(taglist,TAG_GUI_Y,0L);
00311 
00312   if(x<rect->left||x>=rect->left+rect->width||y<rect->top||y>=rect->top+rect->height) ret=FALSE;
00313 
00314   debug_End();
00315 
00316   return((u32)ret);
00317 }
00318 
00319 
00327 u32 gui_TimerStart(u32 firsttag, ...)
00328 {
00329   return(gui_TimerStartTL((tag *)&firsttag));
00330 }
00331 u32 gui_TimerStartTL(tag *taglist)
00332 {
00333     Window_t *win;
00334     u32 millisec;
00335     int flags;
00336     u32 userdata;
00337     int (*callback)(Window_t *,u32);
00338 
00339   gui_Timer_t *timer;
00340   Node_t *node;
00341 
00342   debug_Begin();
00343 
00344   win=(Window_t *)tag_GetTagData(taglist,TAG_GUI_WIN,0L);
00345   millisec=(u32 )tag_GetTagData(taglist,TAG_GUI_MILLISEC,0L);
00346   flags=(int )tag_GetTagData(taglist,TAG_GUI_FLAGS,0L);
00347   userdata=(u32 )tag_GetTagData(taglist,TAG_GUI_USERDATA,0L);
00348   callback=(int (*)(Window_t *,u32))tag_GetTagData(taglist,TAG_GUI_CALLBACK,0L);
00349 
00350   if(NULL!=(timer=mem_malloc(sizeof(gui_Timer_t)))&&NULL!=(node=list_CreateNode()))
00351   {
00352     list_SetNodeData(node,timer);
00353     list_InsertNodeTail(window_GetTimerList(win),node);
00354     timer->win=win;
00355     timer->callback=callback;
00356     timer->flags=flags;
00357     timer->millisec=millisec;
00358     timer->userdata=userdata;
00359     timer->id=glw_TimerStart(TAG_GLW_WINDOW,win->handle,TAG_GLW_MILLISEC,millisec,TAG_GLW_USERDATA,(u32)timer,TAG_DONE);
00360     timer->node=node;
00361   }
00362 
00363   debug_End();
00364 
00365   return((u32)timer);
00366 }
00367 
00368 
00373 u32 gui_TimerCancel(u32 firsttag, ...)
00374 {
00375   return(gui_TimerCancelTL((tag *)&firsttag));
00376 }
00377 u32 gui_TimerCancelTL(tag *taglist)
00378 {
00379   Window_t *win;
00380   u32 timer_id;
00381 
00382   int ret=-1;
00383   gui_Timer_t *timer;
00384 
00385   debug_Begin();
00386 
00387   win=(Window_t *)tag_GetTagData(taglist,TAG_GUI_WIN,0L);
00388   timer_id=(u32 )tag_GetTagData(taglist,TAG_GUI_TIMER_ID,0L);
00389 
00390   timer=(gui_Timer_t *)timer_id;
00391 
00392   if(timer!=NULL)
00393   {
00394     timer->callback=gui_TimerCanceller;
00395     ret=0;
00396   }
00397 
00398   debug_End();
00399 
00400   return((u32)ret);
00401 }
00402 
00403 
00409 u32 gui_GetLimitedTextLength(u32 firsttag, ...)
00410 {
00411   return(gui_GetLimitedTextLengthTL((tag *)&firsttag));
00412 }
00413 u32 gui_GetLimitedTextLengthTL(tag *taglist)
00414 {
00415   u32 font;
00416   char *str;
00417   int len;
00418 
00419   char tmpbuf[GUI_TMP_STRING_BUFFER_SIZE];
00420   int ret=-1;
00421   char *text;
00422 
00423 
00424   debug_Begin();
00425 
00426   font=(u32 )tag_GetTagData(taglist,TAG_GUI_FONT,0L);
00427   str=(char *)tag_GetTagData(taglist,TAG_GUI_STR,0L);
00428   len=(int )tag_GetTagData(taglist,TAG_GUI_LEN,0L);
00429 
00430   if(len<GUI_TMP_STRING_BUFFER_SIZE)
00431   {
00432     strncpy(tmpbuf,str,len);
00433     tmpbuf[len-1]='\0';
00434     ret=glw_GetTextLength(TAG_GLW_FONT,font,TAG_GLW_TEXT,tmpbuf,TAG_DONE);
00435   }
00436   else if(NULL!=(text=mem_malloc(len+1)))
00437   {
00438     strncpy(text,str,len);
00439     text[len-1]='\0';
00440     ret=glw_GetTextLength(TAG_GLW_FONT,font,TAG_GLW_TEXT,text,TAG_DONE);
00441     mem_free(text);
00442   }
00443 
00444   debug_End();
00445 
00446   return((u32)ret);
00447 }
00448 
00449 
00450 
00451 /* a string elso RETVAL karaktere fer bele a megadott szelessegbe
00452 */
00458 u32 gui_GetTextFitLength(u32 firsttag, ...)
00459 {
00460   return(gui_GetTextFitLengthTL((tag *)&firsttag));
00461 }
00462 u32 gui_GetTextFitLengthTL(tag *taglist)
00463 {
00464   u32 font;
00465   char *str;
00466   int width;
00467 
00468   int ret=-1;
00469 
00470 
00471   debug_Begin();
00472 
00473   font=(u32 )tag_GetTagData(taglist,TAG_GUI_FONT,0L);
00474   str=(char *)tag_GetTagData(taglist,TAG_GUI_STR,0L);
00475   width=(int )tag_GetTagData(taglist,TAG_GUI_WIDTH,0L);
00476 
00477   if(str!=NULL&&width>0&&font!=0L)
00478   {
00479     ret=strlen(str);
00480     while(width<gui_GetLimitedTextLength(TAG_GUI_FONT,font,TAG_GUI_STR,str,TAG_GUI_LEN,ret,TAG_DONE))
00481     {
00482       ret--;
00483     }
00484   }
00485 
00486   debug_End();
00487 
00488   return((u32)ret);
00489 }
00490 
00491 
00492 /* wrap: '\0', '\n', ' '
00493  * FIXME: SLOOOOW
00494  */
00500 u32 gui_GetTextWrapLength(u32 firsttag, ...)
00501 {
00502   return(gui_GetTextWrapLengthTL((tag *)&firsttag));
00503 }
00504 u32 gui_GetTextWrapLengthTL(tag *taglist)
00505 {
00506   u32 font;
00507   char *str;
00508   int width;
00509 
00510   int ret=-1,sti;
00511   char store,*del1,*del2,*del;
00512 
00513 
00514   debug_Begin();
00515 
00516   font=(u32 )tag_GetTagData(taglist,TAG_GUI_FONT,0L);
00517   str=(char *)tag_GetTagData(taglist,TAG_GUI_STR,0L);
00518   width=(int )tag_GetTagData(taglist,TAG_GUI_WIDTH,0L);
00519 
00520   ret=sti=gui_GetTextFitLength(TAG_GUI_FONT,font,TAG_GUI_STR,str,TAG_GUI_WIDTH,width);
00521   store=str[sti];
00522   str[sti]='\0';
00523   if(store!=' '&&store!='\n'&&store!='\0')
00524   {
00525     del1=strrchr(str,'\n');
00526     del2=strrchr(str,' ');
00527     if(del1!=NULL||del2!=NULL)
00528     {
00529       del=del2;
00530       if(del1<del2&&del1!=NULL) del=del1;
00531       ret=del-str;
00532     }
00533   }
00534   str[sti]=store;
00535 
00536   debug_End();
00537 
00538   return((u32)++ret);
00539 }
00540 
00541 
00542 /*
00543 Window_t *gui_FindWindow(Gadget_t *gadgetroot)
00544 {
00545   Node_t *node;
00546   Window_t *win=NULL;
00547 
00548   debug_Begin();
00549 
00550   for(node=list_GetNodeHead(windowlist);node!=NULL;node=list_GetNodeNext(windowlist,node))
00551   {
00552     win=(Window_t *)list_GetNodeData(node);
00553     if(win!=NULL&&win->gadgetroot==gadgetroot) break;
00554     win=NULL;
00555   }
00556 
00557   debug_End();
00558 
00559   return(win);
00560 }
00561 */
00562 
00563 
00564 
00565 int gui_Event(u32 conn, struct glw_Event *event)
00566 {
00567   int ret=0;
00568   int handled=0;
00569   Window_t *win;
00570   gui_Timer_t *timer;
00571   struct glw_SockMsg *msg;
00572 
00573   debug_Begin();
00574 
00575   win=(Window_t *)glw_GetWindowUserdata(TAG_GLW_WINDOW,event->window,TAG_DONE);
00576 
00577   debug_Message("event=%lx, data=%ld",event->event,event->data);
00578 
00579   if((event->mask&event->event)==0)
00580   {
00581     switch(event->event)
00582     {
00583       case GLWEV_DAMAGE:
00584       {
00585         debug_Message("GLWEV_DAMAGE");
00586         window_DamageWindow(win,(Rect_t *)event->data);
00587         handled=1;
00588         break;
00589       }
00590       case GLWEV_WINDOW:
00591       {
00592         debug_Message("GLWEV_WINDOW");
00593         switch(event->data)
00594         {
00595           case GLWEVD_REPAINT:
00596           case GLWEVD_SIZING:
00597           {
00598             window_RefreshWindow(TAG_WIN_OBJECT,win,TAG_DONE);
00599             handled=1;
00600             break;
00601           }
00602           case GLWEVD_SIZEBEGIN:
00603           {
00604             // vizualis jelzes: size
00605             handled=1;
00606             break;
00607           }
00608           case GLWEVD_SIZEEND:
00609           {
00610             // vizualis jelzes vege
00611             handled=1;
00612             break;
00613           }
00614           case GLWEVD_MOVING:
00615           {
00616             // semmi teendo
00617             handled=1;
00618             break;
00619           }
00620           case GLWEVD_MOVEBEGIN:
00621           {
00622             // vizualis jelzes: move
00623             handled=1;
00624             break;
00625           }
00626           case GLWEVD_MOVEEND:
00627           {
00628             // vizualis jelzes vege
00629             handled=1;
00630             break;
00631           }
00632         }
00633         break;
00634       }
00635       case GLWEV_TIMER:
00636       {
00637         // handle timeouts
00638         debug_Message("GLWEV_TIMER");
00639         timer=(gui_Timer_t *)event->data;
00640         if(0==(timer->callback(win,timer->userdata)))
00641         {
00642           if((timer->flags&GUI_TIMER_REPEAT)!=0) glw_TimerStart(TAG_GLW_WINDOW,win->handle,TAG_GLW_MILLISEC,timer->millisec,TAG_GLW_USERDATA,(u32)timer,TAG_DONE);
00643           else gui_TimerDelete(timer);
00644         }
00645         else gui_TimerDelete(timer);
00646         handled=1;
00647         break;
00648       }
00649       case GLWEV_ACTIVATION:
00650       {
00651         // window border color change
00652         debug_Message("GLWEV_ACTIVATION");
00653         if(event->data==GLWEVD_ACTIVATE)
00654         {
00655           window_WindowEvent(win,0L,CBK_WINDOW_ACTIVATED,window_GetUserdata(TAG_WIN_OBJECT,win,TAG_DONE));
00656         }
00657         if(event->data==GLWEVD_INACTIVATE)
00658         {
00659           window_WindowEvent(win,0L,CBK_WINDOW_INACTIVATED,window_GetUserdata(TAG_WIN_OBJECT,win,TAG_DONE));
00660         }
00661         handled=1;
00662         break;
00663       }
00664       case GLWEV_SYSTEM:
00665       {
00666         debug_Message("GLWEV_SYSTEM");
00667         if(event->data==GLWEVD_QUIT) ret=1;
00668         handled=1;
00669         break;
00670       }
00671       case GLWEV_SOCKET:
00672       {
00673         debug_Message("GLWEV_SOCKET");
00674         handled=1;
00675         if(event->data!=0L)
00676         {
00677           if(NULL!=(msg=mem_malloc(sizeof(struct glw_SockMsg))))
00678           {
00679             memcpy(msg,(struct glw_SockMsg *)event->data,sizeof(struct glw_SockMsg));
00680             ret=net_SerProcessMessage(conn,event->userdata,msg);
00681             if(ret<0)
00682             {
00683 //MSG              printf("(1) az event-et nem kell a tovabbiakban feldolgozni.\n");
00684             }
00685           }
00686         }
00687         else
00688         {
00689           ret=net_SerProcessMessage(conn,event->userdata,NULL);
00690         }
00691         if(ret<0) ret=0;
00692         break;
00693       }
00694     }
00695     if(handled==0&&win!=NULL&&!window_IsSleep(win))
00696     {
00697       ret=gadget_PostMessage(TAG_GADGET_WINDOW,win,TAG_GADGET_OBJECT,window_GetRootGadget(win),TAG_GADGET_EVENT,event,TAG_DONE);
00698       if(ret<0) ret=0;
00699     }
00700   }
00701 
00702   debug_End();
00703 
00704   return(ret);
00705 }
00706 
00707 
00708 static void gui_check_types(void)
00709 {
00710   int er=0;
00711 
00712   if(sizeof(void *)>sizeof(u32))
00713   {
00714     printf("sizeof(u32) < sizeof(void*)  Recompile the system!\n");
00715     er=1;
00716   }
00717   if(er!=0)
00718   {
00719     printf("Fatal error exiting.\n");
00720     exit(0);
00721   }
00722 }
00723 
00724 
00725 int gui_Init(void)
00726 {
00727   int ret=-1;
00728 
00729   debug_Begin();
00730 
00731 //Initialize call vector BEGIN - put this into the init function of this module
00732   call_vector[GUI_ISOVERLAP-GUI_FUNCBASE]=gui_IsOverlapTL;
00733   call_vector[GUI_CALCULATEOVERLAP-GUI_FUNCBASE]=gui_CalculateOverlapTL;
00734   call_vector[GUI_LOADFILE-GUI_FUNCBASE]=gui_LoadFileTL;
00735   call_vector[GUI_LOADSUBGADGETDESCRIPTOR-GUI_FUNCBASE]=gui_LoadSubgadgetDescriptorTL;
00736   call_vector[GUI_ISINSIDE-GUI_FUNCBASE]=gui_IsInsideTL;
00737   call_vector[GUI_TIMERCANCEL-GUI_FUNCBASE]=gui_TimerCancelTL;
00738   call_vector[GUI_GETLIMITEDTEXTLENGTH-GUI_FUNCBASE]=gui_GetLimitedTextLengthTL;
00739   call_vector[GUI_GETTEXTFITLENGTH-GUI_FUNCBASE]=gui_GetTextFitLengthTL;
00740   call_vector[GUI_GETTEXTWRAPLENGTH-GUI_FUNCBASE]=gui_GetTextWrapLengthTL;
00741   call_vector[GUI_TIMERSTART-GUI_FUNCBASE]=gui_TimerStartTL;
00742   call_vector[GUI_UNLOADSUBGADGETDESCRIPTOR-GUI_FUNCBASE]=gui_UnLoadSubgadgetDescriptorTL;
00743 //Initialize call vector END
00744   bases_modules.gui_Call=gui_Call;
00745   bases_modules.gui_CallTL=gui_CallTL;
00746 
00747   gui_check_types();
00748 
00749   term_Init();
00750   bitmap_Init();
00751   window_Init();
00752   net_Init();
00753   gadget_Init();
00754   img_Init();
00755   prefs_Init();
00756   skin_Init();
00757   gxml_Init();
00758 
00759   ret=0;
00760 
00761   debug_End();
00762 
00763   return(ret);
00764 }
00765 
00766 
00767 void gui_CleanUp(void)
00768 {
00769   debug_Begin();
00770 
00771   gxml_CleanUp();
00772   skin_CleanUp();
00773   prefs_CleanUp();
00774   img_CleanUp();
00775   gadget_CleanUp();
00776   net_CleanUp();
00777   window_CleanUp();
00778   bitmap_CleanUp();
00779   term_CleanUp();
00780 
00781   debug_End();
00782 }
00783 
00784 
00785 
00786 int gui_ServerMain(u32 conn)
00787 {
00788   gui_App_t *app;
00789   struct glw_ConnUser *cuser=(struct glw_ConnUser *)conn;
00790 
00791   debug_Begin();
00792 
00793   if(NULL!=(app=mem_malloc(sizeof(gui_App_t))))
00794   {
00795     if(NULL!=(app->windowlist=list_CreateList()))
00796     {
00797       cuser->app=(u32)app;
00798       app->conn=conn;
00799       app->name=cuser->appname;
00800       net_SerSendApp(conn);
00801       if(NULL!=(app->prefs=prefs_InitApp(app->name)))
00802       {
00803         if(NULL!=(app->locale=locale_Init(app,langs,prefs_GetString(app->prefs,"language","en"))))
00804         {
00805           if(NULL!=(app->skin=skin_CreateSkin(app,prefs_GetString(app->prefs,"skin","tst3Skin"))))
00806           {
00807             debug_Message("The new client is up.");
00808             glw_MainLoop(conn,0L,0L);
00809             window_CloseAllWindows(app);
00810             skin_DeleteSkin(app->skin);
00811           }
00812           locale_CleanUp(app->locale);
00813         }
00814         prefs_CleanUpApp(app->prefs);
00815       }
00816       list_DeleteList(app->windowlist);
00817     }
00818     mem_free(app);
00819   }
00820 
00821   debug_End();
00822 
00823   return(0);
00824 }
00825 
00826 
00827 static int gui_TimerCanceller(Window_t *win, u32 userdata)
00828 {
00829   debug_Begin();
00830   debug_End();
00831   return(1);
00832 }
00833 
00834 
00835 void gui_TimerDelete(gui_Timer_t *timer)
00836 {
00837   debug_Begin();
00838 
00839   if(timer!=NULL)
00840   {
00841     list_RemoveNode(window_GetTimerList(timer->win),timer->node);
00842     list_SetNodeData(timer->node,NULL);
00843     list_DeleteNode(timer->node);
00844     glw_TimerCancel(TAG_GLW_WINDOW,timer->win->handle,TAG_GLW_ID,timer->id,TAG_DONE);
00845     mem_free(timer);
00846   }
00847 
00848   debug_End();
00849 }
00850 
00851 
00852 
00853 
00854 /* OBSOLETE!!
00855  */
00856 /*
00857 u32 gui_CallGadget(u32 firsttag, ...)
00858 {
00859   return(gui_CallGadgetTL((tag *)&firsttag));
00860 }
00861 u32 gui_CallGadgetTL(tag *taglist)
00862 {
00863   u32 ret=~0L;
00864   tag *t;
00865 
00866   debug_Begin();
00867 
00868   if(NULL!=(t=tag_FindTag(taglist,TAG_GUI_WIN))) t->Name=TAG_GADGET_WINDOW;
00869   if(NULL!=(t=tag_FindTag(taglist,TAG_GUI_GADGET_ID))) t->Name=TAG_GADGET_GADGET_ID;
00870   if(NULL!=(t=tag_FindTag(taglist,TAG_GUI_METHOD))) t->Name=TAG_GADGET_METHOD;
00871 
00872   ret=gadget_MethodCallTL(taglist);
00873 
00874   debug_End();
00875 
00876   return(ret);
00877 }
00878 */
00879 
00880 
00881 
00882 u32 gui_Call(int function, u32 firsttag, ...)
00883 {
00884   return(gui_CallTL(function,(tag *)&firsttag));
00885 }
00886 u32 gui_CallTL(int function, tag *taglist)
00887 {
00888   u32 ret=~0L;
00889 
00890   debug_Begin();
00891 
00892   debug_Message("function ID : %d",function-GUI_FUNCBASE);
00893 
00894   if(function>=GUI_FUNCBASE&&function<GUI_FUNC_DONE)
00895   {
00896     ret=call_vector[function-GUI_FUNCBASE](taglist);
00897   }
00898   else debug_Warning("%s(): Function code out of range! code=0x%04x",__FUNCTION__,function);
00899 
00900   debug_End();
00901 
00902   return(ret);
00903 }
00904 
00905 
00906 
00907 //END//
00908 

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