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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
{ Copyright (C) 2004
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Mattias Gaertner
Abstract:
Common IDE dialogs.
}
unit IDEDialogs;
{$mode objfpc}{$H+}
interface
uses
Classes, System.UITypes,
// LCL
Dialogs,
// LazUtils
LazFileCache,
// BuildIntf
LazMsgWorker;
type
{ TIDEOpenDialog }
TIDEOpenDialog = class(TOpenDialog)
protected
function DoExecute: boolean; override;
end;
TIDEOpenDialogClass = class of TIDEOpenDialog;
{ TIDESaveDialog }
TIDESaveDialog = class(TSaveDialog)
protected
function DoExecute: boolean; override;
public
class function NeedOverwritePrompt: boolean; virtual;
end;
TIDESaveDialogClass = class of TIDESaveDialog;
TIDESelectDirectory = function(const Title, InitialDir: string): string of object;
TInitIDEFileDialog = procedure(AFileDialog: TFileDialog) of object;
TStoreIDEFileDialog = procedure(AFileDialog: TFileDialog) of object;
var // set by the IDE
LazIDESelectDirectory: TIDESelectDirectory = nil;
InitIDEFileDialog: TInitIDEFileDialog = nil;
StoreIDEFileDialog: TStoreIDEFileDialog = nil;
IDEOpenDialogClass: TIDEOpenDialogClass = TIDEOpenDialog;
IDESaveDialogClass: TIDESaveDialogClass = TIDESaveDialog;
// Wrapper function for LazIDESelectDirectory with a default parameter.
function LazSelectDirectory(const Title: string; const InitialDir: string = ''): string;
// Wrapper function for LazMessageWorker in LazMsgWorker.
function IDEMessageDialog(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: TMsgDlgButtons;
const HelpKeyword: string = ''): Integer;
// Wrapper function for LazQuestionWorker in LazMsgWorker.
function IDEQuestionDialog(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: array of const;
const HelpKeyword: string = ''): Integer;
function IDEMessageDialogAb(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: TMsgDlgButtons;
ShowAbort: boolean; const HelpKeyword: string = ''): Integer;
function IDEQuestionDialogAb(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: array of const;
HideAbort: boolean; const HelpKeyword: string = ''): Integer;
type
{ TIgnoreIDEQuestionItem }
TIgnoreQuestionDuration = (
iiidIDERestart,
iiid24H,
iiidForever
);
TIgnoreQuestionDurations = set of TIgnoreQuestionDuration;
TIgnoreIDEQuestionItem = class
private
FIdentifier: string;
public
Date: TDateTime;
Flag: string;
Duration: TIgnoreQuestionDuration;
constructor Create(const TheIdentifier: string);
property Identifier: string read FIdentifier;
end;
{ TIgnoreIDEQuestionList }
TIgnoreIDEQuestionList = class
public
function Add(const Identifier: string;
const Duration: TIgnoreQuestionDuration;
const Flag: string = ''): TIgnoreIDEQuestionItem; virtual; abstract;
procedure Delete(const Identifier: string); virtual; abstract;
function Find(const Identifier: string): TIgnoreIDEQuestionItem; virtual; abstract;
end;
var
IgnoreQuestions: TIgnoreIDEQuestionList = nil;
implementation
function LazSelectDirectory(const Title: string; const InitialDir: string): string;
begin
Result:=LazIDESelectDirectory(Title,InitialDir);
end;
function IDEMessageDialog(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: TMsgDlgButtons;
const HelpKeyword: string = ''): Integer;
begin
Result := LazMessageWorker(aCaption, aMsg, DlgType, Buttons, HelpKeyword);
end;
function IDEQuestionDialog(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: array of const;
const HelpKeyword: string = ''): Integer;
begin
Result := LazQuestionWorker(aCaption, aMsg, DlgType, Buttons, HelpKeyword);
end;
function IDEMessageDialogAb(const aCaption, aMsg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; ShowAbort: boolean; const HelpKeyword: string): Integer;
begin
Result := LazMsgWorker.LazMessageDialogAb(aCaption, aMsg, DlgType, Buttons,
ShowAbort, HelpKeyword);
end;
function IDEQuestionDialogAb(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: array of const;
HideAbort: boolean; const HelpKeyword: string): Integer;
begin
Result := LazMsgWorker.LazQuestionDialogAb(aCaption, aMsg, DlgType, Buttons,
HideAbort, HelpKeyword);
end;
{ TIDESaveDialog }
function TIDESaveDialog.DoExecute: boolean;
begin
Result:=inherited DoExecute;
LazFileCache.InvalidateFileStateCache;
end;
class function TIDESaveDialog.NeedOverwritePrompt: boolean;
begin
Result:={$if defined(LCLCocoa)}false{$else}true{$endif};
end;
{ TIDEOpenDialog }
function TIDEOpenDialog.DoExecute: boolean;
begin
Result:=inherited DoExecute;
LazFileCache.InvalidateFileStateCache;
end;
{ TIgnoreIDEQuestionItem }
constructor TIgnoreIDEQuestionItem.Create(const TheIdentifier: string);
begin
fIdentifier:=TheIdentifier;
end;
end.
|