home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0632.ZIP / CCE_0632 / GOBJ_111.ZIP / GOBJECTS.111 / SOURCE / BEISPIEL / BEISPL04.PAS < prev    next >
Pascal/Delphi Source File  |  1994-03-03  |  5KB  |  254 lines

  1. program Beispiel; {$X+} { Beispiel Nr.4 }
  2.  
  3. uses
  4.  
  5.     Gem,OTypes,OProcs,OWindows;
  6.  
  7. const
  8.  
  9.     {$I beispiel.i}
  10.  
  11. type
  12.  
  13.     TMyApplication = object(TApplication)
  14.         procedure InitInstance; virtual;
  15.         procedure InitMainWindow; virtual;
  16.     end;
  17.  
  18.     PBeispielWindow = ^TBeispielWindow;
  19.     TBeispielWindow = object(TWindow)
  20.         Veraendert: boolean;
  21.         Dicke,
  22.         Farbe,
  23.         Art       : integer;
  24.         Pfad,
  25.         Datei     : string;
  26.         constructor Init(AParent: PWindow; ATitle: string);
  27.         function CanClose: boolean; virtual;
  28.         procedure WMButton(mX,mY,BStat,KStat,Clicks: integer); virtual;
  29.         { neue Methoden: }
  30.         procedure SetAttr(Width,Color,Style: integer); virtual;
  31.         procedure CreateTitle; virtual;
  32.     end;
  33.  
  34.     PAbout = ^TAbout;
  35.     TAbout = object(TKeyMenu)
  36.         procedure Work; virtual;
  37.     end;
  38.  
  39.     PNew = ^TNew;
  40.     TNew = object(TKeyMenu)
  41.         procedure Work; virtual;
  42.     end;
  43.  
  44.     POpen = ^TOpen;
  45.     TOpen = object(TKeyMenu)
  46.         procedure Work; virtual;
  47.     end;
  48.  
  49.     PSave = ^TSave;
  50.     TSave = object(TKeyMenu)
  51.         procedure Work; virtual;
  52.     end;
  53.  
  54.     PSaveAs = ^TSaveAs;
  55.     TSaveAs = object(TKeyMenu)
  56.         procedure Work; virtual;
  57.     end;
  58.  
  59.     PInfo = ^TInfo;
  60.     TInfo = object(TKeyMenu)
  61.         procedure Work; virtual;
  62.     end;
  63.  
  64.     PAttrib = ^TAttrib;
  65.     TAttrib = object(TKeyMenu)
  66.         procedure Work; virtual;
  67.     end;
  68.  
  69. var
  70.  
  71.     MyApp: TMyApplication;
  72.  
  73.  
  74. procedure MyResource; external; {$L beispiel.o}
  75.  
  76.  
  77. procedure TMyApplication.InitInstance;
  78.  
  79.     begin
  80.         InitResource(@MyResource,nil);
  81.         LoadMenu(BSPMENU);
  82.         new(PAbout,Init(@self,K_CTRL,Ctrl_A,MABOUT,MTITLE1));
  83.         new(PNew,Init(@self,K_CTRL,Ctrl_N,MNEW,MTITLE2));
  84.         new(POpen,Init(@self,K_CTRL,Ctrl_O,MOPEN,MTITLE2));
  85.         new(PSave,Init(@self,K_CTRL,Ctrl_S,MSAVE,MTITLE2));
  86.         new(PSaveAs,Init(@self,K_CTRL,Ctrl_D,MSAVEAS,MTITLE2));
  87.         new(PInfo,Init(@self,K_CTRL,Ctrl_I,MINFO,MTITLE3));
  88.         new(PAttrib,Init(@self,K_CTRL,Ctrl_T,MATTR,MTITLE3));
  89.         inherited InitInstance;
  90.         SetQuit(MQUIT,MTITLE2)
  91.     end;
  92.  
  93.  
  94. procedure TMyApplication.InitMainWindow;
  95.  
  96.     begin
  97.         new(PBeispielWindow,Init(nil,'Beispiel  [unbenannt]'));
  98.         if (MainWindow=nil) or (ChkError<em_OK) then
  99.             Status:=em_InvalidMainWindow
  100.     end;
  101.  
  102.  
  103. constructor TBeispielWindow.Init(AParent: PWindow; ATitle: string);
  104.  
  105.     begin
  106.         if not(inherited Init(AParent,ATitle)) then fail;
  107.         Veraendert:=false;
  108.         SetAttr(3,Blue,LT_SOLID);
  109.         Datei:='';
  110.         Pfad:=''
  111.     end;
  112.  
  113.  
  114. function TBeispielWindow.CanClose: boolean;
  115.     var valid: boolean;
  116.  
  117.     begin
  118.         valid:=inherited CanClose;
  119.         if valid and Veraendert then
  120.             valid:=(Application^.Alert(@self,1,WAIT,
  121.                 ' Die Grafik wurde verändert!| Wollen Sie sie speichern?',
  122.               '&Ja|  &Nein  ')=2);
  123.         CanClose:=valid
  124.     end;
  125.  
  126.  
  127. procedure TBeispielWindow.WMButton(mX,mY,BStat,KStat,Clicks: integer);
  128.     var xalt,yalt,btn,dummy: integer;
  129.         pxyarray           : ptsin_ARRAY;
  130.  
  131.     begin
  132.         if bTst(BStat,1) then
  133.             if GetDC>=0 then
  134.                 begin
  135.                     wind_update(BEG_MCTRL);
  136.                     vsl_width(vdiHandle,Dicke);
  137.                     vsl_color(vdiHandle,Farbe);
  138.                     vsl_type(vdiHandle,Art);
  139.                     repeat
  140.                         xalt:=mX;
  141.                         yalt:=mY;
  142.                         repeat
  143.                             graf_mkstate(mX,mY,btn,dummy)
  144.                         until (mX<>xalt) or (mY<>yalt) or not(bTst(btn,1));
  145.                         pxyarray[0]:=xalt;
  146.                         pxyarray[1]:=yalt;
  147.                         pxyarray[2]:=mX;
  148.                         pxyarray[3]:=mY;
  149.                         v_pline(vdiHandle,2,pxyarray)
  150.                     until not(bTst(btn,1));
  151.                     wind_update(END_MCTRL);
  152.                     ReleaseDC;
  153.                     Veraendert:=true;
  154.                     CreateTitle
  155.                 end;
  156.         if bTst(BStat,2) then
  157.             begin
  158.                 ForceRedraw;
  159.                 Veraendert:=false;
  160.                 CreateTitle
  161.             end
  162.     end;
  163.  
  164.  
  165. procedure TBeispielWindow.SetAttr(Width,Color,Style: integer);
  166.     const farben: array [0..7] of string[7] =
  167.         ('weiß','schwarz','rot','grün','blau','türkis','gelb','violett');
  168.                 arten: array [1..6] of string[16] =
  169.         ('durchgehend','langer Strich','Punkte','Strich, Punkt',
  170.                                      'Strich','Strich, 2 Punkte');
  171.  
  172.     begin
  173.         Dicke:=Width;
  174.         Farbe:=Color;
  175.         Art:=Style;
  176.         SetSubTitle(' Dicke: '+ltoa(Dicke)+'  Farbe: '+farben[Farbe]+
  177.                                 '   Art: '+arten[Art])
  178.     end;
  179.  
  180.  
  181. procedure TBeispielWindow.CreateTitle;
  182.     var titel: string;
  183.  
  184.     begin
  185.         if length(Datei)=0 then titel:='[unbenannt]'
  186.         else
  187.             titel:=Pfad+Datei;
  188.         if Veraendert then titel:='*'+titel;
  189.         titel:='Beispiel  '+titel;
  190.         SetTitle(titel)
  191.     end;
  192.  
  193.  
  194. procedure TAbout.Work;
  195.  
  196.     begin
  197.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  198.                                                     'nicht implementiert.',' &Schade ')
  199.     end;
  200.  
  201.  
  202. procedure TNew.Work;
  203.  
  204.     begin
  205.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  206.                                                     'nicht implementiert.',' &Schade ')
  207.     end;
  208.  
  209.  
  210. procedure TOpen.Work;
  211.  
  212.     begin
  213.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  214.                                                     'nicht implementiert.',' &Schade ')
  215.     end;
  216.  
  217.  
  218. procedure TSave.Work;
  219.  
  220.     begin
  221.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  222.                                                     'nicht implementiert.',' &Schade ')
  223.     end;
  224.  
  225.  
  226. procedure TSaveAs.Work;
  227.  
  228.     begin
  229.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  230.                                                     'nicht implementiert.',' &Schade ')
  231.     end;
  232.  
  233.  
  234. procedure TInfo.Work;
  235.  
  236.     begin
  237.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  238.                                                     'nicht implementiert.',' &Schade ')
  239.     end;
  240.  
  241.  
  242. procedure TAttrib.Work;
  243.  
  244.     begin
  245.         Application^.Alert(nil,1,NOTE,'Die Funktion ist noch|'+
  246.                                                     'nicht implementiert.',' &Schade ')
  247.     end;
  248.  
  249.  
  250. begin
  251.     MyApp.Init('BSPL','Beispiel');
  252.     MyApp.Run;
  253.     MyApp.Done
  254. end.