fpvviewer: Adds the possibility to force a text encoding when reading the file

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2602 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2012-12-21 09:41:22 +00:00
parent 24535a5161
commit 43bbb91965
2 changed files with 75 additions and 5 deletions

View File

@ -1,10 +1,10 @@
object frmFPVViewer: TfrmFPVViewer object frmFPVViewer: TfrmFPVViewer
Left = 322 Left = 322
Height = 538 Height = 600
Top = 143 Top = 143
Width = 485 Width = 485
Caption = 'Free Pascal Vectorial Viewer' Caption = 'Free Pascal Vectorial Viewer'
ClientHeight = 538 ClientHeight = 600
ClientWidth = 485 ClientWidth = 485
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
@ -67,10 +67,10 @@ object frmFPVViewer: TfrmFPVViewer
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 410 Height = 448
Top = 128 Top = 152
Width = 485 Width = 485
PageIndex = 1 PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
TabOrder = 4 TabOrder = 4
TabStop = True TabStop = True
@ -78,11 +78,15 @@ object frmFPVViewer: TfrmFPVViewer
end end
object pageTreeData: TPage object pageTreeData: TPage
object TokensTreeView: TTreeView object TokensTreeView: TTreeView
AnchorSideTop.Control = btnSearchInTokens
AnchorSideTop.Side = asrBottom
Left = 0 Left = 0
Height = 378 Height = 378
Top = 32 Top = 32
Width = 485 Width = 485
Align = alBottom Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 7
DefaultItemHeight = 18 DefaultItemHeight = 18
TabOrder = 0 TabOrder = 0
end end
@ -177,4 +181,59 @@ object frmFPVViewer: TfrmFPVViewer
OnClick = Button2Click OnClick = Button2Click
TabOrder = 10 TabOrder = 10
end end
object Label4: TLabel
Left = 9
Height = 15
Top = 126
Width = 128
Caption = 'Force encoding on read:'
ParentColor = False
end
object comboEncoding: TComboBox
Left = 144
Height = 23
Top = 126
Width = 128
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'Read from the file'
'utf8'
'ansi'
'ucs2le'
'ucs2be'
'iso88591'
'iso88592'
'cp1250'
'cp1251'
'cp1252'
'cp1253'
'cp1254'
'cp1255'
'cp1256'
'cp1257'
'cp1258'
'cp437'
'cp850'
'cp852'
'cp866'
'cp874'
'cp936'
'cp950'
'cp949'
'cp932'
'koi8'
)
Style = csDropDownList
TabOrder = 11
Text = 'Read from the file'
end
object labelFileEncoding: TLabel
Left = 278
Height = 15
Top = 130
Width = 74
Caption = 'File encoding:'
ParentColor = False
end
end end

View File

@ -21,10 +21,13 @@ type
Button2: TButton; Button2: TButton;
btnSearchInTokens: TButton; btnSearchInTokens: TButton;
buttonRenderingTest: TButton; buttonRenderingTest: TButton;
comboEncoding: TComboBox;
editSearchInTokens: TEdit; editSearchInTokens: TEdit;
editFileName: TFileNameEdit; editFileName: TFileNameEdit;
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
Label4: TLabel;
labelFileEncoding: TLabel;
notebook: TNotebook; notebook: TNotebook;
pageViewer: TPage; pageViewer: TPage;
pageTreeData: TPage; pageTreeData: TPage;
@ -84,8 +87,16 @@ begin
Vec := TvVectorialDocument.Create; Vec := TvVectorialDocument.Create;
try try
// If we desire, force a encoding for the read operation
if comboEncoding.ItemIndex > 0 then
Vec.ForcedEncodingOnRead := comboEncoding.Text
else Vec.ForcedEncodingOnRead := '';
Vec.ReadFromFile(editFileName.FileName); Vec.ReadFromFile(editFileName.FileName);
// Show document properties
labelFileEncoding.Caption := 'File encoding: ' + Vec.Encoding;
// We need to be robust, because sometimes the document size won't be given // We need to be robust, because sometimes the document size won't be given
// also give up drawing everything if we need more then 4MB of RAM for the image // also give up drawing everything if we need more then 4MB of RAM for the image
// and also give some space in the image to allow for negative coordinates // and also give some space in the image to allow for negative coordinates