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