1 | unit FormMain;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
|
---|
7 | ComCtrls, FormTables, FormEx;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormMain }
|
---|
12 |
|
---|
13 | TFormMain = class(TFormEx)
|
---|
14 | CoolBar1: TCoolBar;
|
---|
15 | MainMenu1: TMainMenu;
|
---|
16 | MenuItem1: TMenuItem;
|
---|
17 | MenuItem2: TMenuItem;
|
---|
18 | MenuItem3: TMenuItem;
|
---|
19 | MenuItem4: TMenuItem;
|
---|
20 | MenuItem5: TMenuItem;
|
---|
21 | MenuItem6: TMenuItem;
|
---|
22 | MenuItem7: TMenuItem;
|
---|
23 | MenuItem8: TMenuItem;
|
---|
24 | MenuItemPreferences: TMenuItem;
|
---|
25 | StatusBar1: TStatusBar;
|
---|
26 | ToolBar1: TToolBar;
|
---|
27 | ToolButton1: TToolButton;
|
---|
28 | ToolButton2: TToolButton;
|
---|
29 | ToolButton3: TToolButton;
|
---|
30 | procedure FormActivate(Sender: TObject);
|
---|
31 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
32 | procedure FormCreate(Sender: TObject);
|
---|
33 | procedure FormDestroy(Sender: TObject);
|
---|
34 | procedure FormShow(Sender: TObject);
|
---|
35 | private
|
---|
36 | procedure SetToolbarHints;
|
---|
37 | public
|
---|
38 | FormTables: TFormTables;
|
---|
39 | procedure DockInit;
|
---|
40 | procedure UpdateInterface;
|
---|
41 | end;
|
---|
42 |
|
---|
43 |
|
---|
44 | implementation
|
---|
45 |
|
---|
46 | {$R *.lfm}
|
---|
47 |
|
---|
48 | uses
|
---|
49 | Core;
|
---|
50 |
|
---|
51 | { TFormMain }
|
---|
52 |
|
---|
53 | procedure TFormMain.FormActivate(Sender: TObject);
|
---|
54 | begin
|
---|
55 | Core.Core.Init;
|
---|
56 | // TODO: Toolbar height is incorrectly calculated
|
---|
57 | ToolBar1.ButtonHeight := ToolBar1.Height;
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
61 | begin
|
---|
62 | Core.Core.Done;
|
---|
63 | end;
|
---|
64 |
|
---|
65 | procedure TFormMain.FormCreate(Sender: TObject);
|
---|
66 | begin
|
---|
67 | FormTables := TFormTables.Create(nil);
|
---|
68 | end;
|
---|
69 |
|
---|
70 | procedure TFormMain.FormDestroy(Sender: TObject);
|
---|
71 | begin
|
---|
72 | FreeAndNil(FormTables);
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
76 | begin
|
---|
77 | SetToolbarHints;
|
---|
78 | DockInit;
|
---|
79 | end;
|
---|
80 |
|
---|
81 | procedure TFormMain.DockInit;
|
---|
82 | begin
|
---|
83 | FormTables.ManualDock(Self, nil, alClient);
|
---|
84 | FormTables.Align := alClient;
|
---|
85 | FormTables.Show;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TFormMain.UpdateInterface;
|
---|
89 | var
|
---|
90 | NewCaption: string;
|
---|
91 | begin
|
---|
92 | NewCaption := Application.Title;
|
---|
93 | if Assigned(Core.Core.DbClient) then
|
---|
94 | NewCaption := Core.Core.DbClient.ConnectProfile.Name + ' - ' + NewCaption;
|
---|
95 | Caption := NewCaption;
|
---|
96 | FormTables.UpdateInterface;
|
---|
97 | end;
|
---|
98 |
|
---|
99 | procedure TFormMain.SetToolbarHints;
|
---|
100 | var
|
---|
101 | I: Integer;
|
---|
102 | J: Integer;
|
---|
103 | Control: TControl;
|
---|
104 | begin
|
---|
105 | for J := 0 to CoolBar1.ControlCount - 1 do begin
|
---|
106 | Control := CoolBar1.Controls[J];
|
---|
107 | if Control is TToolBar then begin
|
---|
108 | for I := 0 to TToolBar(Control).ButtonCount - 1 do begin
|
---|
109 | TToolBar(Control).Buttons[I].ShowHint := True;
|
---|
110 | TToolBar(Control).Buttons[I].Hint := TToolBar(Control).Buttons[I].Caption;
|
---|
111 | end;
|
---|
112 | end;
|
---|
113 | end;
|
---|
114 | end;
|
---|
115 |
|
---|
116 | end.
|
---|
117 |
|
---|