Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, October 17, 2026

Diff for tucniak/cuchar/cc_user.c between version 1.5 and 1.6

version 1.5, 2005/12/02 17:15:00 version 1.6, 2005/12/08 21:13:04
Line 7 
Line 7 
   
 #include "cc.h"  #include "cc.h"
   
 bool file_open_dialog(WIN *parent,char *caption,char *filename,char *mask)  bool cc_file_open_dialog(Cc_Win *parent,char *caption,char *filename,char *mask)
 {  {
   if((caption==NULL)||(filename==NULL)||(mask==NULL))return false;    if((caption==NULL)||(filename==NULL)||(mask==NULL))return false;
   const cback=C_CYAN;    const cback=CC_C_CYAN;
   bool i;    bool i;
   long x,y;    long x,y;
   static long vx=DEF_FOB_VX,vy=DEF_FOB_VY;    static long vx=DEF_FOB_VX,vy=DEF_FOB_VY;
   x=(screenx-vx)/2;    x=(_cc_screenx-vx)/2;
   y=(screeny-vy)/2;    y=(_cc_screeny-vy)/2;
   screen_to_client(parent,&x,&y);    cc_screen_to_client(parent,&x,&y);
   WIN *di,*diskcombo,*filelist,*nameedit,*maskcombo;    Cc_Win *di,*diskcombo,*filelist,*nameedit,*maskcombo;
   TUFOB *tufob;    TUFOB *tufob;
   PDIALOG pdialog;    Cc_Dialog_P pdialog;
   pdialog.type=CC_TP_DIALOG;    pdialog.type=CC_TP_DIALOG;
   pdialog.style=CC_ST_DI_SIZEABLE;    pdialog.style=CC_ST_DI_SIZEABLE;
   pdialog.caption=caption;    pdialog.caption=caption;
   pdialog.cback=cback;    pdialog.cback=cback;
   pdialog.cbactive=C_DEFAULT;    pdialog.cbactive=CC_C_DEFAULT;
   pdialog.cbinactive=C_DEFAULT;    pdialog.cbinactive=CC_C_DEFAULT;
   pdialog.cbuttext[0]=C_DEFAULT;    pdialog.cbuttext[0]=CC_C_DEFAULT;
   pdialog.cbuttext[1]=C_DEFAULT;    pdialog.cbuttext[1]=CC_C_DEFAULT;
   pdialog.cbuttext[2]=C_DEFAULT;    pdialog.cbuttext[2]=CC_C_DEFAULT;
   pdialog.modal=true;    pdialog.modal=true;
   pdialog.menu=NULL;    pdialog.menu=NULL;
   pdialog.resize=NULL;    pdialog.resize=NULL;
   pdialog.sizeok=fobsizeokproc;    pdialog.sizeok=_cc_fobsizeokproc;
   pdialog.close=fobcloseproc;    pdialog.close=_cc_fobcloseproc;
   di=create_win(parent,x,y,vx,vy,(PUNION*)&pdialog,0,fobdialogacelproc);    di=cc_create_win(parent,x,y,vx,vy,(Cc_Union_P*)&pdialog,0,
                      _cc_fobdialogacelproc);
   di->user=malloc(sizeof(TUFOB));    di->user=malloc(sizeof(TUFOB));
   tufob=((TUFOB*)(di->user));    tufob=((TUFOB*)(di->user));
   tufob->i=-1;    tufob->i=-1;
   PCOMBO pcombo;    Cc_Combo_P pcombo;
   PBUTTON pbutton;    Cc_Button_P pbutton;
   PLIST plist;    Cc_List_P plist;
   PEDIT pedit;    Cc_Edit_P pedit;
   GList *disklines,*masklines;    GList *disklines,*masklines;
   disklines=NULL;    disklines=NULL;
   disklines=g_list_append(disklines,"/");    disklines=g_list_append(disklines,"/");
Line 53  bool file_open_dialog(WIN *parent,char *
Line 54  bool file_open_dialog(WIN *parent,char *
   pbutton.cback[0]=cback;    pbutton.cback[0]=cback;
   pbutton.cback[1]=cback;    pbutton.cback[1]=cback;
   pbutton.cback[2]=cback;    pbutton.cback[2]=cback;
   pbutton.ctext[0]=C_BLACK;    pbutton.ctext[0]=CC_C_BLACK;
   pbutton.ctext[1]=C_BLACK;    pbutton.ctext[1]=CC_C_BLACK;
   pbutton.ctext[2]=C_BLACK;    pbutton.ctext[2]=CC_C_BLACK;
   pbutton.cutext[0]=C_BLUE;    pbutton.cutext[0]=CC_C_BLUE;
   pbutton.cutext[1]=C_BLUE;    pbutton.cutext[1]=CC_C_BLUE;
   pbutton.cutext[2]=C_BLUE;    pbutton.cutext[2]=CC_C_BLUE;
   pbutton.cfocus[0]=C_DEFAULT;    pbutton.cfocus[0]=CC_C_DEFAULT;
   pbutton.cfocus[1]=C_DEFAULT;    pbutton.cfocus[1]=CC_C_DEFAULT;
   pbutton.cfocus[2]=C_DEFAULT;    pbutton.cfocus[2]=CC_C_DEFAULT;
   pbutton.hasfocus=false;    pbutton.hasfocus=false;
   pbutton.push=fobdiskbuttonproc;    pbutton.push=_cc_fobdiskbuttonproc;
   pbutton.text="Look &in:";    pbutton.text="Look &in:";
   create_win(di,3,2,strlen(pbutton.text),1,(PUNION*)&pbutton,CC_ST_VISIBLE,NULL);    cc_create_win(di,3,2,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,
                   CC_ST_VISIBLE,NULL);
   pcombo.type=CC_TP_COMBO;    pcombo.type=CC_TP_COMBO;
   pcombo.activeline=0;    pcombo.activeline=0;
   pcombo.cback=C_DEFAULT;    pcombo.cback=CC_C_DEFAULT;
   pcombo.cbutback[0]=C_BLUE;    pcombo.cbutback[0]=CC_C_BLUE;
   pcombo.cbutback[1]=C_DEFAULT;    pcombo.cbutback[1]=CC_C_DEFAULT;
   pcombo.cbutfront[0]=C_DEFAULT;    pcombo.cbutfront[0]=CC_C_DEFAULT;
   pcombo.cbutfront[1]=C_DEFAULT;    pcombo.cbutfront[1]=CC_C_DEFAULT;
   pcombo.change=fobdiskcombochangeproc;    pcombo.change=_cc_fobdiskcombochangeproc;
   pcombo.maxvisitems=8;    pcombo.maxvisitems=8;
   pcombo.lstvy=0;    pcombo.lstvy=0;
   pcombo.lstcback=C_DEFAULT;    pcombo.lstcback=CC_C_DEFAULT;
   pcombo.lstcborder=C_DEFAULT;    pcombo.lstcborder=CC_C_DEFAULT;
   pcombo.lstctext=C_DEFAULT;    pcombo.lstctext=CC_C_DEFAULT;
   pcombo.lstcselected=C_DEFAULT;    pcombo.lstcselected=CC_C_DEFAULT;
   pcombo.lstcseltext=C_DEFAULT;    pcombo.lstcseltext=CC_C_DEFAULT;
   pcombo.lstcactive=C_DEFAULT;    pcombo.lstcactive=CC_C_DEFAULT;
   pcombo.lstcactivetext=C_DEFAULT;    pcombo.lstcactivetext=CC_C_DEFAULT;
   pcombo.lstscrcback=C_DEFAULT;    pcombo.lstscrcback=CC_C_DEFAULT;
   pcombo.lstscrcmark=C_DEFAULT;    pcombo.lstscrcmark=CC_C_DEFAULT;
   pcombo.lstscrcbar=C_DEFAULT;    pcombo.lstscrcbar=CC_C_DEFAULT;
   pcombo.lstscrcarrowup=C_DEFAULT;    pcombo.lstscrcarrowup=CC_C_DEFAULT;
   pcombo.lstscrcarrowdown=C_DEFAULT;    pcombo.lstscrcarrowdown=CC_C_DEFAULT;
   pcombo.lstlines=disklines;    pcombo.lstlines=disklines;
   pcombo.edistyle=CC_ED_READONLY;    pcombo.edistyle=CC_ED_READONLY;
   pcombo.edicbmask=C_WHITE;    pcombo.edicbmask=CC_C_WHITE;
   pcombo.edicfmask=C_BLACK;    pcombo.edicfmask=CC_C_BLACK;
   diskcombo=create_win(di,12,2,vx-3-12,1,(PUNION*)&pcombo,    diskcombo=cc_create_win(di,12,2,vx-3-12,1,(Cc_Union_P*)&pcombo,
                        CC_ST_VISIBLE|CC_ST_A_HFIXED|CC_ST_CO_WITH_EDIT,NULL);                            CC_ST_VISIBLE|CC_ST_A_HFIXED|CC_ST_CO_WITH_EDIT,NULL);
   tufob->diskcombo=diskcombo;    tufob->diskcombo=diskcombo;
   set_text(diskcombo,filename);    cc_set_text(diskcombo,filename);
   plist.type=CC_TP_LIST;    plist.type=CC_TP_LIST;
   plist.activeline=0;    plist.activeline=0;
   plist.lines=NULL;    plist.lines=NULL;
   plist.combotyp=CC_LI_NORMAL;    plist.combotyp=CC_LI_NORMAL;
   plist.cback=C_DEFAULT;    plist.cback=CC_C_DEFAULT;
   plist.cborder=C_DEFAULT;    plist.cborder=CC_C_DEFAULT;
   plist.ctext=C_DEFAULT;    plist.ctext=CC_C_DEFAULT;
   plist.cselected=C_DEFAULT;    plist.cselected=CC_C_DEFAULT;
   plist.cseltext=C_DEFAULT;    plist.cseltext=CC_C_DEFAULT;
   plist.cactive=C_DEFAULT;    plist.cactive=CC_C_DEFAULT;
   plist.cactivetext=C_DEFAULT;    plist.cactivetext=CC_C_DEFAULT;
   plist.change=NULL;    plist.change=NULL;
   plist.dblclk=fobfilelistdblclkproc;    plist.dblclk=_cc_fobfilelistdblclkproc;
   plist.scrcmark=C_DEFAULT;    plist.scrcmark=CC_C_DEFAULT;
   plist.scrcbar=C_DEFAULT;    plist.scrcbar=CC_C_DEFAULT;
   plist.scrcarrowup=C_DEFAULT;    plist.scrcarrowup=CC_C_DEFAULT;
   plist.scrcarrowdown=C_DEFAULT;    plist.scrcarrowdown=CC_C_DEFAULT;
   plist.scrcback=C_DEFAULT;    plist.scrcback=CC_C_DEFAULT;
   filelist=create_win(di,3,4,vx-5-10-3,vy-6-4,(PUNION*)&plist,    filelist=cc_create_win(di,3,4,vx-5-10-3,vy-6-4,(Cc_Union_P*)&plist,
                       CC_ST_VISIBLE|CC_ST_A_FIXED,fobfilelistacelproc);                           CC_ST_VISIBLE|CC_ST_A_FIXED,_cc_fobfilelistacelproc);
   tufob->filelist=filelist;    tufob->filelist=filelist;
   pbutton.push=fobnamebuttonproc;    pbutton.push=_cc_fobnamebuttonproc;
   pbutton.text="File &name:";    pbutton.text="File &name:";
   create_win(di,3,vy-5,strlen(pbutton.text),1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);    cc_create_win(di,3,vy-5,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,
                   CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);
   pedit.type=CC_TP_EDIT;    pedit.type=CC_TP_EDIT;
   pedit.cback=C_DEFAULT;    pedit.cback=CC_C_DEFAULT;
   pedit.cbmask=C_WHITE;    pedit.cbmask=CC_C_WHITE;
   pedit.cfmask=C_BLACK;    pedit.cfmask=CC_C_BLACK;
   pedit.style=CC_ED_NORMAL;    pedit.style=CC_ED_NORMAL;
   pedit.ctext=C_DEFAULT;    pedit.ctext=CC_C_DEFAULT;
   pedit.change=NULL;    pedit.change=NULL;
   nameedit=create_win(di,18,vy-5,vx-21,1,(PUNION*)&pedit,CC_ST_VISIBLE|CC_ST_AD_FIXED|CC_ST_A_HFIXED,NULL);    nameedit=cc_create_win(di,18,vy-5,vx-21,1,(Cc_Union_P*)&pedit,
                            CC_ST_VISIBLE|CC_ST_AD_FIXED|CC_ST_A_HFIXED,NULL);
   tufob->nameedit=nameedit;    tufob->nameedit=nameedit;
   pbutton.push=fobmaskbuttonproc;    pbutton.push=_cc_fobmaskbuttonproc;
   pbutton.text="Files of &type:";    pbutton.text="Files of &type:";
   create_win(di,3,vy-3,strlen(pbutton.text),1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);    cc_create_win(di,3,vy-3,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,
                   CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);
   masklines=NULL;    masklines=NULL;
   
   
Line 140  bool file_open_dialog(WIN *parent,char *
Line 145  bool file_open_dialog(WIN *parent,char *
   
   
   
   pcombo.change=fobdiskcombochangeproc;    pcombo.change=_cc_fobdiskcombochangeproc;
   pcombo.lstlines=masklines;    pcombo.lstlines=masklines;
   maskcombo=create_win(di,18,vy-3,vx-21,1,(PUNION*)&pcombo,CC_ST_VISIBLE|CC_ST_AD_FIXED|CC_ST_A_HFIXED,NULL);    maskcombo=cc_create_win(di,18,vy-3,vx-21,1,(Cc_Union_P*)&pcombo,
                             CC_ST_VISIBLE|CC_ST_AD_FIXED|CC_ST_A_HFIXED,NULL);
   tufob->maskcombo=maskcombo;    tufob->maskcombo=maskcombo;
   pbutton.cback[0]=C_DEFAULT;    pbutton.cback[0]=CC_C_DEFAULT;
   pbutton.cback[1]=C_DEFAULT;    pbutton.cback[1]=CC_C_DEFAULT;
   pbutton.cback[2]=C_DEFAULT;    pbutton.cback[2]=CC_C_DEFAULT;
   pbutton.ctext[0]=C_DEFAULT;    pbutton.ctext[0]=CC_C_DEFAULT;
   pbutton.ctext[1]=C_DEFAULT;    pbutton.ctext[1]=CC_C_DEFAULT;
   pbutton.ctext[2]=C_DEFAULT;    pbutton.ctext[2]=CC_C_DEFAULT;
   pbutton.cutext[0]=C_DEFAULT;    pbutton.cutext[0]=CC_C_DEFAULT;
   pbutton.cutext[1]=C_DEFAULT;    pbutton.cutext[1]=CC_C_DEFAULT;
   pbutton.cutext[2]=C_DEFAULT;    pbutton.cutext[2]=CC_C_DEFAULT;
   pbutton.hasfocus=true;    pbutton.hasfocus=true;
   pbutton.push=fobopenbuttonproc;    pbutton.push=_cc_fobopenbuttonproc;
   pbutton.text="&Open";    pbutton.text="&Open";
   create_win(di,vx-13,4,10,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AR_FIXED,NULL);    cc_create_win(di,vx-13,4,10,1,(Cc_Union_P*)&pbutton,
   pbutton.push=fobcancelbuttonproc;                  CC_ST_VISIBLE|CC_ST_AR_FIXED,NULL);
     pbutton.push=_cc_fobcancelbuttonproc;
   pbutton.text="&Cancel";    pbutton.text="&Cancel";
   create_win(di,vx-13,6,10,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AR_FIXED,NULL);    cc_create_win(di,vx-13,6,10,1,(Cc_Union_P*)&pbutton,
   set_focus(filelist);                  CC_ST_VISIBLE|CC_ST_AR_FIXED,NULL);
   show_win(di,true);    cc_set_focus(filelist);
   while((tufob->i==-1)&&apprun)message_pump();    cc_show_win(di,true);
     //while((tufob->i==-1)&&_cc_apprun)cc_message_pump();
   i=tufob->i;    i=tufob->i;
   vx=di->vx;    vx=di->vx;
   vy=di->vy;    vy=di->vy;
   delete_win(di);    cc_delete_win(di);
   free(tufob);    free(tufob);
   if(disklines!=NULL)g_list_free(disklines);    if(disklines!=NULL)g_list_free(disklines);
   if(masklines!=NULL)g_list_free(masklines);    if(masklines!=NULL)g_list_free(masklines);
   return i;    return i;
 }  }
   
 long color_dialog(WIN *parent,char *caption,long color)  long cc_color_dialog(Cc_Win *parent,char *caption,long color)
 {  {
   if(caption==NULL)return -1;    if(caption==NULL)return -1;
   long x,y,i;    long x,y,i;
   const vx=34,vy=10,cback=C_CYAN;    const vx=34,vy=10,cback=CC_C_CYAN;
   WIN *di,*p,*combo,*p1,*p2;    Cc_Win *di,*p,*combo,*p1,*p2;
   x=(screenx-vx)/2;    x=(_cc_screenx-vx)/2;
   y=(screeny-vy)/2;    y=(_cc_screeny-vy)/2;
   screen_to_client(parent,&x,&y);    cc_screen_to_client(parent,&x,&y);
   TUCB *tucb;    TUCB *tucb;
   PDIALOG pdialog;    Cc_Dialog_P pdialog;
   PBUTTON pbutton;    Cc_Button_P pbutton;
   PPAINT ppaint;    Cc_Paint_P ppaint;
   PCOMBO pcombo;    Cc_Combo_P pcombo;
   GList *lines;    GList *lines;
   pdialog.type=CC_TP_DIALOG;    pdialog.type=CC_TP_DIALOG;
   pdialog.style=0;    pdialog.style=0;
   pdialog.caption=caption;    pdialog.caption=caption;
   pdialog.cback=cback;    pdialog.cback=cback;
   pdialog.cbactive=C_DEFAULT;    pdialog.cbactive=CC_C_DEFAULT;
   pdialog.cbinactive=C_DEFAULT;    pdialog.cbinactive=CC_C_DEFAULT;
   pdialog.cbuttext[0]=C_DEFAULT;    pdialog.cbuttext[0]=CC_C_DEFAULT;
   pdialog.cbuttext[1]=C_DEFAULT;    pdialog.cbuttext[1]=CC_C_DEFAULT;
   pdialog.cbuttext[2]=C_DEFAULT;    pdialog.cbuttext[2]=CC_C_DEFAULT;
   pdialog.modal=true;    pdialog.modal=true;
   pdialog.menu=NULL;    pdialog.menu=NULL;
   pdialog.resize=NULL;    pdialog.resize=NULL;
   pdialog.sizeok=NULL;    pdialog.sizeok=NULL;
   pdialog.close=cbcloseproc;    pdialog.close=_cc_cbcloseproc;
   di=create_win(parent,x,y,vx,vy,(PUNION*)&pdialog,0,cbdialogacelproc);    di=cc_create_win(parent,x,y,vx,vy,(Cc_Union_P*)&pdialog,0,
                      _cc_cbdialogacelproc);
   di->user=malloc(sizeof(TUCB));    di->user=malloc(sizeof(TUCB));
   tucb=((TUCB*)(di->user));    tucb=((TUCB*)(di->user));
   tucb->i=0;    tucb->i=0;
Line 214  long color_dialog(WIN *parent,char *capt
Line 223  long color_dialog(WIN *parent,char *capt
       i=y*4+x;        i=y*4+x;
       ppaint.cback=i;        ppaint.cback=i;
       ppaint.color=i;        ppaint.color=i;
       p=create_win(di,2*x+5,y+3,2,1,(PUNION*)&ppaint,CC_ST_VISIBLE,cbpaintacelproc);        p=cc_create_win(di,2*x+5,y+3,2,1,(Cc_Union_P*)&ppaint,CC_ST_VISIBLE,
                         _cc_cbpaintacelproc);
       p->user=(void*)i;        p->user=(void*)i;
     }      }
   lines=NULL;    lines=NULL;
   lines=g_list_append(lines,getcolorname(C_BLACK));    lines=g_list_append(lines,_cc_getcolorname(CC_C_BLACK));
   lines=g_list_append(lines,getcolorname(C_RED));    lines=g_list_append(lines,_cc_getcolorname(CC_C_RED));
   lines=g_list_append(lines,getcolorname(C_GREEN));    lines=g_list_append(lines,_cc_getcolorname(CC_C_GREEN));
   lines=g_list_append(lines,getcolorname(C_YELLOW));    lines=g_list_append(lines,_cc_getcolorname(CC_C_YELLOW));
   lines=g_list_append(lines,getcolorname(C_BLUE));    lines=g_list_append(lines,_cc_getcolorname(CC_C_BLUE));
   lines=g_list_append(lines,getcolorname(C_MAGENTA));    lines=g_list_append(lines,_cc_getcolorname(CC_C_MAGENTA));
   lines=g_list_append(lines,getcolorname(C_CYAN));    lines=g_list_append(lines,_cc_getcolorname(CC_C_CYAN));
   lines=g_list_append(lines,getcolorname(C_WHITE));    lines=g_list_append(lines,_cc_getcolorname(CC_C_WHITE));
   lines=g_list_append(lines,getcolorname(C_LBLACK));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LBLACK));
   lines=g_list_append(lines,getcolorname(C_LRED));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LRED));
   lines=g_list_append(lines,getcolorname(C_LGREEN));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LGREEN));
   lines=g_list_append(lines,getcolorname(C_LYELLOW));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LYELLOW));
   lines=g_list_append(lines,getcolorname(C_LBLUE));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LBLUE));
   lines=g_list_append(lines,getcolorname(C_LMAGENTA));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LMAGENTA));
   lines=g_list_append(lines,getcolorname(C_LCYAN));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LCYAN));
   lines=g_list_append(lines,getcolorname(C_LWHITE));    lines=g_list_append(lines,_cc_getcolorname(CC_C_LWHITE));
   pcombo.type=CC_TP_COMBO;    pcombo.type=CC_TP_COMBO;
   pcombo.activeline=color;    pcombo.activeline=color;
   pcombo.cback=C_DEFAULT;    pcombo.cback=CC_C_DEFAULT;
   pcombo.cbutback[0]=C_BLUE;    pcombo.cbutback[0]=CC_C_BLUE;
   pcombo.cbutback[1]=C_DEFAULT;    pcombo.cbutback[1]=CC_C_DEFAULT;
   pcombo.cbutfront[0]=C_DEFAULT;    pcombo.cbutfront[0]=CC_C_DEFAULT;
   pcombo.cbutfront[1]=C_DEFAULT;    pcombo.cbutfront[1]=CC_C_DEFAULT;
   pcombo.change=cbcombochangeproc;    pcombo.change=_cc_cbcombochangeproc;
   pcombo.maxvisitems=8;    pcombo.maxvisitems=8;
   pcombo.lstvy=10;    pcombo.lstvy=10;
   pcombo.lstcback=C_DEFAULT;    pcombo.lstcback=CC_C_DEFAULT;
   pcombo.lstcborder=C_DEFAULT;    pcombo.lstcborder=CC_C_DEFAULT;
   pcombo.lstctext=C_DEFAULT;    pcombo.lstctext=CC_C_DEFAULT;
   pcombo.lstcselected=C_DEFAULT;    pcombo.lstcselected=CC_C_DEFAULT;
   pcombo.lstcseltext=C_DEFAULT;    pcombo.lstcseltext=CC_C_DEFAULT;
   pcombo.lstcactive=C_DEFAULT;    pcombo.lstcactive=CC_C_DEFAULT;
   pcombo.lstcactivetext=C_DEFAULT;    pcombo.lstcactivetext=CC_C_DEFAULT;
   pcombo.lstscrcback=C_DEFAULT;    pcombo.lstscrcback=CC_C_DEFAULT;
   pcombo.lstscrcmark=C_DEFAULT;    pcombo.lstscrcmark=CC_C_DEFAULT;
   pcombo.lstscrcbar=C_DEFAULT;    pcombo.lstscrcbar=CC_C_DEFAULT;
   pcombo.lstscrcarrowup=C_DEFAULT;    pcombo.lstscrcarrowup=CC_C_DEFAULT;
   pcombo.lstscrcarrowdown=C_DEFAULT;    pcombo.lstscrcarrowdown=CC_C_DEFAULT;
   pcombo.lstlines=lines;    pcombo.lstlines=lines;
   combo=create_win(di,17,2,MAXLEN_COLOR_STRING-1,1,(PUNION*)&pcombo,CC_ST_VISIBLE,NULL);    combo=cc_create_win(di,17,2,MAXLEN_COLOR_STRING-1,1,(Cc_Union_P*)&pcombo,
                         CC_ST_VISIBLE,NULL);
   tucb->combo=combo;    tucb->combo=combo;
   ppaint.cback=C_BLUE;    ppaint.cback=CC_C_BLUE;
   ppaint.color=C_WHITE;    ppaint.color=CC_C_WHITE;
   p1=create_win(di,(color%4)*2+5,2,2,1,(PUNION*)&ppaint,CC_ST_VISIBLE,NULL);    p1=cc_create_win(di,(color%4)*2+5,2,2,1,(Cc_Union_P*)&ppaint,
   create_win(p1,0,5,2,1,(PUNION*)&ppaint,CC_ST_VISIBLE,NULL);                     CC_ST_VISIBLE,NULL);
     cc_create_win(p1,0,5,2,1,(Cc_Union_P*)&ppaint,CC_ST_VISIBLE,NULL);
   tucb->p1=p1;    tucb->p1=p1;
   p2=create_win(di,3,(color/4)+3,2,1,(PUNION*)&ppaint,CC_ST_VISIBLE,NULL);    p2=cc_create_win(di,3,(color/4)+3,2,1,(Cc_Union_P*)&ppaint,CC_ST_VISIBLE,
   create_win(p2,10,0,2,1,(PUNION*)&ppaint,CC_ST_VISIBLE,NULL);                     NULL);
     cc_create_win(p2,10,0,2,1,(Cc_Union_P*)&ppaint,CC_ST_VISIBLE,NULL);
   tucb->p2=p2;    tucb->p2=p2;
   pbutton.type=CC_TP_BUTTON;    pbutton.type=CC_TP_BUTTON;
   pbutton.style=CC_BT_NORMAL;    pbutton.style=CC_BT_NORMAL;
   pbutton.checked=false;    pbutton.checked=false;
   pbutton.cback[0]=C_DEFAULT;    pbutton.cback[0]=CC_C_DEFAULT;
   pbutton.cback[1]=C_DEFAULT;    pbutton.cback[1]=CC_C_DEFAULT;
   pbutton.cback[2]=C_DEFAULT;    pbutton.cback[2]=CC_C_DEFAULT;
   pbutton.ctext[0]=C_DEFAULT;    pbutton.ctext[0]=CC_C_DEFAULT;
   pbutton.ctext[1]=C_DEFAULT;    pbutton.ctext[1]=CC_C_DEFAULT;
   pbutton.ctext[2]=C_DEFAULT;    pbutton.ctext[2]=CC_C_DEFAULT;
   pbutton.cutext[0]=C_DEFAULT;    pbutton.cutext[0]=CC_C_DEFAULT;
   pbutton.cutext[1]=C_DEFAULT;    pbutton.cutext[1]=CC_C_DEFAULT;
   pbutton.cutext[2]=C_DEFAULT;    pbutton.cutext[2]=CC_C_DEFAULT;
   pbutton.cfocus[0]=C_DEFAULT;    pbutton.cfocus[0]=CC_C_DEFAULT;
   pbutton.cfocus[1]=C_DEFAULT;    pbutton.cfocus[1]=CC_C_DEFAULT;
   pbutton.cfocus[2]=C_DEFAULT;    pbutton.cfocus[2]=CC_C_DEFAULT;
   pbutton.hasfocus=true;    pbutton.hasfocus=true;
   pbutton.push=cbpushproc;    pbutton.push=_cc_cbpushproc;
   pbutton.text="  &Ok  ";    pbutton.text="  &Ok  ";
   p=create_win(di,19,5,1,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);    p=cc_create_win(di,19,5,1,1,(Cc_Union_P*)&pbutton,
                     CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
   p->user=(void*)1;    p->user=(void*)1;
   pbutton.text="&Cancel";    pbutton.text="&Cancel";
   p=create_win(di,19,7,1,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);    p=cc_create_win(di,19,7,1,1,(Cc_Union_P*)&pbutton,
                     CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
   p->user=(void*)-1;    p->user=(void*)-1;
   show_win(di,true);    cc_show_win(di,true);
   while((tucb->i==0)&&apprun)message_pump();    //while((tucb->i==0)&&_cc_apprun)cc_message_pump();
   if(tucb->i==-1)i=-1;    if(tucb->i==-1)i=-1;
   else if(tucb->i==1)i=combo->extra->combo.activeline;    else if(tucb->i==1)i=combo->extra->combo.activeline;
   delete_win(di);    cc_delete_win(di);
   free(tucb);    free(tucb);
   return i;    return i;
 }  }
   
 long message_box(WIN *parent,char *caption,char *text,long style)  Cc_Win *cc_message_box(Cc_Win *parent,void (*action)(Cc_Win *sender,long i),
                          bool modal,char *caption,char *text,
                          long style)
 {  {
   if((caption==NULL)||(text==NULL))return -1;    if((caption==NULL)||(text==NULL))return NULL;
   long x,y,bx,lastwh,i,j,l,line,vx,vy,len=strlen(text),nlen;    long x,y,bx,lastwh,i,j,l,line,vx,vy,len=strlen(text),nlen;
   const bxok=2+4+2,bxyes=3+4+2,bxno=2+4+2,bxcancel=6+4+2;    const bxok=2+4+2,bxyes=3+4+2,bxno=2+4+2,bxcancel=6+4+2;
   char *st;    char *st;
   WIN *but;    Cc_Win *but;
   bool nonext;    bool nonext;
   PDIALOG pdialog;    Cc_Dialog_P pdialog;
   PTEXT ptext;    Cc_Text_P ptext;
   PBUTTON pbutton;    Cc_Button_P pbutton;
   WIN *di;    Cc_Win *di;
   nlen=len;    nlen=len;
   vx=6;    vx=6;
   vy=4;    vy=4;
Line 323  long message_box(WIN *parent,char *capti
Line 340  long message_box(WIN *parent,char *capti
   if(bx>0)bx-=2;    if(bx>0)bx-=2;
   vx+=bx;    vx+=bx;
   st=malloc(nlen+1);    st=malloc(nlen+1);
   if(st==NULL)return -1;    if(st==NULL)return NULL;
   line=1;    line=1;
   lastwh=-1;    lastwh=-1;
   for(i=0,l=0,j=0;i<len;i++,l++,j++)    for(i=0,l=0,j=0;i<len;i++,l++,j++)
Line 347  long message_box(WIN *parent,char *capti
Line 364  long message_box(WIN *parent,char *capti
           l++;            l++;
           nlen++;            nlen++;
           st=realloc(st,nlen+1);            st=realloc(st,nlen+1);
           if(st==NULL)return -1;            if(st==NULL)return NULL;
           j=0;            j=0;
         }          }
       }        }
Line 366  long message_box(WIN *parent,char *capti
Line 383  long message_box(WIN *parent,char *capti
   vy+=line+1;    vy+=line+1;
   if(vx<MIN_MB_VX)vx=MIN_MB_VX;    if(vx<MIN_MB_VX)vx=MIN_MB_VX;
   if(vy<MIN_MB_VY)vy=MIN_MB_VY;    if(vy<MIN_MB_VY)vy=MIN_MB_VY;
   x=(screenx-vx)/2;    x=(_cc_screenx-vx)/2;
   y=(screeny-vy)/2;    y=(_cc_screeny-vy)/2;
   screen_to_client(parent,&x,&y);    cc_screen_to_client(parent,&x,&y);
   pdialog.type=CC_TP_DIALOG;    pdialog.type=CC_TP_DIALOG;
   pdialog.style=0;    pdialog.style=0;
   pdialog.caption=caption;    pdialog.caption=caption;
   pdialog.cback=C_RED;    pdialog.cback=CC_C_RED;
   pdialog.cbactive=C_DEFAULT;    pdialog.cbactive=CC_C_DEFAULT;
   pdialog.cbinactive=C_DEFAULT;    pdialog.cbinactive=CC_C_DEFAULT;
   pdialog.cbuttext[0]=C_DEFAULT;    pdialog.cbuttext[0]=CC_C_DEFAULT;
   pdialog.cbuttext[1]=C_DEFAULT;    pdialog.cbuttext[1]=CC_C_DEFAULT;
   pdialog.cbuttext[2]=C_DEFAULT;    pdialog.cbuttext[2]=CC_C_DEFAULT;
   pdialog.modal=true;    pdialog.modal=modal;
   pdialog.menu=NULL;    pdialog.menu=NULL;
   pdialog.resize=NULL;    pdialog.resize=NULL;
   pdialog.sizeok=NULL;    pdialog.sizeok=NULL;
   pdialog.close=mbcloseproc;    pdialog.close=_cc_mbcloseproc;
   di=create_win(parent,x,y,vx,vy,(PUNION*)&pdialog,0,mbdialogacelproc);    di=cc_create_win(parent,x,y,vx,vy,(Cc_Union_P*)&pdialog,0,
                      _cc_mbdialogacelproc);
     TUMB *tumb;
     tumb=malloc(sizeof(TUMB));
     di->user=tumb;
     tumb->action=action;
     tumb->st=st;
   ptext.type=CC_TP_TEXT;    ptext.type=CC_TP_TEXT;
   ptext.cback=pdialog.cback;    ptext.cback=pdialog.cback;
   ptext.ctext=C_LWHITE;    ptext.ctext=CC_C_LWHITE;
   for(i=0,j=0;j<nlen;j++)    for(i=0,j=0;j<nlen;j++)
   {    {
     if((j==0)||(st[j-1]=='\0'))      if((j==0)||(st[j-1]=='\0'))
     {      {
       ptext.text=&st[j];        ptext.text=&st[j];
       create_win(di,3,2+i,1,1,(PUNION*)&ptext,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);        cc_create_win(di,3,2+i,1,1,(Cc_Union_P*)&ptext,
                       CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
       i++;        i++;
     }      }
   }    }
   pbutton.type=CC_TP_BUTTON;    pbutton.type=CC_TP_BUTTON;
   pbutton.style=CC_BT_NORMAL;    pbutton.style=CC_BT_NORMAL;
   pbutton.checked=false;    pbutton.checked=false;
   pbutton.cback[0]=C_DEFAULT;    pbutton.cback[0]=CC_C_DEFAULT;
   pbutton.cback[1]=C_DEFAULT;    pbutton.cback[1]=CC_C_DEFAULT;
   pbutton.cback[2]=C_DEFAULT;    pbutton.cback[2]=CC_C_DEFAULT;
   pbutton.ctext[0]=C_DEFAULT;    pbutton.ctext[0]=CC_C_DEFAULT;
   pbutton.ctext[1]=C_DEFAULT;    pbutton.ctext[1]=CC_C_DEFAULT;
   pbutton.ctext[2]=C_DEFAULT;    pbutton.ctext[2]=CC_C_DEFAULT;
   pbutton.cutext[0]=C_DEFAULT;    pbutton.cutext[0]=CC_C_DEFAULT;
   pbutton.cutext[1]=C_DEFAULT;    pbutton.cutext[1]=CC_C_DEFAULT;
   pbutton.cutext[2]=C_DEFAULT;    pbutton.cutext[2]=CC_C_DEFAULT;
   pbutton.cfocus[0]=C_DEFAULT;    pbutton.cfocus[0]=CC_C_DEFAULT;
   pbutton.cfocus[1]=C_DEFAULT;    pbutton.cfocus[1]=CC_C_DEFAULT;
   pbutton.cfocus[2]=C_DEFAULT;    pbutton.cfocus[2]=CC_C_DEFAULT;
   pbutton.hasfocus=true;    pbutton.hasfocus=true;
   pbutton.push=mbpushproc;    pbutton.push=_cc_mbpushproc;
   j=(vx-bx)/2;    j=(vx-bx)/2;
   if(style&CC_MB_OK)    if(style&CC_MB_OK)
   {    {
     pbutton.text="&Ok";      pbutton.text="&Ok";
     but=create_win(di,j,vy-3,10,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);      but=cc_create_win(di,j,vy-3,10,1,(Cc_Union_P*)&pbutton,
                         CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
     but->user=(void*)CC_MB_OK;      but->user=(void*)CC_MB_OK;
     j+=bxok;      j+=bxok;
   }    }
   if(style&CC_MB_YES)    if(style&CC_MB_YES)
   {    {
     pbutton.text="&Yes";      pbutton.text="&Yes";
     but=create_win(di,j,vy-3,10,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);      but=cc_create_win(di,j,vy-3,10,1,(Cc_Union_P*)&pbutton,
                         CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
     but->user=(void*)CC_MB_YES;      but->user=(void*)CC_MB_YES;
     j+=bxyes;      j+=bxyes;
   }    }
   if(style&CC_MB_NO)    if(style&CC_MB_NO)
   {    {
     pbutton.text="&No";      pbutton.text="&No";
     but=create_win(di,j,vy-3,10,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);      but=cc_create_win(di,j,vy-3,10,1,(Cc_Union_P*)&pbutton,
                         CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
     but->user=(void*)CC_MB_NO;      but->user=(void*)CC_MB_NO;
     j+=bxno;      j+=bxno;
   }    }
   if(style&CC_MB_CANCEL)    if(style&CC_MB_CANCEL)
   {    {
     pbutton.text="&Cancel";      pbutton.text="&Cancel";
     but=create_win(di,j,vy-3,10,1,(PUNION*)&pbutton,CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);      but=cc_create_win(di,j,vy-3,10,1,(Cc_Union_P*)&pbutton,
                         CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
     but->user=(void*)CC_MB_CANCEL;      but->user=(void*)CC_MB_CANCEL;
     j+=bxcancel;      j+=bxcancel;
   }    }
   show_win(di,true);    cc_show_win(di,true);
   while((!(bool)di->user)&&apprun)message_pump();    return di;
   i=(long)di->user;  
   delete_win(di);  
   free(st);  
   return i;  
 }  }
   
 void edit_copy(WIN *edit)  void cc_edit_copy(Cc_Win *edit)
 {  {
   if(edit==NULL)return;    if(edit==NULL)return;
   if(edit->extra->type!=CC_TP_EDIT)return;    if(edit->extra->type!=CC_TP_EDIT)return;
Line 469  void edit_copy(WIN *edit)
Line 493  void edit_copy(WIN *edit)
   }    }
   else l=j-i;    else l=j-i;
   l++;    l++;
   clipboard=realloc(clipboard,l+1);    _cc_clipboard=realloc(_cc_clipboard,l+1);
   for(j=0;j<l;j++)clipboard[j]=ed->text[j+i];    for(j=0;j<l;j++)_cc_clipboard[j]=ed->text[j+i];
   clipboard[j]='\0';    _cc_clipboard[j]='\0';
 }  }
   
 void edit_paste(WIN *edit)  void cc_edit_paste(Cc_Win *edit)
 {  {
   if(clipboard==NULL)return;    if(_cc_clipboard==NULL)return;
   if(edit==NULL)return;    if(edit==NULL)return;
   if(edit->extra->type!=CC_TP_EDIT)return;    if(edit->extra->type!=CC_TP_EDIT)return;
   EDIT *ed=&edit->extra->edit;    EDIT *ed=&edit->extra->edit;
   if(ed->style==CC_ED_READONLY)return;    if(ed->style==CC_ED_READONLY)return;
   long i,j,l,len=strlen(ed->text),clen=strlen(clipboard);    long i,j,l,len=strlen(ed->text),clen=strlen(_cc_clipboard);
   if(ed->curpos<0)ed->curpos=0;    if(ed->curpos<0)ed->curpos=0;
   if(ed->maskpos!=-1)    if(ed->maskpos!=-1)
   {    {
Line 515  void edit_paste(WIN *edit)
Line 539  void edit_paste(WIN *edit)
     ed->text=realloc(ed->text,len+clen-l+1);      ed->text=realloc(ed->text,len+clen-l+1);
   }    }
   ed->text[len+clen-l]='\0';    ed->text[len+clen-l]='\0';
   for(j=0;j<clen;j++)ed->text[j+i]=clipboard[j];    for(j=0;j<clen;j++)ed->text[j+i]=_cc_clipboard[j];
   ed->maskpos=-1;    ed->maskpos=-1;
   ed->curpos=i+clen;    ed->curpos=i+clen;
   redrawclientwin(edit);    _cc_redrawclientwin(edit);
 }  }
   
 void edit_delete(WIN *edit)  void cc_edit_delete(Cc_Win *edit)
 {  {
   if(edit==NULL)return;    if(edit==NULL)return;
   if(edit->extra->type!=CC_TP_EDIT)return;    if(edit->extra->type!=CC_TP_EDIT)return;
Line 547  void edit_delete(WIN *edit)
Line 571  void edit_delete(WIN *edit)
   ed->text[len-l]='\0';    ed->text[len-l]='\0';
   ed->maskpos=-1;    ed->maskpos=-1;
   ed->curpos=i;    ed->curpos=i;
   redrawclientwin(edit);    _cc_redrawclientwin(edit);
 }  }
   
 void edit_cut(WIN *edit)  void cc_edit_cut(Cc_Win *edit)
 {  {
   edit_copy(edit);    cc_edit_copy(edit);
   edit_delete(edit);    cc_edit_delete(edit);
 }  }
   
 void edit_select(WIN *edit,long sta,long end)  void cc_edit_select(Cc_Win *edit,long sta,long end)
 {  {
   if(edit==NULL)return;    if(edit==NULL)return;
   if(edit->extra->type!=CC_TP_EDIT)return;    if(edit->extra->type!=CC_TP_EDIT)return;
Line 573  void edit_select(WIN *edit,long sta,long
Line 597  void edit_select(WIN *edit,long sta,long
     if(end>len)end=len;      if(end>len)end=len;
   ed->maskpos=sta;    ed->maskpos=sta;
   ed->curpos=end;    ed->curpos=end;
   redrawclientwin(edit);    _cc_redrawclientwin(edit);
 }  }
   
 void edit_get_selection(WIN *edit,long *sta,long *end)  void cc_edit_get_selection(Cc_Win *edit,long *sta,long *end)
 {  {
   if(edit==NULL)return;    if(edit==NULL)return;
   if(edit->extra->type!=CC_TP_EDIT)return;    if(edit->extra->type!=CC_TP_EDIT)return;
Line 585  void edit_get_selection(WIN *edit,long *
Line 609  void edit_get_selection(WIN *edit,long *
   *end=ed->curpos;    *end=ed->curpos;
 }  }
   
 void set_clipboard(char *text)  void cc_set_clipboard(char *text)
 {  {
   if(text==NULL)    if(text==NULL)
   {    {
     free(clipboard);      free(_cc_clipboard);
     clipboard=NULL;      _cc_clipboard=NULL;
   }    }
   clipboard=realloc(clipboard,strlen(text)+1);    _cc_clipboard=realloc(_cc_clipboard,strlen(text)+1);
   strcpy(clipboard,text);    strcpy(_cc_clipboard,text);
 }  }
   
 char *get_clipboard()  char *cc_get_clipboard()
 {  {
   return clipboard;    return _cc_clipboard;
 }  }
   
 void track_popup_menu(WIN *menu,long x,long y)  void cc_track_popup_menu(Cc_Win *menu,long x,long y)
 {  {
   if(menu==NULL)return;    if(menu==NULL)return;
   screen_to_client(menu->parent,&x,&y);    cc_screen_to_client(menu->parent,&x,&y);
   menu->extra->menu.activeline=-1;    menu->extra->menu.activeline=-1;
   menu->x=x;    menu->x=x;
   menu->y=y;    menu->y=y;
   show_win(menu,true);    cc_show_win(menu,true);
   focuswin=menu;    _cc_focuswin=menu;
   capturewin=menu;    _cc_capturewin=menu;
 }  }
   
 WIN *create_menu(WIN *parent,PMENU *menu,  Cc_Win *cc_create_menu(Cc_Win *parent,Cc_Menu_P *menu,
                  bool (*acel)(WIN *win,long x,long y,unsigned short key))                   bool (*acel)(Cc_Win *win,long x,long y,unsigned short key))
 {  {
   if(menu==NULL)return;    if(menu==NULL)return;
   menu->lines=NULL;    menu->lines=NULL;
   return create_win(parent,0,0,0,0,(PUNION*)menu,menu->vert?0:CC_ST_VISIBLE,acel);    return cc_create_win(parent,0,0,0,0,(Cc_Union_P*)menu,
                          menu->vert?0:CC_ST_VISIBLE,acel);
 }  }
   
 WIN *create_submenu(WIN *menu)  Cc_Win *cc_create_submenu(Cc_Win *menu)
 {  {
   if(menu==NULL)return;    if(menu==NULL)return;
   PMENU pmenu;    Cc_Menu_P pmenu;
   get_win_params(menu,(PUNION*)&pmenu);    cc_get_win_params(menu,(Cc_Union_P*)&pmenu);
   pmenu.vert=true;    pmenu.vert=true;
   pmenu.lines=NULL;    pmenu.lines=NULL;
   return create_win(menu,0,0,0,0,(PUNION*)&pmenu,0,(void*)menu->acel);    return cc_create_win(menu,0,0,0,0,(Cc_Union_P*)&pmenu,0,(void*)menu->acel);
 }  }
   
 void add_menu_item(WIN *menu,CMENU *cmenu)  void cc_add_menu_item(Cc_Win *menu,Cc_Menu_I *cmenu)
 {  {
   if((menu==NULL)||(cmenu==NULL))return;    if((menu==NULL)||(cmenu==NULL))return;
   CMENU *p=malloc(sizeof(CMENU));    Cc_Menu_I *p=malloc(sizeof(Cc_Menu_I));
   p->id=cmenu->id;    p->id=cmenu->id;
   p->checked=cmenu->checked;    p->checked=cmenu->checked;
   p->text=cmenu->text;    p->text=cmenu->text;
   p->shortcut=cmenu->shortcut;    p->shortcut=cmenu->shortcut;
   p->submenu=cmenu->submenu;    p->submenu=cmenu->submenu;
   menu->extra->menu.lines=g_list_append(menu->extra->menu.lines,p);    menu->extra->menu.lines=g_list_append(menu->extra->menu.lines,p);
   redraw();    _cc_redraw();
 }  }
   
 void ins_menu_item(WIN *menu,long pos,CMENU *cmenu)  void cc_ins_menu_item(Cc_Win *menu,long pos,Cc_Menu_I *cmenu)
 {  {
   if((menu==NULL)||(cmenu==NULL))return;    if((menu==NULL)||(cmenu==NULL))return;
   CMENU *p=malloc(sizeof(CMENU));    Cc_Menu_I *p=malloc(sizeof(Cc_Menu_I));
   p->id=cmenu->id;    p->id=cmenu->id;
   p->checked=cmenu->checked;    p->checked=cmenu->checked;
   p->text=cmenu->text;    p->text=cmenu->text;
   p->shortcut=cmenu->shortcut;    p->shortcut=cmenu->shortcut;
   p->submenu=cmenu->submenu;    p->submenu=cmenu->submenu;
   menu->extra->menu.lines=g_list_insert(menu->extra->menu.lines,p,pos);    menu->extra->menu.lines=g_list_insert(menu->extra->menu.lines,p,pos);
   redraw();    _cc_redraw();
 }  }
   
 void set_menu_item(WIN *menu,long pos,CMENU *cmenu)  void cc_set_menu_item(Cc_Win *menu,long pos,Cc_Menu_I *cmenu)
 {  {
   if((menu==NULL)||(cmenu==NULL))return;    if((menu==NULL)||(cmenu==NULL))return;
   MENU *pmenu=&menu->extra->menu;    MENU *pmenu=&menu->extra->menu;
   if(pmenu->lines==NULL)return;    if(pmenu->lines==NULL)return;
   GList *lines=g_list_nth(pmenu->lines,pos);    GList *lines=g_list_nth(pmenu->lines,pos);
   if(lines==NULL)return;    if(lines==NULL)return;
   CMENU *p;    Cc_Menu_I *p;
   p=(CMENU*)lines->data;    p=(Cc_Menu_I*)lines->data;
   p->id=cmenu->id;    p->id=cmenu->id;
   p->checked=cmenu->checked;    p->checked=cmenu->checked;
   p->text=cmenu->text;    p->text=cmenu->text;
   p->shortcut=cmenu->shortcut;    p->shortcut=cmenu->shortcut;
   p->submenu=cmenu->submenu;    p->submenu=cmenu->submenu;
   redrawclientwin(menu);    _cc_redrawclientwin(menu);
 }  }
   
 void get_menu_item(WIN *menu,long pos,CMENU *cmenu)  void cc_get_menu_item(Cc_Win *menu,long pos,Cc_Menu_I *cmenu)
 {  {
   if((menu==NULL)||(cmenu==NULL))return;    if((menu==NULL)||(cmenu==NULL))return;
   MENU *pmenu=&menu->extra->menu;    MENU *pmenu=&menu->extra->menu;
   if(pmenu->lines==NULL)return;    if(pmenu->lines==NULL)return;
   GList *lines=g_list_nth(pmenu->lines,pos);    GList *lines=g_list_nth(pmenu->lines,pos);
   if(lines==NULL)return;    if(lines==NULL)return;
   CMENU *p;    Cc_Menu_I *p;
   p=(CMENU*)lines->data;    p=(Cc_Menu_I*)lines->data;
   cmenu->id=p->id;    cmenu->id=p->id;
   cmenu->checked=p->checked;    cmenu->checked=p->checked;
   cmenu->text=p->text;    cmenu->text=p->text;
Line 690  void get_menu_item(WIN *menu,long pos,CM
Line 715  void get_menu_item(WIN *menu,long pos,CM
   cmenu->submenu=p->submenu;    cmenu->submenu=p->submenu;
 }  }
   
 void del_menu_item(WIN *menu,long pos)  void cc_del_menu_item(Cc_Win *menu,long pos)
 {  {
   if(menu==NULL)return;    if(menu==NULL)return;
   MENU *pmenu=&menu->extra->menu;    MENU *pmenu=&menu->extra->menu;
Line 699  void del_menu_item(WIN *menu,long pos)
Line 724  void del_menu_item(WIN *menu,long pos)
   if(lines==NULL)return;    if(lines==NULL)return;
   pmenu->lines=g_list_remove(pmenu->lines,lines->data);    pmenu->lines=g_list_remove(pmenu->lines,lines->data);
   free(lines->data);    free(lines->data);
   redraw();    _cc_redraw();
 }  }
   
 void set_api_run(bool run)  void cc_set_api_run(bool run)
 {  {
   apprun=run;    _cc_apprun=run;
 }  }
   
 bool is_api_run()  bool cc_is_api_run()
 {  {
   return apprun;    return _cc_apprun;
 }  }
   
 void set_capture(WIN *win)  void cc_set_capture(Cc_Win *win)
 {  {
   capturewin=win;    _cc_capturewin=win;
   if(win!=NULL)usekeys=false;else usekeys=true;    if(win!=NULL)_cc_usekeys=false;else _cc_usekeys=true;
 }  }
   
 WIN *get_capture()  Cc_Win *cc_get_capture()
 {  {
   return capturewin;    return _cc_capturewin;
 }  }
   
 bool set_focus(WIN *win)  bool cc_set_focus(Cc_Win *win)
 {  {
   if(win==NULL)    if(win==NULL)
   {    {
     WIN *p=focuswin;      Cc_Win *p=_cc_focuswin;
     focuswin=NULL;      _cc_focuswin=NULL;
     redrawclientwin(p);      _cc_redrawclientwin(p);
     return false;      return false;
   }    }
   while(win!=NULL)    while(win!=NULL)
   {    {
     if(isactive(win)&&((win->extra->type==CC_TP_EDIT)||((win->extra->type==CC_TP_BUTTON)&&(win->extra->button.hasfocus))||      if(_cc_isactive(win)&&((win->extra->type==CC_TP_EDIT)||
       (win->extra->type==CC_TP_LIST)||(win->extra->type==CC_TP_COMBO)||(win->extra->type==CC_TP_MENU)||         ((win->extra->type==CC_TP_BUTTON)&&(win->extra->button.hasfocus))||
       (win->extra->type==CC_TP_DIALOG)))        (win->extra->type==CC_TP_LIST)||(win->extra->type==CC_TP_COMBO)||
         (win->extra->type==CC_TP_MENU)||(win->extra->type==CC_TP_DIALOG)))
     {      {
       WIN *temp=focuswin;        Cc_Win *temp=_cc_focuswin;
       focuswin=win;        _cc_focuswin=win;
       if(win->parent!=NULL)win->parent->lastfocus=win;        if(win->parent!=NULL)win->parent->lastfocus=win;
       bringwintotop(win);        _cc_bringwintotop(win);
       return true;        return true;
     }      }
     win=win->parent;      win=win->parent;
Line 749  bool set_focus(WIN *win)
Line 775  bool set_focus(WIN *win)
   return false;    return false;
 }  }
   
 WIN *get_focus()  Cc_Win *cc_get_focus()
 {  {
   return focuswin;    return _cc_focuswin;
 }  }
   
 void show_win(WIN *win,bool visible)  void cc_show_win(Cc_Win *win,bool visible)
 {  {
   bool doredraw=false;    bool _cc_doredraw=false;
   WIN *p;    Cc_Win *p;
   if(win==NULL){hlvisible=visible;redraw();return;}    if(win==NULL){_cc_hlvisible=visible;_cc_redraw();return;}
   if((win->active)||(isactive(win->parent)))    if((win->active)||(_cc_isactive(win->parent)))
   {    {
     if(win->active!=visible)doredraw=true;      if(win->active!=visible)_cc_doredraw=true;
     win->active=visible;      win->active=visible;
     if(visible)      if(visible)
     {      {
       p=findchild(win);        p=_cc_findchild(win);
       if(p!=NULL)if(set_focus(p))doredraw=false;        if(p!=NULL)if(cc_set_focus(p))_cc_doredraw=false;
     }      }
     if((win->extra->type==CC_TP_DIALOG)&&win->extra->dialog.modal)      if((win->extra->type==CC_TP_DIALOG)&&win->extra->dialog.modal)
     {      {
       if(win->parent!=NULL)win->parent->hasmodal=visible;        if(win->parent!=NULL)win->parent->hasmodal=_cc_isvisible(win);
       else hasmodal=visible;        else _cc_hasmodal=_cc_isvisible(win);
     }      }
     if(!isactive(focuswin)){focuswin=NULL;set_focus(findchild(win->parent));}      if(!_cc_isactive(_cc_focuswin))
     if(!isactive(capturewin))capturewin=NULL;        {_cc_focuswin=NULL;cc_set_focus(_cc_findchild(win->parent));}
       if(!_cc_isactive(_cc_capturewin))_cc_capturewin=NULL;
   }    }
   win->active=visible;    win->active=visible;
   if(doredraw)redraw();    if(_cc_doredraw)_cc_redraw();
   }
   
   void cc_get_mouse_pos(long *x,long *y)
   {
     if(x!=NULL)*x=_cc_gpmev.x;
     if(y!=NULL)*y=_cc_gpmev.y;
   }
   
   void cc_sleep(long milisec)
   {
     nanosleep(&(struct timespec){milisec/1000,(milisec%1000)*1000000},NULL);
 }  }
   
 long get_tick()  long cc_get_tick()
 {  {
   struct timeb times;    struct timeb times;
   long time;    long time;
Line 790  long get_tick()
Line 828  long get_tick()
   return time;    return time;
 }  }
   
 void client_to_screen(WIN *p,long *x,long *y)  void cc_client_to_screen(Cc_Win *p,long *x,long *y)
 {  {
   WIN *n=p;    Cc_Win *n=p;
   while(n!=NULL)    while(n!=NULL)
   {    {
     if(x!=NULL)*x+=n->x;      if(x!=NULL)*x+=n->x;
Line 801  void client_to_screen(WIN *p,long *x,lon
Line 839  void client_to_screen(WIN *p,long *x,lon
   }    }
 }  }
   
 void screen_to_client(WIN *p,long *x,long *y)  void cc_screen_to_client(Cc_Win *p,long *x,long *y)
 {  {
   WIN *n=p;    Cc_Win *n=p;
   while(n!=NULL)    while(n!=NULL)
   {    {
     if(x!=NULL)*x-=n->x;      if(x!=NULL)*x-=n->x;
Line 812  void screen_to_client(WIN *p,long *x,lon
Line 850  void screen_to_client(WIN *p,long *x,lon
   }    }
 }  }
   
 bool get_menu_pos(WIN *win,long id,WIN **submenu,long *pos)  bool cc_get_menu_pos(Cc_Win *win,long id,Cc_Win **submenu,long *pos)
 {  {
   if(win==NULL)return false;    if(win==NULL)return false;
   if(win->extra->type==CC_TP_MENU)    if(win->extra->type==CC_TP_MENU)
Line 822  bool get_menu_pos(WIN *win,long id,WIN *
Line 860  bool get_menu_pos(WIN *win,long id,WIN *
     long npos=0;      long npos=0;
     while(lines!=NULL)      while(lines!=NULL)
     {      {
       if(((CMENU*)lines->data)->id==id)        if(((Cc_Menu_I*)lines->data)->id==id)
       {        {
         if(submenu!=NULL)*submenu=win;          if(submenu!=NULL)*submenu=win;
         if(pos!=NULL)*pos=npos;          if(pos!=NULL)*pos=npos;
         return true;          return true;
       }        }
       WIN *nsubmenu=((CMENU*)lines->data)->submenu;        Cc_Win *nsubmenu=((Cc_Menu_I*)lines->data)->submenu;
       if(nsubmenu!=NULL)        if(nsubmenu!=NULL)
       {        {
         if(get_menu_pos(nsubmenu,id,submenu,pos))return true;          if(cc_get_menu_pos(nsubmenu,id,submenu,pos))return true;
       }        }
       npos++;        npos++;
       lines=g_list_next(lines);        lines=g_list_next(lines);
Line 840  bool get_menu_pos(WIN *win,long id,WIN *
Line 878  bool get_menu_pos(WIN *win,long id,WIN *
   return false;    return false;
 }  }
   
 void set_user(WIN *win,void *user)  void cc_set_user(Cc_Win *win,void *user)
 {  {
   if(win==NULL)return;    if(win==NULL)return;
   win->user=user;    win->user=user;
 }  }
   
 void *get_user(WIN *win)  void *cc_get_user(Cc_Win *win)
 {  {
   if(win==NULL)return NULL;    if(win==NULL)return NULL;
   return win->user;    return win->user;
 }  }
   
 void set_checked(WIN *win,long pos,bool status)  void cc_set_checked(Cc_Win *win,long pos,bool status)
 {  {
   if(win==NULL)return;    if(win==NULL)return;
   if(win->extra->type==CC_TP_BUTTON)    if(win->extra->type==CC_TP_BUTTON)
Line 868  void set_checked(WIN *win,long pos,bool
Line 906  void set_checked(WIN *win,long pos,bool
       lines=g_list_nth(lines,pos);        lines=g_list_nth(lines,pos);
       if(lines!=NULL)        if(lines!=NULL)
       {        {
         ((CMENU*)lines->data)->checked=status;          ((Cc_Menu_I*)lines->data)->checked=status;
       }        }
     }      }
   }    }
 }  }
   
 bool get_checked(WIN *win,long pos)  bool cc_get_checked(Cc_Win *win,long pos)
 {  {
   if(win==NULL)return false;    if(win==NULL)return false;
   if(win->extra->type==CC_TP_BUTTON)    if(win->extra->type==CC_TP_BUTTON)
Line 890  bool get_checked(WIN *win,long pos)
Line 928  bool get_checked(WIN *win,long pos)
       lines=g_list_nth(lines,pos);        lines=g_list_nth(lines,pos);
       if(lines!=NULL)        if(lines!=NULL)
       {        {
         return((CMENU*)lines->data)->checked;          return((Cc_Menu_I*)lines->data)->checked;
       }        }
     }      }
   }    }
   return false;    return false;
 }  }
   
 void set_text(WIN *win,char *text)  void cc_set_text(Cc_Win *win,char *text)
 {  {
   if(win==NULL)return;    if(win==NULL)return;
   if(win->extra->type==CC_TP_EDIT)    if(win->extra->type==CC_TP_EDIT)
Line 908  void set_text(WIN *win,char *text)
Line 946  void set_text(WIN *win,char *text)
     win->extra->edit.text=er;      win->extra->edit.text=er;
     win->extra->edit.maskpos=-1;      win->extra->edit.maskpos=-1;
     strcpy((char*)win->extra->edit.text,(const char*)text);      strcpy((char*)win->extra->edit.text,(const char*)text);
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
   else if(win->extra->type==CC_TP_TEXT)    else if(win->extra->type==CC_TP_TEXT)
   {    {
     win->extra->text.text=text;      win->extra->text.text=text;
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
   else if((win->extra->type==CC_TP_COMBO)&&(win->extra->combo.edit!=NULL))    else if((win->extra->type==CC_TP_COMBO)&&(win->extra->combo.edit!=NULL))
   {    {
     set_text(win->extra->combo.edit,text);      cc_set_text(win->extra->combo.edit,text);
   }    }
   else if(win->extra->type==CC_TP_DIALOG)    else if(win->extra->type==CC_TP_DIALOG)
   {    {
     win->extra->dialog.caption=text;      win->extra->dialog.caption=text;
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
 }  }
   
 char *get_text(WIN *win)  char *cc_get_text(Cc_Win *win)
 {  {
   if(win==NULL)return;    if(win==NULL)return;
   if(win->extra->type==CC_TP_EDIT)    if(win->extra->type==CC_TP_EDIT)
Line 943  char *get_text(WIN *win)
Line 981  char *get_text(WIN *win)
   }    }
 }  }
   
 void set_pos(WIN *win,long pos)  void cc_set_pos(Cc_Win *win,long pos)
 {  {
   if(win==NULL);    if(win==NULL);
   if(win->extra->type==CC_TP_EDIT)    if(win->extra->type==CC_TP_EDIT)
   {    {
     win->extra->edit.curpos=pos;      win->extra->edit.curpos=pos;
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
   else if(win->extra->type==CC_TP_SCROLL)    else if(win->extra->type==CC_TP_SCROLL)
   {    {
     win->extra->scroll.pos=pos;      win->extra->scroll.pos=pos;
     redrawclientwin(win);      _cc_redrawclientwin(win);
     if(win->extra->scroll.change!=NULL)win->extra->scroll.change(win);      if(win->extra->scroll.change!=NULL)win->extra->scroll.change(win);
   }    }
   else if(win->extra->type==CC_TP_COMBO)    else if(win->extra->type==CC_TP_COMBO)
   {    {
     setcomboactiveitem(&win->extra->combo,win->extra->combo.activeline,pos);      _cc_setcomboactiveitem(&win->extra->combo,win->extra->combo.activeline,pos);
     win->extra->combo.activeline=pos;      win->extra->combo.activeline=pos;
     redrawclientwin(win);      _cc_redrawclientwin(win);
     if(win->extra->combo.change!=NULL)win->extra->combo.change(win);      if(win->extra->combo.change!=NULL)win->extra->combo.change(win);
   }    }
   else if(win->extra->type==CC_TP_LIST)    else if(win->extra->type==CC_TP_LIST)
Line 971  void set_pos(WIN *win,long pos)
Line 1009  void set_pos(WIN *win,long pos)
     if(pos-win->vy+3>vscroll->pos)vscroll->pos=pos-win->vy+3;      if(pos-win->vy+3>vscroll->pos)vscroll->pos=pos-win->vy+3;
     long actline=win->extra->list.activeline;      long actline=win->extra->list.activeline;
     win->extra->list.activeline=pos;      win->extra->list.activeline=pos;
     setlistactiveitem(&win->extra->list,actline,win->extra->list.activeline);      _cc_setlistactiveitem(&win->extra->list,actline,
     redrawclientwin(win);                            win->extra->list.activeline);
       _cc_redrawclientwin(win);
     if(win->extra->list.change!=NULL)win->extra->list.change(win);      if(win->extra->list.change!=NULL)win->extra->list.change(win);
   }    }
   else if(win->extra->type==CC_TP_STATUS)    else if(win->extra->type==CC_TP_STATUS)
   {    {
     win->extra->status.pos=pos;      win->extra->status.pos=pos;
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
 }  }
   
 long get_pos(WIN *win)  long cc_get_pos(Cc_Win *win)
 {  {
   if(win==NULL)return CC_NOCHANGE;    if(win==NULL)return CC_NOCHANGE;
   if(win->extra->type==CC_TP_EDIT)    if(win->extra->type==CC_TP_EDIT)
Line 1012  long get_pos(WIN *win)
Line 1051  long get_pos(WIN *win)
   return CC_NOCHANGE;    return CC_NOCHANGE;
 }  }
   
 void set_list(WIN *win,GList *list)  void cc_set_list(Cc_Win *win,GList *list)
 {  {
   if(win==NULL)return;    if(win==NULL)return;
   if(win->extra->type==CC_TP_LIST)    if(win->extra->type==CC_TP_LIST)
   {    {
     LIST *llist=&win->extra->list;      LIST *llist=&win->extra->list;
     llist->lines=list;      llist->lines=list;
     setuplistparams(win);      _cc_setuplistparams(win);
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
   else if(win->extra->type==CC_TP_COMBO)    else if(win->extra->type==CC_TP_COMBO)
   {    {
     win->extra->combo.list->extra->list.lines=list;      win->extra->combo.list->extra->list.lines=list;
     redrawclientwin(win);      _cc_redrawclientwin(win);
   }    }
   else if(win->extra->type==CC_TP_MENU)    else if(win->extra->type==CC_TP_MENU)
   {    {
     win->extra->menu.lines=list;      win->extra->menu.lines=list;
     redraw();      _cc_redraw();
   }    }
 }  }
   
 GList *get_list(WIN *win)  GList *cc_get_list(Cc_Win *win)
 {  {
   if(win==NULL)return;    if(win==NULL)return;
   if(win->extra->type==CC_TP_LIST)    if(win->extra->type==CC_TP_LIST)
Line 1051  GList *get_list(WIN *win)
Line 1090  GList *get_list(WIN *win)
   }    }
 }  }
   
 void set_hl_downtext(WIN *text)  void cc_set_hl_downtext(Cc_Win *text)
 {  {
   if(text!=NULL)    if(text!=NULL)
     if(text->extra->type!=CC_TP_TEXT)return;      if(text->extra->type!=CC_TP_TEXT)return;
   hldowntext=text;    _cc_hldowntext=text;
 }  }
   
 WIN *get_hl_downtext()  Cc_Win *cc_get_hl_downtext()
 {  {
   return hldowntext;    return _cc_hldowntext;
 }  }
   
 void set_menu(WIN *win,WIN *menu)  void cc_set_menu(Cc_Win *win,Cc_Win *menu)
 {  {
   if(menu!=NULL)    if(menu!=NULL)
   {    {
     if((menu->extra->type!=CC_TP_MENU)||(menu->extra->menu.vert))return;      if((menu->extra->type!=CC_TP_MENU)||(menu->extra->menu.vert))return;
     if(menu->parent!=NULL)      if(menu->parent!=NULL)
     {      {
       WIN *parent=menu->parent;        Cc_Win *parent=menu->parent;
       if(parent->extra->type==CC_TP_DIALOG)        if(parent->extra->type==CC_TP_DIALOG)
       {        {
         DIALOG *dialog=&parent->extra->dialog;          DIALOG *dialog=&parent->extra->dialog;
         if(dialog->menu==menu)dialog->menu=NULL;          if(dialog->menu==menu)dialog->menu=NULL;
       }        }
     }      }
     else if(hlmenu==menu)hlmenu=NULL;      else if(_cc_hlmenu==menu)_cc_hlmenu=NULL;
   }    }
   if(win==NULL)    if(win==NULL)
   {    {
     hlmenu=menu;      _cc_hlmenu=menu;
   }    }
   else if(win->extra->type==CC_TP_DIALOG)    else if(win->extra->type==CC_TP_DIALOG)
   {    {
     win->extra->dialog.menu=menu;      win->extra->dialog.menu=menu;
     if(menu!=NULL)if(menu->parent!=win)setparent(menu,win);      if(menu!=NULL)if(menu->parent!=win)_cc_setparent(menu,win);
   }    }
 }  }
   
 WIN *get_menu(WIN *win)  Cc_Win *cc_get_menu(Cc_Win *win)
 {  {
   if(win==NULL)    if(win==NULL)
   {    {
     return hlmenu;      return _cc_hlmenu;
   }    }
   else if(win->extra->type==CC_TP_DIALOG)    else if(win->extra->type==CC_TP_DIALOG)
   {    {
Line 1102  WIN *get_menu(WIN *win)
Line 1141  WIN *get_menu(WIN *win)
   }    }
 }  }
   
 void set_acel(WIN *win,bool (*acel)(WIN *win,long x,long y,unsigned short key))  void cc_set_acel(Cc_Win *win,bool (*acel)(Cc_Win *win,long x,long y,
                    unsigned short key))
 {  {
   if(win!=NULL)win->acel=(void*)acel;else acelproc=(void*)acel;    if(win!=NULL)win->acel=(void*)acel;else _cc_acelproc=(void*)acel;
 }  }
   
 void *get_acel(WIN *win)  void *cc_get_acel(Cc_Win *win)
 {  {
   if(win!=NULL)return win->acel;else return acelproc;    if(win!=NULL)return win->acel;else return _cc_acelproc;
 }  }
   
 void set_resize_proc(WIN *win,void (*resize)(WIN *win))  void cc_set_resize_proc(Cc_Win *win,void (*resize)(Cc_Win *win))
 {  {
   if(win!=NULL)    if(win!=NULL)
   {    {
     if(win->extra->type==CC_TP_DIALOG)win->extra->dialog.resize=(void*)resize;      if(win->extra->type==CC_TP_DIALOG)win->extra->dialog.resize=(void*)resize;
   }    }
   else resizescreen=(void*)resize;    else _cc_resizescreen=(void*)resize;
 }  }
   
 void *get_resize_proc(WIN *win)  void *cc_get_resize_proc(Cc_Win *win)
 {  {
   if(win!=NULL)    if(win!=NULL)
   {    {
     if(win->extra->type==CC_TP_DIALOG)return win->extra->dialog.resize;      if(win->extra->type==CC_TP_DIALOG)return win->extra->dialog.resize;
   }    }
   else return resizescreen;    else return _cc_resizescreen;
 }  }
   
 void set_parent(WIN *win,WIN *parent)  void cc_set_parent(Cc_Win *win,Cc_Win *parent)
 {  {
   long x=0,y=0;    long x=0,y=0;
   client_to_screen(win,&x,&y);    cc_client_to_screen(win,&x,&y);
   setparent(win,parent);    _cc_setparent(win,parent);
   screen_to_client(win,&x,&y);    cc_screen_to_client(win,&x,&y);
   if(!move_win(win,win->x+x,win->y+y,CC_NOCHANGE,CC_NOCHANGE,CC_NOCHANGE))redraw();    if(!cc_move_win(win,win->x+x,win->y+y,CC_NOCHANGE,CC_NOCHANGE,CC_NOCHANGE))
       _cc_redraw();
 }  }
   
 WIN *get_parent(WIN *win)  Cc_Win *cc_get_parent(Cc_Win *win)
 {  {
   return win->parent;    return win->parent;
 }  }
   
 long create_thread(void *(*proc)())  long cc_create_thread(void *(*proc)())
 {  {
   pthread_t res;    pthread_t res;
   pthread_create(&res,NULL,proc,NULL);    pthread_create(&res,NULL,proc,NULL);
   return res;    return res;
 }  }
   
 TIMER *set_timer(WIN *win,long msec,char prior,void (*timer)(TIMER*))  Cc_Timer *cc_set_timer(Cc_Win *win,long msec,char prior,
                          void (*timer)(Cc_Timer*))
 {  {
   TIMER *time;    Cc_Timer *time;
   time=malloc(sizeof(TIMER));    time=malloc(sizeof(Cc_Timer));
   time->next=hltimer;    time->next=_cc_hltimer;
   time->win=win;    time->win=win;
   time->period=msec;    time->period=msec;
   time->prior=prior;    time->prior=prior;
   time->tminus=get_tick();    time->tminus=cc_get_tick();
   time->timer=timer;    time->timer=timer;
   hltimer=time;    _cc_hltimer=time;
   return time;    return time;
 }  }
   
 void del_timer_for_win(WIN *win)  void cc_del_timer_for_win(Cc_Win *win)
 {  {
   TIMER *tprev,*timer;    Cc_Timer *tprev,*timer;
   if((win==NULL)||(hltimer==NULL))return;    if((win==NULL)||(_cc_hltimer==NULL))return;
   tprev=NULL;    tprev=NULL;
   timer=hltimer;    timer=_cc_hltimer;
   while(timer!=NULL)    while(timer!=NULL)
   {    {
     if(timer->win==win)      if(timer->win==win)
     {      {
       if(tprev!=NULL)tprev->next=timer->next;        if(tprev!=NULL)tprev->next=timer->next;
       else hltimer=timer->next;        else _cc_hltimer=timer->next;
       free(timer);        free(timer);
     }      }
     else tprev=timer;      else tprev=timer;
     if(tprev!=NULL)timer=tprev->next;      if(tprev!=NULL)timer=tprev->next;
     else timer=hltimer;      else timer=_cc_hltimer;
   }    }
 }  }
   
 void del_timer(TIMER *timer)  void cc_del_timer(Cc_Timer *timer)
 {  {
   TIMER *p;    Cc_Timer *p;
   if((timer==NULL)||(hltimer==NULL))return;    if((timer==NULL)||(_cc_hltimer==NULL))return;
   if(timer==hltimer)    if(timer==_cc_hltimer)
   {    {
     hltimer=timer->next;      _cc_hltimer=timer->next;
     free(timer);      free(timer);
   }    }
   else    else
   {    {
     for(p=hltimer;(p!=NULL)&&(p->next!=timer);p=p->next);      for(p=_cc_hltimer;(p!=NULL)&&(p->next!=timer);p=p->next);
     if(p!=NULL)      if(p!=NULL)
     {      {
       p->next=timer->next;        p->next=timer->next;
Line 1205  void del_timer(TIMER *timer)
Line 1247  void del_timer(TIMER *timer)
   }    }
 }  }
   
 long get_timer_clock(TIMER *timer)  long cc_get_timer_clock(Cc_Timer *timer)
 {  {
   if(timer==NULL)return -1;    if(timer==NULL)return -1;
   return get_tick()-timer->tminus;    return cc_get_tick()-timer->tminus;
 }  }
   
 void set_timer_params(TIMER *timer,PTIMER *params)  void cc_set_timer_params(Cc_Timer *timer,Cc_Timer_P *params)
 {  {
   if((timer==NULL)||(params==NULL))return;    if((timer==NULL)||(params==NULL))return;
   timer->win=params->win;    timer->win=params->win;
Line 1220  void set_timer_params(TIMER *timer,PTIME
Line 1262  void set_timer_params(TIMER *timer,PTIME
   timer->timer=params->timer;    timer->timer=params->timer;
 }  }
   
 void get_timer_params(TIMER *timer,PTIMER *params)  void cc_get_timer_params(Cc_Timer *timer,Cc_Timer_P *params)
 {  {
   if((timer==NULL)||(params==NULL))return;    if((timer==NULL)||(params==NULL))return;
   params->win=timer->win;    params->win=timer->win;
Line 1229  void get_timer_params(TIMER *timer,PTIME
Line 1271  void get_timer_params(TIMER *timer,PTIME
   params->timer=timer->timer;    params->timer=timer->timer;
 }  }
   
 bool is_timer_run(TIMER *timer)  bool cc_is_timer_run(Cc_Timer *timer)
 {  {
   if(timer==NULL)return -1;    if(timer==NULL)return -1;
   return get_timer_clock(timer)<=timer->period*timer->prior/100;    return cc_get_timer_clock(timer)<=timer->period*timer->prior/100;
 }  }
   
 void get_client_size(WIN *win,long *x,long *y,long *vx,long *vy)  void cc_get_client_size(Cc_Win *win,long *x,long *y,long *vx,long *vy)
 {  {
   if(win!=NULL)    if(win!=NULL)
   {    {
Line 1252  void get_client_size(WIN *win,long *x,lo
Line 1294  void get_client_size(WIN *win,long *x,lo
   }    }
   else    else
   {    {
     if(vx!=NULL)*vx=screenx;      if(vx!=NULL)*vx=_cc_screenx;
     if(vy!=NULL)*vy=screeny-(hlmenu==NULL?0:1)-(hldowntext==NULL?0:1);      if(vy!=NULL)*vy=_cc_screeny-(_cc_hlmenu==NULL?0:1)-
                       (_cc_hldowntext==NULL?0:1);
     if(x!=NULL)*x=0;      if(x!=NULL)*x=0;
     if(y!=NULL)*y=hlmenu==NULL?0:1;      if(y!=NULL)*y=_cc_hlmenu==NULL?0:1;
   }    }
 }  }
   
 bool send_message(WIN *win,long x,long y,unsigned short key)  bool cc_send_message(Cc_Win *win,long x,long y,unsigned short key)
 {  {
   if(!isactive(win))return false;    if(!_cc_isactive(win))return false;
   if(((key&CC_MASK_KEY)>=CC_OFFSET_C)&&((key&CC_MASK_KEY)<CC_OFFSET_K))return dosendkeymessage(win,key);    if(((key&CC_MASK_KEY)>=CC_OFFSET_CHAR)&&
   else if(((key&CC_MASK_KEY)>=CC_OFFSET_K)&&((key&CC_MASK_KEY)<CC_OFFSET_M))return dosendsyskeymessage(win,key);       ((key&CC_MASK_KEY)<CC_OFFSET_KEY))
   else if(((key&CC_MASK_KEY)>=CC_OFFSET_M)&&((key&CC_MASK_KEY)<CC_OFFSET_X))return dosendmousemessage(win,x,y,key);      return _cc_dosendkeymessage(win,key);
     else if(((key&CC_MASK_KEY)>=CC_OFFSET_KEY)&&
             ((key&CC_MASK_KEY)<CC_OFFSET_MOUSE))
            return _cc_dosendsyskeymessage(win,key);
     else if(((key&CC_MASK_KEY)>=CC_OFFSET_MOUSE)&&
             ((key&CC_MASK_KEY)<CC_OFFSET_END))
            return _cc_dosendmousemessage(win,x,y,key);
 }  }
   
 void delete_win(WIN *win)  void cc_delete_win(Cc_Win *win)
 {  {
   show_win(win,false);    cc_show_win(win,false);
   dodeletewin(win);    _cc_dodeletewin(win);
 }  }
   
 char get_win_type(WIN *win)  char cc_get_win_type(Cc_Win *win)
 {  {
   return win->extra->type;    return win->extra->type;
 }  }
   
 bool move_win(WIN *win,long x,long y,long vx,long vy,long state)  bool cc_move_win(Cc_Win *win,long x,long y,long vx,long vy,long state)
 {  {
   if(win==NULL)return false;    if(win==NULL)return false;
   if(x==CC_NOCHANGE)x=win->x;    if(x==CC_NOCHANGE)x=win->x;
Line 1286  bool move_win(WIN *win,long x,long y,lon
Line 1335  bool move_win(WIN *win,long x,long y,lon
   if(vx==CC_NOCHANGE)vx=win->vx;    if(vx==CC_NOCHANGE)vx=win->vx;
   if(vy==CC_NOCHANGE)vy=win->vy;    if(vy==CC_NOCHANGE)vy=win->vy;
   if((win->extra->type==CC_TP_DIALOG)&&    if((win->extra->type==CC_TP_DIALOG)&&
      (win->extra->dialog.sizeok!=NULL))win->extra->dialog.sizeok(win,&x,&y,&vx,&vy);       (win->extra->dialog.sizeok!=NULL))
       win->extra->dialog.sizeok(win,&x,&y,&vx,&vy);
   if(win->extra->type==CC_TP_DIALOG)    if(win->extra->type==CC_TP_DIALOG)
   {    {
     if(state==CC_NOCHANGE)state=win->extra->dialog.state;      if(state==CC_NOCHANGE)state=win->extra->dialog.state;
Line 1295  bool move_win(WIN *win,long x,long y,lon
Line 1345  bool move_win(WIN *win,long x,long y,lon
     {      {
       if(win->extra->dialog.state!=CC_SV_MAXIMIZED)        if(win->extra->dialog.state!=CC_SV_MAXIMIZED)
       {        {
         get_client_size(win->parent,&x,&y,&vx,&vy);          cc_get_client_size(win->parent,&x,&y,&vx,&vy);
       }        }
       else        else
       {        {
Line 1334  bool move_win(WIN *win,long x,long y,lon
Line 1384  bool move_win(WIN *win,long x,long y,lon
   if(vx<1)vx=1;    if(vx<1)vx=1;
   if(vy<1)vy=1;    if(vy<1)vy=1;
   if((win->vx==vx)&&(win->vy==vy)&&(win->x==x)&&(win->y==y)&&    if((win->vx==vx)&&(win->vy==vy)&&(win->x==x)&&(win->y==y)&&
      (win->extra->type==CC_TP_DIALOG?win->extra->dialog.state==state:true))return false;       (win->extra->type==CC_TP_DIALOG?win->extra->dialog.state==state:true))
       return false;
   if(win->extra->type==CC_TP_DIALOG)    if(win->extra->type==CC_TP_DIALOG)
   {    {
     if(win->extra->dialog.state==CC_SV_NORMAL)      if(win->extra->dialog.state==CC_SV_NORMAL)
Line 1366  bool move_win(WIN *win,long x,long y,lon
Line 1417  bool move_win(WIN *win,long x,long y,lon
   win->vx=vx;    win->vx=vx;
   win->vy=vy;    win->vy=vy;
   long px,py,pvx,pvy;    long px,py,pvx,pvy;
   get_client_size(win->parent,&px,&py,&pvx,&pvy);    cc_get_client_size(win->parent,&px,&py,&pvx,&pvy);
   win->flx=x;    win->flx=x;
   win->fly=y;    win->fly=y;
   win->frx=pvx+px-x-vx;    win->frx=pvx+px-x-vx;
Line 1395  bool move_win(WIN *win,long x,long y,lon
Line 1446  bool move_win(WIN *win,long x,long y,lon
       if((win->extra->dialog.style&CC_ST_DI_HASMINIMIZE)==CC_ST_DI_HASMINIMIZE)        if((win->extra->dialog.style&CC_ST_DI_HASMINIMIZE)==CC_ST_DI_HASMINIMIZE)
         win->extra->dialog.bminimize->extra->button.text="o";          win->extra->dialog.bminimize->extra->button.text="o";
     }      }
     if(win->extra->dialog.resize!=NULL)win->extra->dialog.resize(win->vx,win->vy);      if(win->extra->dialog.resize!=NULL)win->extra->dialog.resize(win);
   }    }
   if(isvisible(win))redraw();    if(_cc_isvisible(win))_cc_redraw();
   return true;    return true;
 }  }
   
 WIN *create_win(WIN *parent,long x,long y,long vx,long vy,  Cc_Win *cc_create_win(Cc_Win *parent,long x,long y,long vx,long vy,
                 PUNION *extra,long style,bool (*acel)(WIN *win,long x,long y,unsigned short key))                        Cc_Union_P *extra,long style,bool (*acel)(Cc_Win *win,
                         long x,long y,unsigned short key))
 {  {
   WIN *ne,*p;    Cc_Win *ne,*p;
   long size,px,py,pvx,pvy;    long size,px,py,pvx,pvy;
   ne=(WIN*)malloc(sizeof(WIN));    ne=(Cc_Win*)malloc(sizeof(Cc_Win));
   ne->parent=parent;    ne->parent=parent;
   ne->x=x;    ne->x=x;
   ne->y=y;    ne->y=y;
Line 1414  WIN *create_win(WIN *parent,long x,long
Line 1466  WIN *create_win(WIN *parent,long x,long
   ne->vy=vy;    ne->vy=vy;
   ne->svx=-1;    ne->svx=-1;
   ne->svy=-1;    ne->svy=-1;
   get_client_size(parent,&px,&py,&pvx,&pvy);    cc_get_client_size(parent,&px,&py,&pvx,&pvy);
   ne->flx=x;    ne->flx=x;
   ne->fly=y;    ne->fly=y;
   ne->frx=pvx+px-x-vx;    ne->frx=pvx+px-x-vx;
Line 1445  WIN *create_win(WIN *parent,long x,long
Line 1497  WIN *create_win(WIN *parent,long x,long
   ne->next=NULL;    ne->next=NULL;
   ne->child=NULL;    ne->child=NULL;
   ne->childend=NULL;    ne->childend=NULL;
   if(hlwin==NULL)    if(_cc_hlwin==NULL)
   {    {
     hlwin=ne;      _cc_hlwin=ne;
     hlendwin=ne;      _cc_hlendwin=ne;
   }    }
   else    else
   {    {
     if(parent==NULL)      if(parent==NULL)
     {      {
       hlendwin->next=ne;        _cc_hlendwin->next=ne;
       hlendwin=ne;        _cc_hlendwin=ne;
     }      }
     else      else
     {      {
Line 1510  WIN *create_win(WIN *parent,long x,long
Line 1562  WIN *create_win(WIN *parent,long x,long
   }    }
   else if(extra->type==CC_TP_LIST)    else if(extra->type==CC_TP_LIST)
   {    {
     PSCROLL scroll;      Cc_Scroll_P scroll;
     LIST *list=&ne->extra->list;      LIST *list=&ne->extra->list;
     scroll.type=CC_TP_SCROLL;      scroll.type=CC_TP_SCROLL;
     scroll.pos=0;      scroll.pos=0;
     scroll.cnt=1;      scroll.cnt=1;
     scroll.change=scrollincombochangeproc;      scroll.change=_cc_scrollincombochangeproc;
     list->exvscroll=EX_NONE;      list->exvscroll=EX_NONE;
     list->exhscroll=EX_NONE;      list->exhscroll=EX_NONE;
     list->lencells=NULL;      list->lencells=NULL;
Line 1525  WIN *create_win(WIN *parent,long x,long
Line 1577  WIN *create_win(WIN *parent,long x,long
     list->activeitem=NULL;      list->activeitem=NULL;
     list->scrollupitem=NULL;      list->scrollupitem=NULL;
     scroll.vert=true;      scroll.vert=true;
     list->vscroll=create_win(ne,ne->vx-1,1,1,ne->vy-2,(PUNION*)&scroll,0,NULL);      list->vscroll=cc_create_win(ne,ne->vx-1,1,1,ne->vy-2,(Cc_Union_P*)&scroll,0,
                                   NULL);
     scroll.vert=false;      scroll.vert=false;
     list->hscroll=create_win(ne,1,ne->vy-1,ne->vx-2,1,(PUNION*)&scroll,0,NULL);      list->hscroll=cc_create_win(ne,1,ne->vy-1,ne->vx-2,1,(Cc_Union_P*)&scroll,0,
                                   NULL);
     if(extra->list.combotyp==CC_LI_COMBO)      if(extra->list.combotyp==CC_LI_COMBO)
     {      {
       PUNION fade;        Cc_Union_P fade;
       fade.type=TP_FADE;        fade.type=TP_FADE;
       list->hfade=create_win(ne,2,ne->vy,ne->vx,1,(PUNION*)&fade,CC_ST_VISIBLE,NULL);        list->hfade=cc_create_win(ne,2,ne->vy,ne->vx,1,(Cc_Union_P*)&fade,
       list->vfade=create_win(ne,ne->vx>1?ne->vx:ne->vx+1,1,ne->vx>1?2:1,ne->vy-1,(PUNION*)&fade,CC_ST_VISIBLE,NULL);                                  CC_ST_VISIBLE,NULL);
         list->vfade=cc_create_win(ne,ne->vx>1?ne->vx:ne->vx+1,1,ne->vx>1?2:1,
                                   ne->vy-1,(Cc_Union_P*)&fade,CC_ST_VISIBLE,NULL);
     }      }
     else      else
     {      {
Line 1543  WIN *create_win(WIN *parent,long x,long
Line 1599  WIN *create_win(WIN *parent,long x,long
   }    }
   else if(extra->type==CC_TP_COMBO)    else if(extra->type==CC_TP_COMBO)
   {    {
     PLIST list;      Cc_List_P list;
     COMBO *combo=&ne->extra->combo;      COMBO *combo=&ne->extra->combo;
     long x,y;      long x,y;
     if(ne->vy>1)ne->vy=1;      if(ne->vy>1)ne->vy=1;
Line 1553  WIN *create_win(WIN *parent,long x,long
Line 1609  WIN *create_win(WIN *parent,long x,long
     list.lines=NULL;      list.lines=NULL;
     list.combotyp=CC_LI_COMBO;      list.combotyp=CC_LI_COMBO;
     list.change=NULL;      list.change=NULL;
     list.dblclk=combodblclkproc;      list.dblclk=_cc_combodblclkproc;
     combo->pushed=SC_UP;      combo->pushed=SC_UP;
     combo->scroll=0;      combo->scroll=0;
     combo->activeitem=NULL;      combo->activeitem=NULL;
     combo->list=create_win(ne,x,y,ne->vx+2,ne->extra->combo.lstvy,(PUNION*)&list,CC_ST_TOP_WIN,NULL);      combo->list=cc_create_win(ne,x,y,ne->vx+2,ne->extra->combo.lstvy,
                                 (Cc_Union_P*)&list,CC_ST_TOP_WIN,NULL);
     if((style&CC_ST_CO_WITH_EDIT)==CC_ST_CO_WITH_EDIT)      if((style&CC_ST_CO_WITH_EDIT)==CC_ST_CO_WITH_EDIT)
     {      {
       PEDIT edit;        Cc_Edit_P edit;
       edit.type=CC_TP_EDIT;        edit.type=CC_TP_EDIT;
       combo->edit=create_win(ne,0,0,ne->vx-1,1,(PUNION*)&edit,CC_ST_VISIBLE,claeditacel);        combo->edit=cc_create_win(ne,0,0,ne->vx-1,1,(Cc_Union_P*)&edit,
                                   CC_ST_VISIBLE,_cc_claeditacel);
     }      }
     else      else
       combo->edit=NULL;        combo->edit=NULL;
   }    }
   else if(extra->type==CC_TP_STATUS)    else if(extra->type==CC_TP_STATUS)
   {    {
     PSTATUS *status=&extra->status;      Cc_Status_P *status=&extra->status;
     if(extra->status.vert)      if(extra->status.vert)
     {      {
       if(ne->vx>1)ne->vx=1;        if(ne->vx>1)ne->vx=1;
Line 1585  WIN *create_win(WIN *parent,long x,long
Line 1643  WIN *create_win(WIN *parent,long x,long
     menu->activeline=-1;      menu->activeline=-1;
     if(extra->menu.vert)      if(extra->menu.vert)
     {      {
       PUNION fade;        Cc_Union_P fade;
       fade.type=TP_FADE;        fade.type=TP_FADE;
       ne->style|=CC_ST_TOP_WIN;        ne->style|=CC_ST_TOP_WIN;
       menu->hfade=create_win(ne,2,ne->vy,ne->vx,1,(PUNION*)&fade,CC_ST_VISIBLE,NULL);        menu->hfade=cc_create_win(ne,2,ne->vy,ne->vx,1,(Cc_Union_P*)&fade,
       menu->vfade=create_win(ne,ne->vx>1?ne->vx:ne->vx+1,1,ne->vx>1?2:1,ne->vy-1,(PUNION*)&fade,CC_ST_VISIBLE,NULL);                                  CC_ST_VISIBLE,NULL);
         menu->vfade=cc_create_win(ne,ne->vx>1?ne->vx:ne->vx+1,1,ne->vx>1?2:1,
                                   ne->vy-1,(Cc_Union_P*)&fade,CC_ST_VISIBLE,NULL);
     }      }
   }    }
   else if(extra->type==CC_TP_DIALOG)    else if(extra->type==CC_TP_DIALOG)
   {    {
     DIALOG *dialog=&ne->extra->dialog;      DIALOG *dialog=&ne->extra->dialog;
     dialog->state=CC_SV_NORMAL;      dialog->state=CC_SV_NORMAL;
     PBUTTON button;      Cc_Button_P button;
     button.type=CC_TP_BUTTON;      button.type=CC_TP_BUTTON;
     button.style=CC_BT_NORMAL;      button.style=CC_BT_NORMAL;
     button.checked=false;      button.checked=false;
     button.hasfocus=false;      button.hasfocus=false;
     long n=3;      long n=3;
     button.text="X";      button.text="X";
     button.push=bclosepush;      button.push=_cc_bclosepush;
     dialog->bclose=create_win(ne,ne->vx-n,0,1,1,(PUNION*)&button,0,NULL);      dialog->bclose=cc_create_win(ne,ne->vx-n,0,1,1,(Cc_Union_P*)&button,0,NULL);
     n++;      n++;
     if((extra->dialog.style&CC_ST_DI_HASMAXIMIZE)==CC_ST_DI_HASMAXIMIZE)      if((extra->dialog.style&CC_ST_DI_HASMAXIMIZE)==CC_ST_DI_HASMAXIMIZE)
     {      {
       button.text="O";        button.text="O";
       button.push=bmaximizepush;        button.push=_cc_bmaximizepush;
       dialog->bmaximize=create_win(ne,ne->vx-n,0,1,1,(PUNION*)&button,0,NULL);        dialog->bmaximize=cc_create_win(ne,ne->vx-n,0,1,1,(Cc_Union_P*)&button,0,
                                         NULL);
       n++;        n++;
     }      }
     else dialog->bmaximize=NULL;      else dialog->bmaximize=NULL;
     if((extra->dialog.style&CC_ST_DI_HASMINIMIZE)==CC_ST_DI_HASMINIMIZE)      if((extra->dialog.style&CC_ST_DI_HASMINIMIZE)==CC_ST_DI_HASMINIMIZE)
     {      {
       button.text=".";        button.text=".";
       button.push=bminimizepush;        button.push=_cc_bminimizepush;
       dialog->bminimize=create_win(ne,ne->vx-n,0,1,1,(PUNION*)&button,0,NULL);        dialog->bminimize=cc_create_win(ne,ne->vx-n,0,1,1,(Cc_Union_P*)&button,0,
                                         NULL);
     }      }
     else dialog->bminimize=NULL;      else dialog->bminimize=NULL;
     FADE fade;      FADE fade;
     fade.type=TP_FADE;      fade.type=TP_FADE;
     dialog->hfade=create_win(ne,2,ne->vy,ne->vx,1,(PUNION*)&fade,CC_ST_VISIBLE,NULL);      dialog->hfade=cc_create_win(ne,2,ne->vy,ne->vx,1,(Cc_Union_P*)&fade,
     dialog->vfade=create_win(ne,ne->vx>1?ne->vx:ne->vx+1,1,ne->vx>1?2:1,ne->vy-1,(PUNION*)&fade,CC_ST_VISIBLE,NULL);                                  CC_ST_VISIBLE,NULL);
       dialog->vfade=cc_create_win(ne,ne->vx>1?ne->vx:ne->vx+1,1,ne->vx>1?2:1,
                                   ne->vy-1,(Cc_Union_P*)&fade,CC_ST_VISIBLE,NULL);
   }    }
   set_win_params(ne,extra);    cc_set_win_params(ne,extra);
   if((style&CC_ST_VISIBLE)==CC_ST_VISIBLE)show_win(ne,true);    if((style&CC_ST_VISIBLE)==CC_ST_VISIBLE)cc_show_win(ne,true);
   return ne;    return ne;
 }  }
   
 void set_win_params(WIN *win,PUNION *params)  void cc_set_win_params(Cc_Win *win,Cc_Union_P *params)
 {  {
   if((win==NULL)||(params==NULL))return;    if((win==NULL)||(params==NULL))return;
   win->extra->type=params->type;    win->extra->type=params->type;
   switch(params->type)    switch(params->type)
   {    {
     case CC_TP_TEXT:settextparams(win,params);break;      case CC_TP_TEXT:_cc_settextparams(win,params);break;
     case CC_TP_EDIT:seteditparams(win,params);break;      case CC_TP_EDIT:_cc_seteditparams(win,params);break;
     case CC_TP_BUTTON:setbuttonparams(win,params);break;      case CC_TP_BUTTON:_cc_setbuttonparams(win,params);break;
     case CC_TP_SCROLL:setscrollparams(win,params);break;      case CC_TP_SCROLL:_cc_setscrollparams(win,params);break;
     case CC_TP_COMBO:setcomboparams(win,params);break;      case CC_TP_COMBO:_cc_setcomboparams(win,params);break;
     case CC_TP_LIST:setlistparams(win,params);break;      case CC_TP_LIST:_cc_setlistparams(win,params);break;
     case CC_TP_STATUS:setstatusparams(win,params);break;      case CC_TP_STATUS:_cc_setstatusparams(win,params);break;
     case CC_TP_PAINT:setpaintparams(win,params);break;      case CC_TP_PAINT:_cc_setpaintparams(win,params);break;
     case CC_TP_MENU:setmenuparams(win,params);break;      case CC_TP_MENU:_cc_setmenuparams(win,params);break;
     case CC_TP_DIALOG:setdialogparams(win,params);break;      case CC_TP_DIALOG:_cc_setdialogparams(win,params);break;
   }    }
   redrawclientwin(win);    _cc_redrawclientwin(win);
 }  }
   
 void get_win_params(WIN *win,PUNION *params)  void cc_get_win_params(Cc_Win *win,Cc_Union_P *params)
 {  {
   if((win==NULL)||(params==NULL))return;    if((win==NULL)||(params==NULL))return;
   params->type=win->extra->type;    params->type=win->extra->type;
   switch(params->type)    switch(params->type)
   {    {
     case CC_TP_TEXT:gettextparams(win,params);break;      case CC_TP_TEXT:_cc_gettextparams(win,params);break;
     case CC_TP_EDIT:geteditparams(win,params);break;      case CC_TP_EDIT:_cc_geteditparams(win,params);break;
     case CC_TP_BUTTON:getbuttonparams(win,params);break;      case CC_TP_BUTTON:_cc_getbuttonparams(win,params);break;
     case CC_TP_SCROLL:getscrollparams(win,params);break;      case CC_TP_SCROLL:_cc_getscrollparams(win,params);break;
     case CC_TP_COMBO:getcomboparams(win,params);break;      case CC_TP_COMBO:_cc_getcomboparams(win,params);break;
     case CC_TP_LIST:getlistparams(win,params);break;      case CC_TP_LIST:_cc_getlistparams(win,params);break;
     case CC_TP_STATUS:getstatusparams(win,params);break;      case CC_TP_STATUS:_cc_getstatusparams(win,params);break;
     case CC_TP_PAINT:getpaintparams(win,params);break;      case CC_TP_PAINT:_cc_getpaintparams(win,params);break;
     case CC_TP_MENU:getmenuparams(win,params);break;      case CC_TP_MENU:_cc_getmenuparams(win,params);break;
     case CC_TP_DIALOG:getdialogparams(win,params);break;      case CC_TP_DIALOG:_cc_getdialogparams(win,params);break;
   }    }
 }  }
   
 #include <term.h>  #include <term.h>
 #undef buttons  #undef buttons
   
 void message_pump()  bool cc_message_pump()
 {  {
   long key,temp;    Cc_Timer *p,*pnext;
   unsigned char res;  
   unsigned short mod;  
   TIMER *p,*pnext;  
   long time;    long time;
   static MEVENT event;  
   bool isevent;  
   Gpm_Event ev;    Gpm_Event ev;
   mousex=CC_NOCHANGE;    static MEVENT event;
   mousey=CC_NOCHANGE;    if(!_cc_apprun)return false;
   res=6;    while(_cc_waitkeyevent);
   mod=0;    _cc_waitevent=true;
   key=getch();    if(_cc_gpmgetevent(&ev))
   if(mouseactive==MOUSE_GPM)isevent=gpmgetevent(&ev);else isevent=false;  
   if(isevent||(key!=-1))  
   {  
     if(ioctl(0,TIOCLINUX,&res)>=0)  
     {  
       if((res&SHIFT_PRESSED)==SHIFT_PRESSED)mod|=CC_D_SHIFT;  
       if((res&CTRL_PRESSED)==CTRL_PRESSED)mod|=CC_D_CTRL;  
       if(((res&ALTL_PRESSED)==ALTL_PRESSED)||((res&ALTR_PRESSED)==ALTR_PRESSED))  
       {  
         mod|=CC_D_ALT;  
         if(key==27)key=getch();  
       }  
     }  
     if(key==27)  
     {  
       if((temp=getch())!=27)  
         ungetch(temp);  
       else  
       {  
         key=temp;  
         mod|=CC_D_ALT;  
       }  
     }  
   }  
   if(isevent)  
   {    {
     event.x=ev.x;      event.x=ev.x;
     event.y=ev.y;      event.y=ev.y;
Line 1729  void message_pump()
Line 1763  void message_pump()
     }      }
     if((ev.modifiers&SHIFT_PRESSED)==SHIFT_PRESSED)event.bstate|=BUTTON_SHIFT;      if((ev.modifiers&SHIFT_PRESSED)==SHIFT_PRESSED)event.bstate|=BUTTON_SHIFT;
     if((ev.modifiers&CTRL_PRESSED)==CTRL_PRESSED)event.bstate|=BUTTON_CTRL;      if((ev.modifiers&CTRL_PRESSED)==CTRL_PRESSED)event.bstate|=BUTTON_CTRL;
     if(((ev.modifiers&ALTL_PRESSED)==ALTL_PRESSED)||((ev.modifiers&ALTR_PRESSED)==ALTR_PRESSED))      if(((ev.modifiers&ALTL_PRESSED)==ALTL_PRESSED)||
          ((ev.modifiers&ALTR_PRESSED)==ALTR_PRESSED))
       event.bstate|=BUTTON_ALT;        event.bstate|=BUTTON_ALT;
     domouseevent(&event);      _cc_domouseevent(&event);
       if(!_cc_waitevent)return _cc_apprun;
   }    }
   if(key!=-1)dokey(key,mod);    if((_cc_screenx!=columns)||(_cc_screeny!=lines))
   if((screenx!=columns)||(screeny!=lines))  
   {    {
     screenx=columns;      _cc_screenx=columns;
     screeny=lines;      _cc_screeny=lines;
     mainwin.vx=screenx;      _cc_mainwin.vx=_cc_screenx;
     mainwin.vy=screeny;      _cc_mainwin.vy=_cc_screeny;
     mainwin.windata=realloc(mainwin.windata,screenx*screeny*sizeof(attr_t));      _cc_mainwin.windata=realloc(_cc_mainwin.windata,
     cmap=realloc(cmap,screenx*screeny*sizeof(CMAP));                                  _cc_screenx*_cc_screeny*sizeof(attr_t));
     if(resizescreen!=NULL)resizescreen(NULL);      _cc_cmap=realloc(_cc_cmap,_cc_screenx*_cc_screeny*sizeof(CMAP));
     redraw();      if(_cc_resizescreen!=NULL)_cc_resizescreen(NULL);
       _cc_redraw();
   }    }
   if(key!=-1)redrawmouse=0;    if(_cc_redrawmouse<2)
   if(redrawmouse<2)  
   {    {
     Gpm_DrawPointer(gpmev.x,gpmev.y,gpm_consolefd);      Gpm_DrawPointer(_cc_gpmev.x,_cc_gpmev.y,gpm_consolefd);
     redrawmouse++;      _cc_redrawmouse++;
   }    }
   refresh();    refresh();
   for(p=hltimer;p!=NULL;p=pnext)    for(p=_cc_hltimer;p!=NULL;p=pnext)
   {    {
     time=get_tick();      time=cc_get_tick();
     pnext=p->next;      pnext=p->next;
     if(time-p->tminus>=p->period)      if(time-p->tminus>=p->period)
     {      {
Line 1762  void message_pump()
Line 1797  void message_pump()
       p->timer(p);        p->timer(p);
     }      }
   }    }
     _cc_waitevent=false;
     nanosleep(&(struct timespec){0,TIMER_GRANULATE},NULL);
     return _cc_apprun;
   }
   
   void cc_init(int argc,char *argv[])
   {
     long i;
     struct sigaction act;
     Gpm_Event ev;
     act.sa_handler=SIG_IGN;
     act.sa_flags=0;
     sigemptyset(&act.sa_mask);
     sigaction(SIGINT,&act,NULL);
     sigaction(SIGQUIT,&act,NULL);
     initscr();
     start_color();
     _cc_oldattr=attrset(0);
     ESCDELAY=0;
     _cc_uglycharset=false;
     for(i=1;i<argc;i++)if(strcmp(argv[i],"-a")==0){_cc_uglycharset=true;break;}
     if(_cc_uglycharset)_cc_mapsymbol=_cc_ugmsymbol;
     _cc_hascolors=has_colors();
     keypad(stdscr,true);
     cbreak();
     noecho();
     nodelay(stdscr,false);
     curs_set(0);
     _cc_mousex=-1;
     _cc_mousey=-1;
     pthread_create(&_cc__cc_getchthreadp,NULL,_cc_getchthread,NULL);
     Gpm_Connect conn;
     conn.eventMask=GPM_MOVE|GPM_DRAG|GPM_DOWN|GPM_UP;
     conn.defaultMask=0;
     conn.minMod=0;
     conn.maxMod=-1;
     gpm_zerobased=true;
     if((Gpm_Open(&conn,0)!=-1)&&(Gpm_GetEvent(&ev)!=-1))
     {
       _cc_gpmev.x=_cc_mousex=ev.x;
       _cc_gpmev.y=_cc_mousey=ev.y;
       _cc_mouseactive=MOUSE_GPM;
       Gpm_Repeat(0);
       GPM_XTERM_ON;
       pthread_create(&_cc_gpmthreadp,NULL,_cc_gpmthread,NULL);
     }
     else
     {
       _cc_mouseactive=MOUSE_XTERM;
       mousemask(ALL_MOUSE_EVENTS|REPORT_MOUSE_POSITION,NULL);
       mouseinterval(0);
     }
     _cc_screenx=columns;
     _cc_screeny=lines;
     _cc_mainwin.x=0;
     _cc_mainwin.y=0;
     _cc_mainwin.vx=_cc_screenx;
     _cc_mainwin.vy=_cc_screeny;
     _cc_mainwin.parent=NULL;
     _cc_mainwin.windata=malloc(_cc_screenx*_cc_screeny*sizeof(attr_t));
     _cc_cmap=malloc(_cc_screenx*_cc_screeny*sizeof(CMAP));
     Cc_Menu_P menu;
     menu.type=CC_TP_MENU;
     menu.cback=CC_C_DEFAULT;
     menu.cborder=CC_C_DEFAULT;
     menu.ctext=CC_C_DEFAULT;
     menu.cutext=CC_C_DEFAULT;
     menu.cactive=CC_C_DEFAULT;
     menu.cactivetext=CC_C_DEFAULT;
     menu.cactiveutext=CC_C_DEFAULT;
     menu.change=NULL;
     menu.select=_cc_clipboardmenuproc;
     menu.vert=true;
     _cc_clipboardmenu=cc_create_menu(NULL,&menu,NULL);
     cc_add_menu_item(_cc_clipboardmenu,&(Cc_Menu_I){0,false,"Cu&t",
                      CC_MOD_CTRL|'X',NULL});
     cc_add_menu_item(_cc_clipboardmenu,&(Cc_Menu_I){1,false,"&Copy",
                      CC_MOD_CTRL|'C',NULL});
     cc_add_menu_item(_cc_clipboardmenu,&(Cc_Menu_I){2,false,"&Paste",
                      CC_MOD_CTRL|'V',NULL});
     cc_add_menu_item(_cc_clipboardmenu,&(Cc_Menu_I){3,false,"&Delete",0,NULL});
     cc_add_menu_item(_cc_clipboardmenu,&(Cc_Menu_I){4,false,"Select &All",0,
                      NULL});
     _cc_redraw();
   }
   
   void cc_done()
   {
     struct sigaction act;
     bkgd(_cc_oldattr);
     clear();
     refresh();
     if(_cc_mouseactive==MOUSE_GPM)
     {
       GPM_XTERM_OFF;
       Gpm_Close();
     }
     noecho();
     cbreak();
     free(_cc_mainwin.windata);
     free(_cc_cmap);
     endwin();
     mousemask(0,NULL);
     curs_set(1);
     act.sa_handler=SIG_DFL;
     act.sa_flags=0;
     sigemptyset(&act.sa_mask);
     sigaction(SIGINT,&act,NULL);
     sigaction(SIGQUIT,&act,NULL);
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top