#include "alg.h" #include "mylib.h" #include "control.h" #include "alg_cfg.h" #include "demohelp.h" db_str_rec Compt[] = { {"SHIFR",'C',0,3,0}, {"TC",'N',0,2,0}, {"NFA",'C',0,11,0}, {"NFD",'C',0,11,0}, {"PER",'C',0,5,0}, // {"SPEED",'N',0,4,0}, {"PORT",'C',0,2,0}, {"ADRES",'C',0,3,0}, {"LINE",'C',0,2,0}, {"LA",'C',0,4,0}, {"LD",'C',0,4,0}, }; db_str_rec Pasp[] = { {"SHIFR",'C',0,9,0} }; TControlDialog::TControlDialog( ) : TDialog( TRect( 0, 0, 60, 15 ),""), TWindowInit( TControlDialog::initFrame ) { char str[256],*str1,NmbElem; int i,ii,iii,j,j1; strelem *TmpElem; db_str_rec *Db_ptr_rec; mode=0; //Описатель контроллеров x_max=40;x_min=8;y_max=3;y_min=2;loadOk=False; getcwd(PathDir,sizeof(PathDir)); sprintf(str,Text_msg[43],PathDir); title=newStr(str); options |= ofCentered; helpCtx=hcAllASave; TView *Monosel = new TView(TRect(8,2,43,15)); Monosel->options |= ofFramed; insert(Monosel); if(myApp->LoadTipContr(PathDir,&ContrTip,&ContrTipAm) == -1) {message(this,evBroadcast,cmClose,this); return;} loadOk=True; CreateTipContr(this); Monosel->setBounds(TRect(x_min,y_min,x_max,y_max)); setBounds(TRect(0,0,x_max+2,max(y_max+3,10)+1)); //drawView(); frame->setBounds(TRect(0,0,x_max+2,max(y_max+3,10)+1)); myApp->LoadCnt(NameDescrCnt,&ContDBF); LabelAn = new TMyLabel(TRect(1, 2, 4, 3),"",NULL,0); insert(LabelAn); LabelDg = new TMyLabel(TRect(1, 2, 4, 3),"",NULL,0); insert(LabelDg); TButton *Button = new TButton( TRect( 9,y_max+1, 19, y_max+3),Text_msg[115], cmOK, bfDefault ); insert(Button); Button = new TButton( TRect( 22,y_max+1, 32, y_max+3),Text_msg[114], cmCancel, bfNormal ); insert(Button); ContrColect1 = new TCompCollect(10,10); ContrColect2 = new TCompCollect(10,10); for(i=0;iinsert(ContrTip[i]->Name); ScrollBar1 = new TScrollBar( TRect( 6, 2, 7, 10) ); insert(ScrollBar1); MyTListBox1 = new TMyTListBox(TRect( 2, 2, 6, 10), 1, ScrollBar1,NULL); insert(MyTListBox1); MyTListBox1->helpCtx=hcMax; TMyLabel *Label = new TMyLabel(TRect(2, 1, 7, 2),"Contr.",MyTListBox1,1); insert(Label); Edit1 = new TEdit( TRect( 30, 2, 40, 3 ),11,NoEdit); insert(Edit1); Label = new TMyLabel(TRect(8, 2, 24, 3), "Tip controler:",Edit1,0); insert(Label); ComboBox1 = new TComboBox(TRect( 40, 2, 41, 3 ), Edit1,ContrColect2,SelCombo); insert(ComboBox1); for(i=0;iGetCountItems();i++) { str1 = new char[4]; ContDBF->GetFieldIt(i,"SHIFR",str1); ContrColect1->insert(str1); } MyTListBox1->newList(ContrColect1); OldIndChek=0;OldTip= -1; //Проверка DBF на отсутствующие и лишние поля с удалением или созданием их в последствии //Создание отсутствующих полей for(iii=0;iiiNumbElem; TmpElem=ContrTip[iii]->Elem; for(i=0;igetField(TmpElem[i].Edit1.NameField); if(Db_ptr_rec== NULL) { Db_ptr_rec = (db_str_rec *)calloc(sizeof(db_str_rec),1); strcpy(Db_ptr_rec->name,TmpElem[i].Edit1.NameField); Db_ptr_rec->tip_fild='C'; Db_ptr_rec->len_fild=TmpElem[i].Edit1.lenEntr; for(j=0;jNumbElem;j1++) if(!strcmp(ContrTip[j]->Elem[j1].Edit1.NameField,TmpElem[i].Edit1.NameField)) { if(ContrTip[j]->Elem[j1].tipElem==0) Db_ptr_rec->len_fild=max(Db_ptr_rec->len_fild,ContrTip[j]->Elem[j1].Edit1.lenEntr); if(ContrTip[j]->Elem[j1].tipElem==1) Db_ptr_rec->len_fild=max(Db_ptr_rec->len_fild,2); } ContDBF->addField(1000,Db_ptr_rec); } } if(TmpElem[i].tipElem==1) { Db_ptr_rec=ContDBF->getField(TmpElem[i].Combo1.NameField); if(Db_ptr_rec== NULL) { Db_ptr_rec = (db_str_rec *)calloc(sizeof(db_str_rec),1); strcpy(Db_ptr_rec->name,TmpElem[i].Combo1.NameField); Db_ptr_rec->tip_fild='N'; Db_ptr_rec->len_fild=2; for(j=0;jNumbElem;j1++) if(!strcmp(ContrTip[j]->Elem[j1].Edit1.NameField,TmpElem[i].Edit1.NameField)) { if(ContrTip[j]->Elem[j1].tipElem==0) Db_ptr_rec->len_fild=max(Db_ptr_rec->len_fild,ContrTip[j]->Elem[j1].Edit1.lenEntr); if(ContrTip[j]->Elem[j1].tipElem==1) Db_ptr_rec->len_fild=max(Db_ptr_rec->len_fild,2); } ContDBF->addField(1000,Db_ptr_rec); } } } } //Поиск и удаление неиспользуемых полей for(i=0;(Db_ptr_rec=ContDBF->getField(i))!=NULL;i++) { for(iii=0;iiiNumbElem; TmpElem=ContrTip[iii]->Elem; for(ii=0;iiname)) break; if(TmpElem[ii].tipElem==1) if(!strcmp(TmpElem[ii].Combo1.NameField,Db_ptr_rec->name)) break; for(j=0;jname)) break; if(j!=sizeof(Compt)/sizeof(db_str_rec)) break; } if(ii!=NmbElem) break; } if(ii==NmbElem) { ContDBF->DelField(i); i--;} } ViewElem(OldIndChek,1); Modif=Modifs=False; MyTListBox1->select(); } TControlDialog::~TControlDialog() { if(!loadOk) return; myApp->FreeTipContr(ContrTip,ContrTipAm); delete ContDBF; delete ContrColect2; myApp->FreeColect(ContrColect1); } void TControlDialog::handleEvent ( TEvent& event ) { char str[256],*str1,*str2; int i,iii,k1; ushort control; TView *ViewTemp; if( event.what == evCommand && event.message.command == cmClose) { if(Modif || Modifs) { control = messageBox(Text_msg[26],mfWarning | mfOKCancel); if(control==cmOK) { if(Modif) { sprintf(str,"%d",ComboBox1->posit); ContDBF->ModifiFieldIt(MyTListBox1->focused,"TC",str); SaveChengeCntr(MyTListBox1->focused); } sprintf(str,Text_msg[109],PathDir,NameDescrCnt); ContDBF->SaveFile(str); } } } TDialog::handleEvent(event); #ifdef __DOS32__ if( event.what == evBroadcast && event.message.command == cmGetBuf) Modif=True; #endif if( event.what == evBroadcast && event.message.command == cmScrollBarChanged) //List ListBox { if(MyTListBox1->state & sfFocused) // ListBox1 { if(Modif) { control = messageBox(mfWarning | mfOKCancel,"Контроллер изменен. Сохранить изменения?"); if(control==cmOK) { sprintf(str,"%d",ComboBox1->posit); ContDBF->ModifiFieldIt(OldIndChek,"TC",str); SaveChengeCntr(OldIndChek); Modifs=True; } Modif=False; } #ifdef __DOS32__ if(getShiftState() & (kbLeftShift|kbRightShift)) { str1=(char *)ContDBF->getItem(OldIndChek); str2=(char *)ContDBF->getItem(MyTListBox1->focused); ContDBF->DeleteItems(OldIndChek,0); ContDBF->AddItem(OldIndChek,str2); ContDBF->DeleteItems(MyTListBox1->focused,0); ContDBF->AddItem(MyTListBox1->focused,str1); ContrColect1->freeAll(); for(i=0;iGetCountItems();i++) { str1 = new char[4]; ContDBF->GetFieldIt(i,"SHIFR",str1); ContrColect1->insert(str1); } MyTListBox1->drawView(); Modifs=True; } #endif ViewElem(MyTListBox1->focused,1); clearEvent(event); OldIndChek=MyTListBox1->focused; MyTListBox1->select(); } } if( event.what == evCommand ) switch( event.message.command ) { case cmRes1: sprintf(str,Text_msg[44],PathDir); if(!myApp->ChekWin(str)) {ViewTemp = new TPasportDialog(PathDir,1,MyTListBox1->focused); myApp->deskTop->insert( ViewTemp );} break; case cmRes2: sprintf(str,Text_msg[45],PathDir); if(!myApp->ChekWin(str)) {ViewTemp = new TPasportDialog(PathDir,2,MyTListBox1->focused); myApp->deskTop->insert( ViewTemp );} break; case cmOK: ViewTemp=current; sprintf(str,"%d",ComboBox1->posit); ContDBF->ModifiFieldIt(MyTListBox1->focused,"TC",str); SaveChengeCntr(MyTListBox1->focused); Modifs=True; Modif=False; ViewElem(MyTListBox1->focused,0); ViewTemp->select(); clearEvent(event); break; case cmCancel: ViewElem(MyTListBox1->focused,0); Modif=False; clearEvent(event); break; case cmSave1: control = messageBox(mfWarning | mfOKCancel,Text_msg[37]); if(control!=cmOK) break; sprintf(str,"%d",ComboBox1->posit); ContDBF->ModifiFieldIt(MyTListBox1->focused,"TC",str); SaveChengeCntr(MyTListBox1->focused); sprintf(str,Text_msg[109],PathDir,NameDescrCnt); ContDBF->SaveFile(str); Modif=Modifs=False; break; case cmReLoad: control = messageBox(mfWarning | mfOKCancel,Text_msg[38]); if(control!=cmOK) break; sprintf(str,Text_msg[109],PathDir,NameDescrCnt); myApp->LoadCnt(str,&ContDBF); ContrColect1->freeAll(); for(i=0;iGetCountItems();i++) { str1 = new char[4]; ContDBF->GetFieldIt(i,"SHIFR",str1); ContrColect1->insert(str1); } MyTListBox1->setRange( MyTListBox1->list()->getCount()); MyTListBox1->drawView(); MyTListBox1->focusItem(OldIndChek=0); ViewElem(OldIndChek,0); Modif=Modifs=False; break; case cmInsert: case cmAdd: case cmRename: str1 = new char[4]; str1[0]=0; if(event.message.command==cmRename) ContDBF->GetFieldIt(MyTListBox1->focused,"SHIFR",str1); control = inputBox("Ввод имени контроллера", "Желательно цифры",str1, 4); if(control==cmOK) { for(i=0;iGetCountItems();i++) { ContDBF->GetFieldIt(i,"SHIFR",str); for(iii=2;iii>=0;iii--)if(str[iii]==' ')str[iii]=0;else break; if(!strncmp(str1,str,3)){ i= -1; break;} } if(i== -1){ DispFixErr(0,Text_msg[15],str1); delete str1; break;} if(event.message.command==cmInsert || event.message.command==cmRename) k1 = MyTListBox1->focused; if(event.message.command==cmAdd) k1 = ContDBF->GetCountItems(); if(event.message.command==cmRename) MyTListBox1->list()->atFree(k1); else {ContDBF->CreateItems(k1); setNULL(k1);} ContDBF->ModifiFieldIt(k1,"SHIFR",str1); MyTListBox1->list()->atInsert(k1,str1); MyTListBox1->setRange( MyTListBox1->list()->getCount() ); MyTListBox1->drawView(); ViewElem(MyTListBox1->focused,1); Modifs=True; } else delete str1; clearEvent(event); break; case cmDelete: if(!MyTListBox1->list()->getCount()) break; control = messageBox(mfWarning | mfOKCancel,Text_msg[29],(char *)MyTListBox1->list()->at(MyTListBox1->focused)); if(control==cmOK) { ContDBF->DeleteItems(MyTListBox1->focused,1); MyTListBox1->list()->atFree(MyTListBox1->focused); MyTListBox1->setRange( MyTListBox1->list()->getCount() ); MyTListBox1->drawView(); ViewElem(MyTListBox1->focused,1); MyTListBox1->select(); Modifs=True; } clearEvent(event); break; default: ; } } int TControler::EnterNumb(void* source,TEvent& event) { byte code, *str1; char str[15]; int numb,i,ii,isch; float numb1; TEdit *Edit = (TEdit *)source; TControlDialog *Dialog = (TControlDialog *)Edit->owner; TDialog *Dialg = (TDialog *)Edit->owner; strelem *TmpElem; char NmbElem; if(Dialog->mode==0) {NmbElem=Dialog->ContrTip[Dialog->tip]->NumbElem; TmpElem=Dialog->ContrTip[Dialog->tip]->Elem;} if(Dialog->mode==1) {NmbElem=Dialog->ContrTip[Dialog->tip]->NumbElemAn;TmpElem=Dialog->ContrTip[Dialog->tip]->ElemAn;} if(Dialog->mode==2) {NmbElem=Dialog->ContrTip[Dialog->tip]->NumbElemDig;TmpElem=Dialog->ContrTip[Dialog->tip]->ElemDig;} // if(TmpElem[i].tipElem==1||TmpElem[i].tipElem==2) return(1); for(i=0;idata); if(chkbound(TmpElem[i].Edit1.znach,numb1)<0) numb1=TmpElem[i].Edit1.def; sprintf(str,"%f",numb1); Edit->setData(str); } else { str1=(byte *)TmpElem[i].Edit1.EntMsk; isch=10; for(ii=0;ii='A'&&str1[ii]<='F')||(str1[ii]>='a'&&str1[ii]<='f')){isch=16; break;} numb= strtol(Edit->data,NULL,isch); if(chkbound(TmpElem[i].Edit1.znach,(float)numb)<0) numb=(int)TmpElem[i].Edit1.def; if(isch==16) sprintf(str,"%x",numb); else sprintf(str,"%d",numb); Edit->setData(str); } Dialg->selectNext(False); break; case kbDown: Dialg->selectNext(False); Edit->clearEvent(event); break; case kbUp: Dialg->selectNext(True); Edit->clearEvent(event); break; } code=event.keyDown.charScan.charCode; if((TmpElem[i].Edit1.option&o_edit)==1) return(1); if((TmpElem[i].Edit1.option&o_edit)==3) return(0); if((TmpElem[i].Edit1.option&o_edit)==2) { if(code<' ') return(0); str1=(byte *)TmpElem[i].Edit1.EntMsk; if(!str1) return(0); if((TmpElem[i].Edit1.option&o_float) && (code == '.' || code == '-')) return(0); for(ii=0;ii=str1[ii]&& code<=str1[ii+2]) return(0); ii+=2; continue; } if(code==str1[ii]) return(0); } // if((str1[0]>='0' && str1[0]<='9') || (str1[0]>='A' && str1[0]<='F')) // if( code>=str1[0] && code<=str1[2]) return(0); // if((str1[3]>='0' && str1[3]<='9') || (str1[3]>='A' && str1[3]<='F')) // if( code>=str1[3] && code<=str1[5]) return(0); Edit->clearEvent(event); } } return(0); } int TControler::SelCombEl(void* source,TEvent& event) { TView *temp; TComboBox *ComboBox = (TComboBox *)source; TControlDialog *Dialog = (TControlDialog *)ComboBox->owner; temp=Dialog->current; Dialog->ViewEl(-1); temp->select(); // ComboBox->select(); return(0); } int TControlDialog::SelCombo(void* source,TEvent& event) { int i,ii; char str[20]; TComboBox *ComboBox = (TComboBox *)source; TControlDialog *Dialog = (TControlDialog *)ComboBox->owner; i=ComboBox->posit; for(ii=0;iiContrTip[i]->NumbElem;ii++) { if(Dialog->ContrTip[i]->Elem[ii].tipElem==0 && Dialog->ContrTip[i]->Elem[ii].Edit1.option&o_anal) { sprintf(str,"%s%s.dbf",Dialog->ContrTip[i]->NameAn,(char *)Dialog->ContrColect1->at(Dialog->MyTListBox1->focused)); Dialog->ContDBF->ModifiFieldIt(Dialog->MyTListBox1->focused,Dialog->ContrTip[i]->Elem[ii].Edit1.NameField,str); } if(Dialog->ContrTip[i]->Elem[ii].tipElem==0 && Dialog->ContrTip[i]->Elem[ii].Edit1.option&o_dig) { sprintf(str,"%s%s.dbf",Dialog->ContrTip[i]->NameDig,(char *)Dialog->ContrColect1->at(Dialog->MyTListBox1->focused)); Dialog->ContDBF->ModifiFieldIt(Dialog->MyTListBox1->focused,Dialog->ContrTip[i]->Elem[ii].Edit1.NameField,str); } } Dialog->ViewElem(Dialog->MyTListBox1->focused,0); Dialog->Modif=True; Dialog->Edit1->select(); return(0); } //--------------------------------------------------------------------------------------- void TControlDialog::ViewElem(int item,char opt) { char str1[30]; if(opt) { ContDBF->GetFieldIt(item,"TC",str1); ComboBox1->posit=atoi(str1); if(ComboBox1->posit>=ContrTipAm) ComboBox1->posit=0; Edit1->setData(ContrTip[ComboBox1->posit]->Name); } tip=ComboBox1->posit; ViewEl(item); } //---------------------------------------------------------------------------------------- void TControler::SaveChengeCntr(int item) { int i; char str1[30]; strelem *TmpElem; char NmbElem; TBasaDBF *TempDBF; if(mode==0){TempDBF=ContDBF; NmbElem=ContrTip[tip]->NumbElem;TmpElem=ContrTip[tip]->Elem;} if(mode==1){TempDBF=PspDBF; NmbElem=ContrTip[tip]->NumbElemAn;TmpElem=ContrTip[tip]->ElemAn;} if(mode==2){TempDBF=PspDBF; NmbElem=ContrTip[tip]->NumbElemDig;TmpElem=ContrTip[tip]->ElemDig;} for(i=0;igetState( sfVisible )) continue; TempDBF->ModifiFieldIt(item,TmpElem[i].Edit1.NameField,TmpElem[i].Edit1.Editptr->data); } if(TmpElem[i].tipElem==1) { if(!TmpElem[i].Combo1.Comboptr->getState( sfVisible )) continue; // sprintf(str1,"%d",TmpElem[i].Combo1.Comboptr->posit); sprintf(str1,"%d",((str20 *)(TmpElem[i].Combo1.Comboptr->list()->at(TmpElem[i].Combo1.Comboptr->posit)))->index); TempDBF->ModifiFieldIt(item,TmpElem[i].Combo1.NameField,str1); } } } //======================================================================================= int TMyApp::LoadTipContr(char *PathDir,tip_contr ***Contr,int *ContrTipAm) { char str[256],*str1; int i,ii,len,ind,cntr,elem,tip,strel,fh,el; strelem *TempEl; sprintf(str,Text_msg[109],PathDir,NameCntTip); if((fh=open(str,O_BIN|O_RDONLY))<=0) { DispFixErr(1,Text_msg[12],NameCntTip); return(-1);} len=filelength_(fh); str1=(char *)calloc(len+2,1); ::read(fh,str1,len); ::close(fh); for(*ContrTipAm=0,i=0;iName,str1+i,ii); if(ind==1)strncpy((*Contr)[cntr]->NameAn,str1+i,ii); if(ind==2)strncpy((*Contr)[cntr]->NameDig,str1+i,ii); i+=(ii+1); ind++; continue; } if(*(word_s *)&(str1[i+ii])=='//'){ for(;((i+ii)NumbElem++; elem=(*Contr)[cntr]->NumbElem-1; TempEl=(*Contr)[cntr]->Elem;} if(!strncmp(str1+i,"ELEMA:",6)){ el=2; (*Contr)[cntr]->NumbElemAn++; elem=(*Contr)[cntr]->NumbElemAn-1; TempEl=(*Contr)[cntr]->ElemAn;} if(!strncmp(str1+i,"ELEMD:",6)){ el=3; (*Contr)[cntr]->NumbElemDig++;elem=(*Contr)[cntr]->NumbElemDig-1;TempEl=(*Contr)[cntr]->ElemDig;} if(el) { i+=6; ind=0; strel= 0; if(!TempEl) TempEl=(strelem *)calloc(elem+1,sizeof(strelem)); else TempEl=(strelem *)realloc(TempEl,(elem+1)*sizeof(strelem)); TempEl[elem].n_el_comb=-1; memset(TempEl+elem,0,sizeof(strelem)); for(;;) { for(ii=0;(i+ii)=7&&tip==1) { if(!TempEl[elem].Combo1.StrElem) TempEl[elem].Combo1.StrElem=(str20 *)calloc(strel+1,sizeof(str20)); else TempEl[elem].Combo1.StrElem=(str20 *)realloc(TempEl[elem].Combo1.StrElem,(strel+1)*sizeof(str20)); memset(TempEl[elem].Combo1.StrElem+strel,0,sizeof(str20)); strncpy((char *)(TempEl[elem].Combo1.StrElem[strel].name),str1+i,ii); TempEl[elem].Combo1.StrElem[strel].index=TempEl[elem].Combo1.NumbElem; TempEl[elem].Combo1.NumbElem++; strel++; } if(ind==8&&tip==0) {TempEl[elem].Edit1.EntMsk=(char *)calloc(ii+1,1); strncpy(TempEl[elem].Edit1.EntMsk,str1+i,ii); } if(ind==9&&tip==0) { TempEl[elem].Edit1.znach=(char *)calloc(ii+1,1); strncpy(TempEl[elem].Edit1.znach,str1+i,ii); } if(ind==10&&tip==0) { strncpy(str,str1+i,ii); TempEl[elem].Edit1.def=atof(str); } i+=(ii+1); ind++; continue; } if(*(word_s *)&(str1[i+ii])=='//') { i+=ii; for(;iElem=TempEl; if(el==2) (*Contr)[cntr]->ElemAn=TempEl; if(el==3) (*Contr)[cntr]->ElemDig=TempEl; break; } if(str1[i+ii]==0x0D) // if(str1[i+ii]=='\n') { if(el==1) (*Contr)[cntr]->Elem=TempEl; if(el==2) (*Contr)[cntr]->ElemAn=TempEl; if(el==3) (*Contr)[cntr]->ElemDig=TempEl; i+=(ii+1); break; } } } } if(*(word_s *)&(str1[i])=='//') for(;(iNumbElem; if(mode==1) NmbElem=ContrTip[ii]->NumbElemAn; if(mode==2) NmbElem=ContrTip[ii]->NumbElemDig; for(i=0;iElem[i]; if(mode==1) TmpElem=&ContrTip[ii]->ElemAn[i]; if(mode==2) TmpElem=&ContrTip[ii]->ElemDig[i]; if(TmpElem->tipElem==0) { ax=TmpElem->ax_n; ay=TmpElem->ay_n; bx=ax+TmpElem->Edit1.lenEntr; by=ay+1; fptr=NULL; if((TmpElem->Edit1.option&o_edit)==1 || (TmpElem->Edit1.option&o_edit)==2 || (TmpElem->Edit1.option&o_edit)==3) fptr=EnterNumb; TmpElem->Edit1.Editptr = new TEdit( TRect( ax, ay, bx, by ),TmpElem->Edit1.lenEntr+1,fptr); group->insert(TmpElem->Edit1.Editptr); if(!mode) x_max=max(x_max,bx+4);else x_max=max(x_max,bx); x_min=min(x_min,ax); y_max=max(y_max,by); y_min=min(y_min,ay); if(TmpElem->Edit1.option&o_anal) TmpElem->Edit1.Editptr->helpCtx=hcAnCtr; if(TmpElem->Edit1.option&o_dig) TmpElem->Edit1.Editptr->helpCtx=hcDigCtr; TmpElem->Edit1.Editptr->setState(sfVisible,False); } if(TmpElem->tipElem==1) { ax=TmpElem->ax_n; ay=TmpElem->ay_n; bx=ax+TmpElem->Combo1.lenEntr; by=ay+1; fptr=NoEdit; TmpElem->Combo1.Editptr = new TEdit( TRect( ax, ay, bx, by ),TmpElem->Combo1.lenEntr+1,fptr); group->insert(TmpElem->Combo1.Editptr); TmpElem->Combo1.Editptr->setState(sfVisible,False); x_max=max(x_max,bx+1); x_min=min(x_min,ax); y_max=max(y_max,by); y_min=min(y_min,ay); TCompCollect *Colect = new TCompCollect(10,10); for(iii=0;iiiCombo1.NumbElem;iii++) //Colect->insert(TmpElem->Combo1.StrElem[iii].name); if(TmpElem->Combo1.StrElem[iii].name[0]!=' '&& TmpElem->Combo1.StrElem[iii].name[0]!=0) Colect->insert((char *)(TmpElem->Combo1.StrElem+iii)); TmpElem->Combo1.Comboptr = new TComboBox(TRect(bx,ay,bx+1,by),TmpElem->Combo1.Editptr,Colect,SelCombEl); group->insert(TmpElem->Combo1.Comboptr);TmpElem->Combo1.Comboptr->setState(sfVisible,False); x_max=max(x_max,bx); x_min=min(x_min,ax); y_max=max(y_max,by); y_min=min(y_min,ay); } } } for(ii=0;iiNumbElem; if(mode==1) NmbElem=ContrTip[ii]->NumbElemAn; if(mode==2) NmbElem=ContrTip[ii]->NumbElemDig; for(i=0;iElem; if(mode==1) TmpElem=ContrTip[ii]->ElemAn; if(mode==2) TmpElem=ContrTip[ii]->ElemDig; if(TmpElem[i].tipElem==2) { ax=TmpElem[i].ax_n; ay=TmpElem[i].ay_n; bx=ax+strlen(TmpElem[i].Label1.NameEl); by=ay+1; ViewTemp=NULL; if(TmpElem[i].Label1.activ>=0&&TmpElem[i].Label1.activinsert(TmpElem[i].Label1.Labelptr); x_max=max(x_max,bx); x_min=min(x_min,ax); y_max=max(y_max,by); y_min=min(y_min,ay); TmpElem[i].Label1.Labelptr->setState(sfVisible,False); } } } } //---------------------------------------------------------------------------------------- void TMyApp::FreeTipContr(tip_contr **Contr,int ContrTipAm) { int i,ii; for(i=0;iNumbElem;ii++) { if(Contr[i]->Elem[ii].tipElem==1) if(Contr[i]->Elem[ii].Combo1.NumbElem) free(Contr[i]->Elem[ii].Combo1.StrElem); if(Contr[i]->Elem[ii].tipElem==0) if(Contr[i]->Elem[ii].Edit1.EntMsk) free(Contr[i]->Elem[ii].Edit1.EntMsk); if(Contr[i]->Elem[ii].tipElem==0) if(Contr[i]->Elem[ii].Edit1.znach) free(Contr[i]->Elem[ii].Edit1.znach); if(Contr[i]->Elem[ii].tipElem==2) if(Contr[i]->Elem[ii].Label1.NameEl) free(Contr[i]->Elem[ii].Label1.NameEl); } if(Contr[i]->NumbElem)free(Contr[i]->Elem); for(ii=0;iiNumbElemAn;ii++) { if(Contr[i]->ElemAn[ii].tipElem==1) if(Contr[i]->ElemAn[ii].Combo1.NumbElem) free(Contr[i]->ElemAn[ii].Combo1.StrElem); if(Contr[i]->ElemAn[ii].tipElem==0) if(Contr[i]->ElemAn[ii].Edit1.EntMsk) free(Contr[i]->ElemAn[ii].Edit1.EntMsk); if(Contr[i]->ElemAn[ii].tipElem==0) if(Contr[i]->ElemAn[ii].Edit1.znach) free(Contr[i]->ElemAn[ii].Edit1.znach); if(Contr[i]->ElemAn[ii].tipElem==2) if(Contr[i]->ElemAn[ii].Label1.NameEl) free(Contr[i]->ElemAn[ii].Label1.NameEl); } if(Contr[i]->NumbElemAn)free(Contr[i]->ElemAn); for(ii=0;iiNumbElemDig;ii++) { if(Contr[i]->ElemDig[ii].tipElem==1) if(Contr[i]->ElemDig[ii].Combo1.NumbElem) free(Contr[i]->ElemDig[ii].Combo1.StrElem); if(Contr[i]->ElemDig[ii].tipElem==0) if(Contr[i]->ElemDig[ii].Edit1.EntMsk) free(Contr[i]->ElemDig[ii].Edit1.EntMsk); if(Contr[i]->ElemDig[ii].tipElem==0) if(Contr[i]->ElemDig[ii].Edit1.znach) free(Contr[i]->ElemDig[ii].Edit1.znach); if(Contr[i]->ElemDig[ii].tipElem==2) if(Contr[i]->ElemDig[ii].Label1.NameEl) free(Contr[i]->ElemDig[ii].Label1.NameEl); } if(Contr[i]->NumbElemDig)free(Contr[i]->ElemDig); free(Contr[i]); } free(Contr); } //---------------------------------------------------------------------------------------- void TMyApp::LoadCnt(char* Name, TBasaDBF **BasaDBF) { *BasaDBF = new TBasaDBF(); if((*BasaDBF)->LoadFile(Name)== -1) (*BasaDBF)->LoadFields(Compt,sizeof(Compt)/sizeof(db_str_rec)); } //**************************************************************************************** //************************* Паспарта параметров ****************************************** //**************************************************************************************** struct zap_contr { char name[20]; char n_contr; }; TPasportDialog::TPasportDialog(char *Path,char md,int pos) : TDialog( TRect( 0, 0, 70, 20 ),""), TWindowInit( TPasportDialog::initFrame ) { char str[256]; int i,ii,tip_t; zap_contr *z_contr; mode=md; //Редактор паспортов аналоговых параметров x_max=40;x_min=20;y_max=3;y_min=2;loadOk=False; PspDBF=NULL; OldCntrSrch= -1; NameSearch[0]=0; options |= ofCentered; helpCtx=hcAllASave; strcpy(PathDir,Path); if(mode==1) {sprintf(str,Text_msg[44],PathDir); NameField="NFA";} else {sprintf(str,Text_msg[45],PathDir); NameField="NFD";} title=newStr(str); TView *Monosel = new TView(TRect(8,2,43,15)); Monosel->options |= ofFramed; insert(Monosel); if(myApp->LoadTipContr(PathDir,&ContrTip,&ContrTipAm)== -1) {message(this,evBroadcast,cmClose,this); return;} loadOk=True; CreateTipContr(this); Monosel->setBounds(TRect(x_min,y_min,x_max,y_max)); setBounds(TRect(0,0,x_max+2,max(y_max+3,13)+1)); //drawView(); frame->setBounds(TRect(0,0,x_max+2,max(y_max+3,13)+1)); myApp->LoadCnt(NameDescrCnt,&ContDBF); Button1 = new TButton( TRect( 20,y_max+1, 30, y_max+3),Text_msg[115], cmOK, bfDefault ); insert(Button1); Button2 = new TButton( TRect( 32,y_max+1, 42, y_max+3),Text_msg[114], cmCancel, bfNormal ); insert(Button2); ContrColect1 = new TCompCollect(10,10); ContrColect2 = new TCompCollect(10,10); ScrollBar1 = new TScrollBar( TRect( 6, 2, 7, 12) ); insert(ScrollBar1); MyTListBox1 = new TMyTListBox(TRect( 2, 2, 6, 12), 1, ScrollBar1,NULL); insert(MyTListBox1); TMyLabel *Label = new TMyLabel(TRect(2, 1, 7, 2),"Contr.",MyTListBox1,1); insert(Label); ScrollBar2 = new TScrollBar( TRect( 18, 2, 19, 12) ); insert(ScrollBar2); MyTListBox2 = new TMyTListBox(TRect( 8, 2, 18, 12), 1, ScrollBar2,NULL); insert(MyTListBox2); MyTListBox2->helpCtx=hcAllASearch; Label = new TMyLabel(TRect(8, 1, 19, 2),"~S~hifr",MyTListBox2,1); insert(Label); MyTListBox2->newList(ContrColect2); Lab_Sfr = new TMyLabel(TRect(8,12,18,13),"",NULL,1); insert(Lab_Sfr); for(i=0;iGetCountItems();i++) { ContDBF->GetFieldIt(i,"TC",str); tip_t=atoi(str); if(mode==1) for(ii=0;iiNumbElem;ii++) if(ContrTip[tip_t]->Elem[ii].tipElem==0 && ContrTip[tip_t]->Elem[ii].Edit1.option&o_anal) break; if(mode==2) for(ii=0;iiNumbElem;ii++) if(ContrTip[tip_t]->Elem[ii].tipElem==0 && ContrTip[tip_t]->Elem[ii].Edit1.option&o_dig) break; if(ii==ContrTip[tip_t]->NumbElem) continue; //Не нашел z_contr=(zap_contr *)malloc(sizeof(zap_contr)); ContDBF->GetFieldIt(i,"SHIFR",z_contr->name); z_contr->n_contr=i; ContrColect1->insert(z_contr); // str1 = new char[4]; // ContDBF->GetFieldIt(i,"SHIFR",str1); // ContrColect1->insert(str1); } MyTListBox1->newList(ContrColect1); OldIndChek=pos;OldIndChek1=0;OldTip= -1; MyTListBox1->focusItem(OldIndChek); ViewContr(OldIndChek); ViewElem(OldIndChek1); Modif=Modifs=False; MyTListBox1->select(); } //---------------------------------------------------------------------------------------- TPasportDialog::~TPasportDialog() { if(!loadOk) return; myApp->FreeTipContr(ContrTip,ContrTipAm); delete ContDBF; delete PspDBF; myApp->FreeColect(ContrColect1); myApp->FreeColect(ContrColect2); } //---------------------------------------------------------------------------------------- void TPasportDialog::handleEvent ( TEvent& event ) { char str[256],*str1,*str2,str3[30],str_old[10]; int i,ii,k1,k2; ushort control; TBasaDBF *BaseTmp; TView *temp; TRect r1,r2; db_str_rec *Db_ptr_rec; TComboBoxWindow *ComboWin; if( event.what == evCommand && event.message.command == cmClose) { if(Modif || Modifs) { control = messageBox(Text_msg[26],mfWarning | mfOKCancel); if(control==cmOK) { if(Modif) SaveChengeCntr(MyTListBox2->focused); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); } } } TDialog::handleEvent(event); #ifdef __DOS32__ if( event.what == evBroadcast && event.message.command == cmGetBuf) Modif=True; #endif if( event.what == evBroadcast && event.message.command == cmScrollBarChanged) //List ListBox { if(MyTListBox1->state & sfFocused) // ListBox1 { if(Modifs) { control = messageBox(mfWarning | mfOKCancel,"Паспорта изменены. Сохранить изменения?"); if(control==cmOK) { ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(OldIndChek))->n_contr,NameField,str3); // ContDBF->GetFieldIt(OldIndChek,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); } Modifs=False; } ViewContr(MyTListBox1->focused); ViewElem(OldIndChek1); OldIndChek=MyTListBox1->focused; MyTListBox1->select(); } if(MyTListBox2->state & sfFocused) // ListBox1 { if(Modif) { control = messageBox(mfWarning | mfOKCancel,"Паспорт изменен. Сохранить изменения?"); if(control==cmOK) { SaveChengeCntr(OldIndChek1); Modifs=True; } Modif=False; } #ifdef __DOS32__ if(getShiftState() & (kbLeftShift|kbRightShift)&& !searchOk) { str1=(char *)PspDBF->getItem(OldIndChek1); str2=(char *)PspDBF->getItem(MyTListBox2->focused); PspDBF->DeleteItems(OldIndChek1,0); PspDBF->AddItem(OldIndChek1,str2); PspDBF->DeleteItems(MyTListBox2->focused,0); PspDBF->AddItem(MyTListBox2->focused,str1); ContrColect2->freeAll(); for(i=0;iGetCountItems();i++) { str1=new char[10]; PspDBF->GetFieldIt(i,"SHIFR",str1); ContrColect2->insert(str1); } MyTListBox2->drawView(); Modifs=True; } #endif searchOk=False; ViewElem(MyTListBox2->focused); clearEvent(event); OldIndChek1=MyTListBox2->focused; MyTListBox2->select(); sprintf(str,"%d(%d)",MyTListBox2->focused+1,MyTListBox2->list()->getCount()); Lab_Sfr->SetText(str); } } if( event.what == evCommand ) { switch( event.message.command ) { case cmOK: SaveChengeCntr(MyTListBox2->focused); Modifs=True; Modif=False; temp=current; ViewElem(MyTListBox2->focused); temp->select(); clearEvent(event); break; case cmCancel: ViewElem(MyTListBox2->focused); Modif=False; clearEvent(event); break; case cmSave1: control = messageBox(mfWarning | mfOKCancel,Text_msg[37]); if(control!=cmOK) break; SaveChengeCntr(MyTListBox2->focused); ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); Modif=Modifs=False; break; case cmReLoad: control = messageBox(mfWarning | mfOKCancel,Text_msg[38]); if(control!=cmOK) break; ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); ViewContr(MyTListBox1->focused); ViewElem(MyTListBox2->focused); Modif=Modifs=False; break; case cmInsert: case cmAdd: case cmRename: str1 = new char[10]; str1[0]=0; if(event.message.command==cmRename) {PspDBF->GetFieldIt(MyTListBox2->focused,"SHIFR",str1); strcpy(str_old,str1);} #ifdef __DOS32__ control = inputBoxN("Ввод имени", "Паспорт:",str1, 10,3); #else control = inputBox("Ввод имени", "Паспорт:",str1, 10); #endif for(k1=0,ii=0;ii<9;ii++){if(k1)str1[ii]=' ';else if(str1[ii]==0){ii--; k1=1;}} if(control==cmOK) { BaseTmp = new TBasaDBF(); for(ii=0;iiGetCountItems();ii++) { ContDBF->GetFieldIt(ii,"NFA",str3); sprintf(str,Text_msg[109],PathDir,str3); if(BaseTmp->LoadFile(str)== -1) continue; for(i=0;iGetCountItems();i++) { BaseTmp->GetFieldIt(i,"SHIFR",str); if(!strncmp(str1,str,9)){ i= -1; break;} } if(i== -1) break; ContDBF->GetFieldIt(ii,"NFD",str3); sprintf(str,Text_msg[109],PathDir,str3); if(BaseTmp->LoadFile(str)== -1) continue; for(i=0;iGetCountItems();i++) { BaseTmp->GetFieldIt(i,"SHIFR",str); if(!strncmp(str1,str,9)){ i= -1; break;} } if(i== -1) break; } delete BaseTmp; if(i== -1){ DispFixErr(0,Text_msg[15],str1); delete str1; break;} if(event.message.command==cmInsert || event.message.command==cmRename) k1 = MyTListBox2->focused; if(event.message.command==cmAdd) k1 = PspDBF->GetCountItems(); if(event.message.command==cmRename) MyTListBox2->list()->atFree(k1); else {PspDBF->CreateItems(k1); setNULL(k1);} PspDBF->ModifiFieldIt(k1,"SHIFR",str1); MyTListBox2->list()->atInsert(k1,str1); MyTListBox2->setRange( MyTListBox2->list()->getCount() ); MyTListBox2->drawView(); ViewElem(MyTListBox2->focused); Modifs=True; if(event.message.command==cmRename) { ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); Modif=Modifs=False; myApp->scanAll(str_old,str1,PathDir,1); } } else delete str1; clearEvent(event); break; case cmDelete: if(!MyTListBox2->list()->getCount()) break; for(k1=0,i=0;ilist()->getCount();i++) if(MyTListBox2->list()->GetOptItem(i)) k1++; if(k1) { control = messageBox(mfWarning | mfOKCancel,Text_msg[46],k1); if(control==cmOK) { str1=(char *)calloc(10,k1); for(k2=0,i=0;ilist()->getCount();i++) if(MyTListBox2->list()->GetOptItem(i)) { PspDBF->GetFieldIt(i,"SHIFR",str1+k2*10); k2++; PspDBF->DeleteItems(i,1); MyTListBox2->list()->atFree(i); i--; } } } else { control = messageBox(mfWarning | mfOKCancel,Text_msg[29],(char *)MyTListBox2->list()->at(MyTListBox2->focused)); if(control==cmOK) { k1=1; str1=(char *)calloc(10,k1); PspDBF->GetFieldIt(MyTListBox2->focused,"SHIFR",str1); PspDBF->DeleteItems(MyTListBox2->focused,1); MyTListBox2->list()->atFree(MyTListBox2->focused); } } if(control==cmOK) { MyTListBox2->setRange( MyTListBox2->list()->getCount() ); MyTListBox2->drawView(); ViewElem(MyTListBox2->focused); ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); Modif=Modifs=False; // Modifs=True; clearEvent(event); myApp->scanAll(str1,(char *)&k1,PathDir,2); free(str1); } break; case cmSearch: if(Modifs) { control = messageBox(mfWarning | mfOKCancel,Text_msg[37]); if(control==cmOK) { SaveChengeCntr(MyTListBox2->focused); ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); Modif=Modifs=False; } } #ifdef __DOS32__ control = inputBoxN("Ввод имени", "Поиск:",NameSearch, 10,3); #else control = inputBox("Ввод имени", "Поиск:",NameSearch, 10); #endif if(control==cmOK) { OldCntrSrch=OldShifrSrch=0; i=SearchPasp(&OldCntrSrch,&OldShifrSrch,NameSearch); if(i > -1) { for(i=0;ilist()->getCount();i++) if(((zap_contr *)MyTListBox1->list()->at(i))->n_contr==OldCntrSrch) break; if(i==MyTListBox1->list()->getCount()) OldCntrSrch=OldShifrSrch=0; else OldCntrSrch=i; searchOk=True; MyTListBox1->focusItem(OldCntrSrch); searchOk=True; ViewContr(OldCntrSrch); searchOk=True; MyTListBox2->focusItem(OldShifrSrch);ViewElem(OldShifrSrch); } else DispFixErr(2,Text_msg[25]); Modif=Modifs=False; } else OldCntrSrch = -1; clearEvent(event); break; case cmSearchNext: if(Modifs) { control = messageBox(mfWarning | mfOKCancel,Text_msg[37]); if(control==cmOK) { SaveChengeCntr(MyTListBox2->focused); ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); Modif=Modifs=False; } } if(OldCntrSrch == -1){DispFixErr(2,Text_msg[25]);break;} OldShifrSrch++; i=SearchPasp(&OldCntrSrch,&(OldShifrSrch),NameSearch); if(i < 0) {OldCntrSrch=OldShifrSrch=0; SearchPasp(&OldCntrSrch,&OldShifrSrch,NameSearch);} for(i=0;ilist()->getCount();i++) if(((zap_contr *)MyTListBox1->list()->at(i))->n_contr==OldCntrSrch) break; if(i==MyTListBox1->list()->getCount()) OldCntrSrch=OldShifrSrch=0; else OldCntrSrch=i; searchOk=True; MyTListBox1->focusItem(OldCntrSrch); searchOk=True; ViewContr(OldCntrSrch); searchOk=True; MyTListBox2->focusItem(OldShifrSrch); ViewElem(OldShifrSrch); clearEvent(event); Modif=Modifs=False; break; case cmMove: if(!MyTListBox2->list()->getCount()) break; for(k1=0,i=0;ilist()->getCount();i++) if(MyTListBox2->list()->GetOptItem(i)) k1++; r1 = MyTListBox2->getBounds(); r1.a.x += 10; r1.b.x += 8; r2 = getExtent(); r1.intersect( r2 ); ComboWin = new TComboBoxWindow(r1,MyTListBox1->list(),0); control = execView(ComboWin); if(!k1) if(control==cmOK) MyTListBox2->list()->SetOptItem(MyTListBox2->focused,1); if(control==cmOK&&MyTListBox1->focused!=ComboWin->selpos) { BaseTmp = new TBasaDBF(); ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(ComboWin->selpos))->n_contr,NameField,str3); // ContDBF->GetFieldIt(ComboWin->selpos,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); if(BaseTmp->LoadFile(str)== -1) BaseTmp->LoadFields(Pasp,sizeof(Pasp)/sizeof(db_str_rec)); for(i=0;ilist()->getCount();i++) if(MyTListBox2->list()->GetOptItem(i)) { k2=BaseTmp->GetCountItems(); BaseTmp->CreateItems(k2); for(ii=0;(Db_ptr_rec=PspDBF->getField(ii))!=NULL;ii++) { PspDBF->GetFieldIt(i,Db_ptr_rec->name,str3); BaseTmp->ModifiFieldIt(k2,Db_ptr_rec->name,str3); } PspDBF->DeleteItems(i,1); MyTListBox2->list()->atFree(i); i--; } MyTListBox2->setRange( MyTListBox2->list()->getCount() ); MyTListBox2->drawView(); ViewElem(MyTListBox2->focused); BaseTmp->SaveFile(str); delete BaseTmp; delete ComboWin; ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // ContDBF->GetFieldIt(MyTListBox1->focused,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); PspDBF->SaveFile(str); // Modifs=True; } clearEvent(event); break; case cmFill: if(!MyTListBox2->list()->getCount()) break; TDialog *Dial =new TDialog( TRect( 0, 0, 27, 8 ),"Заполнение"); Dial->options |= ofCentered; TEdit *EdShifr = new TEdit( TRect(12, 2, 20, 3),9,NULL); Dial->insert(EdShifr); TMyLabel *LabShifr = new TMyLabel(TRect(2, 2, 7, 3),"База:",EdShifr,1); Dial->insert(LabShifr); TEdit *EdMin = new TEdit( TRect(12, 3, 16, 4),5,NULL); Dial->insert(EdMin); TEdit *EdMax = new TEdit( TRect(17, 3, 21, 4),5,NULL); Dial->insert(EdMax); TMyLabel *Lab = new TMyLabel(TRect(2, 3, 12, 4),"Диапазон:",NULL,1); Dial->insert(Lab); TButton *Butt = new TButton( TRect(8,5,18,7), "~О~к", cmOK, bfDefault ); Dial->insert(Butt); EdShifr->select(); PspDBF->GetFieldIt(MyTListBox2->focused,"SHIFR",str); EdShifr->setData(str); EdMin->setData("0"); EdMax->setData("10"); control = execView(Dial); if(control==cmOK) { int min_zn = atoi(EdMin->data), max_zn = atoi(EdMax->data); if(max_zn>min_zn) { sprintf(str,"%s%d",EdShifr->data,max_zn); if(strlen(str)>8) messageBox("Общая длина строки более 8 символов!", mfError | mfOKButton); else { for(i=min_zn;iCreateItems(MyTListBox2->focused+1+i-min_zn); str1 = new char[10]; str1[0]=0; sprintf(str1,"%s%d",EdShifr->data,i); MyTListBox2->list()->atInsert(MyTListBox2->focused+1+i-min_zn,str1); for(ii=0;(Db_ptr_rec=PspDBF->getField(ii))!=NULL;ii++) { if(strcmp(Db_ptr_rec->name,"SHIFR")) { PspDBF->GetFieldIt(MyTListBox2->focused,Db_ptr_rec->name,str3); PspDBF->ModifiFieldIt(MyTListBox2->focused+1+i-min_zn,Db_ptr_rec->name,str3); } else PspDBF->ModifiFieldIt(MyTListBox2->focused+1+i-min_zn,Db_ptr_rec->name,str1); } } MyTListBox2->setRange( MyTListBox2->list()->getCount() ); MyTListBox2->drawView(); ViewElem(MyTListBox2->focused); Modifs=True; } } } TObject::destroy(Dial); // for(k1=0,i=0;ilist()->getCount();i++) if(MyTListBox2->list()->GetOptItem(i)) k1++; // r1 = MyTListBox2->getBounds(); r1.a.x += 10; r1.b.x += 8; // r2 = getExtent(); r1.intersect( r2 ); // ComboWin = new TComboBoxWindow(r1,MyTListBox1->list(),0); // control = execView(ComboWin); // if(!k1) if(control==cmOK) MyTListBox2->list()->SetOptItem(MyTListBox2->focused,1); // if(control==cmOK&&MyTListBox1->focused!=ComboWin->selpos) // { // BaseTmp = new TBasaDBF(); // ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(ComboWin->selpos))->n_contr,NameField,str3); // sprintf(str,Text_msg[109],PathDir,str3); // if(BaseTmp->LoadFile(str)== -1) BaseTmp->LoadFields(Pasp,sizeof(Pasp)/sizeof(db_str_rec)); // for(i=0;ilist()->getCount();i++) // if(MyTListBox2->list()->GetOptItem(i)) // { // k2=BaseTmp->GetCountItems(); BaseTmp->CreateItems(k2); // for(ii=0;(Db_ptr_rec=PspDBF->getField(ii))!=NULL;ii++) // { // PspDBF->GetFieldIt(i,Db_ptr_rec->name,str3); // BaseTmp->ModifiFieldIt(k2,Db_ptr_rec->name,str3); // } // PspDBF->DeleteItems(i,1); MyTListBox2->list()->atFree(i); i--; // } // MyTListBox2->setRange( MyTListBox2->list()->getCount() ); // MyTListBox2->drawView(); // ViewElem(MyTListBox2->focused); // BaseTmp->SaveFile(str); // delete BaseTmp; delete ComboWin; // ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,NameField,str3); // sprintf(str,Text_msg[109],PathDir,str3); // PspDBF->SaveFile(str); // } clearEvent(event); break; default: ; } } } int TPasportDialog::SearchPasp(int *contr,int *chifr,char *str1) { int i1,i,ii,iii,start=1,k; TBasaDBF *BaseTmp; char str[256],str3[30]; BaseTmp = new TBasaDBF(); for(ii=*contr;iiGetCountItems();ii++) { ContDBF->GetFieldIt(ii,NameField,str3); sprintf(str,Text_msg[109],PathDir,str3); if(BaseTmp->LoadFile(str)== -1) continue; if(start)i= *chifr;else i=0; start=0; for(;iGetCountItems();i++) { BaseTmp->GetFieldIt(i,"SHIFR",str); // for(iii=8;iii>=0;iii--)if(str[iii]==' ')str[iii]=0;else break; for(iii=0;iii<(int)(10-strlen(str1));iii++) { k=i; for(i1=0;i1setState(sfVisible,False); ScrollBar2->setState(sfVisible,False); Button1->setState(sfVisible,False); Button2->setState(sfVisible,False); item=((zap_contr *)MyTListBox1->list()->at(item))->n_contr; ContDBF->GetFieldIt(item/*MyTListBox1->focused*/,"TC",str1); tip=atoi(str1); if(mode==1) for(i=0;iNumbElem;i++) if(ContrTip[tip]->Elem[i].tipElem==0 && ContrTip[tip]->Elem[i].Edit1.option&o_anal) break; if(mode==2) for(i=0;iNumbElem;i++) if(ContrTip[tip]->Elem[i].tipElem==0 && ContrTip[tip]->Elem[i].Edit1.option&o_dig) break; if(i==ContrTip[tip]->NumbElem) return; //Не нашел MyTListBox2->setState(sfVisible,True); ScrollBar2->setState(sfVisible,True); Button1->setState(sfVisible,True); Button2->setState(sfVisible,True); MyTListBox2->list()->freeAll(); ContDBF->GetFieldIt(item,NameField,str3); sprintf(str1,Text_msg[109],PathDir,str3); if(PspDBF->LoadFile(str1)== -1) PspDBF->LoadFields(Pasp,sizeof(Pasp)/sizeof(db_str_rec)); for(i=0;iGetCountItems();i++) { str2=new char[10]; PspDBF->GetFieldIt(i,"SHIFR",str2); MyTListBox2->list()->insert(str2); } MyTListBox2->setRange( MyTListBox2->list()->getCount()); MyTListBox2->focusItem(0); MyTListBox2->drawView(); //Проверка DBF на отсутствующие и лишние поля с удалением или созданием их в последствии if(mode==1) {NmbElem=ContrTip[tip]->NumbElemAn; TmpElem=ContrTip[tip]->ElemAn; } if(mode==2) {NmbElem=ContrTip[tip]->NumbElemDig;TmpElem=ContrTip[tip]->ElemDig;} //Создание отсутствующих полей for(i=0;igetField(TmpElem[i].Edit1.NameField); if(Db_ptr_rec== NULL) { Db_ptr_rec = (db_str_rec *)calloc(sizeof(db_str_rec),1); strcpy(Db_ptr_rec->name,TmpElem[i].Edit1.NameField); Db_ptr_rec->tip_fild='C'; Db_ptr_rec->len_fild=TmpElem[i].Edit1.lenEntr; PspDBF->addField(1000,Db_ptr_rec); } } if(TmpElem[i].tipElem==1) { Db_ptr_rec=PspDBF->getField(TmpElem[i].Combo1.NameField); if(Db_ptr_rec== NULL) { Db_ptr_rec = (db_str_rec *)calloc(sizeof(db_str_rec),1); strcpy(Db_ptr_rec->name,TmpElem[i].Combo1.NameField); Db_ptr_rec->tip_fild='N'; Db_ptr_rec->len_fild=2; PspDBF->addField(1000,Db_ptr_rec); } } } //Поиск и удаление неиспользуемых полей for(i=0;(Db_ptr_rec=PspDBF->getField(i))!=NULL;i++) { for(ii=0;iiname)) break; if(TmpElem[ii].tipElem==1) if(!strcmp(TmpElem[ii].Combo1.NameField,Db_ptr_rec->name)) break; for(j=0;jname)) break; if(j!=sizeof(Pasp)/sizeof(db_str_rec)) break; } if(ii==NmbElem) { PspDBF->DelField(i); i--;} } sprintf(str1,"%d(%d)",MyTListBox2->focused+1,MyTListBox2->list()->getCount()); Lab_Sfr->SetText(str1); } void TPasportDialog::ViewElem(int item) { int tip; char str1[30]; ContDBF->GetFieldIt(((zap_contr *)MyTListBox1->list()->at(MyTListBox1->focused))->n_contr,"TC",str1); tip=atoi(str1); // ContDBF->GetFieldIt(MyTListBox1->focused,"TC",str1); tip=atoi(str1); ViewEl(item); } void TControler::ViewEl(int item) { int i,ii,iii,k,ind_n; strelem *TmpElem; char NmbElem, str1[30]; TBasaDBF *TempDBF; TBasaDBF *BaseTmp; TRect r; if(OldTip!= -1) { if(mode==0) {TempDBF=ContDBF;NmbElem=ContrTip[OldTip]->NumbElem; TmpElem=ContrTip[OldTip]->Elem;} if(mode==1) {TempDBF=PspDBF; NmbElem=ContrTip[OldTip]->NumbElemAn;TmpElem=ContrTip[OldTip]->ElemAn;} if(mode==2) {TempDBF=PspDBF; NmbElem=ContrTip[OldTip]->NumbElemDig;TmpElem=ContrTip[OldTip]->ElemDig;} for(i=0;iGetCountItems()) continue; if(TmpElem[i].tipElem==0) { TmpElem[i].Edit1.Editptr->setState(sfVisible,False); if((mode==0)&&(TmpElem[i].Edit1.option&o_anal)) LabelAn->setState(sfVisible,False); if((mode==0)&&(TmpElem[i].Edit1.option&o_dig)) LabelDg->setState(sfVisible,False); } if(TmpElem[i].tipElem==1) { TmpElem[i].Combo1.Editptr->setState(sfVisible,False); TmpElem[i].Combo1.Comboptr->setState(sfVisible,False); } if(TmpElem[i].tipElem==2) TmpElem[i].Label1.Labelptr->setState(sfVisible,False); } } if(mode==0) {TempDBF=ContDBF;NmbElem=ContrTip[tip]->NumbElem; TmpElem=ContrTip[tip]->Elem;} if(mode==1) {TempDBF=PspDBF; NmbElem=ContrTip[tip]->NumbElemAn;TmpElem=ContrTip[tip]->ElemAn;} if(mode==2) {TempDBF=PspDBF; NmbElem=ContrTip[tip]->NumbElemDig;TmpElem=ContrTip[tip]->ElemDig;} if(!TempDBF->GetCountItems()) {OldTip=tip; return;} for(i=0;iGetFieldIt(item,TmpElem[TmpElem[ind_n].n_el_comb].NameField,str1)== -1)str1[0]=0; // k=atoi(str1); // } // else k=((str20*)(TmpElem[TmpElem[ind_n].n_el_comb].Combo1.Comboptr->list()->at(TmpElem[TmpElem[ind_n].n_el_comb].Combo1.Comboptr->posit)))->index; // k=TmpElem[TmpElem[ind_n].n_el_comb].Combo1.Comboptr->posit; for(ii=0;iisetState(sfVisible,True); if((mode==0)&&(TmpElem[i].Edit1.option&o_anal)) { r = TmpElem[i].Edit1.Editptr->getBounds(); LabelAn->setBounds(TRect(r.b.x+1,r.a.y,r.b.x+4,r.b.y)); LabelAn->setState(sfVisible,True); } if((mode==0)&&(TmpElem[i].Edit1.option&o_dig)) { r = TmpElem[i].Edit1.Editptr->getBounds(); LabelDg->setBounds(TRect(r.b.x+1,r.a.y,r.b.x+4,r.b.y)); LabelDg->setState(sfVisible,True); } if(item!= -1) {if(TempDBF->GetFieldIt(item,TmpElem[i].Edit1.NameField,str1)== -1)str1[0]=0; TmpElem[i].Edit1.Editptr->setData(str1);} if((mode==0)&&(TmpElem[i].Edit1.option&o_anal)) { BaseTmp = new TBasaDBF(); if( BaseTmp->LoadFile(TmpElem[i].Edit1.Editptr->data)== -1) strcpy(str1,"NA"); else sprintf(str1,"%d",BaseTmp->GetCountItems()); delete BaseTmp; LabelAn->SetText(str1); } if((mode==0)&&(TmpElem[i].Edit1.option&o_dig)) { BaseTmp = new TBasaDBF(); if( BaseTmp->LoadFile(TmpElem[i].Edit1.Editptr->data)== -1) strcpy(str1,"NA"); else sprintf(str1,"%d",BaseTmp->GetCountItems()); delete BaseTmp; LabelDg->SetText(str1); } } if(TmpElem[i].tipElem==1) { if(item!= -1) { if(TempDBF->GetFieldIt(item,TmpElem[i].Combo1.NameField,str1)== -1)str1[0]=0;//return; for(iii=0;iiilist()->getCount();iii++) if(((str20*)(TmpElem[i].Combo1.Comboptr->list()->at(iii)))->index==atoi(str1)) { TmpElem[i].Combo1.Editptr->setData(((str20*)(TmpElem[i].Combo1.Comboptr->list()->at(iii)))->name); TmpElem[i].Combo1.Comboptr->posit=iii; } // TmpElem[i].Combo1.Editptr->setData(TmpElem[i].Combo1.StrElem[atoi(str1)].name); // TmpElem[i].Combo1.Comboptr->posit=atoi(str1); } TmpElem[i].Combo1.Editptr->setState(sfVisible,True); TmpElem[i].Combo1.Comboptr->setState(sfVisible,True); } if(TmpElem[i].tipElem==2) TmpElem[i].Label1.Labelptr->setState(sfVisible,True); } OldTip=tip; } void TControler::setNULL(int index) { int i; char NmbElem,str[20]; TBasaDBF *TempDBF; strelem *TmpElem; if(mode==0) {TempDBF=ContDBF;NmbElem=ContrTip[tip]->NumbElem; TmpElem=ContrTip[tip]->Elem;} if(mode==1) {TempDBF=PspDBF; NmbElem=ContrTip[tip]->NumbElemAn;TmpElem=ContrTip[tip]->ElemAn;} if(mode==2) {TempDBF=PspDBF; NmbElem=ContrTip[tip]->NumbElemDig;TmpElem=ContrTip[tip]->ElemDig;} for(i=0;iModifiFieldIt(index,TmpElem[i].Edit1.NameField,str); } else { sprintf(str,"%x",(int)TmpElem[i].Edit1.def); TempDBF->ModifiFieldIt(index,TmpElem[i].Edit1.NameField,str); } if(TmpElem[i].tipElem==1) TempDBF->ModifiFieldIt(index,TmpElem[i].Combo1.NameField,"0"); } }