diff options
-rw-r--r-- | src/corelib/fpg_base.pas | 18 | ||||
-rw-r--r-- | src/gui/fpg_dialogs.pas | 8 | ||||
-rw-r--r-- | src/gui/fpg_form.pas | 4 | ||||
-rw-r--r-- | src/gui/messagedialog.inc | 8 | ||||
-rw-r--r-- | uidesigner/newformdesigner.pas | 2 | ||||
-rw-r--r-- | uidesigner/vfddesigner.pas | 8 | ||||
-rw-r--r-- | uidesigner/vfdforms.pas | 6 | ||||
-rw-r--r-- | uidesigner/vfdmain.pas | 5 | ||||
-rw-r--r-- | uidesigner/vfdpropeditgrid.pas | 5 | ||||
-rw-r--r-- | uidesigner/vfdprops.pas | 2 | ||||
-rw-r--r-- | uidesigner/vfdwidgets.pas | 2 |
11 files changed, 27 insertions, 41 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas index c592e6e7..b3595300 100644 --- a/src/corelib/fpg_base.pas +++ b/src/corelib/fpg_base.pas @@ -32,7 +32,6 @@ type TfpgColor = type longword; // Always in RRGGBB (Alpha, Red, Green, Blue) format!! TfpgString = type string; TfpgChar = type string[4]; - TfpgModalResult = Low(integer)..MaxInt; PPoint = ^TPoint; @@ -59,6 +58,10 @@ type TClipboardKeyType = (ckNone, ckCopy, ckPaste, ckCut); + // If you have to convert this to an Integer, mrNone = 0 etc. + TfpgModalResult = (mrNone, mrOK, mrCancel, mrYes, mrNo, mrAbort, mrRetry, + mrIgnore, mrAll, mrNoToAll, mrYesToAll); + const MOUSE_LEFT = 1; MOUSE_RIGHT = 3; @@ -90,19 +93,6 @@ const // The special keys, based on the well-known keyboard scan codes {$I keys.inc} - { TfpgModalResult values } - mrNone = 0; - mrOk = mrNone + 1; - mrCancel = mrOk + 1; - mrYes = mrCancel + 1; - mrNo = mrYes + 1; - mrAbort = mrNo + 1; - mrRetry = mrAbort + 1; - mrIgnore = mrRetry + 1; - mrAll = mrIgnore + 1; - mrNoToAll = mrAll + 1; - mrYesToAll = mrNoToAll + 1; - { Default fpGUI help viewer } FPG_HELPVIEWER = 'docview'; diff --git a/src/gui/fpg_dialogs.pas b/src/gui/fpg_dialogs.pas index 1136ea0b..a98ff328 100644 --- a/src/gui/fpg_dialogs.pas +++ b/src/gui/fpg_dialogs.pas @@ -342,7 +342,7 @@ begin Result := False; frm := TfpgFontSelectDialog.Create(nil); frm.SetFontDesc(FontDesc); - if frm.ShowModal = 1 then + if frm.ShowModal = mrOK then begin FontDesc := frm.GetFontDesc; Result := True; @@ -1228,7 +1228,7 @@ var begin dlg := TfpgNewDirDialog.Create(nil); try - if dlg.ShowModal = 1 then + if dlg.ShowModal = mrOK then begin if dlg.Directory <> '' then begin @@ -1385,7 +1385,7 @@ begin btnOK.ImageName := 'stdimg.open'; // Do NOT localize btnOK.Text := rsOpen; - if ShowModal = 1 then + if ShowModal = mrOK then Result := True else Result := False; @@ -1409,7 +1409,7 @@ begin btnOK.ImageName := 'stdimg.save'; // Do NOT localize btnOK.Text := rsSave; - if ShowModal = 1 then + if ShowModal = mrOK then Result := True else Result := False; diff --git a/src/gui/fpg_form.pas b/src/gui/fpg_form.pas index 26d24f0d..254477e6 100644 --- a/src/gui/fpg_form.pas +++ b/src/gui/fpg_form.pas @@ -97,7 +97,7 @@ type procedure InvokeHelp; override; procedure Show; procedure Hide; - function ShowModal: integer; + function ShowModal: TfpgModalResult; procedure Close; function CloseQuery: boolean; virtual; end; @@ -288,7 +288,7 @@ begin HandleShow; end; -function TfpgBaseForm.ShowModal: integer; +function TfpgBaseForm.ShowModal: TfpgModalResult; var lCloseAction: TCloseAction; begin diff --git a/src/gui/messagedialog.inc b/src/gui/messagedialog.inc index f07ec013..10ffd515 100644 --- a/src/gui/messagedialog.inc +++ b/src/gui/messagedialog.inc @@ -170,9 +170,9 @@ var { TODO : At some stage the StyleManager can give us the correct button order based on the OS and Window Manager. } Result := 3; - sl.Add(cMsgDlgBtnText[mbYes] + '=' + IntToStr(mrYes)); - sl.Add(cMsgDlgBtnText[mbNo] + '=' + IntToStr(mrNo)); - sl.Add(cMsgDlgBtnText[mbCancel] + '=' + IntToStr(mrCancel)); + sl.Add(cMsgDlgBtnText[mbYes] + '=' + IntToStr(Integer(mrYes))); + sl.Add(cMsgDlgBtnText[mbNo] + '=' + IntToStr(Integer(mrNo))); + sl.Add(cMsgDlgBtnText[mbCancel] + '=' + IntToStr(Integer(mrCancel))); case DefaultButton of mbYes: lDefault := 0; mbNo: lDefault := 1; @@ -207,7 +207,7 @@ begin b := TfpgButton.Create(self); b.Name := 'DlgButton' + IntToStr(i+1); b.Text := sl.Names[i]; - b.ModalResult := StrToInt(sl.ValueFromIndex[i]); + b.ModalResult := TfpgModalResult(StrToInt(sl.ValueFromIndex[i])); if (i = lDefault) or (lcount = 1) then b.Default := True; FButtonList.Add(b); diff --git a/uidesigner/newformdesigner.pas b/uidesigner/newformdesigner.pas index 2e5d00d9..87feed33 100644 --- a/uidesigner/newformdesigner.pas +++ b/uidesigner/newformdesigner.pas @@ -224,7 +224,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := 'stdimg.close'; - ModalResult := 1; + ModalResult := mrOK; TabOrder := 2; end; diff --git a/uidesigner/vfddesigner.pas b/uidesigner/vfddesigner.pas index 9c120686..5405b9bb 100644 --- a/uidesigner/vfddesigner.pas +++ b/uidesigner/vfddesigner.pas @@ -676,7 +676,7 @@ begin if fi <= frm.list.ItemCount then frm.list.FocusItem := fi; - if frm.ShowModal = 1 then + if frm.ShowModal = mrOK then begin for n := 0 to FWidgets.Count - 1 do TWidgetDesigner(FWidgets.Items[n]).Widget.Visible := False; @@ -747,7 +747,7 @@ begin if fi <= frm.list.ItemCount then frm.list.FocusItem := fi; - if frm.ShowModal = 1 then + if frm.ShowModal = mrOK then begin taborder := 1; for n := 0 to frm.List.Items.Count - 1 do @@ -1051,7 +1051,7 @@ begin end; posval := -9999; - if frm.ShowModal = 1 then + if frm.ShowModal = mrOK then posval := StrToIntDef(frm.edPos.Text, -9999); frm.Free; @@ -1422,7 +1422,7 @@ begin //frmie.Top := ay; frmie.edItems.Lines.Assign(sl); - if frmie.ShowModal = 1 then + if frmie.ShowModal = mrOK then begin // Writeln('OK'); sl.Assign(frmie.edItems.Lines); diff --git a/uidesigner/vfdforms.pas b/uidesigner/vfdforms.pas index 00bb3e38..ec60265d 100644 --- a/uidesigner/vfdforms.pas +++ b/uidesigner/vfdforms.pas @@ -364,9 +364,9 @@ var begin if Sender = btnOK then - ModalResult := 1 + ModalResult := mrOK else if Sender = btnCancel then - ModalResult := 2 + ModalResult := mrCancel else begin // up / down @@ -512,7 +512,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := 'stdimg.cancel'; - ModalResult := -1; + ModalResult := mrCancel; TabOrder := 7; end; diff --git a/uidesigner/vfdmain.pas b/uidesigner/vfdmain.pas index 7468a99f..a6b8f0b2 100644 --- a/uidesigner/vfdmain.pas +++ b/uidesigner/vfdmain.pas @@ -24,6 +24,7 @@ interface uses Classes, SysUtils, + fpg_base, fpg_main, fpg_widget, fpg_dialogs, @@ -278,7 +279,7 @@ var nfrm: TNewFormForm; begin nfrm := TNewFormForm.Create(nil); - if nfrm.ShowModal = 1 then + if nfrm.ShowModal = mrOK then if nfrm.edName.Text <> '' then begin fd := TFormDesigner.Create; @@ -412,7 +413,7 @@ var begin frm := TfrmVFDSetup.Create(nil); try - if frm.ShowModal = 1 then + if frm.ShowModal = mrOK then begin LoadDefaults; frmMain.mru.MaxItems := gINI.ReadInteger('Options', 'MRUFileCount', 4); diff --git a/uidesigner/vfdpropeditgrid.pas b/uidesigner/vfdpropeditgrid.pas index bd41f3ee..1a6944cb 100644 --- a/uidesigner/vfdpropeditgrid.pas +++ b/uidesigner/vfdpropeditgrid.pas @@ -227,7 +227,6 @@ begin Text := 'New'; FontDesc := '#Label1'; ImageName := ''; - ModalResult := 0; OnClick := @NewButtonClick; end; @@ -239,7 +238,6 @@ begin Text := 'Delete'; FontDesc := '#Label1'; ImageName := ''; - ModalResult := 0; OnClick := @DeleteButtonClick; end; @@ -251,7 +249,6 @@ begin Text := 'UP'; FontDesc := '#Label1'; ImageName := ''; - ModalResult := 0; OnClick := @UpDownButtonClick; end; @@ -263,7 +260,6 @@ begin Text := 'DOWN'; FontDesc := '#Label1'; ImageName := ''; - ModalResult := 0; OnClick := @UpDownButtonClick; end; @@ -275,7 +271,6 @@ begin Text := 'Close'; FontDesc := '#Label1'; ImageName := 'stdimg.close'; - ModalResult := 0; OnClick := @CloseButtonClick; end; diff --git a/uidesigner/vfdprops.pas b/uidesigner/vfdprops.pas index 0332a47d..99e932a5 100644 --- a/uidesigner/vfdprops.pas +++ b/uidesigner/vfdprops.pas @@ -173,7 +173,7 @@ begin frm := TItemEditorForm.Create(nil); try frm.edItems.Lines.Assign(sl); - if frm.ShowModal = 1 then + if frm.ShowModal = mrOK then sl.Assign(frm.edItems.Lines); finally frm.Free; diff --git a/uidesigner/vfdwidgets.pas b/uidesigner/vfdwidgets.pas index 597a6a30..112462f4 100644 --- a/uidesigner/vfdwidgets.pas +++ b/uidesigner/vfdwidgets.pas @@ -360,7 +360,7 @@ begin wc.AddProperty('ImageMargin', TPropertyInteger, 'Space between image and border, -1 centers image/text'); wc.AddProperty('ImageName', TPropertyString, ''); wc.AddProperty('ImageSpacing', TPropertyInteger, 'Space between image and text, -1 centers text'); - wc.AddProperty('ModalResult', TPropertyInteger, ''); + wc.AddProperty('ModalResult', TPropertyEnum, 'Modal Result returned and overrides the OnClick event handler'); wc.AddProperty('ParentShowHint', TPropertyBoolean, ''); wc.AddProperty('ShowHint', TPropertyBoolean, ''); wc.AddProperty('ShowImage', TPropertyBoolean, 'Boolean value'); |