home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d12345 / CHEMPLOT.ZIP / TPlot / Propedit.pas < prev    next >
Pascal/Delphi Source File  |  2001-05-28  |  11KB  |  323 lines

  1. unit Propedit;
  2.  
  3. {-----------------------------------------------------------------------------
  4. The contents of this file are subject to the Q Public License
  5. ("QPL"); you may not use this file except in compliance
  6. with the QPL. You may obtain a copy of the QPL from 
  7. the file QPL.html in this distribution, derived from:
  8.  
  9. http://www.trolltech.com/products/download/freelicense/license.html
  10.  
  11. The QPL prohibits development of proprietary software. 
  12. There is a Professional Version of this software available for this. 
  13. Contact sales@chemware.hypermart.net for more information.
  14.  
  15. Software distributed under the QPL is distributed on an "AS IS" basis,
  16. WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the QPL for
  17. the specific language governing rights and limitations under the QPL.
  18.  
  19. The Original Code is: PropEdit.pas, released 12 September 2000.
  20.  
  21. The Initial Developer of the Original Code is Mat Ballard.
  22. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
  23. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
  24. All Rights Reserved.
  25.  
  26. Contributor(s): Mat Ballard                 e-mail: mat.ballard@chemware.hypermart.net.
  27.  
  28. Last Modified: 10/10/2000
  29. Current Version: 2.00
  30.  
  31. You may retrieve the latest version of this file from:
  32.  
  33.         http://Chemware.hypermart.net/
  34.  
  35. This work was created with the Project JEDI VCL guidelines:
  36.  
  37.         http://www.delphi-jedi.org/Jedi:VCLVCL
  38.  
  39. in mind. 
  40.  
  41. Purpose:
  42. To edit various TPlot properties not covered by other dialogs..
  43.  
  44. Known Issues:
  45. -----------------------------------------------------------------------------}
  46.  
  47. interface
  48.  
  49. uses
  50.   Classes, SysUtils, TypInfo,
  51. {$IFDEF WINDOWS}
  52.   WinTypes, WinProcs,
  53.   Buttons, Controls, ComCtrls, ExtCtrls, Forms, Graphics, Printers, StdCtrls,
  54. {$ENDIF}
  55. {$IFDEF WIN32}
  56.   Windows,
  57.   Buttons, Controls, ComCtrls, ExtCtrls, Forms, Graphics, Printers, StdCtrls,
  58. {$ENDIF}
  59. {$IFDEF LINUX}
  60.   QButtons, QControls, QExtCtrls, QForms, QGraphics, QPrinters, QStdCtrls,
  61. {$ENDIF}
  62.  
  63.   Axis, Misc, Plotdefs, Nedit, Coloredt;
  64.  
  65. type
  66.   TPlotPropertyEditorForm = class(TForm)
  67.     HelpBitBtn: TBitBtn;
  68.     CancelBitBtn: TBitBtn;
  69.     OKBitBtn: TBitBtn;
  70.     PlotTypeComboBox: TComboBox;
  71.     PlotTypeLabel: TLabel;
  72.     MultiplicityLabel: TLabel;
  73.     Label3: TLabel;
  74.     CreatedByEdit: TEdit;
  75.     DescriptionEdit: TEdit;
  76.     Label4: TLabel;
  77.     Label5: TLabel;
  78.     MultiplicityPenGroupBox: TGroupBox;
  79.     PenColorLabel: TLabel;
  80.     PenWidthLabel: TLabel;
  81.     PenStyleLabel: TLabel;
  82.     PenWidthComboBox: TComboBox;
  83.     PenStyleComboBox: TComboBox;
  84.     PieRowCountComboBox: TComboBox;
  85.     PieRowCountLabel: TLabel;
  86.     ClickAndDragDelayNEdit: TNEdit;
  87.     Label2: TLabel;
  88.     ColumnGapLabel: TLabel;
  89.     ColumnGapNEdit: TNEdit;
  90.     Label6: TLabel;
  91.     PrintOrientationComboBox: TComboBox;
  92.     Label7: TLabel;
  93.     BackColorEdit: TEdit;
  94.     MultiplicityComboBox: TComboBox;
  95.     ZAxisAngleNEdit: TNEdit;
  96.     ZAxisAngleLabel: TLabel;
  97.     ContourDetailLabel: TLabel;
  98.     ContourDetailComboBox: TComboBox;
  99.     LinkZSeriesCheckBox: TCheckBox;
  100.     GridLabel: TLabel;
  101.     GridComboBox: TComboBox;
  102.     GridStyleComboBox: TComboBox;
  103.     GridStyleLabel: TLabel;
  104.     PenColorEdit: TColorEdit;
  105.     PolarRangeLabel: TLabel;
  106.     PolarRangeNEdit: TNEdit;
  107.     ApplyBitBtn: TBitBtn;
  108.     BubbleSizeLabel: TLabel;
  109.     BubbleSizeNEdit: TNEdit;
  110.     MultiJoinLabel: TLabel;
  111.     MultiJoinEdit: TEdit;
  112.     XYFastAtLabel: TLabel;
  113.     XYFastAtNEdit: TNEdit;
  114.  
  115.     procedure FormCreate(Sender: TObject);
  116.     procedure PlotTypeComboBoxClick(Sender: TObject);
  117.     procedure FormShow(Sender: TObject);
  118.     procedure BackColorEditClick(Sender: TObject);
  119.     procedure BackColorEditKeyDown(Sender: TObject; var Key: Word;
  120.       Shift: TShiftState);
  121.     procedure HelpBitBtnClick(Sender: TObject);
  122.     procedure ApplyBitBtnClick(Sender: TObject);
  123.  
  124.   private
  125.  
  126.   public
  127.     ThePlot: TObject;
  128.  
  129.   end;
  130.  
  131. var
  132.   PlotPropertyEditorForm: TPlotPropertyEditorForm;
  133.  
  134. implementation
  135.  
  136. {$R *.dfm}
  137.  
  138. uses
  139.   Data, Plot;
  140.  
  141. {------------------------------------------------------------------------------
  142.     Procedure: TPointEditorForm.FormCreate
  143.   Description: standard FormCreate procedure
  144.        Author: Mat Ballard
  145.  Date created: 10/10/2000
  146. Date modified: 10/10/2000 by Mat Ballard
  147.       Purpose: sets the position
  148.  Known Issues:
  149.  ------------------------------------------------------------------------------}
  150. procedure TPlotPropertyEditorForm.FormCreate(Sender: TObject);
  151. var
  152.   i: TColor;
  153. begin
  154.   SetDialogGeometry(Self, ApplyBitBtn, PlotTypeLabel.Left);
  155.  
  156. {set combo and edit box widths:}
  157.   for i := 0 to Self.ComponentCount - 1 do
  158.     if ((Self.Components[i] is TNEdit) or
  159.         (Self.Components[i] is TColorEdit) or
  160.         (Self.Components[i] is TComboBox)) then
  161.       TControl(Self.Components[i]).Width := 88;
  162. {the exceptions:}
  163.   PieRowCountComboBox.Width := 64;
  164.   PenWidthComboBox.Width := 64;
  165.   ContourDetailComboBox.Width := 73;
  166.   ClickAndDragDelayNEdit.Width := 48;
  167.   ZAxisAngleNEdit.Width := 73;
  168.  
  169.   BubbleSizeNEdit.Top := MultiplicityComboBox.Top;
  170.   BubbleSizeLabel.Top := MultiplicityLabel.Top;
  171.   ColumnGapLabel.Top := MultiplicityLabel.Top;
  172.   ColumnGapNEdit.Top := MultiplicityComboBox.Top;
  173.   ContourDetailLabel.Top := MultiplicityLabel.Top;
  174.   ContourDetailComboBox.Top := MultiplicityComboBox.Top;
  175.   PieRowCountLabel.Top := MultiplicityLabel.Top;
  176.   PieRowCountComboBox.Top := MultiplicityComboBox.Top;
  177.   PolarRangeLabel.Top := MultiplicityLabel.Top;
  178.   PolarRangeNEdit.Top := MultiplicityComboBox.Top;
  179.   XYFastAtNEdit.Top := MultiplicityComboBox.Top;
  180.   XYFastAtLabel.Top := MultiplicityLabel.Top;
  181.   ZAxisAngleLabel.Top := MultiJoinLabel.Top;
  182.   ZAxisAngleNEdit.Top := MultiJoinEdit.Top;
  183.  
  184. {Populate the combo boxes:}
  185.   for i := 0 to Ord(High(TContourDetail)) do
  186.     ContourDetailComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TContourDetail), i), 3, 99));
  187.   for i := 0 to Ord(High(TGridType)) do
  188.     GridComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TGridType), i), 3, 99));
  189.   for i := 0 to Ord(High(TPenStyle)) do
  190.     GridStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPenStyle), i), 3, 99));
  191.   for i := 0 to Ord(High(TPlotType)) do
  192.     PlotTypeComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPlotType), i), 3, 99));
  193.   for i := 0 to Ord(High(TPenStyle)) do
  194.     PenStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPenStyle), i), 3, 99));
  195.   for i := 0 to Ord(High(TPrinterOrientation)) do
  196.     PrintOrientationComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPrinterOrientation), i), 3, 99));
  197.   for i := 0 to 20 do
  198.     PenWidthComboBox.Items.Add(IntToStr(i));
  199. end;
  200.  
  201. {------------------------------------------------------------------------------
  202.     Procedure: TPointEditorForm.CancelBitBtnClick
  203.   Description: Standard ComboBoxChange event handler
  204.        Author: Mat Ballard
  205.  Date created: 10/10/2000
  206. Date modified: 10/10/2000 by Mat Ballard
  207.       Purpose: Disables and enables edit and combo boxes depending on the Plot Type
  208.  Known Issues:
  209.  ------------------------------------------------------------------------------}
  210. procedure TPlotPropertyEditorForm.PlotTypeComboBoxClick(Sender: TObject);
  211. begin
  212.   BubbleSizeNEdit.Visible := FALSE;
  213.   ContourDetailComboBox.Visible := FALSE;
  214.   ColumnGapNEdit.Visible := FALSE;
  215.   GridLabel.Enabled := FALSE;
  216.   LinkZSeriesCheckBox.Visible := FALSE;
  217.   MultiplicityComboBox.Visible := FALSE;
  218.   MultiJoinEdit.Visible := FALSE;
  219.   PieRowCountComboBox.Visible := FALSE;
  220.   PolarRangeNEdit.Visible := FALSE;
  221.   XYFastAtNEdit.Visible := FALSE;
  222.   ZAxisAngleNEdit.Visible := FALSE;
  223.  
  224.   case TPlotType(PlotTypeComboBox.ItemIndex) of
  225.     ptXY:
  226.       begin
  227.         GridLabel.Enabled := TRUE;
  228.         XYFastAtNEdit.Visible := TRUE;
  229.       end;
  230.     ptError: GridLabel.Enabled := TRUE;
  231.     ptMultiple:
  232.       begin
  233.         GridLabel.Enabled := TRUE;
  234.         MultiplicityComboBox.Visible := TRUE;
  235.         MultiJoinEdit.Visible := TRUE;
  236.       end;
  237.     ptBubble:
  238.       begin
  239.         BubbleSizeNEdit.Visible := TRUE;
  240.         GridLabel.Enabled := TRUE;
  241.       end;
  242.     ptColumn, ptStack, ptNormStack: ColumnGapNEdit.Visible := TRUE;
  243.     ptPie: PieRowCountComboBox.Visible := TRUE;
  244.     ptPolar: PolarRangeNEdit.Visible := TRUE;
  245.     ptContour: ContourDetailComboBox.Visible := TRUE;
  246.     pt3DContour:
  247.       begin
  248.         ContourDetailComboBox.Visible := TRUE;
  249.         ZAxisAngleNEdit.Visible := TRUE;
  250.       end;
  251.     pt3DWire:
  252.       begin
  253.         ZAxisAngleNEdit.Visible := TRUE;
  254.         LinkZSeriesCheckBox.Visible := TRUE;
  255.       end;
  256.   end;
  257.  
  258.   BubbleSizeLabel.Visible := BubbleSizeNEdit.Visible;
  259.   ColumnGapLabel.Visible := ColumnGapNEdit.Visible;
  260.   ContourDetailLabel.Visible := ContourDetailComboBox.Visible;
  261.   GridStyleLabel.Enabled := GridLabel.Enabled;
  262.   GridComboBox.Visible := GridLabel.Enabled;
  263.   GridStyleComboBox.Visible := GridLabel.Enabled;
  264.   MultiplicityLabel.Visible := MultiplicityComboBox.Visible;
  265.   MultiplicityPenGroupBox.Visible := MultiplicityComboBox.Visible;
  266.   MultiJoinLabel.Visible := MultiJoinEdit.Visible;
  267.   PieRowCountLabel.Visible := PieRowCountComboBox.Visible;
  268.   PolarRangeLabel.Visible := PolarRangeNEdit.Visible;
  269.   XYFastAtLabel.Visible := XYFastAtNEdit.Visible;
  270.   ZAxisAngleLabel.Visible := ZAxisAngleNEdit.Visible;
  271. end;
  272.  
  273. procedure TPlotPropertyEditorForm.FormShow(Sender: TObject);
  274. begin
  275.   PlotTypeComboBoxClick(Self);
  276. end;
  277.  
  278. procedure TPlotPropertyEditorForm.BackColorEditClick(Sender: TObject);
  279. var
  280.   AColor: TColor;
  281. begin
  282.   AColor := BackColorEdit.Color;
  283.   if (InputColor(AColor)) then
  284.   begin
  285.     BackColorEdit.Color := AColor;
  286.     BackColorEdit.Text := ColorToString(BackColorEdit.Color);
  287.   end;
  288. end;
  289.  
  290. procedure TPlotPropertyEditorForm.BackColorEditKeyDown(Sender: TObject;
  291.   var Key: Word; Shift: TShiftState);
  292. begin
  293.   BackColorEditClick(Self);
  294. end;
  295.  
  296. procedure TPlotPropertyEditorForm.HelpBitBtnClick(Sender: TObject);
  297. {$IFDEF LINUX}
  298. var
  299.   TheHelpFile: String;
  300. {$ENDIF}
  301. begin
  302. {$IFDEF LINUX}
  303.   TheHelpFile := 'hs' + IntToStr(HelpBitBtn.HelpContext) + '.htm';
  304. {$ENDIF}
  305. end;
  306.  
  307. {------------------------------------------------------------------------------
  308.     Procedure: TPlotPropertyEditorForm.ApplyBitBtnClick
  309.   Description: Standard ButtonClick event handler
  310.        Author: Mat Ballard
  311.  Date created: 03/28/2001
  312. Date modified: 03/28/2001 by Mat Ballard
  313.       Purpose: Applies the currently selected properties
  314.  Known Issues:
  315.  ------------------------------------------------------------------------------}
  316. procedure TPlotPropertyEditorForm.ApplyBitBtnClick(Sender: TObject);
  317. begin
  318.   TPlot(ThePlot).ApplyPropertiesChange(Self);
  319. end;
  320.  
  321.  
  322. end.
  323.