home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d123456 / CHEMPLOT.ZIP / TPlot / Plotzoom.pas < prev    next >
Pascal/Delphi Source File  |  2001-07-24  |  6KB  |  208 lines

  1. unit Plotzoom;
  2.  
  3. {$I Plot.inc}
  4.  
  5. {-----------------------------------------------------------------------------
  6. The contents of this file are subject to the Q Public License
  7. ("QPL"); you may not use this file except in compliance
  8. with the QPL. You may obtain a copy of the QPL from 
  9. the file QPL.html in this distribution, derived from:
  10.  
  11. http://www.trolltech.com/products/download/freelicense/license.html
  12.  
  13. The QPL prohibits development of proprietary software. 
  14. There is a Professional Version of this software available for this. 
  15. Contact sales@chemware.hypermart.net for more information.
  16.  
  17. Software distributed under the QPL is distributed on an "AS IS" basis,
  18. WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the QPL for
  19. the specific language governing rights and limitations under the QPL.
  20.  
  21. The Original Code is: Zoom.pas, released 12 September 2000.
  22.  
  23. The Initial Developer of the Original Code is Mat Ballard.
  24. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
  25. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
  26. All Rights Reserved.
  27.  
  28. Contributor(s): Mat Ballard                 e-mail: mat.ballard@chemware.hypermart.net.
  29.  
  30. Last Modified: 06/25/2001
  31. Current Version: 2.00
  32.  
  33. You may retrieve the latest version of this file from:
  34.  
  35.         http://Chemware.hypermart.net/
  36.  
  37. This work was created with the Project JEDI VCL guidelines:
  38.  
  39.         http://www.delphi-jedi.org/Jedi:VCLVCL
  40.  
  41. in mind. 
  42.  
  43. Purpose:
  44. To facilitate user manipluation of the plot scale.
  45.  
  46. Known Issues:
  47. -----------------------------------------------------------------------------}
  48.  
  49. interface
  50.  
  51. uses
  52.   Classes, SysUtils,
  53. {$IFDEF WINDOWS}
  54.   WinTypes, WinProcs,  Buttons, Controls, Forms, Graphics, StdCtrls,
  55. {$ENDIF}
  56. {$IFDEF WIN32}
  57.   Windows,
  58.   Buttons, Controls, Forms, Graphics, StdCtrls,
  59. {$ENDIF}
  60. {$IFDEF LINUX}
  61.   QButtons, QControls, QForms, QGraphics, QStdCtrls,
  62. {$ENDIF}
  63.   Misc, Nedit, Plotdefs;
  64.  
  65. type
  66.   TZoomForm = class(TForm)
  67.     HelpBitBtn: TBitBtn;
  68.     CancelBitBtn: TBitBtn;
  69.     ApplyBitBtn: TBitBtn;
  70.     XMinLabel: TLabel;
  71.     XMaxLabel: TLabel;
  72.     YMinLabel: TLabel;
  73.     YMaxLabel: TLabel;
  74.     XMinNEdit: TNEdit;
  75.     XMaxNEdit: TNEdit;
  76.     YMinNEdit: TNEdit;
  77.     YMaxNEdit: TNEdit;
  78.     OKBitBtn: TBitBtn;
  79.     procedure FormCreate(Sender: TObject);
  80.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  81.     procedure ApplyBitBtnClick(Sender: TObject);
  82.   private
  83.  
  84.   public
  85.     ThePlot: TObject;
  86. {$IFNDEF LANG_ENGLISH}
  87.     procedure DoCaptionsFromResource;
  88. {$ENDIF}
  89.     procedure DoHintsFromResource;
  90.   end;
  91.  
  92. var
  93.   ZoomForm: TZoomForm;
  94.  
  95. implementation
  96.  
  97. {$R *.dfm}
  98.  
  99. uses
  100.   Plot;
  101.   
  102. {------------------------------------------------------------------------------
  103.     Procedure: TZoomForm.FormCreate
  104.   Description: standard FormCreate procedure
  105.        Author: Mat Ballard
  106.  Date created: 04/25/2000
  107. Date modified: 04/25/2000 by Mat Ballard
  108.       Purpose: sets the position
  109.  Known Issues:
  110.  ------------------------------------------------------------------------------}
  111. procedure TZoomForm.FormCreate(Sender: TObject);
  112. var
  113.   i: Integer;
  114. begin
  115. {$IFNDEF LANG_ENGLISH}
  116.   DoCaptionsFromResource;
  117. {$ENDIF}
  118.   DoHintsFromResource;
  119. {set all widths:}
  120.   for i := 0 to Self.ComponentCount - 1 do
  121.     TControl(Self.Components[i]).Width := 97;
  122.  
  123.   SetDialogGeometry(Self, OKBitBtn, HelpBitBtn.Left);
  124. end;
  125.  
  126. {------------------------------------------------------------------------------
  127.     Procedure: TZoomForm.DoCaptionsFromResource
  128.   Description: standard loading of labels from resources
  129.        Author: Mat Ballard
  130.  Date created: 06/25/2001
  131. Date modified: 06/25/2001 by Mat Ballard
  132.       Purpose: display in different languages
  133.  Known Issues:
  134.  ------------------------------------------------------------------------------}
  135. {$IFNDEF LANG_ENGLISH}
  136. procedure TZoomForm.DoCaptionsFromResource;
  137. begin
  138.   Self.Caption := sZooming + ' ' + strIn;
  139.   XMinLabel.Caption := 'X ' + sMin;
  140.   XMaxLabel.Caption := 'X ' + sMax;
  141.   YMinLabel.Caption := 'Y ' + sMin;
  142.   YMaxLabel.Caption := 'Y ' + sMax;
  143.   HelpBitBtn.Caption := sHelp;
  144.   CancelBitBtn.Caption := sCancel;
  145.   OKBitBtn.Caption := sOk;
  146.   ApplyBitBtn.Caption := sApply;
  147. end;
  148. {$ENDIF}
  149.  
  150. {------------------------------------------------------------------------------
  151.     Procedure: TZoomForm.DoHintsFromResource
  152.   Description: standard loading of Hints from resources
  153.        Author: Mat Ballard
  154.  Date created: 06/25/2001
  155. Date modified: 06/25/2001 by Mat Ballard
  156.       Purpose: display in different languages
  157.  Known Issues:
  158.  ------------------------------------------------------------------------------}
  159. procedure TZoomForm.DoHintsFromResource;
  160. begin
  161.   ApplyBitBtn.Hint := sApplyHint;
  162. end;
  163.  
  164. {------------------------------------------------------------------------------
  165.     Procedure: TZoomForm.FormClose
  166.   Description: standard FormClose procedure
  167.        Author: Mat Ballard
  168.  Date created: 04/25/2000
  169. Date modified: 04/25/2000 by Mat Ballard
  170.       Purpose: checks for valid user input
  171.  Known Issues:
  172.  ------------------------------------------------------------------------------}
  173. procedure TZoomForm.FormClose(Sender: TObject; var Action: TCloseAction);
  174. var
  175.   Test, TestMax: Single;
  176. begin
  177. {Check that floating point values are valid:}
  178.   Action := caHide;
  179.   try
  180.     XMinNEdit.SetFocus;
  181.     Test := StrToFloat(XMinNEdit.Text);
  182.     XMaxNEdit.SetFocus;
  183.     TestMax := StrToFloat(XMaxNEdit.Text);
  184.     if (TestMax < Test) then
  185.       ERangeError.CreateFmt(sFormClose1, [Test, TestMax]);
  186.     YMinNEdit.SetFocus;
  187.     Test := StrToFloat(YMinNEdit.Text);
  188.     YMaxNEdit.SetFocus;
  189.     TestMax := StrToFloat(YMaxNEdit.Text);
  190.     if (TestMax < Test) then
  191.       ERangeError.CreateFmt(sFormClose1,
  192.         [Test, TestMax]);
  193. {We do the above and below the squelch the warning messages.}
  194.     Tag := Trunc(Test);
  195.   except
  196. {Prevent closure:}
  197.     Action := caNone;
  198.   end;
  199. end;
  200.  
  201.  
  202. procedure TZoomForm.ApplyBitBtnClick(Sender: TObject);
  203. begin
  204.   TPlot(ThePlot).ApplyZoom(Self);
  205. end;
  206.  
  207. end.
  208.