| version 1.2, 2005/11/27 20:14:50 |
version 1.3, 2005/11/29 18:46:31 |
|
|
| /* |
/* |
| Name: lc_main.c |
Name: cc_main.c |
| Author: Michal Sudolsky |
Author: Michal Sudolsky <michals@sulysoft.com> |
| Date: 24.08.2005 18:34 |
Date: 24.08.2005 18:34 |
| */ |
*/ |
| // modified by Juraj Kolesar <koli@koli.sk> |
// modified by Juraj Kolesar <koli@koli.sk> |
| Line 23 bool hlvisible=false; |
|
| Line 23 bool hlvisible=false; |
|
| GList *dialoglist=NULL; |
GList *dialoglist=NULL; |
| char *clipboard=NULL; |
char *clipboard=NULL; |
| WIN *clipboardmenu=NULL; |
WIN *clipboardmenu=NULL; |
| |
GSList *topwinlist=NULL; |
| |
CMAP *cmap=NULL; |
| char *bitmap[BITMAPY]={ // nejake to logo do pozadia |
char *bitmap[BITMAPY]={ // nejake to logo do pozadia |
| "oo...........................................................................oo", |
"oo...........................................................................oo", |
| "o.............................................................................o", |
"o.............................................................................o", |
| Line 181 bool claeditacel(WIN *sender,long x,long |
|
| Line 183 bool claeditacel(WIN *sender,long x,long |
|
| return ret; |
return ret; |
| } |
} |
| |
|
| |
void setuplistparams(WIN *win) |
| |
{ |
| |
LIST *list=&win->extra->list; |
| |
if(list->lines==NULL) |
| |
{ |
| |
list->numlines=0; |
| |
list->maxitemlen=0; |
| |
free(list->lencells); |
| |
list->lencells=NULL; |
| |
list->activeitem=NULL; |
| |
return; |
| |
} |
| |
GList *lines; |
| |
long poz; |
| |
list->numlines=g_list_length(list->lines); |
| |
if((list->activeline>=0)&&(list->activeline<list->numlines)) |
| |
list->activeitem=g_list_nth(list->lines,list->activeline); |
| |
if(list->combotyp!=CT_TABLE) |
| |
{ |
| |
list->maxitemlen=0; |
| |
lines=list->lines; |
| |
while(lines!=NULL) |
| |
{ |
| |
if(lines->data==NULL)continue; |
| |
poz=strlen(lines->data); |
| |
if(poz>list->maxitemlen)list->maxitemlen=poz; |
| |
lines=g_list_next(lines); |
| |
} |
| |
} |
| |
else |
| |
{ |
| |
GSList *sc; |
| |
long i; |
| |
sc=list->lencells; |
| |
list->maxitemlen=-1; |
| |
while(sc!=NULL) |
| |
{ |
| |
list->maxitemlen+=(long)sc->data+1; |
| |
sc=g_slist_next(sc); |
| |
i++; |
| |
} |
| |
if(list->maxitemlen<0)list->maxitemlen=0; |
| |
} |
| |
if(list->combotyp==CT_TABLE) |
| |
{ |
| |
long i; |
| |
if(list->lencells!=NULL)g_slist_free(list->lencells); |
| |
for(i=0;i<g_slist_length((GSList*)list->lines->data);i++) |
| |
list->lencells=g_slist_append(list->lencells,NULL); |
| |
lines=list->lines; |
| |
GSList *sc,*sl; |
| |
sc=list->lencells; |
| |
while(sc!=NULL) |
| |
{ |
| |
sc->data=(void*)0; |
| |
sc=g_slist_next(sc); |
| |
} |
| |
while(lines!=NULL) |
| |
{ |
| |
sl=(GSList*)lines->data; |
| |
sc=list->lencells; |
| |
while((sl!=NULL)&&(sc!=NULL)) |
| |
{ |
| |
i=strlen(sl->data); |
| |
if(i>(long)sc->data)sc->data=(void*)i; |
| |
sc=g_slist_next(sc); |
| |
sl=g_slist_next(sl); |
| |
} |
| |
lines=g_list_next(lines); |
| |
} |
| |
} |
| |
} |
| |
|
| char *getcolorname(long color) |
char *getcolorname(long color) |
| { |
{ |
| switch(color) |
switch(color) |
| Line 521 WIN *findchildnom(WIN *win) |
|
| Line 596 WIN *findchildnom(WIN *win) |
|
| return win; |
return win; |
| } |
} |
| |
|
| void combodblclkproc(WIN *Sender) |
void combodblclkproc(WIN *sender) |
| { |
{ |
| if(Sender->extra->type==TP_LIST) |
if(sender->extra->type==TP_LIST) |
| if(Sender->parent!=NULL) |
if(sender->parent!=NULL) |
| if(Sender->parent->extra->type==TP_COMBO) |
if(sender->parent->extra->type==TP_COMBO) |
| { |
{ |
| COMBO *combo=&Sender->parent->extra->combo; |
COMBO *combo=&sender->parent->extra->combo; |
| combo->activeline=Sender->extra->list.activeline; |
combo->activeline=sender->extra->list.activeline; |
| combo->scroll=0; |
combo->scroll=0; |
| if(combo->change!=NULL)combo->change(Sender->parent); |
if(combo->change!=NULL)combo->change(sender->parent); |
| } |
} |
| } |
} |
| |
|
| Line 761 bool runacel(WIN *win,long x,long y,unsi |
|
| Line 836 bool runacel(WIN *win,long x,long y,unsi |
|
| return false; |
return false; |
| } |
} |
| |
|
| WIN *searchwin(WIN *win,long x,long y) |
|
| { |
|
| long px,py; |
|
| WIN *p=NULL,*n; |
|
| while(win!=NULL) |
|
| { |
|
| px=0; |
|
| py=0; |
|
| client_to_screen(win,&px,&py); |
|
| if((px<=x)&&(py<=y)&&(px+win->vx>x)&&(py+win->vy>y)&&(isactive(win)||win->hasmodal))p=win; |
|
| n=searchwin(win->child,x,y); |
|
| if(n!=NULL)p=n; |
|
| win=win->next; |
|
| } |
|
| return p; |
|
| } |
|
| |
|
| WIN *findwin(long x,long y) |
WIN *findwin(long x,long y) |
| { |
{ |
| return searchwin(hlwin,x,y); |
if((x<0)||(y<0)||(x>=screenx)||(y>=screeny))return NULL; |
| } |
return cmap[x+y*screenx].win; |
| |
|
| WIN *searchwintostop(WIN *stop,WIN *win,long x,long y) |
|
| { |
|
| long px,py; |
|
| WIN *p=NULL,*n; |
|
| while(win!=NULL) |
|
| { |
|
| if((win==stop)&&(stop!=NULL))return p; |
|
| px=0; |
|
| py=0; |
|
| client_to_screen(win,&px,&py); |
|
| if((px<=x)&&(py<=y)&&(px+win->vx>x)&&(py+win->vy>y)&&isvisible(win))p=win; |
|
| n=searchwintostop(stop,win->child,x,y); |
|
| if(n!=NULL)p=n; |
|
| win=win->next; |
|
| } |
|
| return p; |
|
| } |
|
| |
|
| WIN *findwintostop(WIN *stop,long x,long y) |
|
| { |
|
| return searchwintostop(stop,hlwin,x,y); |
|
| } |
|
| |
|
| WIN *searchwinonlypaint(WIN *win,long x,long y) |
|
| { |
|
| long px,py; |
|
| WIN *p=NULL,*n; |
|
| while(win!=NULL) |
|
| { |
|
| px=0; |
|
| py=0; |
|
| client_to_screen(win,&px,&py); |
|
| if((px<=x)&&(py<=y)&&(px+win->vx>x)&&(py+win->vy>y)&& |
|
| (win->extra->type==TP_PAINT)&&(win->extra->paint.style==PA_BORDER)&& |
|
| (win->redrawed)&&isvisible(win))p=win; |
|
| n=searchwinonlypaint(win->child,x,y); |
|
| if(n!=NULL)p=n; |
|
| win=win->next; |
|
| } |
|
| return p; |
|
| } |
} |
| |
|
| WIN *findwinonlypaint(long x,long y) |
WIN *findwinonlypaint(long x,long y) |
| { |
{ |
| return searchwinonlypaint(hlwin,x,y); |
if((x<0)||(y<0)||(x>=screenx)||(y>=screeny))return NULL; |
| |
return cmap[x+y*screenx].paint; |
| } |
} |
| |
|
| void dosetredrawed(WIN *win,bool redrawed) |
void dosetredrawed(WIN *win,bool redrawed) |
| { |
{ |
| if(hldowntext!=NULL) |
|
| { |
|
| if(hldowntext!=hlendwin) |
|
| { |
|
| WIN *p=hlwin; |
|
| while(p!=NULL) |
|
| { |
|
| if(p->next==hldowntext) |
|
| { |
|
| p->next=hldowntext->next; |
|
| break; |
|
| } |
|
| p=p->next; |
|
| } |
|
| hldowntext->next=NULL; |
|
| hlendwin->next=hldowntext; |
|
| hlendwin=hldowntext; |
|
| } |
|
| } |
|
| if(hlmenu!=NULL) |
if(hlmenu!=NULL) |
| { |
{ |
| if(hlmenu->parent!=NULL)setparent(hlmenu,NULL); |
if(hlmenu->parent!=NULL)setparent(hlmenu,NULL); |
| Line 862 void dosetredrawed(WIN *win,bool redrawe |
|
| Line 861 void dosetredrawed(WIN *win,bool redrawe |
|
| if(hldowntext!=NULL) |
if(hldowntext!=NULL) |
| { |
{ |
| if(hldowntext->parent!=NULL)setparent(hldowntext,NULL); |
if(hldowntext->parent!=NULL)setparent(hldowntext,NULL); |
| |
hldowntext->style|=ST_TOP_WIN; |
| hldowntext->x=0; |
hldowntext->x=0; |
| hldowntext->y=screeny-1; |
hldowntext->y=screeny-1; |
| hldowntext->vx=screenx; |
hldowntext->vx=screenx; |
| Line 875 void dosetredrawed(WIN *win,bool redrawe |
|
| Line 875 void dosetredrawed(WIN *win,bool redrawe |
|
| } |
} |
| } |
} |
| |
|
| int doredraw(WIN *win) |
int doredraw(WIN *win,char drawmode) |
| { |
{ |
| for(;win!=NULL;win=win->next) |
for(;win!=NULL;win=win->next) |
| { |
{ |
| if(drawwin(win,true)==ERR)return ERR; |
if(drawmode==DM_BOTTOM) |
| win->redrawed=true; |
{ |
| checkbars(win,true); |
if(!(win->style&ST_TOP_WIN)) |
| if(doredraw(win->child)==ERR)return ERR; |
{ |
| |
if(drawwin(win,true)==ERR)return ERR; |
| |
win->redrawed=true; |
| |
checkbars(win,true); |
| |
if(doredraw(win->child,DM_BOTTOM)==ERR)return ERR; |
| |
} |
| |
else |
| |
{ |
| |
topwinlist=g_slist_append(topwinlist,win); |
| |
if(doredraw(win->child,DM_MARK_TOP)==ERR)return ERR; |
| |
} |
| |
} |
| |
else if(drawmode==DM_MARK_TOP) |
| |
{ |
| |
if(win->style&ST_TOP_WIN)topwinlist=g_slist_append(topwinlist,win); |
| |
if(doredraw(win->child,DM_MARK_TOP)==ERR)return ERR; |
| |
} |
| |
else if(drawmode==DM_TOP_BOTTOM) |
| |
{ |
| |
if(!(win->style&ST_TOP_WIN)) |
| |
{ |
| |
if(drawwin(win,true)==ERR)return ERR; |
| |
win->redrawed=true; |
| |
checkbars(win,true); |
| |
} |
| |
if(doredraw(win->child,DM_TOP_BOTTOM)==ERR)return ERR; |
| |
} |
| } |
} |
| return OK; |
return OK; |
| } |
} |
|
|
| WIN *win; |
WIN *win; |
| long x,y,px,py,a1,a2; |
long x,y,px,py,a1,a2; |
| short c1,c2; |
short c1,c2; |
| |
GSList *sl; |
| if(hlvisible) |
if(hlvisible) |
| { |
{ |
| c1=C_BLUE;c1<<=3;c1+=C_WHITE; |
c1=C_BLUE;c1<<=3;c1+=C_WHITE; |
|
|
| for(x=px;x<px+BITMAPX;x++) |
for(x=px;x<px+BITMAPX;x++) |
| if(bitmap[y-py][x-px]=='o') |
if(bitmap[y-py][x-px]=='o') |
| maddch(&mainwin,y,x,a2); |
maddch(&mainwin,y,x,a2); |
| |
memset(cmap,0,screenx*screeny*sizeof(CMAP)); |
| dosetredrawed(hlwin,false); |
dosetredrawed(hlwin,false); |
| if(doredraw(hlwin)==ERR)return ERR; |
if(doredraw(hlwin,DM_BOTTOM)==ERR)return ERR; |
| |
sl=topwinlist; |
| |
while(sl!=NULL) |
| |
{ |
| |
win=(WIN*)sl->data; |
| |
if(drawwin(win,true)==ERR)return ERR; |
| |
win->redrawed=true; |
| |
checkbars(win,true); |
| |
if(doredraw(win->child,DM_TOP_BOTTOM)==ERR)return ERR; |
| |
sl=g_slist_next(sl); |
| |
} |
| |
if(topwinlist!=NULL) |
| |
{ |
| |
g_slist_free(topwinlist); |
| |
topwinlist=NULL; |
| |
} |
| } |
} |
| else |
else |
| { |
{ |
| Line 1091 void checkwin(WIN *win) |
|
| Line 1134 void checkwin(WIN *win) |
|
| } |
} |
| else if(win->extra->type==TP_LIST) |
else if(win->extra->type==TP_LIST) |
| { |
{ |
| long poz,maxlen=0,numlines=0; |
|
| LIST *list=&win->extra->list; |
LIST *list=&win->extra->list; |
| GList *lines=list->lines; |
GList *lines=list->lines; |
| if(lines!=NULL)numlines=g_list_length(lines); |
if((win->style&ST_AUTOXSIZE)==ST_AUTOXSIZE)win->vx=list->maxitemlen+2; |
| |
if((win->style&ST_AUTOYSIZE)==ST_AUTOYSIZE)win->vy=list->numlines+2; |
| |
|
| // this may be in list setup function |
|
| if(list->combotyp!=CT_TABLE) |
|
| { |
|
| while(lines!=NULL) |
|
| { |
|
| if(lines->data==NULL)continue; |
|
| poz=strlen(lines->data); |
|
| if(poz>maxlen)maxlen=poz; |
|
| lines=g_list_next(lines); |
|
| } |
|
| } |
|
| else |
|
| { |
|
| GSList *sc; |
|
| long i; |
|
| sc=list->lencells; |
|
| maxlen=-1; |
|
| while(sc!=NULL) |
|
| { |
|
| maxlen+=(long)sc->data+1; |
|
| sc=g_slist_next(sc); |
|
| i++; |
|
| } |
|
| if(maxlen<0)maxlen=0; |
|
| } |
|
| // ----------------------------------- |
|
| |
|
| |
|
| if((win->style&ST_AUTOXSIZE)==ST_AUTOXSIZE)win->vx=maxlen+2; |
|
| if((win->style&ST_AUTOYSIZE)==ST_AUTOYSIZE)win->vy=numlines+2; |
|
| } |
} |
| screen_to_client(win->parent,&x,&y); |
screen_to_client(win->parent,&x,&y); |
| win->x=x; |
win->x=x; |
| Line 1254 int main(int argc,char *argv[]) |
|
| Line 1265 int main(int argc,char *argv[]) |
|
| mainwin.vy=screeny; |
mainwin.vy=screeny; |
| mainwin.parent=NULL; |
mainwin.parent=NULL; |
| mainwin.windata=malloc(screenx*screeny*sizeof(attr_t)); |
mainwin.windata=malloc(screenx*screeny*sizeof(attr_t)); |
| |
cmap=malloc(screenx*screeny*sizeof(CMAP)); |
| { |
{ |
| PMENU menu; |
PMENU menu; |
| menu.type=TP_MENU; |
menu.type=TP_MENU; |
| Line 1289 int main(int argc,char *argv[]) |
|
| Line 1301 int main(int argc,char *argv[]) |
|
| noecho(); |
noecho(); |
| cbreak(); |
cbreak(); |
| free(mainwin.windata); |
free(mainwin.windata); |
| |
free(cmap); |
| endwin(); |
endwin(); |
| mousemask(0,NULL); |
mousemask(0,NULL); |
| curs_set(1); |
curs_set(1); |