static int c_direct_set(const struct buxton_layer *layer, const char *key, const char *value, enum buxton_key_type type) { int r; struct buxton_value val; if (!layer || !key || !*key || !value) { errno = EINVAL; bxt_err("Set: Layer '%s' Key '%s' Value '%s': %s", layer ? buxton_layer_get_name(layer) : "", key ? key : "", value ? value : "", strerror(errno)); return -1; } r = c_set_value(type, value, &val); if (r == -1) return -1; r = c_init(); if (r == -1) return -1; r = direct_set(layer, key, &val); c_exit(); if (r == -1) { bxt_err("Set: Layer '%s' Key '%s' Value '%s': %s", buxton_layer_get_name(layer), key, value, strerror(errno)); } return r; }
static void change_turn() { int id=o_aktual->id; int i; for(i=60;i<90;i+=10) c_set_value(0,i,f_get_value(0,i) & ~1 | (i==id)); turn_speed((id-60)/10); }
static void change_zoom() { int id=o_aktual->id; int i; for(i=30;i<60;i+=10) c_set_value(0,i,f_get_value(0,i) & ~1 | (i==id)); zoom_speed((id-30)/10); }
void fill_bit_fields(int win,int id_start,int source,int count) { while (count) { c_set_value(win,id_start,source & 1); id_start+=10; source>>=1; count--; } }
void jdi_na_sektor(s) { WINDOW *w,*w2; if (!s) return; cur_layer=minfo[s].layer; xmap_offs=minfo[s].x; ymap_offs=minfo[s].y; c_set_value(map_win,20,ymap_offs); c_set_value(map_win,30,xmap_offs); unselect_map(); minfo[s].flags=1; info_sector(s); w=find_window(map_win); w2=waktual; if (w!=NULL) { waktual=w; redraw_window(); waktual=w2; } }
void string_list_sup_call() { int id,v; OBJREC *p; id=o_aktual->id; p=o_aktual; v=f_get_value(0,id); v=string_list(*(char **)(o_aktual->userptr),v); if (v+1) c_set_value(0,id,v); o_aktual=p; p->events[3](); o_aktual=o_start; }
static int c_direct_create(const struct buxton_layer *layer, const char *key, const char *value, enum buxton_key_type type, const char *rpriv, const char *wpriv) { int r; struct buxton_value val; if (!layer || !key || !*key || !value || !rpriv || !wpriv) { errno = EINVAL; bxt_err("Create: '%s' '%s' '%s' Priv '%s' '%s': %s", layer ? buxton_layer_get_name(layer) : "", key ? key : "", value ? value : "", rpriv ? rpriv : "", wpriv ? wpriv : "", strerror(errno)); return -1; } r = c_set_value(type, value, &val); if (r == -1) return -1; r = c_init(); if (r == -1) return -1; r = direct_create(layer, key, rpriv, wpriv, &val); c_exit(); if (r == -1) { bxt_err("Create: '%s' '%s' '%s' Priv '%s' '%s': %s", buxton_layer_get_name(layer), key, value, rpriv, wpriv, strerror(errno)); } return r; }
void action_flags() { CTL3D b1; long flags; flags=f_get_value(0,350); memcpy(&b1,def_border(1,0),sizeof(CTL3D)); def_dialoge(300,220,300,210,"V¡ce vlajek"); define(CANCEL_BUTT,11,5,80,20,2,button,"Zru¨it");property(&b1,NULL,NULL,WINCOLOR); on_change(terminate); define(OK_BUTT,100,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR); on_change(terminate); define(10,10,20,250,10,0,check_box,side_flgs[24]); define(20,10,32,250,10,0,check_box,side_flgs[25]); define(30,10,44,250,10,0,check_box,side_flgs[26]); define(40,10,56,250,10,0,check_box,side_flgs[27]); define(50,10,68,250,10,0,check_box,side_flgs[28]); define(60,10,88,250,10,0,check_box,side_flgs[29]); define(70,10,100,250,10,0,check_box,side_flgs[30]); define(80,10,112,250,10,0,check_box,side_flgs[31]); define(90,10,124,250,10,0,check_box,side_flgs[20]); define(100,10,136,250,10,0,check_box,side_flgs[21]); define(110,10,148,250,10,0,check_box,side_flgs[22]); define(120,10,160,250,10,0,check_box,side_flgs[23]); fill_bit_fields(0,10,flags>>24,8); fill_bit_fields(0,90,flags>>20,4); redraw_window(); escape(); if (o_aktual->id==OK_BUTT) { flags=get_bit_fields(0,10,8)<<24; flags|=get_bit_fields(0,90,4)<<20; } close_window(waktual); c_set_value(0,350,flags); }
void string_list_event(EVENT_MSG *msg,OBJREC *o) { STRING_LIST_DATA *p; int y; int znh,i; TSTR_LIST ls; MS_EVENT *ms; static char clicked=0; p=o->userptr; ls=p->list; y=o->locy; switch (msg->msg) { case E_MOUSE: i=get_to_topline(ls,p->topline,NULL); ms=get_mouse(msg); curfont=o->font; if (ms->tl1 && clicked || ms->event_type & 0x2) { if (ls) do { char *c; clicked=1; c=ls[i]; if (i>=p->maxitems) return; if (c!=NULL) znh=text_height(c); else znh=0; if (y+znh>o->locy+o->ys) return; if (ms->y>=y && ms->y<y+znh) { if (ls[i]!=NULL) c_set_value(0,o->id,i);else clicked=0; return; } i++; y+=znh; } while (1); } if (ms->event_type & 0x4 && clicked) { clicked=0;set_change(); } return; case E_KEYBOARD: { int pos=*(int *)(o->data); int key=(*(int *)msg->data) & 0xff; if (!key) { int save; int curLine; key=*(int *)msg->data >> 8; { do { save=pos; switch (key) { case 'H':pos--;break; case 'P':pos++;break; case 'I':pos-=p->maxview;break; case 'Q':pos+=p->maxview;break; } if (pos<0) pos=0; if (pos>=p->maxitems) pos=p->maxitems-1; curLine=set_line_back(p->list,pos); if (curLine>=p->topline+p->maxview) p->topline=curLine-p->maxview+1; if (curLine<p->topline) p->topline=curLine; } while (save!=pos && p->list[pos]==NULL); c_set_value(0,o->id,pos); } } break; } case E_CONTROL: { int *q; q=msg->data; switch (*q++) { case 1:p->list=(TSTR_LIST)*q; redraw_object(o); break; case 0:*(void **)*q=p->list; break; case 2: i=get_to_topline(ls,p->topline,NULL); if (*(int *)o->data<i) p->topline=set_line_back(ls,*(int *)o->data); if (*(int *)o->data>=i+p->maxview) p->topline=set_line_back(ls,*(int *)o->data); break; } } case E_LOST_FOCUS:clicked=0; }
void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o) { STRING_LIST_DATA *p; int xs,ys,y; char savech[]=" "; int znh,i,j,max; TSTR_LIST ls; int savcolor=curcolor; xs=x2-x1;ys=y2-y1; p=o->userptr; ls=p->list; bar(x1,y1,x2,y2); y=y1;p->maxitems=str_count(ls); for(j=p->maxitems-1;j>=0;j--) if (ls[j]!=NULL) break; j++; if (ls) { do { i=get_to_topline(ls,p->topline,&max); p->maxview=0; y=y1; do { char *c; int x,j; c=ls[i]; if (c!=NULL && y+(znh=text_height(c))<y2) { j=p->skipshow; while (j-- && *c) c++; if (i==*(int *)(o->data)) { curcolor=p->selcolor; bar(x1,y,x2,y+znh-1); } position(x1,y); for(j=0,x=x1,savech[0]=c[j]; c[j]!='\0' && x+text_width(savech)<x2; j++,x+=text_width(savech),savech[0]=c[j] ) outtext(savech); y+=znh; p->maxview++; } else znh=0; i++; } while (y+znh<y2 && i<p->maxitems); if (p->topline && y+2*znh<y2 && znh) { int dif=y2-(y+znh); p->topline-=(dif*2/3)/znh+1; curcolor=savcolor; bar(x1,y1,x2,y2); } } while (p->topline && y+2*znh<y2 && znh); } if (waktual->id==p->obj_win) { OBJREC *ob; ob=find_object(waktual,o->id+1); if (ob!=NULL) { send_message(E_GUI,o->id+1,E_CONTROL,0,max-p->maxview,p->maxview); ob->events[3]=string_list_change; } c_set_value(p->obj_win,o->id+1,p->topline); } }