Make grid export dialog resizable, store/restore its width and height, and resize contained group boxes proportional to the window. See #19.

This commit is contained in:
Ansgar Becker
2018-11-13 19:45:30 +01:00
parent f1c9f1a8a4
commit 55ed9ae738
3 changed files with 69 additions and 48 deletions

View File

@ -148,7 +148,7 @@ type
asStartupScriptFilename, asDatabases, asComment, asDatabaseFilter, asTableFilter, asExportSQLCreateDatabases, asStartupScriptFilename, asDatabases, asComment, asDatabaseFilter, asTableFilter, asExportSQLCreateDatabases,
asExportSQLCreateTables, asExportSQLDataHow, asExportSQLDataInsertSize, asExportSQLFilenames, asExportZIPFilenames, asExportSQLDirectories, asExportSQLCreateTables, asExportSQLDataHow, asExportSQLDataInsertSize, asExportSQLFilenames, asExportZIPFilenames, asExportSQLDirectories,
asExportSQLDatabase, asExportSQLServerDatabase, asExportSQLOutput, asExportSQLAddComments, asExportSQLRemoveAutoIncrement, asExportSQLDatabase, asExportSQLServerDatabase, asExportSQLOutput, asExportSQLAddComments, asExportSQLRemoveAutoIncrement,
asGridExportOutputCopy, asGridExportOutputFile, asGridExportWindowWidth, asGridExportWindowHeight, asGridExportOutputCopy, asGridExportOutputFile,
asGridExportFilename, asGridExportRecentFiles, asGridExportEncoding, asGridExportFormat, asGridExportSelection, asGridExportFilename, asGridExportRecentFiles, asGridExportEncoding, asGridExportFormat, asGridExportSelection,
asGridExportColumnNames, asGridExportIncludeAutoInc, asGridExportIncludeQuery, asGridExportColumnNames, asGridExportIncludeAutoInc, asGridExportIncludeQuery,
asGridExportSeparator, asGridExportEncloser, asGridExportTerminator, asGridExportNull, asGridExportSeparator, asGridExportEncloser, asGridExportTerminator, asGridExportNull,
@ -3621,6 +3621,8 @@ begin
InitSetting(asExportSQLOutput, 'ExportSQL_Output', 0); InitSetting(asExportSQLOutput, 'ExportSQL_Output', 0);
InitSetting(asExportSQLAddComments, 'ExportSQLAddComments', 0, True); InitSetting(asExportSQLAddComments, 'ExportSQLAddComments', 0, True);
InitSetting(asExportSQLRemoveAutoIncrement, 'ExportSQLRemoveAutoIncrement', 0, False); InitSetting(asExportSQLRemoveAutoIncrement, 'ExportSQLRemoveAutoIncrement', 0, False);
InitSetting(asGridExportWindowWidth, 'GridExportWindowWidth', 400);
InitSetting(asGridExportWindowHeight, 'GridExportWindowHeight', 460);
InitSetting(asGridExportOutputCopy, 'GridExportOutputCopy', 0, True); InitSetting(asGridExportOutputCopy, 'GridExportOutputCopy', 0, True);
InitSetting(asGridExportOutputFile, 'GridExportOutputFile', 0, False); InitSetting(asGridExportOutputFile, 'GridExportOutputFile', 0, False);
InitSetting(asGridExportFilename, 'GridExportFilename', 0, False, ''); InitSetting(asGridExportFilename, 'GridExportFilename', 0, False, '');

View File

