diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-14 13:17:05 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-14 13:17:05 +0000 |
commit | b17a9f64a983fa86def54aa66edcd5edcd556790 (patch) | |
tree | ea23f5da436d69393f9420acf217443ff91c4ac0 | |
parent | 0ef9a3252d098c28ef2e32f793824afef01b1808 (diff) | |
download | fpGUI-b17a9f64a983fa86def54aa66edcd5edcd556790.tar.xz |
* Implemented a ModalResult type and related constants.
* Updated fpGUI framework to use the new TfpgModalResult type and mrXXX constants.
-rw-r--r-- | src/corelib/fpgfx.pas | 4 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 24 | ||||
-rw-r--r-- | src/gui/gui_button.pas | 6 | ||||
-rw-r--r-- | src/gui/gui_dialogs.pas | 20 | ||||
-rw-r--r-- | src/gui/gui_form.pas | 14 | ||||
-rw-r--r-- | src/gui/messagedialog.inc | 12 |
6 files changed, 48 insertions, 32 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index ddbee4d5..e915db0a 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -36,12 +36,12 @@ type txtAutoSize); TMouseButton = (mbLeft, mbRight, mbMiddle); - + const AllAnchors = [anLeft, anRight, anTop, anBottom]; TextFlagsDflt = [txtLeft, txtTop, txtEnabled]; - + // Used for the internal message queue cMessageQueueSize = 1024; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 67548997..e1e5400a 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -27,11 +27,12 @@ uses gfx_impl; type - TfpgCoord = integer; // we might use floating point coordinates in the future... - TfpgColor = type longword; // Always in RRGGBB (Alpha, Red, Green, Blue) format!! - TfpgString = type string; - TfpgChar = type string[4]; - + TfpgCoord = integer; // we might use floating point coordinates in the future... + TfpgColor = type longword; // Always in RRGGBB (Alpha, Red, Green, Blue) format!! + TfpgString = type string; + TfpgChar = type string[4]; + TfpgModalResult = Low(integer)..High(integer); + TRGBTriple = record Red: word; Green: word; @@ -81,6 +82,19 @@ 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; + var FPG_DEFAULT_FONT_DESC: string = 'Arial-10:antialias=true'; diff --git a/src/gui/gui_button.pas b/src/gui/gui_button.pas index 1f24a13b..17392714 100644 --- a/src/gui/gui_button.pas +++ b/src/gui/gui_button.pas @@ -46,7 +46,7 @@ type FClickOnPush: Boolean; FGroupIndex: integer; FAllowAllUp: boolean; - FModalResult: integer; + FModalResult: TfpgModalResult; function GetFontDesc: string; procedure SetDefault(const AValue: boolean); procedure SetEmbedded(const AValue: Boolean); @@ -100,7 +100,7 @@ type property ImageName: string read FImageName write SetImageName; property ImageSpacing: integer read FImageSpacing write SetImageSpacing default -1; property ImageLayout: TImageLayout read FImageLayout write SetImageLayout default ilImageLeft; - property ModalResult: integer read FModalResult write FModalResult default 0; + property ModalResult: TfpgModalResult read FModalResult write FModalResult default mrNone; property ShowImage: Boolean read FShowImage write SetShowImage default True; property Text: string read FText write SetText; public @@ -270,7 +270,7 @@ begin FImageLayout := ilImageLeft; FImageMargin := 3; // image is 3 pixels from edge of button. -1 will centre image. FImageSpacing := -1; // text is centered in remaining space - FModalResult := 0; + FModalResult := mrNone; FEmbedded := False; FDefault := False; FAllowAllUp := False; diff --git a/src/gui/gui_dialogs.pas b/src/gui/gui_dialogs.pas index d0397664..b9127337 100644 --- a/src/gui/gui_dialogs.pas +++ b/src/gui/gui_dialogs.pas @@ -53,7 +53,7 @@ type mtCustom); TfpgMsgDlgBtn = (mbNoButton, mbOK, mbCancel, mbYes, mbNo, mbAbort, - mbRetry, mbIgnore, mbYesToAll, mbNoToAll, mbHelp, mbClose); + mbRetry, mbIgnore, mbAll, mbNoToAll, mbYesToAll, mbHelp, mbClose); TfpgMsgDlgButtons = set of TfpgMsgDlgBtn; @@ -66,7 +66,7 @@ const cMsgDlgBtnText: array[TfpgMsgDlgBtn] of string = ( '', rsOK, rsCancel, rsYes, rsNo, rsAbort, rsRetry, rsIgnore, - rsYesToAll, rsNoToAll, rsHelp, rsClose ); + rsAll, rsNoToAll, rsYesToAll, rsHelp, rsClose ); type @@ -389,7 +389,7 @@ begin FButton := TfpgButton.Create(self); FButton.Text := cMsgDlgBtnText[mbOK]; FButton.Width := 75; - FButton.ModalResult := Ord(mbOK); + FButton.ModalResult := mrOK; end; destructor TfpgMessageBox.Destroy; @@ -423,12 +423,12 @@ end; procedure TfpgBaseDialog.btnOKClick(Sender: TObject); begin - ModalResult := 1; + ModalResult := mrOK; end; procedure TfpgBaseDialog.btnCancelClick(Sender: TObject); begin - ModalResult := 2; + ModalResult := mrCancel; Close; end; @@ -948,7 +948,7 @@ begin Text := ''; FontDesc := '#Label1'; ImageName := 'stdimg.folderup'; // Do NOT localize - ModalResult := 0; + ModalResult := mrNone; Focusable := False; OnClick := @UpDirClick; end; @@ -961,7 +961,7 @@ begin Text := ''; FontDesc := '#Label1'; ImageName := 'stdimg.foldernew'; // Do NOT localize - ModalResult := 0; + ModalResult := mrNone; Focusable := False; OnClick := @btnDirNewClicked; end; @@ -974,7 +974,7 @@ begin Text := ''; FontDesc := '#Label1'; ImageName := 'stdimg.hidden'; // Do NOT localize - ModalResult := 0; + ModalResult := mrNone; Focusable := False; GroupIndex := 1; AllowAllUp := True; @@ -1095,10 +1095,10 @@ begin if not FOpenMode or fpgFileExists(edFileName.Text) then begin - ModalResult := 1; + ModalResult := mrOK; end; - if ModalResult = 1 then + if ModalResult = mrOK then // FileName := fpgExpandFileName(edFileName.Text); FileName := grid.FileList.DirectoryName + edFileName.Text; end; diff --git a/src/gui/gui_form.pas b/src/gui/gui_form.pas index 27877bf9..f58d08f9 100644 --- a/src/gui/gui_form.pas +++ b/src/gui/gui_form.pas @@ -47,7 +47,7 @@ type FOnHide: TNotifyEvent; FOnShow: TNotifyEvent; protected - FModalResult: integer; + FModalResult: TfpgModalResult; FParentForm: TfpgBaseForm; FWindowPosition: TWindowPosition; FWindowTitle: string; @@ -68,7 +68,7 @@ type procedure DoOnClose(var CloseAction: TCloseAction); virtual; // properties property Sizeable: boolean read FSizeable write FSizeable; - property ModalResult: integer read FModalResult write FModalResult; + property ModalResult: TfpgModalResult read FModalResult write FModalResult; property FullScreen: boolean read FFullScreen write FFullScreen default False; property WindowPosition: TWindowPosition read FWindowPosition write FWindowPosition default wpAuto; property WindowTitle: string read FWindowTitle write SetWindowTitle; @@ -238,7 +238,7 @@ begin FTextColor := clText1; FMinWidth := 32; FMinHeight := 32; - FModalResult := 0; + FModalResult := mrNone; FFullScreen := False; FIsContainer := True; end; @@ -260,7 +260,7 @@ var begin FWindowType := wtModalForm; fpgApplication.PushModalForm(self); - ModalResult := 0; + ModalResult := mrNone; Show; @@ -270,7 +270,7 @@ begin try repeat fpgWaitWindowMessage; - until (ModalResult <> 0) or (not Visible); + until (ModalResult <> mrNone) or (not Visible); except on E: Exception do begin @@ -283,7 +283,7 @@ begin fpgApplication.PopModalForm; Result := ModalResult; - if ModalResult <> 0 then + if ModalResult <> mrNone then begin lCloseAction := caFree; // Dummy variable - we do nothing with it DoOnClose(lCloseAction); // Simply so the OnClose event fires. @@ -376,7 +376,7 @@ procedure TfpgBaseForm.Hide; begin Visible := False; // HandleHide; - if ModalResult = 0 then + if ModalResult = mrNone then ModalResult := -1; end; diff --git a/src/gui/messagedialog.inc b/src/gui/messagedialog.inc index 4e1257e7..d72a3de6 100644 --- a/src/gui/messagedialog.inc +++ b/src/gui/messagedialog.inc @@ -148,15 +148,15 @@ 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(Ord(mbYes))); - sl.Add(cMsgDlgBtnText[mbNo] + '=' + IntToStr(Ord(mbNo))); - sl.Add(cMsgDlgBtnText[mbCancel] + '=' + IntToStr(Ord(mbCancel))); + sl.Add(cMsgDlgBtnText[mbYes] + '=' + IntToStr(mrYes)); + sl.Add(cMsgDlgBtnText[mbNo] + '=' + IntToStr(mrNo)); + sl.Add(cMsgDlgBtnText[mbCancel] + '=' + IntToStr(mrCancel)); case DefaultButton of mbYes: lDefault := 0; mbNo: lDefault := 1; mbCancel: lDefault := 2; end; - Exit; + Exit; //==> end; // if we got here, try all known buttons. @@ -165,6 +165,8 @@ var if i in Buttons then begin inc(Result); + { TODO : How could we improve this to stay in sync with TfpgModalResult values + like mrOK, mrCancel etc... } sl.Add(cMsgDlgBtnText[i] + '=' + IntToStr(Ord(i))); if i = DefaultButton then lDefault := Result-1; @@ -300,7 +302,7 @@ procedure TfpgMessageDialog.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); begin if keycode = keyEscape then // Esc cancels the dialog - ModalResult := Ord(mbCancel) + ModalResult := mrCancel else inherited HandleKeyPress(keycode, shiftstate, consumed); end; |