Permalink
Browse files

Make grid export dialog resizable, store/restore its width and height…

…, and resize contained group boxes proportional to the window. See #19.
  • Loading branch information...
ansgarbecker committed Nov 13, 2018
1 parent f1c9f1a commit 55ed9ae7386bf4e9323d875bded0b3fd0aac6b55
Showing with 69 additions and 48 deletions.
  1. +3 −1 source/apphelpers.pas
  2. +32 −30 source/exportgrid.dfm
  3. +34 −17 source/exportgrid.pas
@@ -148,7 +148,7 @@ TQueryThread = class(TThread)
asStartupScriptFilename, asDatabases, asComment, asDatabaseFilter, asTableFilter, asExportSQLCreateDatabases,
asExportSQLCreateTables, asExportSQLDataHow, asExportSQLDataInsertSize, asExportSQLFilenames, asExportZIPFilenames, asExportSQLDirectories,
asExportSQLDatabase, asExportSQLServerDatabase, asExportSQLOutput, asExportSQLAddComments, asExportSQLRemoveAutoIncrement,
asGridExportOutputCopy, asGridExportOutputFile,
asGridExportWindowWidth, asGridExportWindowHeight, asGridExportOutputCopy, asGridExportOutputFile,
asGridExportFilename, asGridExportRecentFiles, asGridExportEncoding, asGridExportFormat, asGridExportSelection,
asGridExportColumnNames, asGridExportIncludeAutoInc, asGridExportIncludeQuery,
asGridExportSeparator, asGridExportEncloser, asGridExportTerminator, asGridExportNull,
@@ -3621,6 +3621,8 @@ constructor TAppSettings.Create;
InitSetting(asExportSQLOutput, 'ExportSQL_Output', 0);
InitSetting(asExportSQLAddComments, 'ExportSQLAddComments', 0, True);
InitSetting(asExportSQLRemoveAutoIncrement, 'ExportSQLRemoveAutoIncrement', 0, False);
InitSetting(asGridExportWindowWidth, 'GridExportWindowWidth', 400);
InitSetting(asGridExportWindowHeight, 'GridExportWindowHeight', 460);
InitSetting(asGridExportOutputCopy, 'GridExportOutputCopy', 0, True);
InitSetting(asGridExportOutputFile, 'GridExportOutputFile', 0, False);
InitSetting(asGridExportFilename, 'GridExportFilename', 0, False, '');
@@ -1,26 +1,28 @@
object frmExportGrid: TfrmExportGrid
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Export grid rows'
ClientHeight = 432
ClientWidth = 383
ClientHeight = 422
ClientWidth = 373
Color = clBtnFace
Constraints.MinHeight = 450
Constraints.MinWidth = 350
ParentFont = True
OldCreateOrder = False
Position = poMainFormCenter
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
OnResize = FormResize
OnShow = FormShow
DesignSize = (
383
432)
373
422)
PixelsPerInch = 96
TextHeight = 13
object btnOK: TButton
Left = 219
Top = 399
Left = 209
Top = 389
Width = 75
Height = 25
Anchors = [akRight, akBottom]
@@ -31,8 +33,8 @@ object frmExportGrid: TfrmExportGrid
OnClick = btnOKClick
end
object btnCancel: TButton
Left = 300
Top = 399
Left = 290
Top = 389
Width = 75
Height = 25
Anchors = [akRight, akBottom]
@@ -45,7 +47,7 @@ object frmExportGrid: TfrmExportGrid
Left = 8
Top = 112
Width = 137
Height = 281
Height = 271
Anchors = [akLeft, akTop, akBottom]
Caption = 'Output format'
ItemIndex = 0
@@ -65,9 +67,9 @@ object frmExportGrid: TfrmExportGrid
object grpSelection: TRadioGroup
Left = 151
Top = 112
Width = 224
Width = 214
Height = 66
Anchors = [akLeft, akTop, akRight]
Anchors = [akTop, akRight]
Caption = 'Row selection'
ItemIndex = 1
Items.Strings = (
@@ -78,13 +80,13 @@ object frmExportGrid: TfrmExportGrid
object grpOutput: TGroupBox
Left = 8
Top = 8
Width = 367
Width = 357
Height = 98
Anchors = [akLeft, akTop, akRight]
Caption = 'Output target'
TabOrder = 4
DesignSize = (
367
357
98)
object lblEncoding: TLabel
Left = 8
@@ -96,7 +98,7 @@ object frmExportGrid: TfrmExportGrid
object radioOutputCopyToClipboard: TRadioButton
Left = 8
Top = 18
Width = 345
Width = 335
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Copy to clipboard'
@@ -108,7 +110,7 @@ object frmExportGrid: TfrmExportGrid
object radioOutputFile: TRadioButton
Left = 8
Top = 43
Width = 65
Width = 55
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'File'
@@ -118,7 +120,7 @@ object frmExportGrid: TfrmExportGrid
object editFilename: TButtonedEdit
Left = 79
Top = 42
Width = 274
Width = 264
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
@@ -136,7 +138,7 @@ object frmExportGrid: TfrmExportGrid
object comboEncoding: TComboBox
Left = 79
Top = 69
Width = 274
Width = 264
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
@@ -146,14 +148,14 @@ object frmExportGrid: TfrmExportGrid
object grpOptions: TGroupBox
Left = 151
Top = 184
Width = 224
Height = 209
Anchors = [akLeft, akTop, akRight, akBottom]
Width = 214
Height = 199
Anchors = [akTop, akRight, akBottom]
Caption = 'Options'
TabOrder = 5
DesignSize = (
224
209)
214
199)
object lblSeparator: TLabel
Left = 6
Top = 97
@@ -185,7 +187,7 @@ object frmExportGrid: TfrmExportGrid
object chkIncludeColumnNames: TCheckBox
Left = 6
Top = 18
Width = 201
Width = 191
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Include column names'
@@ -196,7 +198,7 @@ object frmExportGrid: TfrmExportGrid
object editSeparator: TButtonedEdit
Left = 106
Top = 93
Width = 103
Width = 93
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
@@ -211,7 +213,7 @@ object frmExportGrid: TfrmExportGrid
object editEncloser: TButtonedEdit
Left = 106
Top = 119
Width = 103
Width = 93
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
@@ -225,7 +227,7 @@ object frmExportGrid: TfrmExportGrid
object editTerminator: TButtonedEdit
Left = 106
Top = 145
Width = 103
Width = 93
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
@@ -240,7 +242,7 @@ object frmExportGrid: TfrmExportGrid
object chkIncludeAutoIncrement: TCheckBox
Left = 6
Top = 41
Width = 201
Width = 191
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Include auto increment column'
@@ -257,7 +259,7 @@ object frmExportGrid: TfrmExportGrid
object editNull: TButtonedEdit
Left = 106
Top = 172
Width = 103
Width = 93
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
@@ -271,7 +273,7 @@ object frmExportGrid: TfrmExportGrid
end
object btnSetClipboardDefaults: TButton
Left = 8
Top = 399
Top = 389
Width = 153
Height = 25
Anchors = [akLeft, akBottom]
@@ -4,12 +4,13 @@ interface
uses
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
TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efLaTeX, efWiki, efPHPArray, efMarkDown, efJSON);
TfrmExportGrid = class(TForm)
TfrmExportGrid = class(TFormWithSizeGrip)
btnOK: TButton;
btnCancel: TButton;
grpFormat: TRadioGroup;
@@ -64,6 +65,7 @@ TfrmExportGrid = class(TForm)
procedure FormShow(Sender: TObject);
procedure grpFormatClick(Sender: TObject);
procedure btnSetClipboardDefaultsClick(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
FCSVEditor: TButtonedEdit;
@@ -102,6 +104,8 @@ procedure TfrmExportGrid.FormCreate(Sender: TObject);
FormatDesc: String;
begin
TranslateComponent(Self);
Width := AppSettings.ReadInt(asGridExportWindowWidth);
Height := AppSettings.ReadInt(asGridExportWindowHeight);
editFilename.Text := AppSettings.ReadString(asGridExportFilename);
radioOutputCopyToClipboard.Checked := AppSettings.ReadBool(asGridExportOutputCopy);
radioOutputFile.Checked := AppSettings.ReadBool(asGridExportOutputFile);
@@ -142,25 +146,38 @@ procedure TfrmExportGrid.FormCreate(Sender: TObject);
procedure TfrmExportGrid.FormDestroy(Sender: TObject);
begin
// Store settings
if (ModalResult = mrOK) and (not FHiddenCopyMode) then begin
AppSettings.WriteBool(asGridExportOutputCopy, radioOutputCopyToClipboard.Checked);
AppSettings.WriteBool(asGridExportOutputFile, radioOutputFile.Checked);
AppSettings.WriteString(asGridExportFilename, editFilename.Text);
AppSettings.WriteString(asGridExportRecentFiles, ImplodeStr(DELIM, FRecentFiles));
AppSettings.WriteInt(asGridExportEncoding, comboEncoding.ItemIndex);
AppSettings.WriteInt(asGridExportFormat, grpFormat.ItemIndex);
AppSettings.WriteInt(asGridExportSelection, grpSelection.ItemIndex);
AppSettings.WriteBool(asGridExportColumnNames, chkIncludeColumnNames.Checked);
AppSettings.WriteBool(asGridExportIncludeAutoInc, chkIncludeAutoIncrement.Checked);
AppSettings.WriteBool(asGridExportIncludeQuery, chkIncludeQuery.Checked);
AppSettings.WriteString(asGridExportSeparator, FCSVSeparator);
AppSettings.WriteString(asGridExportEncloser, FCSVEncloser);
AppSettings.WriteString(asGridExportTerminator, FCSVTerminator);
AppSettings.WriteString(asGridExportNull, FCSVNull);
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(asGridExportOutputFile, radioOutputFile.Checked);
AppSettings.WriteString(asGridExportFilename, editFilename.Text);
AppSettings.WriteString(asGridExportRecentFiles, ImplodeStr(DELIM, FRecentFiles));
AppSettings.WriteInt(asGridExportEncoding, comboEncoding.ItemIndex);
AppSettings.WriteInt(asGridExportFormat, grpFormat.ItemIndex);
AppSettings.WriteInt(asGridExportSelection, grpSelection.ItemIndex);
AppSettings.WriteBool(asGridExportColumnNames, chkIncludeColumnNames.Checked);
AppSettings.WriteBool(asGridExportIncludeAutoInc, chkIncludeAutoIncrement.Checked);
AppSettings.WriteBool(asGridExportIncludeQuery, chkIncludeQuery.Checked);
AppSettings.WriteString(asGridExportSeparator, FCSVSeparator);
AppSettings.WriteString(asGridExportEncloser, FCSVEncloser);
AppSettings.WriteString(asGridExportTerminator, FCSVTerminator);
AppSettings.WriteString(asGridExportNull, FCSVNull);
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);
begin
// Show dialog. Expect "Grid" property to be set now by the caller.

0 comments on commit 55ed9ae

Please sign in to comment.