Source code of file oscpmwin_v0.1.2.189/configmod.pas from the
osCommerce Product Manager for Windows.
0000: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001: osCommerce Product Manager for Windows (oscpmwin).
0002: Copyright �2003,2004,2005 by Mario A. Valdez-Ramirez.
0003:
0004: You can contact Mario A. Valdez-Ramirez
0005: by email at mario@mariovaldez.org or paper mail at
0006: Olmos 809, San Nicolas, NL. 66495, Mexico.
0007:
0008: This program is free software; you can redistribute it and/or modify
0009: it under the terms of the GNU General Public License as published by
0010: the Free Software Foundation; either version 2 of the License, or (at
0011: your option) any later version.
0012:
0013: This program is distributed in the hope that it will be useful, but
0014: WITHOUT ANY WARRANTY; without even the implied warranty of
0015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0016: General Public License for more details.
0017:
0018: You should have received a copy of the GNU General Public License
0019: along with this program; if not, write to the Free Software
0020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0022: unit configmod;
0023:
0024: interface
0025:
0026: uses
0027: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
0028: Dialogs, StdCtrls, Spin, Buttons;
0029:
0030: type
0031: Topm_Form_ConfigMod = class(TForm)
0032: opm_BitBtn_ConfigModOk: TBitBtn;
0033: opm_BitBtn_ConfigModCancel: TBitBtn;
0034: opm_Label_ConfigModName: TLabel;
0035: opm_Edit_ConfigModName: TEdit;
0036: opm_Label_ConfigModFile: TLabel;
0037: opm_Edit_ConfigModCmd: TEdit;
0038: opm_BitBtn_ConfigModFile: TBitBtn;
0039: opm_Label_ConfigModPara: TLabel;
0040: opm_Edit_ConfigModPara: TEdit;
0041: opm_Label_ConfigModPort: TLabel;
0042: opm_SpinEdit_ConfigModPort: TSpinEdit;
0043: opm_CheckBox_ConfigModJustRun: TCheckBox;
0044: opm_CheckBox_ConfigModOnSelection: TCheckBox;
0045: opm_CheckBox_ConfigModRemote: TCheckBox;
0046: opm_Label_ConfigModIndex: TLabel;
0047: opm_ComboBox_ConfigModIndex: TComboBox;
0048: opm_Label_ConfigModResult: TLabel;
0049: opm_ComboBox_ConfigModResult: TComboBox;
0050: opm_OpenDialog_ConfigMod: TOpenDialog;
0051: procedure opm_BitBtn_ConfigModFileClick(Sender: TObject);
0052: procedure opm_BitBtn_ConfigModOkClick(Sender: TObject);
0053: procedure FormCreate(Sender: TObject);
0054: procedure FormShow(Sender: TObject);
0055: private
0056: { Private declarations }
0057: public
0058: MC_Name : STRING;
0059: MC_AddEdit : BOOLEAN;
0060: end;
0061:
0062: var
0063: opm_Form_ConfigMod: Topm_Form_ConfigMod;
0064:
0065: implementation
0066:
0067: {$R *.dfm}
0068:
0069: Uses gnugettext, oscpmdata, dataman, attention, balloons, modules;
0070:
0071:
0072: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0073: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0074: procedure Topm_Form_ConfigMod.opm_BitBtn_ConfigModFileClick (Sender: TObject);
0075: begin
0076: opm_OpenDialog_ConfigMod.DefaultExt := opmC_Def_LoadModExt;
0077: opm_OpenDialog_ConfigMod.FileName := '';
0078: opm_OpenDialog_ConfigMod.Filter := _('Executable files') + ' (' + opmC_Def_LoadModFilter + ')|' + opmC_Def_LoadModFilter + '|' + _('All files (*.*)');
0079: opm_OpenDialog_ConfigMod.Title := _('Choosing module file...');
0080: opm_OpenDialog_ConfigMod.InitialDir := opm_ModuleDirectory;
0081: IF (opm_OpenDialog_ConfigMod.Execute = TRUE) THEN
0082: BEGIN
0083: opm_Edit_ConfigModCmd.Text := TRIM (ExtractFileName (opm_OpenDialog_ConfigMod.FileName));
0084: END;
0085: end;
0086:
0087: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0088: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0089: procedure Topm_Form_ConfigMod.opm_BitBtn_ConfigModOkClick(Sender: TObject);
0090: begin
0091: opm_CurrentModuleRecord.Name := FNopm_CleanUploadName (TRIM (opm_Edit_ConfigModName.Text));
0092: opm_CurrentModuleRecord.CommandFile := ExtractFileName (TRIM (opm_Edit_ConfigModCmd.Text));
0093: opm_CurrentModuleRecord.CommandPara := TRIM (opm_Edit_ConfigModPara.Text);
0094: opm_CurrentModuleRecord.Port := opm_SpinEdit_ConfigModPort.Value;
0095: IF (opm_CheckBox_ConfigModRemote.Checked = TRUE) THEN opm_CurrentModuleRecord.Remote := 1 ELSE opm_CurrentModuleRecord.Remote := 0;
0096: IF (opm_CheckBox_ConfigModJustRun.Checked = TRUE) THEN opm_CurrentModuleRecord.JustRun := 1 ELSE opm_CurrentModuleRecord.JustRun := 0;
0097: IF (opm_CheckBox_ConfigModOnSelection.Checked = TRUE) THEN opm_CurrentModuleRecord.OnSelection := 1 ELSE opm_CurrentModuleRecord.OnSelection := 0;
0098: opm_CurrentModuleRecord.IndexData := TRIM (opm_ComboBox_ConfigModIndex.Text);
0099: opm_CurrentModuleRecord.ResultData := TRIM (opm_ComboBox_ConfigModResult.Text);
0100: IF (opm_FNSave_ModuleData (opm_CurrentModuleRecord) = FALSE) THEN
0101: BEGIN
0102: FNopm_Message (_('Missing or wrong data.'), mtError, [mbOK], opmG_UISilent);
0103: ModalResult := mrNone;
0104: END;
0105: end;
0106:
0107:
0108: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0109: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0110: procedure Topm_Form_ConfigMod.FormCreate(Sender: TObject);
0111: begin
0112: MC_Name := '';
0113: MC_AddEdit := FALSE;
0114: opm_SpinEdit_ConfigModPort.MinValue := opmC_Min_ModPort;
0115: opm_SpinEdit_ConfigModPort.MaxValue := opmC_Max_ModPort;
0116: opm_ComboBox_ConfigModIndex.Sorted := FALSE;
0117: opm_ComboBox_ConfigModResult.Sorted := FALSE;
0118: opm_Edit_ConfigModName.MaxLength := opmC_Max_ModNameWidth;
0119: opm_Edit_ConfigModCmd.MaxLength := opmC_Max_ModCMDWidth;
0120: TranslateComponent (self);
0121: end;
0122:
0123:
0124: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0125: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0126: procedure Topm_Form_ConfigMod.FormShow(Sender: TObject);
0127: begin
0128: opm_Form_ConfigMod.Caption := _('Module configuration');
0129: opm_ComboBox_ConfigModIndex.Items := opmG_ModIndexData_BoxList;
0130: opm_ComboBox_ConfigModResult.Items := opmG_ModResultData_BoxList;
0131: opm_Edit_ConfigModName.Enabled := MC_AddEdit;
0132: opm_CurrentModuleRecord := opm_FNLoad_ModuleData (MC_Name);
0133: IF (MC_AddEdit = TRUE) THEN
0134: BEGIN
0135: opm_Edit_ConfigModName.Text := '';
0136: opm_Edit_ConfigModCmd.Text := '';
0137: opm_Edit_ConfigModPara.Text := '';
0138: opm_SpinEdit_ConfigModPort.Value := opmC_Def_ModPort;
0139: opm_CheckBox_ConfigModRemote.Checked := FALSE;
0140: opm_CheckBox_ConfigModJustRun.Checked := FALSE;
0141: opm_CheckBox_ConfigModOnSelection.Checked := TRUE;
0142: opm_ComboBox_ConfigModIndex.ItemIndex := 0;
0143: opm_ComboBox_ConfigModResult.ItemIndex := 0;
0144: END
0145: ELSE
0146: BEGIN
0147: opm_Edit_ConfigModName.Text := opm_CurrentModuleRecord.Name;
0148: opm_Edit_ConfigModCmd.Text := opm_CurrentModuleRecord.CommandFile;
0149: opm_Edit_ConfigModPara.Text := opm_CurrentModuleRecord.CommandPara;
0150: opm_SpinEdit_ConfigModPort.Value := opm_CurrentModuleRecord.Port;
0151: opm_CheckBox_ConfigModRemote.Checked := (opm_CurrentModuleRecord.Remote > 0);
0152: opm_CheckBox_ConfigModJustRun.Checked := (opm_CurrentModuleRecord.JustRun > 0);
0153: opm_CheckBox_ConfigModOnSelection.Checked := (opm_CurrentModuleRecord.OnSelection > 0);
0154: opm_ComboBox_ConfigModIndex.ItemIndex := opm_FNGetListIndexByString (opm_CurrentModuleRecord.IndexData, opmG_ModIndexData_BoxList);
0155: opm_ComboBox_ConfigModResult.ItemIndex := opm_FNGetListIndexByString (opm_CurrentModuleRecord.ResultData, opmG_ModResultData_BoxList);
0156: END;
0157: end;
0158:
0159: end.