📄 eibdrv_fl.c
字号:
switch(Content->Type) { case FL_EXT_PANEL_OK : case FL_EXT_BROWSERPANEL_OK : fl_ext_formobjects_add_btn(&Panel->OkBtn,FL_NORMAL_BUTTON, Content->Width-110,Content->Height-45,90,25,"OK", FL_RESIZE_NONE,FL_SouthEast,FL_SouthEast); fl_set_object_callback(Panel->OkBtn,Btn_cb,FL_EXT_PANEL_OKBTN); break; case FL_EXT_PANEL_CONTINUE_CANCEL : case FL_EXT_BROWSERPANEL_CONTINUE_CANCEL : fl_ext_formobjects_add_btn(&Panel->ContinueBtn,FL_NORMAL_BUTTON, Content->Width-110,Content->Height-80,90,25,"Continue", FL_RESIZE_NONE,FL_SouthEast,FL_SouthEast); fl_set_object_callback(Panel->ContinueBtn,Btn_cb,FL_EXT_PANEL_CONTINUEBTN); fl_ext_formobjects_add_btn(&Panel->CancelBtn,FL_NORMAL_BUTTON, Content->Width-110,Content->Height-45,90,25,"Cancel", FL_RESIZE_NONE,FL_SouthEast,FL_SouthEast); fl_set_object_callback(Panel->CancelBtn,Btn_cb,FL_EXT_PANEL_CANCELBTN); break; } if ((Content->Type==FL_EXT_BROWSERPANEL_OK)|| (Content->Type==FL_EXT_BROWSERPANEL_CONTINUE_CANCEL)) { fl_ext_formobjects_add_browser(&Panel->Browser, FL_NORMAL_BROWSER,20,20,Content->Width-150,Content->Height-40,"", FL_RESIZE_ALL,FL_NorthWest,FL_SouthEast); fl_set_browser_fontstyle(Panel->Browser,FL_FIXED_STYLE); fl_addto_browser(Panel->Browser,Content->Text1); } fl_end_form(); if ((Content->Type==FL_EXT_BROWSERPANEL_OK)|| (Content->Type==FL_EXT_BROWSERPANEL_CONTINUE_CANCEL)) { fl_set_form_position(Panel->Form,Content->X,Content->Y); fl_show_form(Panel->Form,FL_PLACE_POSITION,FL_FULLBORDER,Content->Title); } else { fl_set_form_geometry(Panel->Form,Content->X,Content->Y,Content->Width,Content->Height); fl_show_form(Panel->Form,FL_PLACE_GEOMETRY,FL_FULLBORDER,Content->Title); } return Panel;}void *fl_ext_panel2(PanelContent *Content,void *UserData, void (*Panel_cb)(void *,int)){ FL_FORM *Form; FL_OBJECT *Text; FL_OBJECT *ArrowBox; int Offset_x=FL_EXT_PANEL_OFFSET_X; int Text_x=Offset_x; int Tab_x; int Offset_y=FL_EXT_PANEL_OFFSET_Y; int Text_y=Offset_y; int Tab_y; int Arrow_x=Offset_x; int Arrow_y; int TextWidth=Content->Width-2*FL_EXT_PANEL_BORDER_WIDTH; int LineHeight=FL_EXT_PANEL_LINEHEIGHT; int i=0; int CharCount; char *help_Text; char *help_PanelText; char *TextSegment; char *p; Form=fl_bgn_form(FL_FLAT_BOX,Content->Width,Content->Height); help_PanelText=Content->Text1; if ((Content->Type != FL_EXT_BROWSERPANEL_OK) && (Content->Type != FL_EXT_BROWSERPANEL_CONTINUE_CANCEL)) { do { i++; while (*help_PanelText!='\0') { if (*help_PanelText=='\n') { Text_x=Offset_x; Text_y+=LineHeight; help_PanelText++; } else if ((*help_PanelText=='@')&&(*(help_PanelText+1)!='@')) { sscanf(help_PanelText,"@%d@%d",&Tab_x,&Tab_y); Text_x=Offset_x+Tab_x; Text_y+=Tab_y; while (*help_PanelText!=' ') help_PanelText++; help_PanelText++; } else { CharCount=0; help_Text=help_PanelText; while ((*help_PanelText!='\n')&& (*help_PanelText!='\0') && ((*help_PanelText!='@') || ((*help_PanelText=='@')&&(*(help_PanelText+1)=='@')) || ((*help_PanelText=='@')&&(*(help_PanelText-1)=='@')) )) { CharCount++; help_PanelText++; } TextSegment=(char *)malloc((CharCount+1)*sizeof(char)); *TextSegment='\0'; strncat(TextSegment,help_Text,CharCount); while ((p=strstr(TextSegment,"@@"))!=NULL) strcpy(p+1,p+2); Text=fl_add_text(FL_NORMAL_TEXT,Text_x,Text_y,TextWidth-Text_x,LineHeight,TextSegment); fl_set_object_lcol(Text,FL_EXT_PANEL_DEFAULT_COL); free(TextSegment); } } if (i==1) { help_PanelText=Content->Text2; Offset_x+=30; Text_x=Offset_x; Text_y+=(2*LineHeight); Arrow_y=Text_y; } } while (i<2); if (*(Content->Text2)!='\0') { ArrowBox=fl_add_box(FL_NO_BOX,Arrow_x,Arrow_y,30,30,"@->"); fl_set_object_color(ArrowBox,FL_EXT_PANEL_BOX_COL1,FL_EXT_PANEL_BOX_COL2); fl_set_object_lcol(ArrowBox,FL_EXT_PANEL_ICON_COL); } } fl_end_form(); return Form;}void fl_ext_hide_panel(PanelType *Panel){ fl_hide_form(Panel->Form);}void fl_ext_free_panel(PanelType *Panel){ returnPanel(Panel);}void fl_ext_cancel_panel(PanelType *Panel){ fl_hide_form(Panel->Form); (*Panel->Panel_cb)(Panel->UserData,FL_EXT_PANEL_NULLBTN); returnPanel(Panel);}#define FL_EXT_INDICATOR_TIMEOK 0 /* 00:00 <= Zeit <= 99:59 */#define FL_EXT_INDICATOR_TIMEOVERFLOW 1 /* Zeit > 99:59 */IndicatorType *getIndicator(void);void returnIndicator(IndicatorType *helpIndicator);int calc_Time(char *TimeString,int Seconds);void fl_ext_time_indicator(IndicatorType *Indicator,int Mode);void fl_ext_start_indicator(IndicatorType *Indicator);void fl_ext_reset_indicator(IndicatorType *Indicator);void fl_ext_update_indicator(IndicatorType *Indicator, int StateNew, double PercentValueNew);IndicatorType *fl_ext_add_indicator(FL_FORM *Form,int PosX,int PosY, int Width,int Height,int FL_Gravity);void fl_ext_free_indicator(IndicatorType *Indicator);IndicatorType *getIndicator(void){ IndicatorType *help=(IndicatorType *)fl_calloc(1,sizeof(IndicatorType)); help->PercentValue=-1; help->State=FL_EXT_INDICATOR_INITIAL; return help;}void returnIndicator(IndicatorType *helpIndicator){ free (helpIndicator); /* Das das Indikatorpanel in ein vorhandenes Form */ /* eingebettet wird, werden die visuellen */ /* mit Freigabe dieses Forms freigegeben. */}int calc_Time(char *TimeString,int Seconds){ int Hours, Minutes; Minutes=Seconds/60; Seconds=Seconds%60; Hours =Minutes/60; Minutes=Minutes%60; if (Hours<100) { sprintf(TimeString,"%02i:%02i:%02i",Hours,Minutes,Seconds); return FL_EXT_INDICATOR_TIMEOK; } else return FL_EXT_INDICATOR_TIMEOVERFLOW;}void fl_ext_time_indicator(IndicatorType *Indicator,int Mode){ time_t ActualTime; int Seconds; char help_TimeText[9]; ActualTime=time(NULL); Seconds=(int)(difftime(ActualTime,Indicator->StartTime)); if (calc_Time(help_TimeText,Seconds)==FL_EXT_INDICATOR_TIMEOK) fl_set_object_label(Indicator->ActualTimeText,help_TimeText); else fl_set_object_label(Indicator->ActualTimeText,"Overflow"); if ((Mode==FL_EXT_INDICATOR_ACTUAL_AND_ESTIMATED_TIME)&&(Indicator->PercentValue>0)) { if (calc_Time(help_TimeText,(int)(Seconds*(100.0/Indicator->PercentValue)))==FL_EXT_INDICATOR_TIMEOK) fl_set_object_label(Indicator->EstimatedTimeText,help_TimeText); else fl_set_object_label(Indicator->EstimatedTimeText,"Overflow"); }}void fl_ext_start_indicator(IndicatorType *Indicator){ Indicator->StartTime=time(NULL);}void fl_ext_reset_indicator(IndicatorType *Indicator){ fl_set_object_label(Indicator->StateText,""); Indicator->State=FL_EXT_INDICATOR_INITIAL; Indicator->InnerBox->w=200; fl_redraw_object(Indicator->InnerBox); fl_set_object_color(Indicator->InnerBox,BOX_COL1,BOX_COL2); Indicator->InnerBox->w=0; fl_redraw_object(Indicator->InnerBox); fl_set_object_label(Indicator->PercentValueText,"0 %"); Indicator->PercentValue=-1.0; fl_set_object_label(Indicator->ActualTimeText,"00:00:00"); fl_set_object_label(Indicator->EstimatedTimeText,"00:00:00");}void fl_ext_update_indicator(IndicatorType *Indicator,int StateNew, double PercentValueNew){ char help_PercentValue[20]; if (PercentValueNew>100.0) PercentValueNew=100.0; else if (PercentValueNew<0.0) PercentValueNew=Indicator->PercentValue; fl_freeze_form(Indicator->Form); sprintf(&(help_PercentValue[0]),"%i %%",(int)PercentValueNew); if ((PercentValueNew!=Indicator->PercentValue)&& // Fortschritt (PercentValueNew>0.0)) { Indicator->InnerBox->w=(int)PercentValueNew*2; // Balken verlaengern fl_redraw_object(Indicator->InnerBox); // und neu zeichnen fl_set_object_label(Indicator->PercentValueText,help_PercentValue); Indicator->PercentValue=PercentValueNew; } if (StateNew!=Indicator->State) // Neuer State { switch (StateNew) { case FL_EXT_INDICATOR_STOPPED : fl_set_object_label(Indicator->StateText,"STOPPED"); fl_set_object_color(Indicator->InnerBox,INDICATOR_STOPPED_COL,0); break; case FL_EXT_INDICATOR_RUNNING : fl_set_object_label(Indicator->StateText,"RUNNING"); fl_set_object_color(Indicator->InnerBox,INDICATOR_RUNNING_COL,0); break; case FL_EXT_INDICATOR_FINISHED : fl_set_object_label(Indicator->StateText,"FINISHED"); fl_set_object_color(Indicator->InnerBox,INDICATOR_FINISHED_COL,0); break; } Indicator->State=StateNew; } fl_ext_time_indicator(Indicator,FL_EXT_INDICATOR_ACTUAL_AND_ESTIMATED_TIME); fl_unfreeze_form(Indicator->Form);}IndicatorType *fl_ext_add_indicator(FL_FORM *Form,int PosX,int PosY, int Width,int Height,int FL_Gravity){ int OffsetX=0; int OffsetY=0; FL_OBJECT *obj; IndicatorType *Indicator=getIndicator(); if (Width<FL_EXT_INDICATOR_MINWIDTH) Width=FL_EXT_INDICATOR_MINWIDTH; else OffsetX=(int)((Width-FL_EXT_INDICATOR_MINWIDTH)/2); if (Height<FL_EXT_INDICATOR_MINHEIGHT) Height=FL_EXT_INDICATOR_MINHEIGHT; else OffsetY=(int)((Height-FL_EXT_INDICATOR_MINHEIGHT)/2); Indicator->Form=Form; fl_addto_form(Indicator->Form); fl_ext_formobjects_add_frame(FL_ENGRAVED_FRAME,PosX,PosY, Width,Height,"",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+33,PosY+OffsetY+20,50,20,"Status:",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_ext_formobjects_add_text(&(Indicator->PercentValueText),FL_DOWN_BOX, PosX+OffsetX+100,PosY+OffsetY+20,50,20,"0 %",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(Indicator->PercentValueText,FL_ALIGN_CENTER); fl_set_object_bw(Indicator->PercentValueText,1); fl_ext_formobjects_add_text(&(Indicator->StateText),FL_DOWN_BOX, PosX+OffsetX+160,PosY+OffsetY+20,82,20,"",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(Indicator->StateText,FL_ALIGN_CENTER); fl_set_object_bw(Indicator->StateText,1); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+100,PosY+OffsetY+45,50,20,"Estimated",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(obj,FL_ALIGN_CENTER); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+192,PosY+OffsetY+45,50,20,"Actual",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(obj,FL_ALIGN_CENTER); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+33,PosY+OffsetY+65,100,20,"Total Time:",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_ext_formobjects_add_text(&(Indicator->EstimatedTimeText),FL_DOWN_BOX, PosX+OffsetX+100,PosY+OffsetY+65,50,20,"00:00:00",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(Indicator->EstimatedTimeText,FL_ALIGN_CENTER); fl_set_object_bw(Indicator->EstimatedTimeText,1); fl_ext_formobjects_add_text(&(Indicator->ActualTimeText),FL_DOWN_BOX, PosX+OffsetX+192,PosY+OffsetY+65,50,20,"00:00:00",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(Indicator->ActualTimeText,FL_ALIGN_CENTER); fl_set_object_bw(Indicator->ActualTimeText,1); fl_ext_formobjects_add_box2(&(Indicator->OuterBox),FL_DOWN_BOX, PosX+OffsetX+38,PosY+OffsetY+100,204,20,"",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_ext_formobjects_add_box2(&(Indicator->InnerBox),FL_FLAT_BOX, PosX+OffsetX+40,PosY+OffsetY+102,0,16,"",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+20,PosY+OffsetY+125,40,12,"0 %",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(obj,FL_ALIGN_CENTER); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+120,PosY+OffsetY+125,40,12,"50 %",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(obj,FL_ALIGN_CENTER); fl_ext_formobjects_add_text(&obj,FL_NO_BOX, PosX+OffsetX+220,PosY+OffsetY+125,40,12,"100 %",FL_RESIZE_NONE,FL_Gravity,FL_Gravity); fl_set_object_lalign(obj,FL_ALIGN_CENTER); fl_end_form(); fl_ext_reset_indicator(Indicator); return Indicator;}void fl_ext_free_indicator(IndicatorType *Indicator){ returnIndicator(Indicator);}#include <sys/ipc.h>#include <sys/sem.h>void pv(int id, int operation){ static struct sembuf semaphor; semaphor.sem_num=0; semaphor.sem_op=operation; semaphor.sem_flg=SEM_UNDO; if (semop(id,&semaphor,1)==-1) { printf("IPC-Error: PV-Operation failed on semaphor!\n"); exit(-1); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -