1 | {
|
---|
2 | Maze scaling form of the Lazarus Mazes program
|
---|
3 |
|
---|
4 | Copyright (C) 2012 G.A. Nijland (eny @ lazarus forum http://www.lazarus.freepascal.org/)
|
---|
5 |
|
---|
6 | This source is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
|
---|
7 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
|
---|
8 | version.
|
---|
9 |
|
---|
10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
---|
11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
12 | details.
|
---|
13 |
|
---|
14 | A copy of the GNU General Public License is available on the World Wide Web at
|
---|
15 | <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing to the Free Software Foundation, Inc., 59
|
---|
16 | Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
17 | }
|
---|
18 | unit ufrmScaling;
|
---|
19 |
|
---|
20 | {$mode objfpc}{$H+}
|
---|
21 |
|
---|
22 | interface
|
---|
23 |
|
---|
24 | uses
|
---|
25 | LazesGlobals,
|
---|
26 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls;
|
---|
27 |
|
---|
28 | type
|
---|
29 |
|
---|
30 | { TfrmScaling }
|
---|
31 |
|
---|
32 | TfrmScaling = class(TForm)
|
---|
33 | cbLocked: TCheckBox;
|
---|
34 | cbLockedDrawing: TCheckBox;
|
---|
35 | Label1: TLabel;
|
---|
36 | Label2: TLabel;
|
---|
37 | Label3: TLabel;
|
---|
38 | Label4: TLabel;
|
---|
39 | Label5: TLabel;
|
---|
40 | Label6: TLabel;
|
---|
41 | tbHeightDrawing: TTrackBar;
|
---|
42 | tbWidth: TTrackBar;
|
---|
43 | tbHeight: TTrackBar;
|
---|
44 | tbWidthDrawing: TTrackBar;
|
---|
45 | procedure cbLockedChange(Sender: TObject);
|
---|
46 | procedure cbLockedDrawingChange(Sender: TObject);
|
---|
47 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
48 | procedure FormCreate(Sender: TObject);
|
---|
49 | procedure tbHeightChange(Sender: TObject);
|
---|
50 | procedure tbHeightDrawingChange(Sender: TObject);
|
---|
51 | procedure tbWidthChange(Sender: TObject);
|
---|
52 | procedure tbWidthDrawingChange(Sender: TObject);
|
---|
53 |
|
---|
54 | private
|
---|
55 | { private declarations }
|
---|
56 | MazeMetrics: TMazeUpdateInfo;
|
---|
57 |
|
---|
58 | procedure CheckLock(pCB: TCheckBox; pMaster, pSlave: TTrackBar);
|
---|
59 | procedure UpdateMaze;
|
---|
60 |
|
---|
61 | public
|
---|
62 | { public declarations }
|
---|
63 | end;
|
---|
64 |
|
---|
65 | var
|
---|
66 | frmScaling: TfrmScaling;
|
---|
67 |
|
---|
68 | implementation
|
---|
69 |
|
---|
70 | {$R *.lfm}
|
---|
71 |
|
---|
72 | uses
|
---|
73 | ufrmMain1;
|
---|
74 |
|
---|
75 | { TfrmScaling }
|
---|
76 |
|
---|
77 | procedure TfrmScaling.FormCreate(Sender: TObject);
|
---|
78 | begin
|
---|
79 | // Get some global settings
|
---|
80 | tbWidth.Min := C_MIN_MAZE_SIZE;
|
---|
81 | tbWidth.Max := C_MAX_MAZE_SIZE;
|
---|
82 | tbHeight.Min := C_MIN_MAZE_SIZE;
|
---|
83 | tbHeight.Max := C_MAX_MAZE_SIZE;
|
---|
84 |
|
---|
85 | // Because of an omission on the OI the checkbox font
|
---|
86 | // needs to be set separately
|
---|
87 | cbLocked.Font.Style := [];
|
---|
88 | cbLocked.Font.Color := Label1.Font.Color;
|
---|
89 | cbLockedDrawing.Font.Style := [];
|
---|
90 | cbLockedDrawing.Font.Color := Label1.Font.Color;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TfrmScaling.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
94 | begin
|
---|
95 | CloseAction := caHide;
|
---|
96 | end;
|
---|
97 |
|
---|
98 | procedure TfrmScaling.CheckLock(pCB: TCheckBox; pMaster, pSlave: TTrackBar);
|
---|
99 | begin
|
---|
100 | if pCB.Checked then
|
---|
101 | if pMaster.Position <> pSlave.Position then
|
---|
102 | pSlave.Position := pMaster.Position;
|
---|
103 | UpdateMaze;
|
---|
104 | end;
|
---|
105 |
|
---|
106 | procedure TfrmScaling.UpdateMaze;
|
---|
107 | begin
|
---|
108 | with MazeMetrics do
|
---|
109 | begin
|
---|
110 | MazeWidth := tbWidth.Position;
|
---|
111 | MazeHeight := tbHeight.Position;
|
---|
112 | DrawWidth := tbWidthDrawing.Position;
|
---|
113 | DrawHeight := tbHeightDrawing.Position;
|
---|
114 | end;
|
---|
115 | frmMain1.MazeMetrics := MazeMetrics;
|
---|
116 | end;
|
---|
117 |
|
---|
118 | procedure TfrmScaling.cbLockedChange(Sender: TObject);
|
---|
119 | begin
|
---|
120 | CheckLock(cbLocked, tbWidth, tbHeight);
|
---|
121 | end;
|
---|
122 |
|
---|
123 | procedure TfrmScaling.cbLockedDrawingChange(Sender: TObject);
|
---|
124 | begin
|
---|
125 | CheckLock(cbLockedDrawing, tbWidthDrawing, tbHeightDrawing)
|
---|
126 | end;
|
---|
127 |
|
---|
128 | procedure TfrmScaling.tbHeightChange(Sender: TObject);
|
---|
129 | begin
|
---|
130 | CheckLock(cbLocked, tbHeight, tbWidth)
|
---|
131 | end;
|
---|
132 |
|
---|
133 | procedure TfrmScaling.tbHeightDrawingChange(Sender: TObject);
|
---|
134 | begin
|
---|
135 | CheckLock(cbLockedDrawing, tbHeightDrawing, tbWidthDrawing)
|
---|
136 | end;
|
---|
137 |
|
---|
138 | procedure TfrmScaling.tbWidthChange(Sender: TObject);
|
---|
139 | begin
|
---|
140 | CheckLock(cbLocked, tbWidth, tbHeight)
|
---|
141 | end;
|
---|
142 |
|
---|
143 | procedure TfrmScaling.tbWidthDrawingChange(Sender: TObject);
|
---|
144 | begin
|
---|
145 | CheckLock(cbLockedDrawing, tbWidthDrawing, tbHeightDrawing)
|
---|
146 | end;
|
---|
147 |
|
---|
148 | end.
|
---|
149 |
|
---|