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

  1. unit Propedit;
  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: PropEdit.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: 10/10/2000
  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 edit various TPlot properties not covered by other dialogs..
  45.  
  46. Known Issues:
  47. -----------------------------------------------------------------------------}
  48.  
  49. interface
  50.  
  51. uses
  52.   Classes, SysUtils, TypInfo,
  53. {$IFDEF WINDOWS}
  54.   WinTypes, WinProcs,
  55.   Buttons, Controls, ComCtrls, ExtCtrls, Forms, Graphics, Printers, StdCtrls,
  56. {$ENDIF}
  57. {$IFDEF WIN32}
  58.   Windows,
  59.   Buttons, Controls, ComCtrls, ExtCtrls, Forms, Graphics, Printers, StdCtrls,
  60. {$ENDIF}
  61. {$IFDEF LINUX}
  62.   QButtons, QControls, QExtCtrls, QForms, QGraphics, QPrinters, QStdCtrls,
  63. {$ENDIF}
  64.  
  65.   Axis, Misc, Plotdefs, Nedit, Coloredt;
  66.  
  67. type
  68.   TPlotPropertyEditorForm = class(TForm)
  69.     HelpBitBtn: TBitBtn;
  70.     CancelBitBtn: TBitBtn;
  71.     OKBitBtn: TBitBtn;
  72.     PlotTypeComboBox: TComboBox;
  73.     PlotTypeLabel: TLabel;
  74.     MultiplicityLabel: TLabel;
  75.     ColorLabel: TLabel;
  76.     CreatedByEdit: TEdit;
  77.     DescriptionEdit: TEdit;
  78.     CreatedByLabel: TLabel;
  79.     DescriptionLabel: TLabel;
  80.     MultiplicityPenGroupBox: TGroupBox;
  81.     MultiplicityPenColorLabel: TLabel;
  82.     MultiplicityPenWidthLabel: TLabel;
  83.     MultiplicityPenStyleLabel: TLabel;
  84.     PenWidthComboBox: TComboBox;
  85.     PenStyleComboBox: TComboBox;
  86.     PieRowCountComboBox: TComboBox;
  87.     PieRowCountLabel: TLabel;
  88.     ClickAndDragDelayNEdit: TNEdit;
  89.     DragDelayLabel: TLabel;
  90.     ColumnGapLabel: TLabel;
  91.     ColumnGapNEdit: TNEdit;
  92.     PrintOrientLabel: TLabel;
  93.     PrintOrientationComboBox: TComboBox;
  94.     Label7: TLabel;
  95.     MultiplicityComboBox: TComboBox;
  96.     ZAxisAngleNEdit: TNEdit;
  97.     ZAxisAngleLabel: TLabel;
  98.     LinkZSeriesCheckBox: TCheckBox;
  99.     GridLabel: TLabel;
  100.     GridComboBox: TComboBox;
  101.     GridStyleComboBox: TComboBox;
  102.     GridStyleLabel: TLabel;
  103.     PenColorEdit: TColorEdit;
  104.     PolarRangeLabel: TLabel;
  105.     PolarRangeNEdit: TNEdit;
  106.     ApplyBitBtn: TBitBtn;
  107.     BubbleSizeLabel: TLabel;
  108.     BubbleSizeNEdit: TNEdit;
  109.     MultiJoinLabel: TLabel;
  110.     MultiJoinEdit: TEdit;
  111.     XYFastAtLabel: TLabel;
  112.     XYFastAtNEdit: TNEdit;
  113.     ZLengthLabel: TLabel;
  114.     ZLengthNEdit: TNEdit;
  115.     GridColorLabel: TLabel;
  116.     WallColorLabel: TLabel;
  117.     BackColorEdit: TColorEdit;
  118.     GridColorEdit: TColorEdit;
  119.     WallColorEdit: TColorEdit;
  120.     ContourGroupBox: TGroupBox;
  121.     ContourDetailLabel: TLabel;
  122.     ContourDetailComboBox: TComboBox;
  123.     ContourIntervalLabel: TLabel;
  124.     ContourIntervalNEdit: TNEdit;
  125.     ContourStartLabel: TLabel;
  126.     ContourStartNEdit: TNEdit;
  127.     ContourWireFrameCheckBox: TCheckBox;
  128.  
  129.     procedure FormCreate(Sender: TObject);
  130.     procedure PlotTypeComboBoxClick(Sender: TObject);
  131.     procedure FormShow(Sender: TObject);
  132.     procedure HelpBitBtnClick(Sender: TObject);
  133.     procedure ApplyBitBtnClick(Sender: TObject);
  134.  
  135.   private
  136.  
  137.   public
  138.     ThePlot: TObject;
  139.  
  140. {$IFNDEF LANG_ENGLISH}
  141.     procedure DoCaptionsFromResource;
  142. {$ENDIF}
  143.     procedure DoHintsFromResource;
  144.   end;
  145.  
  146. var
  147.   PlotPropertyEditorForm: TPlotPropertyEditorForm;
  148.  
  149. implementation
  150.  
  151. {$R *.dfm}
  152.  
  153. uses
  154.   Data, Plot;
  155.  
  156. {------------------------------------------------------------------------------
  157.     Procedure: TPointEditorForm.FormCreate
  158.   Description: standard FormCreate procedure
  159.        Author: Mat Ballard
  160.  Date created: 10/10/2000
  161. Date modified: 10/10/2000 by Mat Ballard
  162.       Purpose: sets the position
  163.  Known Issues:
  164.  ------------------------------------------------------------------------------}
  165. procedure TPlotPropertyEditorForm.FormCreate(Sender: TObject);
  166. var
  167.   i: TColor;
  168. begin
  169. {$IFNDEF LANG_ENGLISH}
  170.   DoCaptionsFromResource;
  171. {$ENDIF}
  172.   DoHintsFromResource;
  173.  
  174.   SetDialogGeometry(Self, ApplyBitBtn, PlotTypeLabel.Left);
  175.  
  176. {set combo and edit box widths:}
  177.   for i := 0 to Self.ComponentCount - 1 do
  178.     if ((Self.Components[i] is TNEdit) or
  179.         (Self.Components[i] is TColorEdit) or
  180.         (Self.Components[i] is TComboBox)) then
  181.       TControl(Self.Components[i]).Width := 88;
  182.   for i := 0 to Self.ComponentCount - 1 do
  183.     if (Self.Components[i] is TBitBtn) then
  184.       TControl(Self.Components[i]).Width := 97;
  185. {the exceptions:}
  186.   PieRowCountComboBox.Width := 50;
  187.   ClickAndDragDelayNEdit.Width := 64;
  188.   ZAxisAngleNEdit.Width := 64;
  189.  
  190.   BubbleSizeNEdit.Top := MultiplicityComboBox.Top;
  191.   BubbleSizeLabel.Top := MultiplicityLabel.Top;
  192.   ColumnGapLabel.Top := MultiplicityLabel.Top;
  193.   ColumnGapNEdit.Top := MultiplicityComboBox.Top;
  194.   ContourGroupBox.Top := MultiplicityPenGroupBox.Top;
  195.   ContourWireFrameCheckBox.Left := ContourStartNEdit.Left;
  196.   PieRowCountLabel.Top := MultiplicityLabel.Top;
  197.   PieRowCountComboBox.Top := MultiplicityComboBox.Top;
  198.   PolarRangeLabel.Top := MultiplicityLabel.Top;
  199.   PolarRangeNEdit.Top := MultiplicityComboBox.Top;
  200.   XYFastAtNEdit.Top := MultiplicityComboBox.Top;
  201.   XYFastAtLabel.Top := MultiplicityLabel.Top;
  202.   //ZAxisAngleLabel.Top := MultiJoinLabel.Top;
  203.   //ZAxisAngleNEdit.Top := MultiJoinEdit.Top;
  204.   ZLengthNEdit.Top := ZAxisAngleNEdit.Top;
  205.   ZLengthLabel.Top := ZAxisAngleLabel.Top;
  206.  
  207. {Populate the combo boxes:}
  208.   for i := 0 to Ord(High(TContourDetail)) do
  209.     ContourDetailComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TContourDetail), i), 3, 99));
  210.   for i := 0 to Ord(High(TGridType)) do
  211.     GridComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TGridType), i), 3, 99));
  212.   for i := 0 to Ord(High(TPenStyle)) do
  213.     GridStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPenStyle), i), 3, 99));
  214.   for i := 0 to Ord(High(TPlotType)) do
  215.     PlotTypeComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPlotType), i), 3, 99));
  216.   for i := 0 to Ord(High(TPenStyle)) do
  217.     PenStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPenStyle), i), 3, 99));
  218.   for i := 0 to Ord(High(TPrinterOrientation)) do
  219.     PrintOrientationComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPrinterOrientation), i), 3, 99));
  220.   for i := 0 to 20 do
  221.     PenWidthComboBox.Items.Add(IntToStr(i));
  222. end;
  223.  
  224. {------------------------------------------------------------------------------
  225.     Procedure: TPlotPropertyEditorForm.DoCaptionsFromResource
  226.   Description: standard loading of labels from resources
  227.        Author: Mat Ballard
  228.  Date created: 06/25/2001
  229. Date modified: 06/25/2001 by Mat Ballard
  230.       Purpose: display in different languages
  231.  Known Issues:
  232.  ------------------------------------------------------------------------------}
  233. {$IFNDEF LANG_ENGLISH}
  234. procedure TPlotPropertyEditorForm.DoCaptionsFromResource;
  235. begin
  236.   Self.Caption := sPlot + ' ' + sProperty + ' ' + sEditor;
  237.   PlotTypeLabel.Caption := sPlot + ' ' + sType;
  238.   ColorLabel.Caption := sColor;
  239.   GridLabel.Caption := sGrid + ' ' + sType;
  240.   GridStyleLabel.Caption := sGrid + ' ' + sStyle;
  241.   GridColorLabel.Caption := sGrid + ' ' + sColor;
  242.   WallColorLabel.Caption := sWall + ' ' + sColor;
  243.   PrintOrientLabel.Caption := sPrintOrient;
  244.   DragDelayLabel.Caption := sDragDelay;
  245.   CreatedByLabel.Caption := sCreatedBy;
  246.   DescriptionLabel.Caption := sDescription;
  247.   MultiplicityLabel.Caption := sMultiplicity;
  248.   MultiJoinLabel.Caption := sMultiJoin;
  249.   MultiplicityPenGroupBox.Caption := sMultiplicity + ' ' + sPen;
  250.   MultiplicityPenColorLabel.Caption := sColor;
  251.   MultiplicityPenWidthLabel.Caption := sWidth;
  252.   MultiplicityPenStyleLabel.Caption := sStyle;
  253.   LinkZSeriesCheckBox.Caption := sLink + ' Z ' + sSeries;
  254.   ColumnGapLabel.Caption := sColumn + ' ' + sGap;
  255.   ContourGroupBox.Caption := sContour;
  256.   ContourDetailLabel.Caption := sDetail;
  257.   ContourIntervalLabel.Caption := sInterval;
  258.   ContourStartLabel.Caption := sStart;
  259.   PolarRangeLabel.Caption := sPolarRange;
  260.   BubbleSizeLabel.Caption := sBubble + ' ' + sSize;
  261.   ZAxisAngleLabel.Caption := 'Z ' + sAxis + ' ' + sAngle;
  262.   ZLengthLabel.Caption := 'Z ' + sLength;
  263.   XYFastAtLabel.Caption := sXYFastAt;
  264.   PieRowCountLabel.Caption := sPieRowCount;
  265.   HelpBitBtn.Caption := sHelp;
  266.   OKBitBtn.Caption := sOK;
  267.   CancelBitBtn.Caption := sCancel;
  268.   ApplyBitBtn.Caption := sApply;
  269. end;
  270. {$ENDIF}
  271.  
  272. {------------------------------------------------------------------------------
  273.     Procedure: TPlotPropertyEditorForm.DoHintsFromResource
  274.   Description: standard loading of Hints from resources
  275.        Author: Mat Ballard
  276.  Date created: 06/25/2001
  277. Date modified: 06/25/2001 by Mat Ballard
  278.       Purpose: display in different languages
  279.  Known Issues:
  280.  ------------------------------------------------------------------------------}
  281. procedure TPlotPropertyEditorForm.DoHintsFromResource;
  282. begin
  283.   PlotTypeComboBox.Hint := sPlotTypeComboBoxHint;
  284.   BackColorEdit.Hint := sBackColorEditHint;
  285.   GridComboBox.Hint := sGridComboBoxHint;
  286.   GridStyleComboBox.Hint := sGridStyleComboBoxHint;
  287.   GridColorEdit.Hint := sGridColorEditHint;
  288.   WallColorEdit.Hint := sWallColorEditHint;
  289.   ClickAndDragDelayNEdit.Hint := sClickAndDragDelayNEditHint;
  290.   CreatedByEdit.Hint := sCreatedByEditHint;
  291.   MultiplicityComboBox.Hint := sMultiplicityComboBoxHint;
  292.   MultiJoinEdit.Hint := sMultiJoinEditHint;
  293.   LinkZSeriesCheckBox.Hint := sLinkZSeriesCheckBoxHint;
  294.   MultiplicityPenGroupBox.Hint := sMultiplicityPenGroupBoxHint;
  295.   ColumnGapNEdit.Hint := sColumnGapNEditHint;
  296.   ContourGroupBox.Hint := sContourGroupBoxHint;
  297.   ContourDetailComboBox.Hint := sContourDetailComboBoxHint;
  298.   ContourIntervalNEdit.Hint := sContourIntervalNEditHint;
  299.   ContourStartNEdit.Hint := sContourStartNEditHint;
  300.   PolarRangeNEdit.Hint := sPolarRangeNEditHint;
  301.   BubbleSizeNEdit.Hint := sBubbleSizeNEditHint;
  302.   ZAxisAngleNEdit.Hint := sZAxisAngleNEditHint;
  303.   ZLengthNEdit.Hint := sZLengthNEditHint;
  304.   XYFastAtNEdit.Hint := sXYFastAtNEditHint;
  305.   PieRowCountComboBox.Hint := sPieRowCountComboBoxHint;
  306.   ApplyBitBtn.Hint := sApplyHint;
  307. end;
  308.  
  309. {------------------------------------------------------------------------------
  310.     Procedure: TPlotPropertyEditorForm.CancelBitBtnClick
  311.   Description: Standard ComboBoxChange event handler
  312.        Author: Mat Ballard
  313.  Date created: 10/10/2000
  314. Date modified: 10/10/2000 by Mat Ballard
  315.       Purpose: Disables and enables edit and combo boxes depending on the Plot Type
  316.  Known Issues:
  317.  ------------------------------------------------------------------------------}
  318. procedure TPlotPropertyEditorForm.PlotTypeComboBoxClick(Sender: TObject);
  319. begin
  320.   BubbleSizeNEdit.Visible := FALSE;
  321.   ContourGroupBox.Visible := FALSE;
  322.   ContourIntervalNEdit.Visible := FALSE;
  323.   ContourStartNEdit.Visible := FALSE;
  324.   ContourWireFrameCheckBox.Visible := FALSE;
  325.   ColumnGapNEdit.Visible := FALSE;
  326.   GridLabel.Enabled := FALSE;
  327.   LinkZSeriesCheckBox.Visible := FALSE;
  328.   MultiplicityComboBox.Visible := FALSE;
  329.   MultiJoinEdit.Visible := FALSE;
  330.   PieRowCountComboBox.Visible := FALSE;
  331.   PolarRangeNEdit.Visible := FALSE;
  332.   XYFastAtNEdit.Visible := FALSE;
  333.   ZAxisAngleNEdit.Visible := FALSE;
  334.  
  335.   case TPlotType(PlotTypeComboBox.ItemIndex) of
  336.     ptXY:
  337.       begin
  338.         GridLabel.Enabled := TRUE;
  339.         XYFastAtNEdit.Visible := TRUE;
  340.       end;
  341.     ptError: GridLabel.Enabled := TRUE;
  342.     ptMultiple:
  343.       begin
  344.         GridLabel.Enabled := TRUE;
  345.         MultiplicityComboBox.Visible := TRUE;
  346.         MultiJoinEdit.Visible := TRUE;
  347.       end;
  348.     ptBubble:
  349.       begin
  350.         BubbleSizeNEdit.Visible := TRUE;
  351.         GridLabel.Enabled := TRUE;
  352.       end;
  353.     ptColumn, ptStack, ptNormStack: ColumnGapNEdit.Visible := TRUE;
  354.     ptPie: PieRowCountComboBox.Visible := TRUE;
  355.     ptPolar: PolarRangeNEdit.Visible := TRUE;
  356.     ptLineContour:
  357.       begin
  358.         ContourGroupBox.Visible := TRUE;
  359.         ContourIntervalNEdit.Visible := TRUE;
  360.         ContourStartNEdit.Visible := TRUE;
  361.       end;
  362.     ptContour: ContourGroupBox.Visible := TRUE;
  363.     pt3DContour:
  364.       begin
  365.         GridLabel.Enabled := TRUE;
  366.         ContourGroupBox.Visible := TRUE;
  367.         ContourWireFrameCheckBox.Visible := TRUE;
  368.         ZAxisAngleNEdit.Visible := TRUE;
  369.       end;
  370.     pt3DWire:
  371.       begin
  372.         GridLabel.Enabled := TRUE;
  373.         ZAxisAngleNEdit.Visible := TRUE;
  374.         LinkZSeriesCheckBox.Visible := TRUE;
  375.       end;
  376.     pt3DColumn:
  377.       begin
  378.         GridLabel.Enabled := TRUE;
  379.         ColumnGapNEdit.Visible := TRUE;
  380.         ZAxisAngleNEdit.Visible := TRUE;
  381.       end;
  382.   end;
  383.  
  384.   ZLengthNEdit.Visible := ZAxisAngleNEdit.Visible;
  385.  
  386.   BubbleSizeLabel.Visible := BubbleSizeNEdit.Visible;
  387.   ColumnGapLabel.Visible := ColumnGapNEdit.Visible;
  388.   ContourDetailLabel.Visible := ContourDetailComboBox.Visible;
  389.   ContourIntervalLabel.Visible := ContourIntervalNEdit.Visible;
  390.   ContourStartLabel.Visible := ContourStartNEdit.Visible;
  391.   GridStyleLabel.Enabled := GridLabel.Enabled;
  392.   GridComboBox.Visible := GridLabel.Enabled;
  393.   GridStyleComboBox.Visible := GridLabel.Enabled;
  394.   GridColorLabel.Enabled := GridLabel.Enabled;
  395.   GridColorEdit.Visible := GridLabel.Enabled;
  396.   MultiplicityLabel.Visible := MultiplicityComboBox.Visible;
  397.   MultiplicityPenGroupBox.Visible := MultiplicityComboBox.Visible;
  398.   MultiJoinLabel.Visible := MultiJoinEdit.Visible;
  399.   PieRowCountLabel.Visible := PieRowCountComboBox.Visible;
  400.   PolarRangeLabel.Visible := PolarRangeNEdit.Visible;
  401.   WallColorLabel.Enabled := ZAxisAngleNEdit.Visible;
  402.   WallColorEdit.Visible := ZAxisAngleNEdit.Visible;
  403.   XYFastAtLabel.Visible := XYFastAtNEdit.Visible;
  404.   ZAxisAngleLabel.Visible := ZAxisAngleNEdit.Visible;
  405.   ZLengthLabel.Visible := ZAxisAngleNEdit.Visible;
  406. end;
  407.  
  408. procedure TPlotPropertyEditorForm.FormShow(Sender: TObject);
  409. begin
  410.   PlotTypeComboBoxClick(Self);
  411. end;
  412.  
  413. procedure TPlotPropertyEditorForm.HelpBitBtnClick(Sender: TObject);
  414. {$IFDEF LINUX}
  415. var
  416.   TheHelpFile: String;
  417. {$ENDIF}
  418. begin
  419. {$IFDEF LINUX}
  420.   TheHelpFile := 'hs' + IntToStr(HelpBitBtn.HelpContext) + '.htm';
  421. {$ENDIF}
  422. end;
  423.  
  424. {------------------------------------------------------------------------------
  425.     Procedure: TPlotPropertyEditorForm.ApplyBitBtnClick
  426.   Description: Standard ButtonClick event handler
  427.        Author: Mat Ballard
  428.  Date created: 03/28/2001
  429. Date modified: 03/28/2001 by Mat Ballard
  430.       Purpose: Applies the currently selected properties
  431.  Known Issues:
  432.  ------------------------------------------------------------------------------}
  433. procedure TPlotPropertyEditorForm.ApplyBitBtnClick(Sender: TObject);
  434. begin
  435.   TPlot(ThePlot).ApplyPropertiesChange(Self);
  436. end;
  437.  
  438.  
  439. end.
  440.