[r190]: Transdlg.pas Maximize Restore History

Download this file

Transdlg.pas    233 lines (204 with data), 6.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
(*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Initial Developer of this code is John Hansen.
* Portions created by John Hansen are Copyright (C) 2009 John Hansen.
* All Rights Reserved.
*
*)
unit Transdlg;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
{$IFDEF FPC}
LResources,
{$ENDIF}
Classes, Controls, Graphics, Forms, Dialogs, StdCtrls, Buttons;
type
TfrmTransEdit = class(TForm)
lblTitle: TLabel;
lblProgram: TLabel;
lblParameters: TLabel;
lblMacros: TLabel;
lblWorkingDir: TLabel;
edTitle: TEdit;
edProgram: TEdit;
edWorkingDir: TEdit;
edParameters: TEdit;
MacroButton: TBitBtn;
MacroList: TListBox;
OKButton: TButton;
CancelButton: TButton;
InsertButton: TButton;
BrowseButton: TButton;
OpenDialog: TOpenDialog;
btnHelp: TButton;
chkWait: TCheckBox;
chkClose: TCheckBox;
lblExt: TLabel;
edtExt: TEdit;
chkRestrict: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure MacroButtonClick(Sender: TObject);
procedure BrowseButtonClick(Sender: TObject);
procedure InsertButtonClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure edTitleChange(Sender: TObject);
procedure MacroListClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
procedure btnHelpClick(Sender: TObject);
private
{ Private declarations }
bmpUp, bmpDn : TBitmap;
fCaptionHeight : integer;
procedure SetSize(bLarge : boolean = false);
function SizeIsLarge : boolean;
function GetMacroGlyph : TBitmap;
procedure UpdateButtonState;
procedure LoadMacros;
public
{ Public declarations }
end;
var
frmTransEdit: TfrmTransEdit;
TransferMacros : array[0..12] of String =
('$COL', '$ROW', '$CURTOKEN', '$PATH()', '$NAME()', '$NAMEONLY()',
'$EXT()', '$EDNAME', '$PROMPT()', '$SAVE', '$SAVEALL', '$PORT',
'$TARGET');
const
M_COL = 0;
M_ROW = 1;
M_CURTOKEN = 2;
M_PATH = 3;
M_NAME = 4;
M_NAMEONLY = 5;
M_EXT = 6;
M_EDNAME = 7;
M_PROMPT = 8;
M_SAVE = 9;
M_SAVEALL = 10;
M_PORT = 11;
M_TARGET = 12;
implementation
uses
SysUtils, uLocalizedStrings, uGuiUtils;
{$IFNDEF FPC}
{$R *.DFM}
{$ENDIF}
const
SMALL_SIZE = 160+28;
LARGE_SIZE = 282+28;
procedure TfrmTransEdit.FormCreate(Sender: TObject);
begin
LoadMacros;
fCaptionHeight := GetWindowTitleBarHeight;
bmpUp := TBitmap.Create;
bmpDn := TBitmap.Create;
bmpUp.LoadFromResourceName(HInstance, 'MACROUP');
bmpDn.LoadFromResourceName(HInstance, 'MACRODN');
SetSize;
UpdateButtonState;
end;
procedure TfrmTransEdit.FormDestroy(Sender: TObject);
begin
bmpUp.Free;
bmpDn.Free;
end;
procedure TfrmTransEdit.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
//
end;
procedure TfrmTransEdit.MacroButtonClick(Sender: TObject);
begin
SetSize(not SizeIsLarge);
end;
procedure TfrmTransEdit.BrowseButtonClick(Sender: TObject);
begin
if OpenDialog.Execute then
begin
edProgram.Text := OpenDialog.FileName;
edWorkingDir.Text := ExtractFileDir(OpenDialog.FileName);
end;
end;
procedure TfrmTransEdit.InsertButtonClick(Sender: TObject);
begin
if MacroList.ItemIndex <> -1 then
begin
edParameters.SelText := TransferMacros[MacroList.ItemIndex];
end;
end;
procedure TfrmTransEdit.SetSize(bLarge: boolean);
var
h : integer;
begin
if bLarge then
h := Trunc(LARGE_SIZE * (Screen.PixelsPerInch / 96))
else
h := Trunc(SMALL_SIZE * (Screen.PixelsPerInch / 96));
Height := h + fCaptionHeight;
MacroButton.Glyph := GetMacroGlyph;
end;
function TfrmTransEdit.SizeIsLarge: boolean;
begin
result := Height = Trunc(LARGE_SIZE * (Screen.PixelsPerInch / 96)) + fCaptionHeight;
end;
function TfrmTransEdit.GetMacroGlyph: TBitmap;
begin
result := bmpDn;
if SizeIsLarge then
result := bmpUp;
end;
procedure TfrmTransEdit.edTitleChange(Sender: TObject);
begin
UpdateButtonState;
end;
procedure TfrmTransEdit.UpdateButtonState;
begin
OKButton.Enabled := not ((edTitle.Text = '') or (edProgram.Text = ''));
InsertButton.Enabled := MacroList.ItemIndex <> -1;
end;
procedure TfrmTransEdit.MacroListClick(Sender: TObject);
begin
UpdateButtonState;
end;
procedure TfrmTransEdit.LoadMacros;
begin
MacroList.Items.Add(TransferMacros[0]+#9+sColMacro);
MacroList.Items.Add(TransferMacros[1]+#9+sRowMacro);
MacroList.Items.Add(TransferMacros[2]+#9+sCurTokenMacro);
MacroList.Items.Add(TransferMacros[3]+#9+sPathMacro);
MacroList.Items.Add(TransferMacros[4]+#9+sNameMacro);
MacroList.Items.Add(TransferMacros[5]+#9+sNameOnlyMacro);
MacroList.Items.Add(TransferMacros[6]+#9+sExtMacro);
MacroList.Items.Add(TransferMacros[7]+#9+sEdNameMacro);
MacroList.Items.Add(TransferMacros[8]+#9+sPromptMacro);
MacroList.Items.Add(TransferMacros[9]+#9+sSaveMacro);
MacroList.Items.Add(TransferMacros[10]+#9+sSaveAllMacro);
MacroList.Items.Add(TransferMacros[11]+#9+sPortMacro);
MacroList.Items.Add(TransferMacros[12]+#9+sTargetMacro);
end;
procedure TfrmTransEdit.OKButtonClick(Sender: TObject);
begin
// verify correctness of parameters
end;
procedure TfrmTransEdit.btnHelpClick(Sender: TObject);
begin
Application.HelpContext(HelpContext);
end;
{$IFDEF FPC}
initialization
{$i Transdlg.lrs}
{$ENDIF}
end.