Menu

[r3166]: / trunk / Src / Notifications.UData.pas  Maximize  Restore  History

Download this file

118 lines (99 with data), 4.4 kB

  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
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2013, Peter Johnson (www.delphidabbler.com).
*
* $Rev$
* $Date$
*
* Defines a record that stores information to be displayed in a notification
* window along with a related task that can be performed from the window.
}
unit Notifications.UData;
interface
uses
// Delphi
SysUtils;
type
/// <summary>Stores information to be displayed in a notification window
/// along with a related task that can be performed from the window.
/// </summary>
/// <remarks>
/// <para>A notification always has a title and at least one paragraph of
/// content text.</para>
/// <para>An associated task and help keyword are optional.</para>
/// </remarks>
TNotificationData = record
strict private
var
/// <summary>Value of Title property.</summary>
fTitle: string;
/// <summary>Value of Content property.</summary>
fContent: TArray<string>;
/// <summary>Value of HelpKeyword property.</summary>
fHelpKeyword: string;
/// <summary>Valure of TaskCallback property.</summary>
fTaskCallback: TProc;
/// <summary>Value of TaskPrompt property.</summary>
fTaskPrompt: string;
public
/// <summary>Title of notification.</summary>
property Title: string read fTitle;
/// <summary>Notification content.</summary>
/// <remarks>Each array element is a paragraph of text.</remarks>
property Content: TArray<string> read fContent;
/// <summary>Keyword of any related help topic.</summary>
/// <remarks>Set to the empty string to inhibit display of help.</remarks>
property HelpKeyword: string read fHelpKeyword;
/// <summary>Callback procedure called from notification window when user
/// clicks the task button.</summary>
/// <remarks>Note that no task button will appear if this property is nil.
/// </remarks>
property TaskCallback: TProc read fTaskCallback;
/// <summary>Prompt text that appears in notification window's task button.
/// </summary>
/// <remarks>This property is ignored if TaskCallback is nil.</remarks>
property TaskPrompt: string read fTaskPrompt;
/// <summary>Creates an initialised notification data record.</summary>
/// <param name="ATitle">string [in] Notification title. Must be empty
/// string or contain only white space.</param>
/// <param name="AContent">array of string [in] Paragraphs of text forming
/// content of notification. Must contain at least one element that
/// contains non-whitespace text. Empty elements or elements containing
/// only white space are ignored.</param>
/// <param name="AHelpKeyword">string [in] A-link keyword of associated
/// help topic or empty string if there is no such help topic.</param>
/// <param name="ATaskCallback">TProc [in] Procedure to be called from
/// notification window if user clicks the task button, or nil if no
/// such button is required.</param>
/// <param name="ATaskPrompt">string [in] Prompt or caption to appear on
/// any task button. May be empty string if ATaskCallback is nil.</param>
/// <param name="AInhibitCallback">TProc [in] Procedure to be called from
/// notification window if user chooses to inhibit similar messages in
/// future, or nil if message can't be inhibited.</param>
constructor Create(const ATitle: string; const AContent: array of string;
const AHelpKeyord: string; const ATaskCallback: TProc;
const ATaskPrompt: string);
end;
implementation
{ TNotificationData }
constructor TNotificationData.Create(const ATitle: string;
const AContent: array of string; const AHelpKeyord: string;
const ATaskCallback: TProc; const ATaskPrompt: string);
var
I: Integer;
begin
Assert(ATitle <> '', 'TNotificationData.Create: ATitle = empty string');
Assert((Length(AContent) > 0),
'TNotificationData.Create: AContent has no elements');
fTitle := ATitle;
SetLength(fContent, Length(AContent));
for I := 0 to Pred(Length(AContent)) do
fContent[I] := AContent[I];
fHelpKeyword := AHelpKeyord;
fTaskCallback := ATaskCallback;
fTaskPrompt := ATaskPrompt;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.