📄 eibdrv_fl.c
字号:
} free(objstring); free(helpstring); free(nullstring); return ReturnValue;}void line_count(char *s, int *LineCount, int *MaxCharCount){ char *help; int CharCount=0; (*MaxCharCount)=0; (*LineCount)=0; help=s; while(*help!='\0') { if (*help=='\n') /* Lines ending with \n */ { (*LineCount)++; if (CharCount>(*MaxCharCount)) (*MaxCharCount)=CharCount; CharCount=0; } else CharCount++; help++; } if (CharCount>0) /* Last Line not ending with \n */ { (*LineCount)++; if (CharCount>(*MaxCharCount)) (*MaxCharCount)=CharCount; }} int count_Lines(char *Text){ char *help_Text=Text; int CharCount=0; int LineCount=0; while(*help_Text!='\0') { if (*help_Text=='\n') /* Lines ending with \n */ { LineCount++; CharCount=0; } else CharCount++; help_Text++; } if (CharCount>0) /* Last Line not ending with \n */ LineCount++; return LineCount;} void get_line(char **sPtr, char *TextLine){ char *help; int CharCount=0; help=*sPtr; while((*help!='\n')&&(*help!='\0')) { CharCount++; help++; } strcpy(TextLine,""); strncat(TextLine,*sPtr,CharCount); (*sPtr)+=(CharCount+1);} int info_panel(int x, int y, int w, int InfoPanelType, char *InfoPanelTitle, char *text){ FL_FORM *InfoPanelForm; FL_OBJECT *OkBtn; FL_OBJECT *ContinueBtn; FL_OBJECT *CancelBtn; FL_OBJECT *Obj; FL_OBJECT *Box1,*Box2,*Text1; char *TextLine; char *help; int LineCount; int MaxCharCount; int Box2Y; int i; help=text; line_count(help,&LineCount,&MaxCharCount); TextLine=(char *)malloc((MaxCharCount+1)*sizeof(char)); Box2Y=60+LineCount*15; /* Starting point for the Button-Box */ InfoPanelForm=fl_bgn_form(FL_NO_BOX,w,Box2Y+70); Box1=fl_add_box(FL_UP_BOX,0,0,w,Box2Y,""); fl_set_object_color(Box1,BOX_COL1,BOX_COL2); fl_set_object_lcol(Box1,LABEL_COL); help=text; for (i=0;i<LineCount;i++) { get_line(&help,TextLine); Text1=fl_add_text(FL_NORMAL_TEXT,20,30+15*i,w-40,15,TextLine); fl_set_object_lcol(Text1,LABEL_COL); } free(TextLine); Box2=fl_add_box(FL_UP_BOX,0,Box2Y,w,70,""); fl_set_object_color(Box2,BOX_COL1,BOX_COL2); fl_set_object_lcol(Box2,LABEL_COL); switch(InfoPanelType) { case NORMAL_INFOPANEL: OkBtn=fl_add_button(FL_NORMAL_BUTTON,20,Box2Y+20,80,30,"Ok"); fl_set_object_boxtype(OkBtn,FL_UP_BOX); fl_set_object_color(OkBtn,BUTTON_COL1,BUTTON_COL2); fl_set_object_lcol(OkBtn,LABEL_COL); break; case CONTINUE_CANCEL_PANEL: ContinueBtn=fl_add_button(FL_NORMAL_BUTTON,20,Box2Y+20,80,30,"Continue"); fl_set_object_boxtype(ContinueBtn,FL_UP_BOX); fl_set_object_color(ContinueBtn,BUTTON_COL1,BUTTON_COL2); fl_set_object_lcol(ContinueBtn,LABEL_COL); CancelBtn=fl_add_button(FL_NORMAL_BUTTON,120,Box2Y+20,80,30,"Cancel"); fl_set_object_boxtype(CancelBtn,FL_UP_BOX); fl_set_object_color(CancelBtn,BUTTON_COL1,BUTTON_COL2); fl_set_object_lcol(CancelBtn,LABEL_COL); break; } fl_end_form(); fl_set_form_geometry(InfoPanelForm,x,y,w,Box2Y+70); fl_show_form(InfoPanelForm,FL_PLACE_GEOMETRY,FL_TRANSIENT,InfoPanelTitle); while(1==1) { Obj=fl_do_forms(); if (Obj==OkBtn) { fl_hide_form(InfoPanelForm); return OKBTN; } else if (Obj==ContinueBtn) { fl_hide_form(InfoPanelForm); return CONTINUEBTN; } else if (Obj==CancelBtn) { fl_hide_form(InfoPanelForm); return CANCELBTN; } }}void fl_ext_activate_button(FL_OBJECT *Button){ fl_activate_object(Button); fl_set_object_lcol(Button,LABEL_COL);}void fl_ext_activate_object(FL_OBJECT *obj){ fl_ext_activate_button(obj);}void fl_ext_deactivate_button(FL_OBJECT *Button){ fl_deactivate_object(Button); fl_set_object_lcol(Button,FL_INACTIVE_COL);}void fl_ext_deactivate_object(FL_OBJECT *obj){ fl_ext_deactivate_button(obj);}int load_DefaultParam(int (*read_Param_from_File)(char *,void *),void *Param, void (*init_Param)(void *), char *DefaultFile){ int ReturnValue; switch(ReturnValue=(*read_Param_from_File)(DefaultFile,Param)) { case -1 : { char *Text1=(char *)malloc(1000*sizeof(char)); char *Text2=(char *)malloc(1000+sizeof(char)); strcpy(Text1,"File @20@0@5 "); strcat(Text1,DefaultFile); strcat(Text1,"\n@0@0@0 cannot be opened for reading the default\n"); strcat(Text1,"parameter."); strcpy(Text2,"Press@30@0@1 Continue@77@0@0 to set all parameter\n"); strcat(Text2,"to initial values or press@112@0@1 Cancel@147@0@0 to\n"); strcat(Text2,"restore the previous values.");// if (fl_ext_panel(30,30,380,145,FL_EXT_PANEL_CONTINUE_CANCEL,// "Load Default Parameter - Error",Text1,Text2)==FL_EXT_PANEL_CONTINUEBTN) { (*init_Param)(Param); ReturnValue=-3; } free(Text1); free(Text2); } break; case -2 : { char *Text1=(char *)malloc(1000*sizeof(char)); char *Text2=(char *)malloc(1000+sizeof(char)); strcpy(Text1,"File @20@0@5 "); strcat(Text1,DefaultFile); strcat(Text1,"\n@0@0@0 is not a valid parameter file."); strcpy(Text2,"Press@30@0@1 Continue@77@0@0 to set all parameter\n"); strcat(Text2,"to initial values or press@112@0@1 Cancel@147@0@0 to\n"); strcat(Text2,"restore the previous values.");// if (fl_ext_panel(30,30,380,145,FL_EXT_PANEL_CONTINUE_CANCEL,// "Load Default Parameter - Error",Text1,Text2)==FL_EXT_PANEL_CONTINUEBTN) { (*init_Param)(Param); ReturnValue=-4; } free(Text1); free(Text2); } break; } return ReturnValue;} int save_DefaultParam(int (*write_Param_to_File)(char *,void *),void *Param, char *DefaultFile){ int ReturnValue; switch(ReturnValue=(*write_Param_to_File)(DefaultFile,Param)) { case -1 : { char *Text1=(char *)malloc(1000*sizeof(char)); char *Text2=(char *)malloc(1000+sizeof(char)); strcpy(Text1,"File @20@0@5 "); strcat(Text1,DefaultFile); strcat(Text1,"\n@0@0@0 cannot be opened for writing the default parameter."); strcpy(Text2,"Press@30@0@1 Ok@50@0@0 to dismiss this message.");// fl_ext_panel(30,30,420,110,FL_EXT_PANEL_OK,// "Save Default Parameter - Error",Text1,Text2); free(Text1); free(Text2); } break; case -2 : { char *Text1=(char *)malloc(1000*sizeof(char)); char *Text2=(char *)malloc(1000+sizeof(char)); strcpy(Text1,"An error occured when writing the default parameter\n"); strcat(Text1,"to File @33@0@5 "); strcat(Text1,DefaultFile); strcpy(Text2,"Press@30@0@1 Ok@50@0@0 to dismiss this message.");// fl_ext_panel(30,30,420,110,FL_EXT_PANEL_OK,// "Save Default Parameter - Error",Text1,Text2); free(Text1); free(Text2); } break; } return ReturnValue;} char *check_ReadString(char *String){ char *helpChar1; char *helpChar2; char *ReadString; if (strcmp(String,"_EMPTYSTRING")==0) { ReadString=(char *)malloc(2*sizeof(char)); strcpy(ReadString,""); } else { helpChar1=String; ReadString=(char *)malloc((strlen(String)+1)*sizeof(char)); helpChar2=ReadString; while (*helpChar1!='\0') { if (*helpChar1=='\\') { helpChar1++; if (*helpChar1=='_') { *helpChar2=' '; helpChar2++; } else if (*helpChar1=='\\') { *helpChar2='\\'; helpChar2++; } } else { *helpChar2=*helpChar1; helpChar2++; } helpChar1++; } *helpChar2='\0'; } return ReadString;}char *check_WriteString(char *String){ char *helpChar1; char *helpChar2; char *WriteString; if (strcmp(String,"")==0) { WriteString=(char *)malloc(13*sizeof(char)); strcpy(WriteString,"_EMPTYSTRING"); } else { helpChar1=String; WriteString=(char *)malloc((strlen(String)*2+1)*sizeof(char)); helpChar2=WriteString; while (*helpChar1!='\0') { if (*helpChar1==' ') { *helpChar2='\\'; helpChar2++; *helpChar2='_'; helpChar2++; } else if (*helpChar1=='\\') { *helpChar2='\\'; helpChar2++; *helpChar2='\\'; helpChar2++; } else { *helpChar2=(*helpChar1); helpChar2++; } helpChar1++; } *helpChar2='\0'; } return WriteString;} void fl_ext_formobjects_add_btn(FL_OBJECT **Btn,int Type,int x,int y,int width,int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Btn=obj=fl_add_button(Type,x,y,width,height,Title); fl_set_object_boxtype(obj,FL_UP_BOX); fl_set_object_color(obj,BUTTON_COL1,BUTTON_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_checkbtn(FL_OBJECT **Btn,int Type,int x,int y,int width,int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Btn=obj=fl_add_checkbutton(Type,x,y,width,height,Title); fl_set_object_boxtype(obj,FL_NO_BOX); fl_set_object_color(obj,CHECKBUTTON_COL1,CHECKBUTTON_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_lightbtn(FL_OBJECT **Btn,int Type,int x,int y,int width,int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; *Btn=obj=fl_add_lightbutton(Type,x,y,width,height,Title); fl_set_object_boxtype(obj,FL_UP_BOX); fl_set_object_color(obj,LIGHTBUTTON_COL1,LIGHTBUTTON_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_box(int Type,int x,int y,int width,int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj; 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_box2(FL_OBJECT **Box,int Type,int x,int y,int width,int height,char *Title, unsigned howresize,unsigned NWgravity,unsigned SEgravity){ FL_OBJECT *obj;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -