-
Notifications
You must be signed in to change notification settings - Fork 5
/
lea_gwin-toolbars.adb
94 lines (81 loc) · 2.95 KB
/
lea_gwin-toolbars.adb
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
with LEA_Resource_GUI,
LEA_Common.Color_Themes;
with GWindows.Base,
GWindows.Menus,
GWindows.Colors;
with GWin_Util;
with Interfaces.C;
package body LEA_GWin.Toolbars is
procedure Init_Main_Tool_Bar
(tb : in out Office_Applications.Classic_Main_Tool_Bar_Type'Class;
parent : in out LEA_GWin.MDI_Main.MDI_Main_Type)
is
use LEA_Resource_GUI;
use LEA_Common.Color_Themes;
sep_width : constant := 8;
Fake_Menu : Menu_MDI_Child_Type;
--
procedure Add_Button_with_Tip
(Image_Index : in Natural;
Command_ID : in Integer)
is
use GWindows.Menus;
-- The tool tip's text is a copy of the menu's text.
label : constant GString :=
GWin_Util.Menu_Entry_Title_to_Toolbar_Label (Text (Fake_Menu.Main, Command, Command_ID));
begin
tb.Add_String (label);
tb.Add_Button (Image_Index, Command_ID, tb.String_Count);
tb.String_Count := tb.String_Count + 1;
end Add_Button_with_Tip;
st : Interfaces.C.unsigned;
TBSTYLE_TOOLTIPS : constant := 16#0100#;
TBSTYLE_FLAT : constant := 16#0800#;
TBSTYLE_LIST : constant := 16#1000#;
TBSTYLE_EX_MIXEDBUTTONS : constant := 8;
use type Interfaces.C.unsigned;
begin
tb.Create (parent, 0, 0, 0, 40);
tb.Dock (GWindows.Base.At_Top);
tb.Images.Create (Num_resource (Toolbar_BMP), 32);
tb.Set_Image_List (tb.Images);
st := tb.Get_Style;
tb.Set_Style (TBSTYLE_FLAT or TBSTYLE_TOOLTIPS or TBSTYLE_LIST or st);
tb.Set_Extended_Style (TBSTYLE_EX_MIXEDBUTTONS);
Create_Full_Menu (Fake_Menu);
Add_Button_with_Tip (0, IDM_New_File);
Add_Button_with_Tip (1, IDM_Open_File);
Add_Button_with_Tip (2, IDM_Save_File);
Add_Button_with_Tip (4, IDM_Save_All);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (13, IDM_Cut);
Add_Button_with_Tip (14, IDM_Copy);
Add_Button_with_Tip (15, IDM_Paste);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (5, IDM_Undo);
Add_Button_with_Tip (6, IDM_Redo);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (9, IDM_Indent);
Add_Button_with_Tip (8, IDM_Unindent);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (10, IDM_Comment);
Add_Button_with_Tip (11, IDM_Uncomment);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (3, IDM_Find);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (17, IDM_Build_and_run);
tb.Add_Separator (sep_width);
Add_Button_with_Tip (12, IDM_Show_special_symbols);
Add_Button_with_Tip (16, IDM_Show_indentation_lines);
tb.Background_Color (Color_Convert (Theme_Color (background)));
end Init_Main_Tool_Bar;
procedure Update_Theme
(tb : in out Office_Applications.Classic_Main_Tool_Bar_Type'Class)
is
use LEA_Common.Color_Themes;
begin
tb.Background_Color (Color_Convert (Theme_Color (background)));
tb.Redraw (Erase => True,
Redraw_Now => True);
end Update_Theme;
end LEA_GWin.Toolbars;