home *** CD-ROM | disk | FTP | other *** search
/ Best of German Only 1 / romside_best_of_german_only_1.iso / wissen / dos / wgraph / entpack.exe / WGDEMOQ!.EXE / GFILEDLG.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-21  |  4KB  |  157 lines

  1. {$A+,B-,D-,E-,F+,I-,L-,N-,O+,R-,S-,V-}
  2. UNIT GFileDlg;
  3.  
  4. INTERFACE
  5.  
  6. USES GDecl,
  7.      GDlg,
  8.      GViews,
  9.      GEvent,
  10.      GDrivers,
  11.      dos,
  12.      graph;
  13.  
  14. const msgLoadPic = 10;
  15.       msgSavePic = 11;
  16.  
  17. type PInputDialog=^TInputDialog;
  18.      TInputDialog=object(TDlgWindow)
  19.       procedure SetDateiListBox(x,y,xl,yl:integer;Bez:str25;LScroller:word);
  20.       procedure HandleEvent; virtual;
  21.      end;
  22.  
  23.      POutputDialog=^TOutputDialog;
  24.      TOutputDialog=object(TDlgWindow)
  25.       procedure HandleEvent; virtual;
  26.      end;
  27.  
  28.      PDateiListBox=^TDateiListBox;
  29.      TDateiListBox=object(TListBox)
  30.       procedure CreateDataList;
  31.      end;
  32.  
  33.      tDialogData=record
  34.                     Schalter:string[5];
  35.                     DateiName   : string[32];
  36.                     Datei       : string[12];
  37.                  end;
  38.  
  39.      tImgData =record
  40.                  Schalter:string[4];
  41.                  DateiName:string[32];
  42.                end;
  43.  
  44.  
  45. var DlgData:tDialogData;
  46.     ImgData:tImgData;
  47.  
  48. IMPLEMENTATION
  49.  
  50. {Implementation TInputDialog}
  51.  
  52. procedure TInputDialog.SetDateiListBox(x,y,xl,yl:integer;Bez:str25;
  53.                                         LScroller:word);
  54. var LBox:PDateiListBox;
  55. begin
  56.   TDlgWindow.SetListBox(x,y,xl,yl,Bez,LScroller);
  57.   LBox:=new(PDateiListBox, Init(R,Bez,SBH,SBV));
  58.   LBox^.CreateDataList;
  59.   LBox^.P.x:=x; LBox^.P.y:=y;
  60.   DlgList^.InsertItem(LBox);
  61. end;
  62.  
  63. procedure TInputDialog.HandleEvent;
  64. var LfdPtr:PGroup;
  65.     i:byte;
  66. begin
  67.   TDlgWindow.HandleEvent;
  68.   with Event do
  69.    begin
  70.      if Event.Command=cmOK then
  71.       begin
  72.         Message:=msgLoadPic;
  73.         LfdPtr:=DlgList^.GetItems(1);
  74.         with PInputLine(LfdPtr)^ do
  75.          InfoString:=DlgData.DateiName;
  76.         Command:=cmCloseWindow;
  77.       end;
  78.      if Command=cmCancel then
  79.       with DlgData do
  80.        begin
  81.          DateiName:='';
  82.          Datei:='';
  83.          Command:=cmCloseWindow;
  84.        end;
  85.      if (What=evKeyboard) and (Keyb.KeyCode=kbEnter) then
  86.       if pos('*',DlgData.DateiName)<>0 then
  87.        begin
  88.          LfdPtr:=DlgList^.GetItems(2);
  89.          with PDateiListBox(LfdPtr)^ do
  90.           begin
  91.             Liste^.DeleteItems;
  92.             ChangeItem:=1;
  93.             AktivItem:=1;
  94.             Delta.X:=1; Delta.Y:=1;
  95.             VertiScrollBar^.Value:=1;
  96.             CreateDataList;
  97.             Draw;
  98.           end;
  99.        end;
  100.      if (Keyb.KeyCode=kbSpace) or Mouse.Double then
  101.       begin
  102.         Mouse.DoubleKlick:=false;
  103.         LfdPtr:=DlgList^.GetItems(2);
  104.         if PDateiListBox(LfdPtr)^.Focus then
  105.          begin
  106.            LfdPtr:=DlgList^.GetItems(1);
  107.            with PInputLine(LfdPtr)^ do
  108.             begin
  109.               Data:=DlgData.Datei;
  110.               Draw;
  111.             end;
  112.          end;
  113.       end;
  114.    end;
  115. end;
  116.  
  117. {Implementation TOutputDialog}
  118.  
  119. procedure TOutputDialog.HandleEvent;
  120. var LfdPtr:PGroup;
  121. begin
  122.   TDlgWindow.HandleEvent;
  123.   if Event.Command=cmOK then
  124.    begin
  125.      Event.Message:=msgSavePic;
  126.      LfdPtr:=DlgList^.GetItems(1);
  127.      with PInputLine(LfdPtr)^ do
  128.       Event.InfoString:=ImgData.DateiName;
  129.       Event.Command:=cmCloseWindow;
  130.    end;
  131.   if Event.Command=cmCancel then
  132.    begin
  133.      ImgData.DateiName:='';
  134.      Event.Command:=cmCloseWindow;
  135.    end;
  136. end;
  137.  
  138. {Implementation TDateiListBox}
  139.  
  140. procedure TDateiListBox.CreateDataList;
  141. var SRec:SearchRec;
  142.     LfdPtr:PLine;
  143. begin
  144.   FindFirst(DlgData.DateiName,Archive,SRec);
  145.   if SRec.Name<>'' then
  146.    repeat
  147.      LfdPtr:=new(PLine, Init);
  148.      LfdPtr^.Eintrag:=SRec.Name;
  149.      Liste^.InsertItem(LfdPtr);
  150.      FindNext(SRec);
  151.    until DOSError=18;
  152.   DataLen:=12;
  153.   SetLimit(12,Liste^.AnzElem,8,11);
  154. end;
  155.  
  156.  
  157. END.