19 |
EB_TOOLBARABLE_AND_MENUABLE_COMMAND |
EB_TOOLBARABLE_AND_MENUABLE_COMMAND |
20 |
redefine |
redefine |
21 |
new_toolbar_item, |
new_toolbar_item, |
22 |
|
new_sd_toolbar_item, |
23 |
new_menu_item, |
new_menu_item, |
|
initialize_menu_item, |
|
24 |
tooltext, |
tooltext, |
25 |
is_tooltext_important |
is_tooltext_important, |
26 |
|
pixel_buffer, |
27 |
|
mini_pixmap |
28 |
end |
end |
29 |
|
|
|
EB_SELECTABLE |
|
|
|
|
30 |
create |
create |
31 |
make |
make |
32 |
|
|
33 |
feature {NONE} -- Initialization |
feature {NONE} -- Initialization |
34 |
|
|
35 |
make (a_target: EB_DEVELOPMENT_WINDOW; an_explorer_bar_item: EB_EXPLORER_BAR_ITEM) is |
make (a_target: EB_DEVELOPMENT_WINDOW; a_content: SD_CONTENT) is |
36 |
|
-- Creation method. |
37 |
require |
require |
38 |
valid_item: an_explorer_bar_item /= Void and then an_explorer_bar_item.is_closeable |
valid_item: a_content /= Void |
39 |
item_has_pixmap: an_explorer_bar_item.pixmap /= Void |
item_has_pixmap: a_content.pixmap /= Void |
40 |
do |
do |
41 |
target_make (a_target) |
target_make (a_target) |
42 |
explorer_bar_item := an_explorer_bar_item |
content := a_content |
|
explorer_bar_item.set_associated_command (Current) |
|
|
is_selected := explorer_bar_item.is_visible |
|
43 |
is_sensitive := True |
is_sensitive := True |
|
-- Show tools are always sensitive |
|
44 |
end |
end |
45 |
|
|
46 |
feature -- Access |
feature -- Access |
47 |
|
|
48 |
explorer_bar_item: EB_EXPLORER_BAR_ITEM |
content: SD_CONTENT |
49 |
-- Tool associated with Current. |
-- Content for docking. |
50 |
|
|
51 |
tooltip: STRING is |
tooltip: STRING is |
52 |
-- Tooltip for Current |
-- Tooltip for Current |
53 |
do |
do |
54 |
if is_selected then |
Result := "Show " |
55 |
Result := "Hide " |
Result.append_string (content.long_title) |
|
else |
|
|
Result := "Show " |
|
|
end |
|
|
Result.append_string (explorer_bar_item.title) |
|
56 |
end |
end |
57 |
|
|
58 |
tooltext: STRING is |
tooltext: STRING is |
59 |
-- Text for toolbar button. |
-- Text for toolbar button. |
60 |
do |
do |
61 |
Result := explorer_bar_item.title |
Result := content.short_title |
62 |
end |
end |
63 |
|
|
64 |
is_tooltext_important: BOOLEAN is |
is_tooltext_important: BOOLEAN is |
70 |
description: STRING is |
description: STRING is |
71 |
-- Description for current command. |
-- Description for current command. |
72 |
do |
do |
73 |
Result := "Show/hide " + explorer_bar_item.title |
Result := "Show/hide " + content.short_title |
74 |
end |
end |
75 |
|
|
76 |
menu_name: STRING is |
menu_name: STRING is |
77 |
-- Name as it appears in menus. |
-- Name as it appears in menus. |
78 |
do |
do |
79 |
Result := explorer_bar_item.menu_name |
Result := content.short_title |
80 |
end |
end |
81 |
|
|
82 |
name: STRING is |
name: STRING is |
83 |
-- Name to be displayed. |
-- Name to be displayed. |
84 |
do |
do |
85 |
Result := explorer_bar_item.title |
Result := content.short_title |
86 |
end |
end |
87 |
|
|
88 |
pixmap: EV_PIXMAP is |
pixmap: EV_PIXMAP is |
89 |
-- Pixmap representing the item (for buttons) |
-- Pixmap representing the item (for buttons) |
90 |
do |
do |
91 |
Result := explorer_bar_item.pixmap |
Result := content.pixmap |
92 |
end |
end |
93 |
|
|
94 |
feature -- Execution |
mini_pixmap: EV_PIXMAP |
95 |
|
-- Mini pixmap |
96 |
|
|
97 |
execute is |
pixel_buffer: EV_PIXEL_BUFFER is |
98 |
-- Execute command (toggle between show and hide). |
-- Pixel buffer representing the command. |
99 |
do |
do |
100 |
set_selected (not is_selected) |
Result := content.pixel_buffer |
101 |
end |
end |
102 |
|
|
103 |
enable_selected is |
feature -- Execution |
|
-- Set `is_selected' to True. |
|
|
do |
|
|
set_selected (True) |
|
|
end |
|
104 |
|
|
105 |
disable_selected is |
execute is |
106 |
-- Set `is_selected' to False. |
-- Execute command (toggle between show and hide). |
107 |
do |
do |
108 |
set_selected (False) |
if not content.is_visible then |
109 |
|
content.show |
110 |
|
end |
111 |
|
content.set_focus |
112 |
end |
end |
113 |
|
|
114 |
feature -- Basic operations |
feature -- Basic operations |
115 |
|
|
116 |
new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOGGLE_TOOL_BAR_BUTTON is |
new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is |
117 |
-- Create a new toolbar button for this command. |
-- Create a new toolbar button for this command. |
118 |
do |
do |
119 |
create Result.make (Current) |
create Result.make (Current) |
120 |
initialize_toolbar_item (Result, display_text) |
initialize_toolbar_item (Result, display_text) |
|
if is_selected then |
|
|
Result.enable_select |
|
|
end |
|
121 |
Result.select_actions.extend (agent execute) |
Result.select_actions.extend (agent execute) |
122 |
Result.select_actions.extend (agent update_tooltip (Result)) |
Result.select_actions.extend (agent update_tooltip (Result)) |
123 |
end |
end |
124 |
|
|
125 |
new_menu_item: EB_COMMAND_CHECK_MENU_ITEM is |
new_sd_toolbar_item (a_display_text: BOOLEAN): EB_SD_COMMAND_TOOL_BAR_BUTTON is |
126 |
|
-- Create a new toolbar button for this command. |
127 |
|
do |
128 |
|
create Result.make (Current) |
129 |
|
initialize_sd_toolbar_item (Result, a_display_text) |
130 |
|
Result.select_actions.extend (agent execute) |
131 |
|
Result.select_actions.extend (agent update_sd_tooltip (Result)) |
132 |
|
end |
133 |
|
|
134 |
|
new_menu_item: EB_COMMAND_MENU_ITEM is |
135 |
-- Create a new menu entry for this command. |
-- Create a new menu entry for this command. |
136 |
do |
do |
137 |
-- Create the menu item |
-- Create the menu item |
138 |
create Result.make (Current) |
create Result.make (Current) |
139 |
initialize_menu_item (Result) |
initialize_menu_item (Result) |
|
if is_selected then |
|
|
Result.enable_select |
|
|
else |
|
|
Result.disable_select |
|
|
end |
|
140 |
Result.select_actions.extend (agent execute) |
Result.select_actions.extend (agent execute) |
141 |
end |
end |
142 |
|
|
152 |
accelerator_not_void: accelerator = a_accel |
accelerator_not_void: accelerator = a_accel |
153 |
end |
end |
154 |
|
|
155 |
|
set_mini_pixmap (a_mini_pixmap: EV_PIXMAP) is |
156 |
|
-- Set `mini_pixmap' with `a_mini_pixmap'. |
157 |
|
do |
158 |
|
mini_pixmap := a_mini_pixmap |
159 |
|
ensure |
160 |
|
mini_pixmap_set: mini_pixmap = a_mini_pixmap |
161 |
|
end |
162 |
|
|
163 |
feature -- Recyclable |
feature -- Recyclable |
164 |
|
|
165 |
recycle is |
recycle is |
171 |
|
|
172 |
feature {NONE} -- Implementation |
feature {NONE} -- Implementation |
173 |
|
|
174 |
set_selected (a_selected: BOOLEAN)is |
update_tooltip (toggle: EB_COMMAND_TOOL_BAR_BUTTON) is |
|
-- Set `is_selected' to `a_selected'. |
|
|
local |
|
|
toolbar_items: like managed_toolbar_items |
|
|
menu_items: like managed_menu_items |
|
|
do |
|
|
if not safety_flag then |
|
|
safety_flag := True |
|
|
is_selected := a_selected |
|
|
toolbar_items := managed_toolbar_items |
|
|
if toolbar_items /= Void then |
|
|
from |
|
|
toolbar_items.start |
|
|
until |
|
|
toolbar_items.after |
|
|
loop |
|
|
if a_selected then |
|
|
toolbar_items.item.enable_select |
|
|
else |
|
|
toolbar_items.item.disable_select |
|
|
end |
|
|
toolbar_items.forth |
|
|
end |
|
|
end |
|
|
|
|
|
menu_items := managed_menu_items |
|
|
if menu_items /= Void then |
|
|
from |
|
|
menu_items.start |
|
|
until |
|
|
menu_items.after |
|
|
loop |
|
|
if a_selected then |
|
|
menu_items.item.enable_select |
|
|
else |
|
|
menu_items.item.disable_select |
|
|
end |
|
|
menu_items.forth |
|
|
end |
|
|
end |
|
|
|
|
|
if a_selected then |
|
|
explorer_bar_item.show |
|
|
else |
|
|
explorer_bar_item.close |
|
|
end |
|
|
safety_flag := False |
|
|
end |
|
|
end |
|
|
|
|
|
update_tooltip (toggle: EB_COMMAND_TOGGLE_TOOL_BAR_BUTTON) is |
|
175 |
-- Update tooltip of `toggle'. |
-- Update tooltip of `toggle'. |
176 |
do |
do |
177 |
toggle.set_tooltip (tooltip) |
toggle.set_tooltip (tooltip) |
178 |
end |
end |
179 |
|
|
180 |
feature {NONE} -- Implementation |
update_sd_tooltip (a_toogle: EB_SD_COMMAND_TOOL_BAR_BUTTON) is |
181 |
|
-- Update tooltip of `a_toggle'. |
|
initialize_menu_item (a_menu_item: EB_COMMAND_MENU_ITEM) is |
|
|
-- Create a new menu entry for this command. |
|
182 |
do |
do |
183 |
Precursor {EB_TOOLBARABLE_AND_MENUABLE_COMMAND} (a_menu_item) |
a_toogle.set_tooltip (tooltip) |
|
-- We do not want pixmaps for check items. |
|
|
a_menu_item.remove_pixmap |
|
184 |
end |
end |
185 |
|
|
186 |
|
feature {NONE} -- Implementation |
187 |
|
|
188 |
safety_flag: BOOLEAN; |
safety_flag: BOOLEAN; |
189 |
-- Are we changing the `is_selected' attribute? (To prevent stack overflows) |
-- Are we changing the `is_selected' attribute? (To prevent stack overflows) |
190 |
|
|