home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / das_buch / tvision / dialogs / linkdlg.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1993-05-03  |  8.4 KB  |  260 lines

  1. (* ------------------------------------------------------ *)
  2. (*                   LINKDLG.PAS                          *)
  3. (*           (c) 1993 te-wi Verlag, München               *)
  4. (* ------------------------------------------------------ *)
  5. PROGRAM LinkDlg;
  6.  
  7. {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q+,R+,S+,T-,V+,X+,Y+}
  8. {$M 16384,0,655360}
  9.  
  10. USES Objects, Drivers, Views, Menus, MsgBox, Dialogs, App;
  11.  
  12. CONST
  13.   cmAbout = 101;
  14.   cmTest  = 102;
  15.  
  16. (* ------------------------------------------------------ *)
  17.  
  18.   FUNCTION LinkOptDlg : pDialog;
  19.   (* Da es jede Menge CheckBoxen und RadioButtons gibt, wurde
  20.      bei der Vergabe der Shortcuts eingespart. Der Dialog
  21.      sollte jedoch auch ohne Maus zu bedienen sein. Aus diesem
  22.      Grund sind die RadioButtons mit Labels versehen, über
  23.      die die entsprechenden Felder angewählt werden können.
  24.      Die Checkboxen können über die Shortcuts manipuliert werden.
  25.  
  26.      Die Z-Ordnung bleibt unberührt: mit Tab kann der Anwedner
  27.      die Felder wechseln. Aus Gründen der Anwenderfreundlichkeit
  28.      sollten die mit [Tab] anzuwählenden Checkboxen abgesetzt werden.
  29.  
  30.      Die Reihenfolge der an den Dialog zu übergebenden Daten hängt
  31.      ebenfalls von der Z-Ordnung (also der Reihenfolge der Subviews
  32.      im Dialog) ab.
  33.    *)
  34.   VAR
  35.     D : pDialog;
  36.     C : pView;
  37.     R : tRect;
  38.   BEGIN
  39.     R.Assign(0, 0, 75, 22);
  40.     D := New(pDialog, Init(R, 'Linker Options'));
  41.  
  42.     WITH D^ DO BEGIN
  43.       Options := Options OR ofCentered;
  44.  
  45.       R.Assign(3, 3, 33, 10);
  46.       C := New(pCheckBoxes, Init(R,
  47.         NewSItem('Map file with publics    (/m)',
  48.         NewSItem('No map file              (/x)',
  49.         NewSItem('Include line numbers     (/l)',
  50.         NewSItem('Detailed map od segs     (/s)',
  51.         NewSItem('Full debug information   (/v)',
  52.         NewSItem('Initialize all segments  (/i)',
  53.         NewSItem('Overlay switch           (/o)',
  54.       NIL)))))))));
  55.       Insert(C);
  56.       R.Assign(2, 2, 30, 3);
  57.       Insert(New(pLabel, Init(R, '~D~ebug Information', C)));
  58.  
  59.       R.Assign(3, 12, 33, 14);
  60.       C := New(pRadioButtons, Init(R,
  61.         NewSItem('Expanded memory   (/ye)',
  62.         NewSItem('Extended memory   (/yx)',
  63.       NIL))));
  64.       Insert(C);
  65.       R.Assign(2, 11, 22, 12);
  66.       Insert(New(pLabel, Init(R, '~M~emory swapping', C)));
  67.  
  68.       R.Assign(33, 3, 72, 10);
  69.       C := New(pCheckBoxes, Init(R,
  70.         NewSItem('No default libraries        (/n)',
  71.         NewSItem('Warn if duplicate symbols   (/d)',
  72.         NewSItem('Case significant in symbols (/c)',
  73.         NewSItem('Ignore extended dictionary  (/e)',
  74.         NewSItem('Case sensitive exports      (/C)',
  75.         NewSItem('Enable 32-bit processing    (/3)',
  76.       NIL))))))));
  77.       Insert(C);
  78.       R.Assign(32, 2, 50, 3);
  79.       Insert(New(pLabel, Init(R, '~L~ibraries', C)));
  80.  
  81.       R.Assign(33, 12, 72, 18);
  82.       C := New(pRadioButtons, Init(R,
  83.         NewSItem('COM for DOS                 (/Tdc)',
  84.         NewSItem('EXE for DOS                 (/Tdx)',
  85.         NewSItem('DLL for DOS                 (/Tdd)',
  86.         NewSItem('COM for Windows             (/Twc)',
  87.         NewSItem('EXE for Windows             (/Twx)',
  88.         NewSItem('DLL for Windows             (/Twd)',
  89.       NIL))))))));
  90.       Insert(C);
  91.       R.Assign(32, 11, 50, 12);
  92.       Insert(New(pLabel, Init(R, '~O~utput', C)));
  93.  
  94.       R.Assign(4, 19, 14, 21);
  95.       Insert(New(pButton, Init(R, 'O~k~', cmOk, bfDefault)));
  96.       Inc(R.A.X, 12);  Inc(R.B.X, 12);
  97.       Insert(New(pButton, Init(R, '~C~ancel', cmCancel, bfNormal)));
  98.  
  99.     END;
  100.     LinkOptDlg := D;
  101.   END;
  102.  
  103. (* -------- Linker Options Data Transfer ---------------- *)
  104.  
  105. TYPE
  106.   LinkOptRec = RECORD
  107.                  DebugInfo : WORD;
  108.                    (* Map file with publics       (/m)   *)
  109.                    (* No map file                 (/x)   *)
  110.                    (* Include line numbers        (/l)   *)
  111.                    (* Detailed map od segs        (/s)   *)
  112.                    (* Full debug information      (/v)   *)
  113.                    (* Initialize all segments     (/i)   *)
  114.                    (* Overlay switch              (/o)   *)
  115.  
  116.                  MemSwap   : WORD;
  117.  
  118.                    (* Expanded memory             (/ye)  *)
  119.                    (* Extended memory             (/yx)  *)
  120.  
  121.                  Libraries : WORD;
  122.  
  123.                    (* No default libraries        (/n)   *)
  124.                    (* Warn if duplicate symbols   (/d)   *)
  125.                    (* Case significant in symbols (/c)   *)
  126.                    (* Ignore extended dictionary  (/e)   *)
  127.                    (* Case sensitive exports      (/C)   *)
  128.                    (* Enable 32-bit processing    (/3)   *)
  129.  
  130.                  Target    : WORD;
  131.  
  132.                    (* COM for DOS                 (/Tdc) *)
  133.                    (* EXE for DOS                 (/Tdx) *)
  134.                    (* DLL for DOS                 (/Tdd) *)
  135.                    (* COM for Windows             (/Twc) *)
  136.                    (* EXE for Windows             (/Twx) *)
  137.                    (* DLL for Windows             (/Twd) *)
  138.                END;
  139.  
  140. (* --- Main Application Object -------------------------- *)
  141.  
  142. TYPE
  143.   tMyApp = OBJECT (tApplication)
  144.     PROCEDURE InitMenuBar; VIRTUAL;
  145.     PROCEDURE HandleEvent(VAR Event : tEvent); VIRTUAL;
  146.   PRIVATE
  147.     PROCEDURE DoTest;
  148.   END;
  149.  
  150. (* Utils *)
  151.  
  152.     FUNCTION HexByte(b : BYTE) : STRING;
  153.     CONST
  154.       H : ARRAY [0..15] OF CHAR = '0123456789ABCDEF';
  155.     BEGIN
  156.       HexByte[0] := #2;
  157.       HexByte[1] := H[b DIV 16];
  158.       HexByte[2] := H[b MOD 16];
  159.     END;
  160.  
  161.     FUNCTION HexWord(w : WORD) : STRING;
  162.     BEGIN
  163.       HexWord := HexByte(w DIV 256) + HexByte(w MOD 256);
  164.     END;
  165.  
  166.     FUNCTION Li2Str(Li : LONGINT) : STRING;
  167.     VAR
  168.       L  : RECORD Hi, Lo : WORD; END ABSOLUTE Li;
  169.     BEGIN
  170.       Li2Str := HexWord(L.Lo) + HexWord(L.Hi);
  171.     END;
  172. (* ----- *)
  173.   PROCEDURE tMyApp.DoTest;
  174.   VAR
  175.     Data : LinkOptRec;
  176.     S    : STRING;
  177.   BEGIN
  178.     S := 'TLINK';
  179.     (* Syntax: TLINK objfiles, exefile, mapfile, libfiles, deffile
  180.        /L  Specify library search paths
  181.      *)
  182.     WITH Data DO BEGIN
  183.       DebugInfo := $0000;
  184.       MemSwap   := $0000;
  185.       Libraries := $0000;
  186.       Target    := $0000;
  187.     END;
  188.     ExecuteDialog(LinkOptDlg, @Data);
  189.     WITH Data DO BEGIN
  190.       IF (DebugInfo AND  1) =  1 THEN S := S + ' /m';
  191.       IF (DebugInfo AND  2) =  2 THEN S := S + ' /x';
  192.       IF (DebugInfo AND  4) =  4 THEN S := S + ' /l';
  193.       IF (DebugInfo AND  8) =  8 THEN S := S + ' /s';
  194.       IF (DebugInfo AND 16) = 16 THEN S := S + ' /v';
  195.       IF (DebugInfo AND 32) = 32 THEN S := S + ' /i';
  196.       IF (DebugInfo AND 64) = 64 THEN S := S + ' /o';
  197.       IF MemSwap = 0 THEN S := S + ' /ye' ELSE S := S + ' /yx';
  198.       IF (Libraries AND  1) =  1 THEN S := S + ' /n';
  199.       IF (Libraries AND  2) =  2 THEN S := S + ' /d';
  200.       IF (Libraries AND  4) =  4 THEN S := S + ' /c';
  201.       IF (Libraries AND  8) =  8 THEN S := S + ' /e';
  202.       IF (Libraries AND 16) = 16 THEN S := S + ' /C';
  203.       IF (Libraries AND 32) = 32 THEN S := S + ' /3';
  204.       CASE Target OF
  205.         0 : S := S + ' /Tdc';
  206.         1 : S := S + ' /Tdx';
  207.         2 : S := S + ' /Tdd';
  208.         3 : S := S + ' /Twc';
  209.         4 : S := S + ' /Twx';
  210.         5 : S := S + ' /Twd';
  211.       END;
  212.     END;
  213.     MessageBox(S, NIL, mfInformation + mfOkButton);
  214.   END;
  215.  
  216.   PROCEDURE tMyApp.InitMenuBar;
  217.   VAR
  218.     R : tRect;
  219.   BEGIN
  220.     GetExtent(R);
  221.     R.B.Y := R.A.Y + 1;
  222.     MenuBar := New(pMenuBar, Init(R, NewMenu(
  223.       NewSubMenu('~≡~', hcNoContext, NewMenu(
  224.         NewItem('~T~est', '', kbNoKey, cmTest, hcNoContext,
  225.         NewItem('~A~bout', '', kbNoKey, cmAbout, hcNoContext,
  226.         NIL))),
  227.       NIL))));
  228.   END;
  229.  
  230.   PROCEDURE tMyApp.HandleEvent(VAR Event : tEvent);
  231.   BEGIN
  232.     inherited HandleEvent(Event);
  233.  
  234.     IF Event.What = evCommand THEN BEGIN
  235.       CASE Event.Command OF
  236.         cmTest  : BEGIN
  237.                     DoTest;
  238.                   END;
  239.         cmAbout : BEGIN
  240.                     MessageBox(#3'Turbo Vision Application',
  241.                     NIL, mfInformation OR mfOkButton);
  242.                   END;
  243.       ELSE
  244.         Exit;
  245.       END;
  246.       ClearEvent(Event);
  247.     END;
  248.   END;
  249.  
  250. VAR
  251.   anApp : tMyApp;
  252.  
  253. BEGIN
  254.   anApp.Init;
  255.   anApp.Run;
  256.   anApp.Done;
  257. END.
  258. (* ------------------------------------------------------ *)
  259. (*                Ende von LINKDLG.PAS                    *)
  260.