1 | unit UFormMain;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, LazFileUtils, Forms, Controls, Graphics, Dialogs, Menus,
|
---|
7 | ComCtrls;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormMain }
|
---|
12 |
|
---|
13 | TFormMain = class(TForm)
|
---|
14 | CoolBar1: TCoolBar;
|
---|
15 | MainMenu1: TMainMenu;
|
---|
16 | MenuItem1: TMenuItem;
|
---|
17 | MenuItem10: TMenuItem;
|
---|
18 | MenuItem11: TMenuItem;
|
---|
19 | MenuItem12: TMenuItem;
|
---|
20 | MenuItem13: TMenuItem;
|
---|
21 | MenuItem3: TMenuItem;
|
---|
22 | MenuItem4: TMenuItem;
|
---|
23 | MenuItem5: TMenuItem;
|
---|
24 | MenuItem6: TMenuItem;
|
---|
25 | MenuItem7: TMenuItem;
|
---|
26 | MenuItem8: TMenuItem;
|
---|
27 | MenuItem9: TMenuItem;
|
---|
28 | MenuItemToolbar: TMenuItem;
|
---|
29 | MenuItemView: TMenuItem;
|
---|
30 | MenuItemExit: TMenuItem;
|
---|
31 | MenuItemHomePage: TMenuItem;
|
---|
32 | MenuItemAbout: TMenuItem;
|
---|
33 | MenuItem2: TMenuItem;
|
---|
34 | MenuItemFileNew: TMenuItem;
|
---|
35 | MenuItemFileOpen: TMenuItem;
|
---|
36 | MenuItemSettings: TMenuItem;
|
---|
37 | MenuItemTools: TMenuItem;
|
---|
38 | MenuItemFileOpenRecent: TMenuItem;
|
---|
39 | MenuItemFileSave: TMenuItem;
|
---|
40 | MenuItemFileSaveAs: TMenuItem;
|
---|
41 | MenuItemFileClose: TMenuItem;
|
---|
42 | MenuItemHelp: TMenuItem;
|
---|
43 | MenuItemFile: TMenuItem;
|
---|
44 | PopupMenuOpenRecent: TPopupMenu;
|
---|
45 | ToolBarOther: TToolBar;
|
---|
46 | ToolBarFile: TToolBar;
|
---|
47 | ToolButton1: TToolButton;
|
---|
48 | ToolButton2: TToolButton;
|
---|
49 | ToolButton3: TToolButton;
|
---|
50 | ToolButton4: TToolButton;
|
---|
51 | ToolButton5: TToolButton;
|
---|
52 | ToolButton6: TToolButton;
|
---|
53 | ToolButton7: TToolButton;
|
---|
54 | ToolButton8: TToolButton;
|
---|
55 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
56 | procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
---|
57 | procedure FormCreate(Sender: TObject);
|
---|
58 | procedure FormDestroy(Sender: TObject);
|
---|
59 | procedure FormResize(Sender: TObject);
|
---|
60 | procedure FormShow(Sender: TObject);
|
---|
61 | procedure MenuItemToolbarClick(Sender: TObject);
|
---|
62 | private
|
---|
63 | procedure SetToolbarHints;
|
---|
64 | procedure UpdateFormTitle;
|
---|
65 | public
|
---|
66 | procedure UpdateInterface;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | var
|
---|
70 | FormMain: TFormMain;
|
---|
71 |
|
---|
72 |
|
---|
73 | implementation
|
---|
74 |
|
---|
75 | {$R *.lfm}
|
---|
76 |
|
---|
77 | uses
|
---|
78 | UCore, UFormContacts, UVCard, UVCardFile;
|
---|
79 |
|
---|
80 | resourcestring
|
---|
81 | SModified = 'Modified';
|
---|
82 |
|
---|
83 | { TFormMain }
|
---|
84 |
|
---|
85 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
86 | begin
|
---|
87 | FormContacts.Close;
|
---|
88 | Core.PersistentForm1.Save(Self);
|
---|
89 | end;
|
---|
90 |
|
---|
91 | procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
---|
92 | begin
|
---|
93 | Core.AFileClose.Execute;
|
---|
94 | CanClose := Core.FileClosed;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | procedure TFormMain.FormCreate(Sender: TObject);
|
---|
98 | begin
|
---|
99 | FormContacts := TFormContacts.Create(nil);
|
---|
100 | end;
|
---|
101 |
|
---|
102 | procedure TFormMain.FormDestroy(Sender: TObject);
|
---|
103 | begin
|
---|
104 | FreeAndNil(FormContacts);
|
---|
105 | end;
|
---|
106 |
|
---|
107 | procedure TFormMain.FormResize(Sender: TObject);
|
---|
108 | begin
|
---|
109 | CoolBar1.AutosizeBands;
|
---|
110 | end;
|
---|
111 |
|
---|
112 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
113 | begin
|
---|
114 | FormContacts.BeginUpdate;
|
---|
115 | try
|
---|
116 | SetToolbarHints;
|
---|
117 | Core.Initialize;
|
---|
118 | Core.ThemeManager1.UseTheme(Self);
|
---|
119 | Core.PersistentForm1.Load(Self);
|
---|
120 | Core.ScaleDPI1.ScaleControl(CoolBar1, Core.ScaleDPI1.DesignDPI);
|
---|
121 | CoolBar1.AutosizeBands;
|
---|
122 |
|
---|
123 | FormContacts.Contacts := TVCardFile(Core.DataFile).VCard.Contacts;
|
---|
124 | FormContacts.ManualDock(Self, nil, alClient);
|
---|
125 | FormContacts.Align := alClient;
|
---|
126 | FormContacts.Show;
|
---|
127 | finally
|
---|
128 | FormContacts.EndUpdate;
|
---|
129 | end;
|
---|
130 | end;
|
---|
131 |
|
---|
132 | procedure TFormMain.MenuItemToolbarClick(Sender: TObject);
|
---|
133 | begin
|
---|
134 | UpdateInterface;
|
---|
135 | end;
|
---|
136 |
|
---|
137 | procedure TFormMain.SetToolbarHints;
|
---|
138 | var
|
---|
139 | I: Integer;
|
---|
140 | J: Integer;
|
---|
141 | Control: TControl;
|
---|
142 | begin
|
---|
143 | for J := 0 to CoolBar1.ControlCount - 1 do begin
|
---|
144 | Control := CoolBar1.Controls[J];
|
---|
145 | if Control is TToolBar then begin
|
---|
146 | for I := 0 to TToolBar(Control).ButtonCount - 1 do begin
|
---|
147 | TToolBar(Control).Buttons[I].ShowHint := True;
|
---|
148 | TToolBar(Control).Buttons[I].Hint := TToolBar(Control).Buttons[I].Caption;
|
---|
149 | end;
|
---|
150 | end;
|
---|
151 | end;
|
---|
152 | end;
|
---|
153 |
|
---|
154 | procedure TFormMain.UpdateFormTitle;
|
---|
155 | var
|
---|
156 | Title: string;
|
---|
157 | begin
|
---|
158 | Title := '';
|
---|
159 | if Assigned(Core.DataFile) and
|
---|
160 | (ExtractFileNameWithoutExt(ExtractFileName(Core.DataFile.FileName)) <> '') then
|
---|
161 | Title := Title + ExtractFileNameWithoutExt(ExtractFileName(Core.DataFile.FileName));
|
---|
162 | if Assigned(Core.DataFile) and Core.DataFile.Modified then
|
---|
163 | Title := Title + ' (' + SModified + ')';
|
---|
164 | if Title <> '' then Title := Title + ' - ';
|
---|
165 | Title := Title + Core.ApplicationInfo1.AppName;
|
---|
166 | //Application.Title := Title;
|
---|
167 | Caption := Title;
|
---|
168 | end;
|
---|
169 |
|
---|
170 | procedure TFormMain.UpdateInterface;
|
---|
171 | begin
|
---|
172 | UpdateFormTitle;
|
---|
173 | CoolBar1.Visible := MenuItemToolbar.Checked;
|
---|
174 | end;
|
---|
175 |
|
---|
176 | end.
|
---|
177 |
|
---|