diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2014-07-17 06:16:33 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2014-07-17 06:16:33 +0100 |
commit | 55acea5de3fedec43b04d62fe8ea0200a884027d (patch) | |
tree | 0051890a0dae332bf6372aac96f6d7a8ac4eb1eb | |
parent | 8ab190907e17f29a54ef5e8201908124dffc8fde (diff) | |
parent | 42ad4a1ac8b68cef017f984aa746bf0f68f696f0 (diff) | |
download | fpGUI-55acea5de3fedec43b04d62fe8ea0200a884027d.tar.xz |
Merge branch 'jml/integer_input_dialog' into develop
-rw-r--r-- | src/corelib/gdi/fpgui_toolkit.lpk | 6 | ||||
-rw-r--r-- | src/corelib/x11/fpgui_toolkit.lpk | 6 | ||||
-rw-r--r-- | src/gui/fpg_dialogs.pas | 5 | ||||
-rw-r--r-- | src/gui/inputintegerdialog.inc | 157 | ||||
-rw-r--r-- | src/gui/inputquerydialog.inc | 2 |
5 files changed, 172 insertions, 4 deletions
diff --git a/src/corelib/gdi/fpgui_toolkit.lpk b/src/corelib/gdi/fpgui_toolkit.lpk index f2dc4202..c4e4958e 100644 --- a/src/corelib/gdi/fpgui_toolkit.lpk +++ b/src/corelib/gdi/fpgui_toolkit.lpk @@ -31,7 +31,7 @@ <Description Value="fpGUI Toolkit"/> <License Value="LGPL 2 with static linking exception."/> <Version Major="1"/> - <Files Count="103"> + <Files Count="104"> <Item1> <Filename Value="..\stdimages.inc"/> <Type Value="Include"/> @@ -444,6 +444,10 @@ <Filename Value="..\..\gui\fpg_style_win8.pas"/> <UnitName Value="fpg_style_win8"/> </Item103> + <Item104> + <Filename Value="..\..\gui\inputquerydialog.inc"/> + <Type Value="Include"/> + </Item104> </Files> <LazDoc Paths="..\..\..\docs\xml\corelib;..\..\..\docs\xml\corelib\x11;..\..\..\docs\xml\corelib\gdi;..\..\..\docs\xml\gui"/> <RequiredPkgs Count="1"> diff --git a/src/corelib/x11/fpgui_toolkit.lpk b/src/corelib/x11/fpgui_toolkit.lpk index d5ad23c8..96af53ed 100644 --- a/src/corelib/x11/fpgui_toolkit.lpk +++ b/src/corelib/x11/fpgui_toolkit.lpk @@ -29,7 +29,7 @@ <Description Value="fpGUI Toolkit"/> <License Value="LGPL 2 with static linking exception."/> <Version Major="1"/> - <Files Count="106"> + <Files Count="107"> <Item1> <Filename Value="../stdimages.inc"/> <Type Value="Include"/> @@ -454,6 +454,10 @@ <Filename Value="../../gui/fpg_scrollframe.pas"/> <UnitName Value="fpg_scrollframe"/> </Item106> + <Item107> + <Filename Value="../../gui/inputintegerdialog.inc"/> + <Type Value="Include"/> + </Item107> </Files> <LazDoc Paths="../../../docs/xml/corelib;../../../docs/xml/corelib/x11;../../../docs/xml/corelib/gdi;../../../docs/xml/gui"/> <RequiredPkgs Count="1"> diff --git a/src/gui/fpg_dialogs.pas b/src/gui/fpg_dialogs.pas index 8f3639e6..d1271bf9 100644 --- a/src/gui/fpg_dialogs.pas +++ b/src/gui/fpg_dialogs.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2012 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2014 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -227,6 +227,7 @@ type {$I charmapdialog.inc} {$I colordialog.inc} {$I inputquerydialog.inc} +{$I inputintegerdialog.inc} {$I managebookmarksdialog.inc} @@ -240,6 +241,7 @@ function SelectDirDialog(const AStartDir: TfpgString = ''): TfpgString; function fpgShowCharMap: TfpgString; function fpgSelectColorDialog(APresetColor: TfpgColor = clBlack): TfpgColor; function fpgInputQuery(const ACaption, APrompt: TfpgString; var Value: TfpgString): Boolean; +function fpgIntegerQuery(const ACaption, APrompt: TfpgString; var Value: Integer; MaxValue: Integer; MinValue: Integer): Boolean; implementation @@ -1632,6 +1634,7 @@ end; {$I charmapdialog.inc} {$I colordialog.inc} {$I inputquerydialog.inc} +{$I inputintegerdialog.inc} {$I managebookmarksdialog.inc} diff --git a/src/gui/inputintegerdialog.inc b/src/gui/inputintegerdialog.inc new file mode 100644 index 00000000..0c540b9b --- /dev/null +++ b/src/gui/inputintegerdialog.inc @@ -0,0 +1,157 @@ +{ + fpGUI - Free Pascal GUI Toolkit + + Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Description: + This unit contains the Input Query dialogs. +} + +{%mainunit fpg_dialogs.pas} + +{$IFDEF read_interface} + +type + + TfpgIntegerDialog = class(TfpgForm) + private + {@VFD_HEAD_BEGIN: fpgIntegerDialog} + lblText: TfpgLabel; + edtInteger: TfpgEditInteger; + btnOK: TfpgButton; + btnCancel: TfpgButton; + {@VFD_HEAD_END: fpgIntegerDialog} + procedure SetupCaptions; + procedure edtIntegerKeyPressed(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean); + protected + procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + public + procedure AfterCreate; override; + end; + + +{$ENDIF read_interface} + +{$IFDEF read_implementation} + +function fpgIntegerQuery(const ACaption, APrompt: TfpgString; var Value: Integer; MaxValue: Integer; MinValue: Integer= 0): Boolean; +var + dlg: TfpgIntegerDialog; +begin + dlg := TfpgIntegerDialog.Create(nil); + try + dlg.WindowTitle := ACaption; + dlg.lblText.Text := APrompt; + dlg.edtInteger.MaxValue:= MaxValue; + dlg.edtinteger.MinValue:= MinValue; + dlg.edtInteger.Value := Value; + Result := dlg.ShowModal = mrOK; + if Result then + Value := dlg.edtInteger.Value; + finally + dlg.Free; + end; +end; + +{ TfpgIntegerDialog } + +procedure TfpgIntegerDialog.SetupCaptions; +begin + btnOK.Text := rsOK; + btnCancel.Text := rsCancel; +end; + +procedure TfpgIntegerDialog.edtIntegerKeyPressed(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean); +begin + if KeyCode = keyEnter then + btnOK.Click; +end; + +procedure TfpgIntegerDialog.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); +begin + if KeyCode = keyEscape then + begin + consumed := True; + ModalResult := mrCancel; + end; +end; + +procedure TfpgIntegerDialog.AfterCreate; +begin + {%region 'Auto-generated GUI code' -fold} + {@VFD_BODY_BEGIN: fpgIntegerDialog} + Name := 'fpgIntegerDialog'; + SetPosition(100, 150, 208, 97); + WindowTitle := 'IntegerDialog'; + Hint := ''; + WindowPosition := wpOneThirdDown; + + lblText := TfpgLabel.Create(self); + with lblText do + begin + Name := 'lblText'; + SetPosition(8, 8, 208, 16); + Anchors := [anLeft,anRight,anTop]; + FontDesc := '#Label1'; + Hint := ''; + Text := 'lblText'; + end; + + edtInteger := TfpgEditInteger.Create(self); + with edtInteger do + begin + Name := 'edtInteger'; + SetPosition(8, 26, 100, 24); + Anchors := [anLeft,anRight,anTop]; + Hint := ''; + TabOrder := 2; + Text := ''; + FontDesc := '#Edit1'; + Value := 0; + OnKeyPress := @edtIntegerKeyPressed; + end; + + btnOK := TfpgButton.Create(self); + with btnOK do + begin + Name := 'btnOK'; + SetPosition(8, 64, 92, 24); + Anchors := [anRight,anBottom]; + Text := 'OK'; + FontDesc := '#Label1'; + Hint := ''; + ImageName := ''; + ModalResult := mrOK; + TabOrder := 3; + end; + + btnCancel := TfpgButton.Create(self); + with btnCancel do + begin + Name := 'btnCancel'; + SetPosition(108, 64, 92, 24); + Anchors := [anRight,anBottom]; + Text := 'Cancel'; + FontDesc := '#Label1'; + Hint := ''; + ImageName := ''; + ModalResult := mrCancel; + TabOrder := 4; + end; + + {@VFD_BODY_END: fpgIntegerDialog} + {%endregion} + + SetupCaptions; +end; + +{$ENDIF read_implementation} + diff --git a/src/gui/inputquerydialog.inc b/src/gui/inputquerydialog.inc index 6330d02c..b41af217 100644 --- a/src/gui/inputquerydialog.inc +++ b/src/gui/inputquerydialog.inc @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2014 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, |