forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewNotebookReg.pas
108 lines (91 loc) · 2.52 KB
/
NewNotebookReg.pas
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
unit NewNotebookReg;
{
Inno Setup
Copyright (C) 1997-2024 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
TNewNotebook design-time registration
}
interface
uses
Classes;
procedure Register;
implementation
uses
NewNotebook, DesignIntf, DesignEditors;
{ TNewNotebookEditor }
type
TNewNotebookEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): String; override;
function GetVerbCount: Integer; override;
end;
procedure TNewNotebookEditor.Edit;
var
Notebook: TNewNotebook;
begin
{ When a page is double-clicked, select the parent notebook }
if Component is TNewNotebookPage then begin
Notebook := TNewNotebookPage(Component).Notebook;
if Assigned(Notebook) then
Designer.SelectComponent(Notebook);
end
end;
procedure TNewNotebookEditor.ExecuteVerb(Index: Integer);
var
Notebook: TNewNotebook;
Page: TNewNotebookPage;
begin
{ Find the notebook component to operate on. Note that this same editor class
is used for both TNewNotebook and TNewNotebookPage. }
if Component is TNewNotebookPage then begin
Notebook := TNewNotebookPage(Component).Notebook;
if Notebook = nil then
Exit; { just in case }
end
else
Notebook := Component as TNewNotebook;
case Index of
0, 1:
begin
Page := Notebook.FindNextPage(Notebook.ActivePage, Index = 0);
Notebook.ActivePage := Page;
Designer.Modified;
Designer.SelectComponent(Page);
end;
3:
begin
Page := TNewNotebookPage.Create(Notebook.Owner);
Page.Name := Designer.UniqueName(Page.ClassName);
Page.Notebook := Notebook;
Notebook.ActivePage := Page;
Designer.Modified;
Designer.SelectComponent(Page);
end;
end;
end;
function TNewNotebookEditor.GetVerbCount: Integer;
begin
Result := 4;
end;
function TNewNotebookEditor.GetVerb(Index: Integer): String;
begin
case Index of
0: Result := 'Next Page';
1: Result := 'Previous Page';
2: Result := '-';
3: Result := 'New Page';
else
Result := '';
end;
end;
procedure Register;
begin
RegisterComponents('JR', [TNewNotebook]);
RegisterClass(TNewNotebookPage);
RegisterComponentEditor(TNewNotebook, TNewNotebookEditor);
RegisterComponentEditor(TNewNotebookPage, TNewNotebookEditor);
end;
end.