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.6 and 1.7

version 1.6, 2005/12/08 21:13:04 version 1.7, 2005/12/10 21:24:55
Line 7 
Line 7 
   
 #include "cc.h"  #include "cc.h"
   
 bool cc_file_open_dialog(Cc_Win *parent,char *caption,char *filename,char *mask)  Cc_Win *cc_file_open_dialog(Cc_Win *parent,
                               void (*action)(Cc_Win *sender,char *filename),
                               bool modal,char *caption,char *filename,char *mask)
 {  {
   if((caption==NULL)||(filename==NULL)||(mask==NULL))return false;    if((caption==NULL)||(filename==NULL)||(mask==NULL))return NULL;
   const cback=CC_C_CYAN;    const cback=CC_C_CYAN;
   bool i;    long x,y,i,j,oldi,act,len,vx=_cc_fobvx,vy=_cc_fobvy;
   long x,y;    GList *disklines,*masklines,*mmlines;
   static long vx=DEF_FOB_VX,vy=DEF_FOB_VY;  
   x=(_cc_screenx-vx)/2;    x=(_cc_screenx-vx)/2;
   y=(_cc_screeny-vy)/2;    y=(_cc_screeny-vy)/2;
   cc_screen_to_client(parent,&x,&y);    cc_screen_to_client(parent,&x,&y);
   Cc_Win *di,*diskcombo,*filelist,*nameedit,*maskcombo;    Cc_Win *di,*diskcombo,*filelist,*nameedit,*maskcombo;
     char *lin;
   TUFOB *tufob;    TUFOB *tufob;
   Cc_Dialog_P pdialog;    Cc_Dialog_P pdialog;
   pdialog.type=CC_TP_DIALOG;    pdialog.type=CC_TP_DIALOG;
Line 29  bool cc_file_open_dialog(Cc_Win *parent,
Line 31  bool cc_file_open_dialog(Cc_Win *parent,
   pdialog.cbuttext[0]=CC_C_DEFAULT;    pdialog.cbuttext[0]=CC_C_DEFAULT;
   pdialog.cbuttext[1]=CC_C_DEFAULT;    pdialog.cbuttext[1]=CC_C_DEFAULT;
   pdialog.cbuttext[2]=CC_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=_cc_fobsizeokproc;    pdialog.sizeok=_cc_fobsizeokproc;
Line 38  bool cc_file_open_dialog(Cc_Win *parent,
Line 40  bool cc_file_open_dialog(Cc_Win *parent,
                    _cc_fobdialogacelproc);                     _cc_fobdialogacelproc);
   di->user=malloc(sizeof(TUFOB));    di->user=malloc(sizeof(TUFOB));
   tufob=((TUFOB*)(di->user));    tufob=((TUFOB*)(di->user));
   tufob->i=-1;    tufob->action=action;
   Cc_Combo_P pcombo;    Cc_Combo_P pcombo;
   Cc_Button_P pbutton;    Cc_Button_P pbutton;
   Cc_List_P plist;    Cc_List_P plist;
   Cc_Edit_P pedit;    Cc_Edit_P pedit;
   GList *disklines,*masklines;  
   disklines=NULL;    disklines=NULL;
   disklines=g_list_append(disklines,"/");    disklines=g_list_append(disklines,"/");
   disklines=g_list_append(disklines,"/root");    disklines=g_list_append(disklines,"/root/");
   disklines=g_list_append(disklines,"/home");    disklines=g_list_append(disklines,"/home/");
   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;
Line 97  bool cc_file_open_dialog(Cc_Win *parent,
Line 98  bool cc_file_open_dialog(Cc_Win *parent,
   diskcombo=cc_create_win(di,12,2,vx-3-12,1,(Cc_Union_P*)&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;
   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;
Line 120  bool cc_file_open_dialog(Cc_Win *parent,
Line 120  bool cc_file_open_dialog(Cc_Win *parent,
                          CC_ST_VISIBLE|CC_ST_A_FIXED,_cc_fobfilelistacelproc);                           CC_ST_VISIBLE|CC_ST_A_FIXED,_cc_fobfilelistacelproc);
   tufob->filelist=filelist;    tufob->filelist=filelist;
   pbutton.push=_cc_fobnamebuttonproc;    pbutton.push=_cc_fobnamebuttonproc;
   pbutton.text="File &name:";    pbutton.text="File &name:    ";
   cc_create_win(di,3,vy-5,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,    cc_create_win(di,3,vy-5,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,
                 CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);                  CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);
   pedit.type=CC_TP_EDIT;    pedit.type=CC_TP_EDIT;
Line 138  bool cc_file_open_dialog(Cc_Win *parent,
Line 138  bool cc_file_open_dialog(Cc_Win *parent,
   cc_create_win(di,3,vy-3,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,    cc_create_win(di,3,vy-3,strlen(pbutton.text),1,(Cc_Union_P*)&pbutton,
                 CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);                  CC_ST_VISIBLE|CC_ST_AD_FIXED,NULL);
   masklines=NULL;    masklines=NULL;
     mmlines=NULL;
     act=0;
     len=strlen(mask);
   //masklines=g_list_append(masklines,"/");    oldi=0;
     for(i=0;i<=len;i++)
     {
       if((i==len)||(mask[i]=='|'))
       {
         lin=malloc(i-oldi+1);
         for(j=0;j<i-oldi;j++)lin[j]=mask[oldi+j];
         lin[i-oldi]='\0';
         if(act==0){masklines=g_list_append(masklines,lin);act=1;}
         else {mmlines=g_list_append(mmlines,lin);act=0;}
         oldi=i+1;
       }
     }
   pcombo.change=_cc_fobdiskcombochangeproc;    pcombo.change=_cc_fobdiskcombochangeproc;
   pcombo.lstlines=masklines;    pcombo.lstlines=masklines;
   maskcombo=cc_create_win(di,18,vy-3,vx-21,1,(Cc_Union_P*)&pcombo,    maskcombo=cc_create_win(di,18,vy-3,vx-21,1,(Cc_Union_P*)&pcombo,
Line 169  bool cc_file_open_dialog(Cc_Win *parent,
Line 178  bool cc_file_open_dialog(Cc_Win *parent,
   cc_create_win(di,vx-13,6,10,1,(Cc_Union_P*)&pbutton,    cc_create_win(di,vx-13,6,10,1,(Cc_Union_P*)&pbutton,
                 CC_ST_VISIBLE|CC_ST_AR_FIXED,NULL);                  CC_ST_VISIBLE|CC_ST_AR_FIXED,NULL);
   cc_set_focus(filelist);    cc_set_focus(filelist);
     tufob->mmlines=mmlines;
     tufob->filename=filename;
     _cc_fobsetnameedit(di);
     _cc_fobsetfilelist(di,mmlines!=NULL?mmlines->data:NULL);
     _cc_fobsetdiskcombo(di);
   cc_show_win(di,true);    cc_show_win(di,true);
   //while((tufob->i==-1)&&_cc_apprun)cc_message_pump();    return di;
   i=tufob->i;  
   vx=di->vx;  
   vy=di->vy;  
   cc_delete_win(di);  
   free(tufob);  
   if(disklines!=NULL)g_list_free(disklines);  
   if(masklines!=NULL)g_list_free(masklines);  
   return i;  
 }  }
   
 long cc_color_dialog(Cc_Win *parent,char *caption,long color)  Cc_Win *cc_color_dialog(Cc_Win *parent,void (*action)(Cc_Win *sender,long i),
                           bool modal,char *caption,long color)
 {  {
   if(caption==NULL)return -1;    if(caption==NULL)return NULL;
   long x,y,i;    long x,y,i;
   const vx=34,vy=10,cback=CC_C_CYAN;    const vx=34,vy=10,cback=CC_C_CYAN;
   Cc_Win *di,*p,*combo,*p1,*p2;    Cc_Win *di,*p,*combo,*p1,*p2;
Line 205  long cc_color_dialog(Cc_Win *parent,char
Line 212  long cc_color_dialog(Cc_Win *parent,char
   pdialog.cbuttext[0]=CC_C_DEFAULT;    pdialog.cbuttext[0]=CC_C_DEFAULT;
   pdialog.cbuttext[1]=CC_C_DEFAULT;    pdialog.cbuttext[1]=CC_C_DEFAULT;
   pdialog.cbuttext[2]=CC_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;
Line 214  long cc_color_dialog(Cc_Win *parent,char
Line 221  long cc_color_dialog(Cc_Win *parent,char
                    _cc_cbdialogacelproc);                     _cc_cbdialogacelproc);
   di->user=malloc(sizeof(TUCB));    di->user=malloc(sizeof(TUCB));
   tucb=((TUCB*)(di->user));    tucb=((TUCB*)(di->user));
   tucb->i=0;    tucb->action=action;
   ppaint.type=CC_TP_PAINT;    ppaint.type=CC_TP_PAINT;
   ppaint.style=CC_PA_PATTERN;    ppaint.style=CC_PA_PATTERN;
   for(y=0;y<4;y++)    for(y=0;y<4;y++)
Line 300  long cc_color_dialog(Cc_Win *parent,char
Line 307  long cc_color_dialog(Cc_Win *parent,char
   pbutton.text="  &Ok  ";    pbutton.text="  &Ok  ";
   p=cc_create_win(di,19,5,1,1,(Cc_Union_P*)&pbutton,    p=cc_create_win(di,19,5,1,1,(Cc_Union_P*)&pbutton,
                   CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);                    CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
   p->user=(void*)1;    p->user=(void*)true;
   pbutton.text="&Cancel";    pbutton.text="&Cancel";
   p=cc_create_win(di,19,7,1,1,(Cc_Union_P*)&pbutton,    p=cc_create_win(di,19,7,1,1,(Cc_Union_P*)&pbutton,
                   CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);                    CC_ST_VISIBLE|CC_ST_AUTOXSIZE,NULL);
   p->user=(void*)-1;    p->user=(void*)false;
   cc_show_win(di,true);    cc_show_win(di,true);
   //while((tucb->i==0)&&_cc_apprun)cc_message_pump();    return di;
   if(tucb->i==-1)i=-1;  
   else if(tucb->i==1)i=combo->extra->combo.activeline;  
   cc_delete_win(di);  
   free(tucb);  
   return i;  
 }  }
   
 Cc_Win *cc_message_box(Cc_Win *parent,void (*action)(Cc_Win *sender,long i),  Cc_Win *cc_message_box(Cc_Win *parent,void (*action)(Cc_Win *sender,long i),
Line 330  Cc_Win *cc_message_box(Cc_Win *parent,vo
Line 332  Cc_Win *cc_message_box(Cc_Win *parent,vo
   Cc_Win *di;    Cc_Win *di;
   nlen=len;    nlen=len;
   vx=6;    vx=6;
   vy=4;    vy=3;
   bx=0;    bx=0;
   if(style!=CC_MB_DEFAULT)vy+=1;    if(style!=CC_MB_DEFAULT)vy+=2;
   if(style&CC_MB_OK)bx+=bxok;    if(style&CC_MB_OK)bx+=bxok;
   if(style&CC_MB_YES)bx+=bxyes;    if(style&CC_MB_YES)bx+=bxyes;
   if(style&CC_MB_NO)bx+=bxno;    if(style&CC_MB_NO)bx+=bxno;
Line 780  Cc_Win *cc_get_focus()
Line 782  Cc_Win *cc_get_focus()
   return _cc_focuswin;    return _cc_focuswin;
 }  }
   
 void cc_show_win(Cc_Win *win,bool visible)  bool cc_show_win(Cc_Win *win,bool visible)
 {  {
   bool _cc_doredraw=false;    bool _cc_doredraw=false;
   Cc_Win *p;    Cc_Win *p;
   if(win==NULL){_cc_hlvisible=visible;_cc_redraw();return;}    if(win==NULL){_cc_hlvisible=visible;_cc_redraw();return true;}
   if((win->active)||(_cc_isactive(win->parent)))    if((win->active)||(_cc_isactive(win->parent)))
   {    {
     if(win->active!=visible)_cc_doredraw=true;      if(win->active!=visible)_cc_doredraw=true;
Line 805  void cc_show_win(Cc_Win *win,bool visibl
Line 807  void cc_show_win(Cc_Win *win,bool visibl
   }    }
   win->active=visible;    win->active=visible;
   if(_cc_doredraw)_cc_redraw();    if(_cc_doredraw)_cc_redraw();
     return _cc_doredraw;
 }  }
   
 void cc_get_mouse_pos(long *x,long *y)  void cc_get_mouse_pos(long *x,long *y)
Line 1820  void cc_init(int argc,char *argv[])
Line 1823  void cc_init(int argc,char *argv[])
   for(i=1;i<argc;i++)if(strcmp(argv[i],"-a")==0){_cc_uglycharset=true;break;}    for(i=1;i<argc;i++)if(strcmp(argv[i],"-a")==0){_cc_uglycharset=true;break;}
   if(_cc_uglycharset)_cc_mapsymbol=_cc_ugmsymbol;    if(_cc_uglycharset)_cc_mapsymbol=_cc_ugmsymbol;
   _cc_hascolors=has_colors();    _cc_hascolors=has_colors();
     intrflush(stdscr,false);
   keypad(stdscr,true);    keypad(stdscr,true);
   cbreak();    cbreak();
   noecho();    noecho();
Line 1885  void cc_init(int argc,char *argv[])
Line 1889  void cc_init(int argc,char *argv[])
   
 void cc_done()  void cc_done()
 {  {
     while(_cc_waitevent);_cc_waitevent=true;
     while(_cc_waitkeyevent);_cc_waitkeyevent=true;
   struct sigaction act;    struct sigaction act;
   bkgd(_cc_oldattr);    bkgd(_cc_oldattr);
   clear();    clear();

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

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