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
46{------------------------------------------------------------------------------
47  function FontCanUTF8(Font: HFont): boolean;
48
49  True if font recognizes Unicode UTF8 encoding.
50
51  FPGUI supports only Unicode
52 ------------------------------------------------------------------------------}
53function TFpGuiWidgetSet.FontCanUTF8(Font: HFont): boolean;
54begin
55  Result := True;
56end;
57
58function TFpGuiWidgetSet.PromptUser(const DialogCaption, DialogMessage: String;
59  DialogType: longint; Buttons: PLongint; ButtonCount, DefaultIndex,
60  EscapeResult: Longint): Longint;
61var
62  btns: TfpgMsgDlgButtons;
63  BtnIdx, BtnID: LongInt;
64  ResultBtn: TfpgMsgDlgBtn;
65
66  function ResponseMappingfpGUItoLCL(const AResultBtn: TfpgMsgDlgBtn): Integer;
67  begin
68    { LCL is so confusing with modal results, button types, button results and
69      Integer/LongInt as possible return results in various location is the
70      LCL. I based the following mapping on trial-and-error with LCL-GTK2, and
71      a best guess. }
72    case AResultBtn of
73      mbNoButton:   Result := idButtonBase; // ???
74      mbOK:         Result := idButtonOK;
75      mbCancel:     Result := idButtonCancel;
76      mbYes:        Result := idButtonYes;
77      mbNo:         Result := idButtonNo;
78      mbAbort:      Result := idButtonAbort;
79      mbRetry:      Result := idButtonRetry;
80      mbIgnore:     Result := idButtonIgnore;
81      mbAll:        Result := idButtonAll;
82      mbNoToAll:    Result := idButtonNoToAll;
83      mbYesToAll:   Result := idButtonYesToAll;
84      mbHelp:       Result := idButtonHelp;
85      mbClose:      Result := idButtonClose;
86    end;
87  end;
88
89begin
90  ResultBtn := mbOK;
91  btns := [];
92  for BtnIdx := 0 to ButtonCount-1 do
93  begin
94    BtnID := Buttons[BtnIdx];
95    if (BtnID >= Low(IdButtonToFPGuiStandardButton)) and
96       (BtnID <= High(IdButtonToFPGuiStandardButton)) and
97       (IdButtonToFPGuiStandardButton[BtnID] <> mbNoButton) then
98      Include(btns, IdButtonToFPGuiStandardButton[BtnID])
99    else
100      btns := [mbOK];
101  end;
102
103  case DialogType of
104    idDialogWarning: ResultBtn := TfpgMessageDialog.Warning(DialogCaption, DialogMessage, btns);
105    idDialogError: ResultBtn := TfpgMessageDialog.Critical(DialogCaption, DialogMessage, btns);
106    idDialogInfo: ResultBtn :=TfpgMessageDialog.Information(DialogCaption, DialogMessage, btns);
107    idDialogConfirm: ResultBtn := TfpgMessageDialog.Question(DialogCaption, DialogMessage, btns);
108    else
109    begin
110      fpg_dialogs.ShowMessage(DialogMessage, DialogCaption);
111    end;
112  end;
113
114  Result := ResponseMappingfpGUItoLCL(ResultBtn);
115end;
116
117{------------------------------------------------------------------------------
118  Function: RawImage_QueryDescription
119  Params: AFlags:
120          ADesc:
121  Returns:
122
123 ------------------------------------------------------------------------------}
124//function TFpguiWidgetSet.RawImage_QueryDescription(AFlags: TRawImageQueryFlags; var ADesc: TRawImageDescription): Boolean;
125//begin
126//  // override only when queried formats are different from screen description
127//end;
128
129//##apiwiz##eps##   // Do not remove, no wizard declaration after this line
130
131