@ -1,26 +1,28 @@
object frmExportGrid: TfrmExportGrid object frmExportGrid: TfrmExportGrid
Left = 0 Left = 0
Top = 0 Top = 0
BorderStyle = bsDialog
Caption = 'Export grid rows' Caption = 'Export grid rows'
ClientHeight = 432 ClientHeight = 422
ClientWidth = 383 ClientWidth = 373
Color = clBtnFace Color = clBtnFace
Constraints.MinHeight = 450
Constraints.MinWidth = 350
ParentFont = True ParentFont = True
OldCreateOrder = False OldCreateOrder = False
Position = poMainFormCenter Position = poMainFormCenter
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
OnResize = FormResize
OnShow = FormShow OnShow = FormShow
DesignSize = ( DesignSize = (
383 373
432) 422)
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object btnOK: TButton object btnOK: TButton
Left = 219 Left = 209
Top = 399 Top = 389
Width = 75 Width = 75
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
@ -31,8 +33,8 @@ object frmExportGrid: TfrmExportGrid
OnClick = btnOKClick OnClick = btnOKClick
end end
object btnCancel: TButton object btnCancel: TButton
Left = 300 Left = 290
Top = 399 Top = 389
Width = 75 Width = 75
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
@ -45,7 +47,7 @@ object frmExportGrid: TfrmExportGrid
Left = 8 Left = 8
Top = 112 Top = 112
Width = 137 Width = 137
Height = 281 Height = 271
Anchors = [akLeft, akTop, akBottom] Anchors = [akLeft, akTop, akBottom]
Caption = 'Output format' Caption = 'Output format'
ItemIndex = 0 ItemIndex = 0
@ -65,9 +67,9 @@ object frmExportGrid: TfrmExportGrid
object grpSelection: TRadioGroup object grpSelection: TRadioGroup
Left = 151 Left = 151
Top = 112 Top = 112
Width = 224 Width = 214
Height = 66 Height = 66
Anchors = [akLeft, akTop, akRight] Anchors = [akTop, akRight]
Caption = 'Row selection' Caption = 'Row selection'
ItemIndex = 1 ItemIndex = 1
Items.Strings = ( Items.Strings = (
@ -78,13 +80,13 @@ object frmExportGrid: TfrmExportGrid
object grpOutput: TGroupBox object grpOutput: TGroupBox
Left = 8 Left = 8
Top = 8 Top = 8
Width = 367 Width = 357
Height = 98 Height = 98
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Output target' Caption = 'Output target'
TabOrder = 4 TabOrder = 4
DesignSize = ( DesignSize = (
367 357
98) 98)
object lblEncoding: TLabel object lblEncoding: TLabel
Left = 8 Left = 8
@ -96,7 +98,7 @@ object frmExportGrid: TfrmExportGrid
object radioOutputCopyToClipboard: TRadioButton object radioOutputCopyToClipboard: TRadioButton
Left = 8 Left = 8
Top = 18 Top = 18
Width = 345 Width = 335
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Copy to clipboard' Caption = 'Copy to clipboard'
@ -108,7 +110,7 @@ object frmExportGrid: TfrmExportGrid
object radioOutputFile: TRadioButton object radioOutputFile: TRadioButton
Left = 8 Left = 8
Top = 43 Top = 43
Width = 65 Width = 55
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'File' Caption = 'File'
@ -118,7 +120,7 @@ object frmExportGrid: TfrmExportGrid
object editFilename: TButtonedEdit object editFilename: TButtonedEdit
Left = 79 Left = 79
Top = 42 Top = 42
Width = 274 Width = 264
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
@ -136,7 +138,7 @@ object frmExportGrid: TfrmExportGrid
object comboEncoding: TComboBox object comboEncoding: TComboBox
Left = 79 Left = 79
Top = 69 Top = 69
Width = 274 Width = 264
Height = 21 Height = 21
Style = csDropDownList Style = csDropDownList
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
@ -146,14 +148,14 @@ object frmExportGrid: TfrmExportGrid
object grpOptions: TGroupBox object grpOptions: TGroupBox
Left = 151 Left = 151
Top = 184 Top = 184
Width = 224 Width = 214
Height = 209 Height = 199
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
Caption = 'Options' Caption = 'Options'
TabOrder = 5 TabOrder = 5
DesignSize = ( DesignSize = (
224 214
209) 199)
object lblSeparator: TLabel object lblSeparator: TLabel
Left = 6 Left = 6
Top = 97 Top = 97
@ -185,7 +187,7 @@ object frmExportGrid: TfrmExportGrid
object chkIncludeColumnNames: TCheckBox object chkIncludeColumnNames: TCheckBox
Left = 6 Left = 6
Top = 18 Top = 18
Width = 201 Width = 191
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Include column names' Caption = 'Include column names'
@ -196,7 +198,7 @@ object frmExportGrid: TfrmExportGrid
object editSeparator: TButtonedEdit object editSeparator: TButtonedEdit
Left = 106 Left = 106
Top = 93 Top = 93
Width = 103 Width = 93
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
@ -211,7 +213,7 @@ object frmExportGrid: TfrmExportGrid
object editEncloser: TButtonedEdit object editEncloser: TButtonedEdit
Left = 106 Left = 106
Top = 119 Top = 119
Width = 103 Width = 93
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
@ -225,7 +227,7 @@ object frmExportGrid: TfrmExportGrid
object editTerminator: TButtonedEdit object editTerminator: TButtonedEdit
Left = 106 Left = 106
Top = 145 Top = 145
Width = 103 Width = 93
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
@ -240,7 +242,7 @@ object frmExportGrid: TfrmExportGrid
object chkIncludeAutoIncrement: TCheckBox object chkIncludeAutoIncrement: TCheckBox
Left = 6 Left = 6
Top = 41 Top = 41
Width = 201 Width = 191
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Include auto increment column' Caption = 'Include auto increment column'
@ -257,7 +259,7 @@ object frmExportGrid: TfrmExportGrid
object editNull: TButtonedEdit object editNull: TButtonedEdit
Left = 106 Left = 106
Top = 172 Top = 172
Width = 103 Width = 93
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
@ -271,7 +273,7 @@ object frmExportGrid: TfrmExportGrid
end end
object btnSetClipboardDefaults: TButton object btnSetClipboardDefaults: TButton
Left = 8 Left = 8
Top = 399 Top = 389
Width = 153 Width = 153
Height = 25 Height = 25
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]

View File

@ -4,12 +4,13 @@ interface
uses uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList; Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList,
extra_controls;
type type
TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efLaTeX, efWiki, efPHPArray, efMarkDown, efJSON); TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efLaTeX, efWiki, efPHPArray, efMarkDown, efJSON);
TfrmExportGrid = class(TForm) TfrmExportGrid = class(TFormWithSizeGrip)
btnOK: TButton; btnOK: TButton;
btnCancel: TButton; btnCancel: TButton;
grpFormat: TRadioGroup; grpFormat: TRadioGroup;
@ -64,6 +65,7 @@ type
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure grpFormatClick(Sender: TObject); procedure grpFormatClick(Sender: TObject);
procedure btnSetClipboardDefaultsClick(Sender: TObject); procedure btnSetClipboardDefaultsClick(Sender: TObject);
procedure FormResize(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FCSVEditor: TButtonedEdit; FCSVEditor: TButtonedEdit;
@ -102,6 +104,8 @@ var
FormatDesc: String; FormatDesc: String;
begin begin
TranslateComponent(Self); TranslateComponent(Self);
Width := AppSettings.ReadInt(asGridExportWindowWidth);
Height := AppSettings.ReadInt(asGridExportWindowHeight);
editFilename.Text := AppSettings.ReadString(asGridExportFilename); editFilename.Text := AppSettings.ReadString(asGridExportFilename);
radioOutputCopyToClipboard.Checked := AppSettings.ReadBool(asGridExportOutputCopy); radioOutputCopyToClipboard.Checked := AppSettings.ReadBool(asGridExportOutputCopy);
radioOutputFile.Checked := AppSettings.ReadBool(asGridExportOutputFile); radioOutputFile.Checked := AppSettings.ReadBool(asGridExportOutputFile);
@ -142,7 +146,10 @@ end;
procedure TfrmExportGrid.FormDestroy(Sender: TObject); procedure TfrmExportGrid.FormDestroy(Sender: TObject);
begin begin
// Store settings // Store settings
if (ModalResult = mrOK) and (not FHiddenCopyMode) then begin if not FHiddenCopyMode then begin
AppSettings.WriteInt(asGridExportWindowWidth, Width);
AppSettings.WriteInt(asGridExportWindowHeight, Height);
if ModalResult = mrOK then begin
AppSettings.WriteBool(asGridExportOutputCopy, radioOutputCopyToClipboard.Checked); AppSettings.WriteBool(asGridExportOutputCopy, radioOutputCopyToClipboard.Checked);
AppSettings.WriteBool(asGridExportOutputFile, radioOutputFile.Checked); AppSettings.WriteBool(asGridExportOutputFile, radioOutputFile.Checked);
AppSettings.WriteString(asGridExportFilename, editFilename.Text); AppSettings.WriteString(asGridExportFilename, editFilename.Text);
@ -158,9 +165,19 @@ begin
AppSettings.WriteString(asGridExportTerminator, FCSVTerminator); AppSettings.WriteString(asGridExportTerminator, FCSVTerminator);
AppSettings.WriteString(asGridExportNull, FCSVNull); AppSettings.WriteString(asGridExportNull, FCSVNull);
end; end;
end;
end; end;
procedure TfrmExportGrid.FormResize(Sender: TObject);
begin
grpFormat.Width := Width div 3;
grpSelection.Left := grpFormat.Left + grpFormat.Width + 8;
grpSelection.Width := Width - grpSelection.Left - 24;
grpOptions.Left := grpSelection.Left;
grpOptions.Width := grpSelection.Width;
end;
procedure TfrmExportGrid.FormShow(Sender: TObject); procedure TfrmExportGrid.FormShow(Sender: TObject);
begin begin
// Show dialog. Expect "Grid" property to be set now by the caller. // Show dialog. Expect "Grid" property to be set now by the caller.