fpvectorial: Fix misc issues in wmfviewer demo project.

This commit is contained in:
wp_xyz 2023-01-17 16:38:43 +01:00
parent bfc81e3972
commit ae2450bb4f
4 changed files with 308 additions and 178 deletions

View File

@ -1,37 +1,42 @@
object Form1: TForm1
Left = 218
object MainForm: TMainForm
Left = 277
Height = 511
Top = 155
Top = 151
Width = 738
Caption = 'Form1'
Caption = 'wmf Viewer'
ClientHeight = 511
ClientWidth = 738
OnActivate = FormActivate
OnCreate = FormCreate
OnDestroy = FormDestroy
LCLVersion = '1.7'
LCLVersion = '2.3.0.0'
object LeftPanel: TPanel
Left = 0
Height = 511
Top = 0
Left = 8
Height = 495
Top = 8
Width = 267
Align = alLeft
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 4
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 511
ClientHeight = 495
ClientWidth = 267
TabOrder = 0
object Splitter1: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 221
Top = 252
Width = 267
Align = alTop
ResizeAnchor = akTop
end
object ShellListView: TShellListView
Left = 0
Height = 285
Top = 226
Height = 238
Top = 257
Width = 267
Align = alClient
Color = clDefault
@ -47,12 +52,11 @@ object Form1: TForm1
object ShellTreeView: TShellTreeView
Left = 0
Height = 221
Top = 0
Top = 31
Width = 267
Align = alTop
FileSortType = fstNone
HideSelection = False
Images = ImageList
ReadOnly = True
TabOrder = 2
OnExpanded = ShellTreeViewExpanded
@ -62,28 +66,46 @@ object Form1: TForm1
ObjectTypes = [otFolders]
ShellListView = ShellListView
end
object CbHistory: TComboBox
Left = 0
Height = 23
Top = 0
Width = 267
Align = alTop
BorderSpacing.Bottom = 8
ItemHeight = 15
OnCloseUp = CbHistoryCloseUp
OnDrawItem = CbHistoryDrawItem
OnEditingDone = CbHistoryEditingDone
TabOrder = 3
end
end
object Splitter2: TSplitter
Left = 267
Left = 279
Height = 511
Top = 0
Width = 5
end
object ImagePanel: TPanel
Left = 272
Height = 511
Top = 0
Width = 466
Left = 288
Height = 495
Top = 8
Width = 442
Align = alClient
BorderSpacing.Left = 4
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
Caption = 'ImagePanel'
ClientHeight = 511
ClientWidth = 466
ClientHeight = 495
ClientWidth = 442
TabOrder = 2
object ScrollBox1: TScrollBox
Left = 1
Height = 455
Top = 1
Width = 464
Left = 0
Height = 438
Top = 0
Width = 442
HorzScrollBar.Increment = 27
HorzScrollBar.Page = 272
HorzScrollBar.Smooth = True
@ -93,8 +115,8 @@ object Form1: TForm1
VertScrollBar.Smooth = True
VertScrollBar.Tracking = True
Align = alClient
ClientHeight = 451
ClientWidth = 460
ClientHeight = 434
ClientWidth = 438
TabOrder = 0
OnResize = ScrollBox1Resize
object Image1: TImage
@ -105,22 +127,24 @@ object Form1: TForm1
end
end
object Panel1: TPanel
Left = 1
Height = 54
Top = 456
Width = 464
Left = 0
Height = 57
Top = 438
Width = 442
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 54
ClientWidth = 464
ClientHeight = 57
ClientWidth = 442
TabOrder = 1
object RbOrigSize: TRadioButton
Left = 8
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = BtnSaveAsWMF
AnchorSideTop.Side = asrCenter
Left = 0
Height = 19
Top = 8
Width = 164
BorderSpacing.Left = 8
Top = 11
Width = 162
BorderSpacing.Top = 8
BorderSpacing.Bottom = 4
Caption = 'Original size taken from file'
@ -134,33 +158,38 @@ object Form1: TForm1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = RbOrigSize
AnchorSideTop.Side = asrCenter
Left = 197
Left = 186
Height = 19
Top = 8
Top = 11
Width = 117
BorderSpacing.Left = 17
BorderSpacing.Left = 16
BorderSpacing.Around = 8
Caption = 'Adapt size to form'
Caption = 'Adjust size to form'
OnChange = RbMaxSizeChange
TabOrder = 0
end
object ImageInfo: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = RbOrigSize
AnchorSideTop.Side = asrBottom
Left = 25
Left = 0
Height = 15
Top = 31
Top = 34
Width = 18
BorderSpacing.Bottom = 8
Caption = ' '
ParentColor = False
end
object BtnSaveAsWMF: TButton
Left = 368
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 351
Height = 25
Top = 6
Top = 8
Width = 91
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
Caption = 'Save as wmf'
OnClick = BtnSaveAsWMFClick
TabOrder = 2
@ -168,106 +197,42 @@ object Form1: TForm1
end
end
object ImageList: TImageList
left = 96
top = 72
Left = 96
Top = 72
Bitmap = {
4C69030000001000000010000000FFFFFF00FFFFFF000088CC610088CC810088
CC810088CC810088CC810088CC810088CC810088CC810088CC810088CC810088
CC810088CC610088CB00FFFFFF00FFFFFF00FFFFFF000087CA82B1F5FFFFAEF2
FFFFAEF2FFFFAEF2FFFFAEF2FFFFAEF2FFFFAEF2FFFFAEF2FFFFAEF2FFFFB1F5
FFFF0087CA820087CA00FFFFFF00FFFFFF00FFFFFF000086C984ACF1FFFFA7EC
FEFFA7ECFEFFA7ECFEFFA7ECFEFFA7ECFEFFA7ECFEFFA7ECFEFFA7ECFEFFACF1
FFFF0086C9840086C900FFFFFF00FFFFFF00FFFFFF000084C686A9EEFDFFA4E9
FCFFA4E9FCFFA4E9FCFFA4E9FCFFA4E9FCFFA4E9FCFFA4E9FCFFA4E9FCFFA9EE
FDFF0084C6860084C600FFFFFF00FFFFFF00FFFFFF000083C489A6EBFCFFA1E6
FBFFA1E6FBFFA1E6FBFFA1E6FBFFA1E6FBFFA1E6FBFFA1E6FBFFA1E6FBFFA6EB
FCFF0083C4890083C400FFFFFF00FFFFFF00FFFFFF000081C18BA3E8FBFF9DE3
F9FF9DE3F9FF9DE3F9FF9DE3F9FF9DE3F9FF9DE3F9FF9DE3F9FF9DE3F9FFA3E8
FBFF0081C18B0081C100FFFFFF00FFFFFF00FFFFFF00007FBE8E9EE5F9FF98DF
F6FF98DFF6FF98DFF6FF98DFF6FF98DFF6FF98DFF6FF98DFF6FF98DFF6FFA1E7
FAFF007FBE8E007EBD00FFFFFF00FFFFFF00FFFFFF00007DBB919BE1F7FF94DB
F4FF94DBF4FF94DBF4FF94DBF4FF94DBF4FF94DBF4FF94DBF4FF9EE4F8FF7BC0
DEFF007DBB91007DBB33FFFFFF00FFFFFF00FFFFFF00007BB89497DEF6FF90D8
F2FF90D8F2FF90D8F2FF90D8F2FF90D8F2FF90D8F2FF97DEF6FF78BDDCFF78BD
DCFFFEFEFDFF007BB894FFFFFF00FFFFFF00FFFFFF000079B59792DAF4FF8BD4
F0FF8BD4F0FF8BD4F0FF8BD4F0FF8BD4F0FF8BD4F0FF92DAF4FF69ADCFFF92DA
F4FFF8F8F3FF0079B597FFFFFF00FFFFFF00FFFFFF000076B19A8ED6F2FF87D0
EDFF87D0EDFF87D0EDFF87D0EDFF87D0EDFF87D0EDFF8ED6F2FF66AACCFF8ED6
F2FFF0F0E6FF0076B19AFFFFFF00FFFFFF00FFFFFF000074AE9D8AD3F0FF82CD
EBFF82CDEBFF82CDEBFF82CDEBFF82CDEBFF82CDEBFF8AD3F0FF62A6C8FF8AD3
F0FFE9E9DBFF0074AE9DFFFFFF00FFFFFF00FFFFFF000072ABA087D0EFFF7FCA
E9FF7FCAE9FF7FCAE9FF7FCAE9FF7FCAE9FF7FCAE9FF87D0EFFF5FA3C5FF87D0
EFFFFEC941FF0072ABA0FFFFFF00FFFFFF00FFFFFF00006CA3A884CEEEFF7CC7
E8FF7CC7E8FF7CC7E8FF7CC7E8FF7CC7E8FF7CC7E8FF84CEEEFF579BBDFF84CE
EEFFF4B62EFF006CA3A8FFFFFF00FFFFFF00FFFFFF00006395B486CFF0FF81CB
EDFF81CBEDFF81CBEDFF81CBEDFF81CBEDFF81CBEDFF86CFF0FF4B8FB1FF86CF
F0FF006395B40064973FFFFFFF00FFFFFF00FFFFFF00005D8C8F005C8BBF005C
8BBF005C8BBF005C8BBF005C8BBF005C8BBF005C8BBF005C8BBF005C8BBF005C
8BBF005D8C8F00639500FFFFFF00FFFFFF00FFFFFF000088CC610088CC810088
CC810088CC810088CC810088CC810088CC810088CC810088CC810088CC810088
CC810088CC610087CB00FFFFFF00FFFFFF00FFFFFF000087CA8388DCF4FF60C0
E9FF5FBFEAFF80D3F4FF9CE3FDFFA2E6FFFFA2E6FFFFA2E6FFFFA2E6FFFFA6EA
FFFF0087CA830087CA00FFFFFF00FFFFFF00FFFFFF000085C885ACF1FFFFABEF
FEFF95E2F8FF6EC9EDFF48A8D9FF98DCFEFF98DCFEFF98DCFEFF98DCFEFFA1E5
FFFF0085C8850085C800FFFFFF00FFFFFF00FFFFFF000084C587A9EEFDFFA4E9
FCFFA4E9FCFFAAEEFDFF42A1D1FF97DBFDFF97DBFDFF97DBFDFF97DBFDFF9FE3
FEFF0084C5870084C500FFFFFF00FFFFFF00FFFFFF000082C28AA6EBFCFFA1E6
FBFFA1E6FBFFA6EBFCFF3C9DCFFF96DAFCFF96DAFCFF96DAFCFF96DAFCFF9EE2
FDFF0082C28A0082C200FFFFFF00FFFFFF00FFFFFF00007FBF8DA3E8FBFF9DE3
F9FF9DE3F9FFA3E8FBFF3594C5FF94D8FAFF94D8FAFF94D8FAFF94D8FAFF9BDF
FCFF007FBF8D007FBE00FFFFFF00FFFFFF00FFFFFF00007DBB909EE5F9FF98DF
F6FF98DFF6FF9EE5F9FF3290C0FF92D6F8FF92D6F8FF92D6F8FF92D6F8FF99DD
FAFF007DBB90007DBB33FFFFFF00FFFFFF00FFFFFF00007BB8949BE1F7FF94DB
F4FF94DBF4FF9BE1F7FF308DBCFF90D4F6FF90D4F6FF90D4F6FF90D4F6FF97DB
F9FFFEFEFDFF007BB894FFFFFF00FFFFFF00FFFFFF000078B49797DEF6FF90D8
F2FF90D8F2FF97DEF6FF2D89B7FF8FD3F5FF8FD3F5FF8FD3F5FF8FD3F5FF95D9
F8FFF5F5EEFF0078B497FFFFFF00FFFFFF00FFFFFF000076B09B92DAF4FF8BD4
F0FF8BD4F0FF92DAF4FF2B85B3FF8DD1F3FF8DD1F3FF8DD1F3FF8DD1F3FF93D7
F6FFEBEBDDFF0076B09BFFFFFF00FFFFFF00FFFFFF000073AC9E8ED6F2FF87D0
EDFF87D0EDFF8ED6F2FF2882AFFF8BCFF1FF8BCFF1FF8BCFF1FF8BCFF1FF91D5
F5FFFEC941FF0073AC9EFFFFFF00FFFFFF00FFFFFF00006FA7A48AD3F0FF82CD
EBFF82CDEBFF8AD3F0FF267EABFF8ACEF0FF8ACEF0FF8ACEF0FF8ACEF0FF8FD3
F4FFF4B62EFF006FA7A4FFFFFF00FFFFFF00FFFFFF00006699B287D1EFFF7FCA
E9FF7FCAE9FF87D0EFFF267DA9FF8DD1F3FF8DD1F3FF8DD1F3FF8DD1F3FF90D4
F5FF006699B200679B3EFFFFFF00FFFFFF00FFFFFF00005E8D8E3591BDF169B8
DDFA81CBECFF84CEEEFF005C8BEF005D8CBE005D8CBE005D8CBE005D8CBE005D
8CBE005E8D8E00669900FFFFFF00FFFFFF00FFFFFF00005D8C00006599500064
97991C7AA9C052A5CDE0005B89C1005B8900005B8900005B8900005B8900005B
8900005D8C0000669900FFFFFF00FFFFFF00FFFFFF00005D8C00006497000062
9300005E8E30005C8C7C0059879200598700005B8900005B8900005B8900005B
8900005D8C0000669900FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF009F9D9B009D9A98009E9C9A009E9C9AFFA5A3
A1FFA5A3A1FFA5A3A1FFA5A3A1FFA5A3A1FFA5A3A1FFA5A3A1FFA5A3A1FF9E9C
9AFF9E9C9A009D9A98009F9D9B009F9D9B009B989600999795FFE4E3E2FFC6C4
C2FFC6C4C2FFC6C4C2FFC6C4C2FFC6C4C2FFC6C4C2FFC6C4C2FFC6C4C2FFE4E3
E2FF999795FF9B9896009F9D9B009D9B9900969390FFE5E4E3FFC7C4C2FFC7C4
C2FFC7C5C3FFC7C5C3FFC7C5C3FFC7C5C3FFC7C5C3FFC7C5C3FFC7C4C2FFC7C4
C2FFE5E4E3FF969390FF9D9B99009A9896AAEFEEEFFFEBEAEAFFEAE9EAFFEAE9
EAFFEAE9EAFFEAE9EAFFEAE9EAFFEAE9EAFFEAE9EAFFEAE9EAFFEAE9EAFFEAE9
EAFFEBEAEAFFEFEEEFFF9A9896AA969492FFE3E1E0FF9D9997FF9D9997FF9C99
97FF9C9997FF9C9997FF9C9997FF9C9997FF9C9997FF9C9997FF9C9997FF9D99
97FF9D9997FFE3E1E0FF969492FF93918FFFDCDBD9FFA6A3A0FFE6E4E4FFE5E3
E4FFE5E4E4FFE6E4E4FFE6E4E4FFE6E4E4FFE6E4E4FFE5E4E4FFE5E3E4FFE6E4
E4FFA6A3A0FFDCDBD9FF93918FFF908E8CFFD7D5D4FFAEACAAFFE1DFE0FFB0AD
ABFFB1AEACFFB2AEACFFB2AEACFFB2AEACFFB2AEACFFB1AEACFFB0ADABFFE1DF
E0FFAEACAAFFD7D5D4FF908E8CFF8D8A88FFD4D2D1FFB7B4B2FFD2D0D0FFC3C1
BFFFC4C2C0FFC4C2C0FFC4C2C0FFC4C2C0FFC4C2C0FFC4C2C0FFC3C1BFFFD2D0
D0FFB7B4B2FFD4D2D1FF8D8A88FF8A8785FFD2D0CFFFC1BFBDFFAEACAAFFAFAD
ABFFAFADABFFAFADABFFAFADABFFAFADABFFAFADABFFAFADABFFAFADABFFAEAC
AAFFC1BFBDFFD2D0CFFF8A8785FF888583FFD6D4D2FFCECCCAFFCECCCAFFCECC
CAFFCECCCAFFCECCCAFFCECCCAFFCECCCAFFCECCCAFFCECCCAFFCECCCAFFCECC
CAFFCECCCAFFD6D4D2FF888583FF7D7A78C084817FFF83807EFF83807EFF8380
7EFF83807EFF83807EFF83807EFF83807EFF83807EFF83807EFF83807EFF8380
7EFF83807EFF84817FFF7D7A78C0000000230000003300000033000000330000
0033000000330000003300000033000000330000003300000033000000330000
0033000000330000003300000023FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00
4C7A030000001000000010000000F90300000000000078DAC594DD4F93570087
CF1FB23B13B364D96266BC5BB6B8AB25BB5976B32C737353E762B26CC9B62C4C
05E4A3140A940285524AD1AE8AF2210A63D364430A82CA877C561401F928304B
8516A4AC20F4B7F37BA7494FFBAE83DD78F1E43DE9799EB621FD0140402272FB
BE9064EC10E9F66ADD0B84B127B3290C34AE26870E5D89DAE7746737AC00179F
44934287AE44EDB36FE5D42E6FE3BC7F2B2974E84AD43EAB33AF26B005D7C2B3
A4D0A12B51FB8CF67CF7E36770FA36924287AE44EDD36F98ABE7375031B59E14
D79F9BA02BD25AD53EF5F762C7CC5FB08EAFFD2BD573119CF23C025DC97EA53F
75DD6A7BB40ECB83555D7897D23AA1118DCABFA1F495FEA75F6D250FD790EF0D
E9C2BB139707B46724F214F495FEC7A64AF3E82A8C834BBAF0EE785D9FF60C85
16405FE97F68749A4642C8BC1BD08577476AEE684FBF7F1CF495FEBBFA73C6C1
20D27BFCBAF0EEB0BB4B7B46BB0F82BED27FEDBE94DDBF8CD3B71FEBC2BB8F1C
ADDA73EDB737405FE98F96B5E40C8490D1BBA40BEFDE2F6AD29E74C531DB3B4A
FF6941913894DFB623E81E2D537F3FBBDDBF3161FF59B9136BF8DCE3C7E1B645
9C195943956F1B3F2F40A16651DB7F56C2FE0D770CDC767D308AB2D908BEE95E
C27B97C65031115570CD4B59BA92B8FD771963F75F27CFEFBA86601BDF5638EB
8B82AE44ED333B4CB1FBE7F92DE700CA1F6E2954CFCADFBE742571FB6D2B8CDD
3FCF07AC5DB03ED854704CC9FF1FD2951B8EDFAF2576FF3CBF69F1A06434A260
9FDCE47E2D7AFB8DDD3FCFFB0AFF80C5BBAE601BDFD0DF6F4A8B2D76FF3CBF9E
770D45236185B2B108C2E165D057F77BD511BB7F9E5F33FC82C2A1A70AA5F7D7
11084C82BED27FDF501DBB7F9E5FCDBC82FC811585E27BE17FF6277DA5FFF6E2
F9D8FDF3BC37AD1EA6FE904291FC5D6AFB93BED21FB7371B8782CADEF7A6D626
7C7F8B370CBAE22BC7DB4AFF59A1F94071EBCA89EB939B19BD4FB49DCBAD05E5
D66E24205DF91E226EBF427C69FF40EEDAFECAC95ACF8717EE4E8B4FF2DA2522
01BA7AFD319B10474AE57731EF13870A4E8B8F8D25921DF52F8BB34E87705656
88EAAA4A820B6E5752E8D065C396382ACA85DD568639DF2C6E757624850E5D36
DA673BECA2BCD482F9391F6ECB7B8DAE9BFA3CBFA7CB866D6545795D703988C0
E22216FD3B832E1BB6E5D612F866A6E1B4DB34AAFE83171E1BB6A5C54598181F
438DFB1C16E6E630EF93C8E7421CF3CFEF78A6CB86ADC55C80FBF7BC686CA8C3
CCD434AE5EAE475363039AE3E06BBCA343970DDB42532EBCC343B8D6D28CE1C1
41DC6C6F4367874717DED1A1CB86ADC96890AF0DA0BDAD557BDF2BF233924187
2E1BB6B9862C8C7A87D1DFD7B32BD8B04D3D99E2C9CE4847D699B45DC186AD10
628F64FFFF64CFCBDEDFDFC0F46CB6
}
end
end

