File: fpguilclintf.inc

package info (click to toggle)
lazarus 2.0.10%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 219,188 kB
  • sloc: pascal: 1,867,962; xml: 265,716; cpp: 56,595; sh: 3,005; java: 609; makefile: 568; perl: 297; sql: 222; ansic: 137
file content (130 lines) | stat: -rw-r--r-- 4,535 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{%MainUnit fpguiint.pp}

{******************************************************************************
                 All FPGUI interface communication implementations.
                   Initial Revision  : Sun Nov 23 23:53:53 2003


  !! Keep alphabetical !!

  Support routines go to gtkproc.pp

 ******************************************************************************
 Implementation
 ******************************************************************************

 *****************************************************************************
  This file is part of the Lazarus Component Library (LCL)

  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************
}

//##apiwiz##sps##   // Do not remove

const
  IdButtonToFPGuiStandardButton: array[idButtonOK..idButtonShield] of TfpgMsgDlgBtn = (
 { idButtonOk       } mbOK,
 { idButtonCancel   } mbCancel,
 { idButtonHelp     } mbHelp,
 { idButtonYes      } mbYes,
 { idButtonNo       } mbNo,
 { idButtonClose    } mbClose,
 { idButtonAbort    } mbAbort,
 { idButtonRetry    } mbRetry,
 { idButtonIgnore   } mbIgnore,
 { idButtonAll      } mbAll,
 { idButtonYesToAll } mbYesToAll,
 { idButtonNoToAll  } mbNoToAll,
 { idButtonOpen     } mbNoButton,
 { idButtonSave     } mbNoButton,
 { idButtonShield   } mbNoButton
  );


{------------------------------------------------------------------------------
  function FontCanUTF8(Font: HFont): boolean;

  True if font recognizes Unicode UTF8 encoding.
  
  FPGUI supports only Unicode
 ------------------------------------------------------------------------------}
function TFpGuiWidgetSet.FontCanUTF8(Font: HFont): boolean;
begin
  Result := True;
end;

function TFpGuiWidgetSet.PromptUser(const DialogCaption, DialogMessage: String;
  DialogType: longint; Buttons: PLongint; ButtonCount, DefaultIndex,
  EscapeResult: Longint): Longint;
var
  btns: TfpgMsgDlgButtons;
  BtnIdx, BtnID: LongInt;
  ResultBtn: TfpgMsgDlgBtn;

  function ResponseMappingfpGUItoLCL(const AResultBtn: TfpgMsgDlgBtn): Integer;
  begin
    { LCL is so confusing with modal results, button types, button results and
      Integer/LongInt as possible return results in various location is the
      LCL. I based the following mapping on trial-and-error with LCL-GTK2, and
      a best guess. }
    case AResultBtn of
      mbNoButton:   Result := idButtonBase; // ???
      mbOK:         Result := idButtonOK;
      mbCancel:     Result := idButtonCancel;
      mbYes:        Result := idButtonYes;
      mbNo:         Result := idButtonNo;
      mbAbort:      Result := idButtonAbort;
      mbRetry:      Result := idButtonRetry;
      mbIgnore:     Result := idButtonIgnore;
      mbAll:        Result := idButtonAll;
      mbNoToAll:    Result := idButtonNoToAll;
      mbYesToAll:   Result := idButtonYesToAll;
      mbHelp:       Result := idButtonHelp;
      mbClose:      Result := idButtonClose;
    end;
  end;

begin
  ResultBtn := mbOK;
  btns := [];
  for BtnIdx := 0 to ButtonCount-1 do
  begin
    BtnID := Buttons[BtnIdx];
    if (BtnID >= Low(IdButtonToFPGuiStandardButton)) and
       (BtnID <= High(IdButtonToFPGuiStandardButton)) and
       (IdButtonToFPGuiStandardButton[BtnID] <> mbNoButton) then
      Include(btns, IdButtonToFPGuiStandardButton[BtnID])
    else
      btns := [mbOK];
  end;

  case DialogType of
    idDialogWarning: ResultBtn := TfpgMessageDialog.Warning(DialogCaption, DialogMessage, btns);
    idDialogError: ResultBtn := TfpgMessageDialog.Critical(DialogCaption, DialogMessage, btns);
    idDialogInfo: ResultBtn :=TfpgMessageDialog.Information(DialogCaption, DialogMessage, btns);
    idDialogConfirm: ResultBtn := TfpgMessageDialog.Question(DialogCaption, DialogMessage, btns);
    else
    begin
      fpg_dialogs.ShowMessage(DialogMessage, DialogCaption);
    end;
  end;

  Result := ResponseMappingfpGUItoLCL(ResultBtn);
end;

{------------------------------------------------------------------------------
  Function: RawImage_QueryDescription
  Params: AFlags:
          ADesc:
  Returns:

 ------------------------------------------------------------------------------}
//function TFpguiWidgetSet.RawImage_QueryDescription(AFlags: TRawImageQueryFlags; var ADesc: TRawImageDescription): Boolean;
//begin
//  // override only when queried formats are different from screen description
//end;

//##apiwiz##eps##   // Do not remove, no wizard declaration after this line