1{%MainUnit fpguiint.pp} 2 3{****************************************************************************** 4 All FPGUI interface communication implementations. 5 Initial Revision : Sun Nov 23 23:53:53 2003 6 7 8 !! Keep alphabetical !! 9 10 Support routines go to gtkproc.pp 11 12 ****************************************************************************** 13 Implementation 14 ****************************************************************************** 15 16 ***************************************************************************** 17 This file is part of the Lazarus Component Library (LCL) 18 19 See the file COPYING.modifiedLGPL.txt, included in this distribution, 20 for details about the license. 21 ***************************************************************************** 22} 23 24//##apiwiz##sps## // Do not remove 25 26const 27 IdButtonToFPGuiStandardButton: array[idButtonOK..idButtonShield] of TfpgMsgDlgBtn = ( 28 { idButtonOk } mbOK, 29 { idButtonCancel } mbCancel, 30 { idButtonHelp } mbHelp, 31 { idButtonYes } mbYes, 32 { idButtonNo } mbNo, 33 { idButtonClose } mbClose, 34 { idButtonAbort } mbAbort, 35 { idButtonRetry } mbRetry, 36 { idButtonIgnore } mbIgnore, 37 { idButtonAll } mbAll, 38 { idButtonYesToAll } mbYesToAll, 39 { idButtonNoToAll } mbNoToAll, 40 { idButtonOpen } mbNoButton, 41 { idButtonSave } mbNoButton, 42 { idButtonShield } mbNoButton 43 ); 44 45 46function TFpGuiWidgetSet.PromptUser(const DialogCaption, DialogMessage: String; 47 DialogType: longint; Buttons: PLongint; ButtonCount, DefaultIndex, 48 EscapeResult: Longint): Longint; 49var 50 btns: TfpgMsgDlgButtons; 51 BtnIdx, BtnID: LongInt; 52 ResultBtn: TfpgMsgDlgBtn; 53 54 function ResponseMappingfpGUItoLCL(const AResultBtn: TfpgMsgDlgBtn): Integer; 55 begin 56 { LCL is so confusing with modal results, button types, button results and 57 Integer/LongInt as possible return results in various location is the 58 LCL. I based the following mapping on trial-and-error with LCL-GTK2, and 59 a best guess. } 60 case AResultBtn of 61 mbNoButton: Result := idButtonBase; // ??? 62 mbOK: Result := idButtonOK; 63 mbCancel: Result := idButtonCancel; 64 mbYes: Result := idButtonYes; 65 mbNo: Result := idButtonNo; 66 mbAbort: Result := idButtonAbort; 67 mbRetry: Result := idButtonRetry; 68 mbIgnore: Result := idButtonIgnore; 69 mbAll: Result := idButtonAll; 70 mbNoToAll: Result := idButtonNoToAll; 71 mbYesToAll: Result := idButtonYesToAll; 72 mbHelp: Result := idButtonHelp; 73 mbClose: Result := idButtonClose; 74 end; 75 end; 76 77begin 78 ResultBtn := mbOK; 79 btns := []; 80 for BtnIdx := 0 to ButtonCount-1 do 81 begin 82 BtnID := Buttons[BtnIdx]; 83 if (BtnID >= Low(IdButtonToFPGuiStandardButton)) and 84 (BtnID <= High(IdButtonToFPGuiStandardButton)) and 85 (IdButtonToFPGuiStandardButton[BtnID] <> mbNoButton) then 86 Include(btns, IdButtonToFPGuiStandardButton[BtnID]) 87 else 88 btns := [mbOK]; 89 end; 90 91 case DialogType of 92 idDialogWarning: ResultBtn := TfpgMessageDialog.Warning(DialogCaption, DialogMessage, btns); 93 idDialogError: ResultBtn := TfpgMessageDialog.Critical(DialogCaption, DialogMessage, btns); 94 idDialogInfo: ResultBtn :=TfpgMessageDialog.Information(DialogCaption, DialogMessage, btns); 95 idDialogConfirm: ResultBtn := TfpgMessageDialog.Question(DialogCaption, DialogMessage, btns); 96 else 97 begin 98 fpg_dialogs.ShowMessage(DialogMessage, DialogCaption); 99 end; 100 end; 101 102 Result := ResponseMappingfpGUItoLCL(ResultBtn); 103end; 104 105{------------------------------------------------------------------------------ 106 Function: RawImage_QueryDescription 107 Params: AFlags: 108 ADesc: 109 Returns: 110 111 ------------------------------------------------------------------------------} 112//function TFpguiWidgetSet.RawImage_QueryDescription(AFlags: TRawImageQueryFlags; var ADesc: TRawImageDescription): Boolean; 113//begin 114// // override only when queried formats are different from screen description 115//end; 116 117//##apiwiz##eps## // Do not remove, no wizard declaration after this line 118 119