View File

@ -6,14 +6,15 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ShellCtrls,
ExtCtrls, ComCtrls, StdCtrls, fpvectorial;
ExtCtrls, ComCtrls, StdCtrls, fpvectorial, Types;
type
{ TForm1 }
{ TMainForm }
TForm1 = class(TForm)
TMainForm = class(TForm)
BtnSaveAsWMF: TButton;
CbHistory: TComboBox;
Image1: TImage;
ImageList: TImageList;
ImageInfo: TLabel;
@ -28,6 +29,11 @@ type
Splitter1: TSplitter;
Splitter2: TSplitter;
procedure BtnSaveAsWMFClick(Sender: TObject);
procedure CbHistoryCloseUp(Sender: TObject);
procedure CbHistoryDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
procedure CbHistoryEditingDone(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure RbMaxSizeChange(Sender: TObject);
@ -42,32 +48,35 @@ type
{ private declarations }
FVec: TvVectorialDocument;
FFileName: String;
FFormActivated: Boolean;
procedure LoadImage(const AFileName: String);
procedure PaintImage(APage: TvPage);
procedure ReadFromIni;
procedure WriteToIni;
procedure ReadIni;
procedure UpdateHistory(const AFileName: String);
procedure WriteIni;
public
{ public declarations }
end;
var
Form1: TForm1;
MainForm: TMainForm;
implementation
{$R *.lfm}
uses
IniFiles, LazFileUtils, fpvUtils;
LCLType, LCLIntf,
IniFiles, LazFileUtils, FileCtrl, fpvUtils;
const
PROGRAM_NAME = 'wmfViewer';
INCH = 25.4;
{ TForm1 }
{ TMainForm }
procedure TForm1.BtnSaveAsWMFClick(Sender: TObject);
procedure TMainForm.BtnSaveAsWMFClick(Sender: TObject);
var
fn: String;
begin
@ -84,16 +93,70 @@ begin
ShowMessage(Format('Saved as "%s"', [fn]));
end;
procedure TForm1.FormCreate(Sender: TObject);
procedure TMainForm.CbHistoryCloseUp(Sender: TObject);
var
dir: String;
begin
if CbHistory.ItemIndex = -1 then
exit;
dir := CbHistory.Items[CbHistory.ItemIndex];
ShellTreeView.Path := dir;
end;
procedure TMainForm.CbHistoryDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
var
s: String;
combobox: TComboBox;
begin
combobox := Control as TComboBox;
s := MinimizeName(combobox.Items[Index], combobox.Canvas, combobox.ClientWidth);
combobox.Canvas.TextOut(ARect.Left, ARect.Top, s);
end;
procedure TMainForm.CbHistoryEditingDone(Sender: TObject);
begin
UpdateHistory(AppendPathDelim(CbHistory.Text)+'.');
ShellTreeView.Path := CbHistory.Text;
ShellTreeView.MakeSelectionVisible;
end;
procedure TMainForm.FormActivate(Sender: TObject);
var
fn: string;
begin
if FFormActivated then
exit;
FFormActivated := true;
if (ParamCount > 0) then
fn := ExpandfileName(ParamStr(1))
else
fn := FFileName;
if (fn <> '') and FileExists(fn) then
begin
ShellTreeView.Path := ExtractFilePath(fn);
ShellListView.Selected := ShellListView.Items.FindCaption(0, ExtractFileName(fn), false, true, false);
LoadImage(fn);
end;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
// Set correct dpi for scaling by wmf reader
ScreenDPIX := ScreenInfo.PixelsPerInchX;
ScreenDPIY := ScreenInfo.PixelsPerInchY;
Caption := PROGRAM_NAME;
ShellListview.Mask := '*.svg;*.wmf';
{$IFNDEF MSWINDOWS}
ShellTreeView.Images := ImageList1;
ShellTreeView.OnGetImageIndex := @ShellTreeViewGetImageIndex;
ShellTreeView.OnGetSelectedIndex := @ShellTreeViewGetSelectedIndex;
{$ENDIF}
ShellListview.Mask := '*.wmf';
ReadFromIni;
ReadIni;
if ParamCount > 0 then begin
ShellTreeview.Path := ExtractFilepath(ParamStr(1));
@ -102,13 +165,13 @@ begin
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
procedure TMainForm.FormDestroy(Sender: TObject);
begin
WriteToIni;
WriteIni;
FreeAndNil(FVec);
end;
procedure TForm1.LoadImage(const AFileName: String);
procedure TMainForm.LoadImage(const AFileName: String);
var
page: TvPage;
begin
@ -119,7 +182,7 @@ begin
FVec.ReadFromFile(AFilename);
// Draw the image
FVec.GuessDocumentSize;
page := FVec.GetPage(0);
page := FVec.GetPageAsVectorial(0);
if (page.Width = 0) or (page.Height = 0) then
page.CalculateDocumentSize;
PaintImage(page);
@ -133,7 +196,7 @@ begin
end;
end;
procedure TForm1.PaintImage(APage: TvPage);
procedure TMainForm.PaintImage(APage: TvPage);
var
bmp: TBitmap;
multiplierX, multiplierY: Double;
@ -207,19 +270,19 @@ begin
end;
end;
procedure TForm1.RbMaxSizeChange(Sender: TObject);
procedure TMainForm.RbMaxSizeChange(Sender: TObject);
begin
if FVec <> nil then
PaintImage(FVec.GetPage(0));
PaintImage(FVec.GetPageAsVectorial(0));
end;
procedure TForm1.RbOrigSizeChange(Sender: TObject);
procedure TMainForm.RbOrigSizeChange(Sender: TObject);
begin
if FVec <> nil then
PaintImage(FVec.GetPage(0));
PaintImage(FVec.GetPageAsVectorial(0));
end;
procedure TForm1.ShellListViewSelectItem(Sender: TObject; Item: TListItem;
procedure TMainForm.ShellListViewSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
var
fn: String;
@ -229,27 +292,87 @@ begin
fn := ShellListview.GetPathFromItem(ShellListview.Selected);
ShellTreeview.MakeSelectionVisible;
LoadImage(fn);
UpdateHistory(fn);
end;
end;
procedure TForm1.ShellTreeViewExpanded(Sender: TObject; Node: TTreeNode);
procedure TMainForm.ShellTreeViewExpanded(Sender: TObject; Node: TTreeNode);
begin
ShellTreeView.AlphaSort;
end;
procedure TForm1.ShellTreeViewGetImageIndex(Sender: TObject; Node: TTreeNode);
procedure TMainForm.ShellTreeViewGetImageIndex(Sender: TObject; Node: TTreeNode);
begin
if Node.Level = 0 then
Node.ImageIndex := 2 else
Node.ImageIndex := 0;
end;
procedure TForm1.ShellTreeViewGetSelectedIndex(Sender: TObject; Node: TTreeNode);
procedure TMainForm.ShellTreeViewGetSelectedIndex(Sender: TObject; Node: TTreeNode);
begin
Node.SelectedIndex := 1;
end;
procedure TForm1.ReadFromIni;
procedure TMainForm.ReadIni;
var
ini: TIniFile;
L, T, W, H, p: Integer;
R: TRect;
List: TStrings;
i: Integer;
s: String;
begin
ini := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
try
T := Ini.ReadInteger('Position', 'Top', Top);
L := Ini.ReadInteger('Position', 'Left', Left);
W := Ini.ReadInteger('Position', 'Width', Width);
H := Ini.ReadInteger('Position', 'Height', Height);
R := Screen.WorkAreaRect;
if W > R.Width then W := R.Width;
if H > R.Height then H := R.Height;
if L < R.Left then L := R.Left;
if T < R.Top then T := R.Top;
if L + W > R.Right then L := R.Right - W - GetSystemMetrics(SM_CXSIZEFRAME);
if T + H > R.Bottom then T := R.Bottom - H - GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYSIZEFRAME);
SetBounds(L, T, W, H);
WindowState := wsNormal;
Application.ProcessMessages;
WindowState := TWindowState(ini.ReadInteger('Position', 'WindowState', 0));
p := ini.ReadInteger('Settings', 'LeftSplitter', LeftPanel.Width);
if p > ClientWidth then p := ClientWidth div 4;
LeftPanel.Width := p;
p := ini.ReadInteger('Settings', 'ShellSplitter', ShellTreeView.Height);
if p > ClientHeight then p := ClientHeight div 2;
ShellTreeView.Height := p;
FFileName := ini.ReadString('Settings', 'Filename', '');
CbHistory.Items.BeginUpdate;
List := TStringList.Create;
try
ini.ReadSection('History', List);
CbHistory.Items.Clear;
for i := 0 to List.Count-1 do
begin
s := ini.ReadString('History', Format('Item%d', [i+1]), '');
if (s <> '') and DirectoryExists(s) then
CbHistory.Items.Add(s);
end;
if CbHistory.Items.Count > 0 then
CbHistory.ItemIndex := 0;
finally
List.Free;
CbHistory.Items.EndUpdate;
end;
finally
ini.Free;
end;
end;
(*
procedure TMainForm.ReadFromIni;
var
ini: TCustomIniFile;
L, T, W, H: Integer;
@ -274,14 +397,56 @@ begin
ini.Free;
end;
end;
procedure TForm1.ScrollBox1Resize(Sender: TObject);
*)
procedure TMainForm.ScrollBox1Resize(Sender: TObject);
begin
if FVec <> nil then
PaintImage(FVec.GetPage(0));
PaintImage(FVec.GetPageAsVectorial(0));
end;
procedure TForm1.WriteToIni;
procedure TMainForm.UpdateHistory(const AFileName: String);
var
dir: String;
idx: Integer;
begin
if AFileName = '' then
exit;
dir := ExtractFilePath(AFileName);
idx := CbHistory.Items.IndexOf(dir);
if idx = -1 then
CbHistory.Items.Insert(0, dir)
else
CbHistory.Items.Move(idx, 0);
while CbHistory.Items.Count > 10 do
CbHistory.Items.Delete(CbHistory.Items.Count-1);
CbHistory.ItemIndex := 0;
end;
procedure TMainForm.WriteIni;
var
ini: TIniFile;
i: Integer;
begin
ini := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
try
ini.WriteInteger('Position', 'Top', RestoredTop);
ini.WriteInteger('Position', 'Left', RestoredLeft);
ini.WriteInteger('Position', 'Width', RestoredWidth);
ini.WriteInteger('Position', 'Height', RestoredHeight);
ini.WriteInteger('Position', 'WindowState', Integer(WindowState));
ini.WriteInteger('Settings', 'LeftSplitter', LeftPanel.Width);
ini.WriteInteger('Settings', 'ShellSplitter', ShellTreeView.Height);
ini.WriteString('Settings', 'FileName', FFileName);
ini.EraseSection('History');
for i := 0 to CbHistory.Items.Count-1 do
ini.WriteString('History', Format('Item%d', [i+1]), CbHistory.Items[i]);
finally
ini.Free;
end;
end;
{
procedure TMainForm.WriteToIni;
var
ini: TCustomIniFile;
begin
@ -300,7 +465,7 @@ begin
ini.Free;
end;
end;
}
end.

View File

@ -40,7 +40,7 @@
<Unit1>
<Filename Value="wmf_mainform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
@ -66,7 +66,7 @@
</CodeGeneration>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<Options>
<Win32>

View File

@ -15,7 +15,7 @@ uses
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.