📄 eibdrv_fl.c
字号:
*Box=obj=fl_add_box(Type,x,y,width,height,Title); fl_set_object_color(obj,BOX_COL1,BOX_COL2); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);} void fl_ext_formobjects_add_browser(FL_OBJECT **Browser,int Type,int x,int y,int width, int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Browser=obj=fl_add_browser(Type,x,y,width,height,Title); fl_set_object_color(obj,BROWSER_COL1,BROWSER_COL2); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_choice(FL_OBJECT **Choice,int Type,int x,int y,int width,int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Choice=obj=fl_add_choice(Type,x,y,width,height,Title); fl_set_object_boxtype(obj,FL_DOWN_BOX); fl_set_object_color(obj,CHOICE_COL1,CHOICE_COL2); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_inp(FL_OBJECT **Inp,int Type,int x,int y,int width, int height,char *Title,int MaxChars,int ReturnType, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Inp=obj=fl_add_input(Type,x,y,width,height,Title);// fl_set_input_maxchars(obj,MaxChars);// fl_set_input_return(obj,ReturnType);/*#if FL_INCLUDE_VERSION == 81 switch(Type) { case FL_EXT_FORMOBJECT_UTCSU_BININPUT : fl_set_input_filter(obj,bin_input_filter); break; case FL_EXT_FORMOBJECT_UTCSU_HEXINPUT : fl_set_input_filter(obj,hex_input_filter); break; case FL_EXT_FORMOBJECT_UTCSU_DECINPUT : fl_set_input_filter(obj,dec_input_filter); break; case FL_EXT_FORMOBJECT_UTCSU_STRINGINPUT : break; case FL_EXT_FORMOBJECT_UTCSU_DIRECTORYINPUT : break; case FL_EXT_FORMOBJECT_UTCSU_FILEINPUT : break; }#endif*/ fl_set_object_color(obj,INPUT_COL1,INPUT_COL2); fl_set_input_color(obj,INPUT_COLTEXT,INPUT_COLCUR); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_text(FL_OBJECT **Text,int boxtype,int x,int y,int width, int height,char *Label, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Text=obj=fl_add_text(FL_NORMAL_TEXT,x,y,width,height,Label); fl_set_object_boxtype(obj,boxtype); if (boxtype==FL_BORDER_BOX) fl_set_object_color(obj,TEXT_COL2,TEXT_COL2); else fl_set_object_color(obj,TEXT_COL1,TEXT_COL1); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_frame(int Type,int x,int y,int width, int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; obj=fl_add_frame(Type,x,y,width,height,Title); fl_set_object_color(obj,FRAME_COL1,FRAME_COL2); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_labelframe(int Type,int x,int y,int width, int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; obj=fl_add_labelframe(Type,x,y,width,height,Title); fl_set_object_color(obj,LABELFRAME_COL1,LABELFRAME_COL2); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_bitmap(int Type,int x,int y,int width, int height,char *Title,char *BitmapFile, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; obj=fl_add_bitmap(Type,x,y,width,height,Title); fl_set_bitmap_file(obj,BitmapFile); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);}void fl_ext_formobjects_add_counter(FL_OBJECT **counter,int Type,int x,int y,int width, int height,char *Title,int lalign, double min_bound,double max_bound,double small_step,double large_step,int prec, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *counter=obj=fl_add_counter(Type,x,y,width,height,Title); fl_set_object_color(obj,COUNTER_COL1,COUNTER_COL2); fl_set_object_lcol(obj,LABEL_COL); fl_set_object_lalign(obj,lalign); fl_set_counter_precision(obj,prec); fl_set_counter_bounds(obj,min_bound,max_bound); fl_set_counter_step(obj,small_step,large_step); fl_set_object_resize(obj,howresize); fl_set_object_gravity(obj,NWgravity,SEgravity);} void expand_TextLine(char **TextLine, int CharCount);int get_Line(char **Text, char **TextLine);void *fl_ext_panel1(PanelContent *Content,void *UserData, void (*Panel_cb)(void *,int));void *fl_ext_panel2(PanelContent *Content,void *UserData, void (*Panel_cb)(void *,int));PanelType *getPanel(void){ PanelType *help=(PanelType *)fl_calloc(1,sizeof(PanelType)); return help;}void returnPanel(PanelType *Panel){ fl_free_form(Panel->Form); free(Panel);}PanelContent *getPanelContentA(int size){ int i; PanelContent *help; if (size==0) return NULL; help=(PanelContent *)malloc(size*sizeof(PanelContent)); for (i=0;i<size;i++) { (help+i)->Type=1; (help+i)->X=0; (help+i)->Y=0; (help+i)->Width=1; (help+i)->Height=1; (help+i)->Title=(char *)malloc(sizeof(char)); *((help+i)->Title)='\0'; (help+i)->Text1=(char *)malloc(sizeof(char)); *((help+i)->Text1)='\0'; (help+i)->Text2=(char *)malloc(sizeof(char)); *((help+i)->Text2)='\0'; } return help;}void returnPanelContentA(PanelContent *ContentA,int size){ int i; if (size==0) return; for (i=0;i<size;i++) { free((ContentA+i)->Title); free((ContentA+i)->Text1); free((ContentA+i)->Text2); } free(ContentA);}int write_str(FILE *file,char *str){ int i; int len=strlen(str); char *ch; if (fprintf(file," %i ",len)<0) return -1; for (i=0,ch=str;i<len;i++,ch++) if (fputc((int)(*ch),file)==EOF) return -1; return 0;}int write_PanelContentA(char *file,PanelContent *ContentA,int size){ int i; FILE *panel_file; PanelContent *help; if ((panel_file=fopen(file,"w"))==NULL) return -1; if (fprintf(panel_file,"%i",size)<0) goto fail_write; for (i=0,help=ContentA;i<size;i++,help++) { if (fprintf(panel_file," %i %i %i %i %i",help->Type,help->X,help->Y,help->Width,help->Height)<0) goto fail_write; if (write_str(panel_file,help->Title)!=0) goto fail_write; if (write_str(panel_file,help->Text1)!=0) goto fail_write; if (write_str(panel_file,help->Text2)!=0) goto fail_write; } fclose(panel_file); return 0; fail_write: fclose(panel_file); return -2;}int read_str(FILE *panel_file,char **str){ int i,len; char *help; if (fscanf(panel_file,"%i",&len)==EOF) return -1; help=(char *)malloc((len+1)*sizeof(char)); if (len>0) { fgetc(panel_file); for (i=0;i<len;i++) if ((*(help+i)=fgetc(panel_file))==EOF) { free(help); return -1; } } *(help+len)='\0'; *str=help; return 0;}int read_PanelContentA(char *file,PanelContent **ContentA){ int i,size; FILE *panel_file; PanelContent *helpA; if ((panel_file=fopen(file,"r"))==NULL) return -1; if (fscanf(panel_file,"%i",&size)==EOF) { fclose(panel_file); return -2; } helpA=(PanelContent *)malloc(size*sizeof(PanelContent)); for (i=0;i<size;i++) { if (fscanf(panel_file," %i %i %i %i %i", &((helpA+i)->Type),&((helpA+i)->X),&((helpA+i)->Y),&((helpA+i)->Width),&((helpA+i)->Height))==EOF) goto fail_read; if (read_str(panel_file,&((helpA+i)->Title))!=0) goto fail_read; if (read_str(panel_file,&((helpA+i)->Text1))!=0) goto fail_read; if (read_str(panel_file,&((helpA+i)->Text2))!=0) goto fail_read; } fclose(panel_file); *ContentA=helpA; return size; fail_read: free(helpA); fclose(panel_file); return -2;}void expand_TextLine(char **TextLine, int CharCount){ char *help_TextLine=(char *)malloc((strlen(*TextLine)+CharCount+1)*sizeof(char)); strcpy(help_TextLine,*TextLine); free(*TextLine); *TextLine=help_TextLine;}int get_Line(char **Text, char **TextLine){ int CharCount=0; char *help_Text=*Text; *TextLine=(char *)malloc(sizeof(char)); strcpy(*TextLine,""); while ((*help_Text!='\n')&&(*help_Text!='\0')) { if (*help_Text=='@') // Steueranweisung Beginn { if (CharCount>0) // vorhergehenden String ablegen { expand_TextLine(TextLine,CharCount); strncat(*TextLine,*Text,CharCount); (*Text)+=CharCount; CharCount=0; } while (*help_Text!=' ') // Steueranweisung ueberlesen { (*Text)++; help_Text++; } (*Text)++; // Steueranweisung Ende help_Text++; } else { CharCount++; // String einlesen help_Text++; } } if (CharCount>0) // gelesenen String ablegen { expand_TextLine(TextLine,CharCount); strncat(*TextLine,*Text,CharCount); } if (*help_Text=='\n') // Zeilentrenner ueberlesen (*Text)+=(CharCount+1); else // am Textende bleiben (*Text)+=CharCount; return strlen(*TextLine);}void Btn_cb(FL_OBJECT *Btn,long BtnCode){ PanelType *helpPanel=(PanelType *)Btn->form->u_vdata; if (*helpPanel->Panel_cb!=NULL) { fl_hide_form(helpPanel->Form); (*helpPanel->Panel_cb)(helpPanel->UserData,(int)BtnCode); returnPanel(helpPanel); }}void *fl_ext_panel1(PanelContent *Content,void *UserData, void (*Panel_cb)(void *,int)){ return ((PanelType *)fl_ext_ppanel1(Content,UserData,Panel_cb))->Form;}void *fl_ext_ppanel1(PanelContent *Content,void *UserData, void (*Panel_cb)(void *,int)){ PanelType *Panel; Panel=getPanel(); switch(Content->Type) { case FL_EXT_PANEL_OK: case FL_EXT_PANEL_CONTINUE_CANCEL: Panel->Form=(FL_FORM *)fl_ext_panel2(Content,UserData,Panel_cb); break; case FL_EXT_BROWSERPANEL_OK: case FL_EXT_BROWSERPANEL_CONTINUE_CANCEL: Panel->Form=(FL_FORM *)fl_ext_panel2(Content,UserData,Panel_cb); break; } Panel->Form->u_vdata=Panel; Panel->UserData=UserData; Panel->Panel_cb=Panel_cb; fl_addto_form(Panel->Form);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -