1 |
indexing |
2 |
description : "Command that can be added in a toolbar." |
3 |
legal: "See notice at end of class." |
4 |
status: "See notice at end of class." |
5 |
date : "$Date$" |
6 |
revision : "$Revision$" |
7 |
|
8 |
deferred class |
9 |
EB_TOOLBARABLE_COMMAND |
10 |
|
11 |
inherit |
12 |
EB_GRAPHICAL_COMMAND |
13 |
|
14 |
EB_TOOLBARABLE |
15 |
redefine |
16 |
new_toolbar_item |
17 |
end |
18 |
|
19 |
feature -- Access |
20 |
|
21 |
pixmap: EV_PIXMAP is |
22 |
-- Pixmap representing the command. |
23 |
deferred |
24 |
end |
25 |
|
26 |
pixel_buffer: EV_PIXEL_BUFFER is |
27 |
-- Pixel buffer which representing the command. |
28 |
deferred |
29 |
end |
30 |
|
31 |
mini_pixmap: EV_PIXMAP is |
32 |
-- Pixmap representing the command for mini toolbars. |
33 |
do |
34 |
end |
35 |
|
36 |
tooltip: STRING is |
37 |
-- Tooltip for the toolbar button. |
38 |
deferred |
39 |
ensure |
40 |
valid_result: Result /= Void |
41 |
end |
42 |
|
43 |
tooltext: STRING is |
44 |
-- Text displayed on the toolbar button. |
45 |
do |
46 |
Result := "" |
47 |
ensure |
48 |
valid_result: Result /= Void |
49 |
end |
50 |
|
51 |
has_text: BOOLEAN is |
52 |
-- Does `Current' show text when displayed |
53 |
do |
54 |
Result := tooltext /= Void and then not tooltext.is_equal ("") |
55 |
end |
56 |
|
57 |
is_tooltext_important: BOOLEAN is |
58 |
-- Is the tooltext important shown when view is 'Selective Text' |
59 |
do |
60 |
Result := False |
61 |
end |
62 |
|
63 |
feature -- Status Report |
64 |
|
65 |
is_displayed: BOOLEAN |
66 |
-- Is the toolbar button currently displayed? |
67 |
|
68 |
feature -- Status setting |
69 |
|
70 |
enable_displayed is |
71 |
-- Set `is_displayed' to True. |
72 |
do |
73 |
is_displayed := True |
74 |
end |
75 |
|
76 |
disable_displayed is |
77 |
-- Set `is_displayed' to False. |
78 |
do |
79 |
is_displayed := False |
80 |
end |
81 |
|
82 |
enable_sensitive is |
83 |
-- Set `is_sensitive' to True. |
84 |
local |
85 |
toolbar_items: like managed_toolbar_items |
86 |
do |
87 |
if not is_sensitive then |
88 |
is_sensitive := True |
89 |
toolbar_items := managed_toolbar_items |
90 |
if toolbar_items /= Void then |
91 |
from |
92 |
toolbar_items.start |
93 |
until |
94 |
toolbar_items.after |
95 |
loop |
96 |
toolbar_items.item.enable_sensitive |
97 |
toolbar_items.forth |
98 |
end |
99 |
end |
100 |
end |
101 |
end |
102 |
|
103 |
disable_sensitive is |
104 |
-- Set `is_sensitive' to True. |
105 |
local |
106 |
toolbar_items: like managed_toolbar_items |
107 |
do |
108 |
if is_sensitive then |
109 |
toolbar_items := managed_toolbar_items |
110 |
if toolbar_items /= Void then |
111 |
from |
112 |
toolbar_items.start |
113 |
until |
114 |
toolbar_items.after |
115 |
loop |
116 |
toolbar_items.item.disable_sensitive |
117 |
toolbar_items.forth |
118 |
end |
119 |
end |
120 |
is_sensitive := False |
121 |
end |
122 |
end |
123 |
|
124 |
feature -- Basic operations |
125 |
|
126 |
new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is |
127 |
-- Create a new toolbar button for this command. |
128 |
-- |
129 |
-- Call `recycle' on the result when you don't need it anymore otherwise |
130 |
-- it will never be garbage collected. |
131 |
do |
132 |
create Result.make (Current) |
133 |
initialize_toolbar_item (Result, display_text) |
134 |
Result.select_actions.extend (agent execute) |
135 |
end |
136 |
|
137 |
new_sd_toolbar_item (display_text: BOOLEAN): EB_SD_COMMAND_TOOL_BAR_BUTTON is |
138 |
-- |
139 |
do |
140 |
create Result.make (Current) |
141 |
initialize_sd_toolbar_item (Result, display_text) |
142 |
Result.select_actions.extend (agent execute) |
143 |
end |
144 |
|
145 |
new_mini_toolbar_item: EB_COMMAND_TOOL_BAR_BUTTON is |
146 |
-- Create a new mini toolbar button for this command. |
147 |
require |
148 |
mini_pixmap_not_void: mini_pixmap /= Void |
149 |
do |
150 |
create Result.make (Current) |
151 |
Result.set_pixmap (mini_pixmap) |
152 |
if is_sensitive then |
153 |
Result.enable_sensitive |
154 |
else |
155 |
Result.disable_sensitive |
156 |
end |
157 |
Result.set_tooltip (tooltip) |
158 |
Result.select_actions.extend (agent execute) |
159 |
end |
160 |
|
161 |
feature {NONE} -- Implementation |
162 |
|
163 |
initialize_toolbar_item (a_item: EB_COMMAND_TOOL_BAR_BUTTON; display_text: BOOLEAN) is |
164 |
-- Initialize `a_item' |
165 |
local |
166 |
l_tt: STRING |
167 |
do |
168 |
if display_text and then has_text then |
169 |
a_item.set_text (tooltext) |
170 |
end |
171 |
a_item.set_pixmap (pixmap) |
172 |
if is_sensitive then |
173 |
a_item.enable_sensitive |
174 |
else |
175 |
a_item.disable_sensitive |
176 |
end |
177 |
l_tt := tooltip.twin |
178 |
if accelerator /= Void then |
179 |
l_tt.append (opening_parenthesis) |
180 |
l_tt.append (accelerator.out) |
181 |
l_tt.append (closing_parenthesis) |
182 |
end |
183 |
a_item.set_tooltip (l_tt) |
184 |
end |
185 |
|
186 |
initialize_sd_toolbar_item (a_item: EB_SD_COMMAND_TOOL_BAR_BUTTON; display_text: BOOLEAN) is |
187 |
-- Initialize `a_item' |
188 |
local |
189 |
l_tt: STRING |
190 |
do |
191 |
if display_text and then has_text then |
192 |
a_item.set_text (tooltext) |
193 |
end |
194 |
a_item.set_pixmap (pixmap) |
195 |
if pixel_buffer /= Void then |
196 |
a_item.set_pixel_buffer (pixel_buffer) |
197 |
end |
198 |
a_item.set_tooltip (tooltip) |
199 |
a_item.set_description (description) |
200 |
if is_sensitive then |
201 |
a_item.enable_sensitive |
202 |
else |
203 |
a_item.disable_sensitive |
204 |
end |
205 |
l_tt := tooltip.twin |
206 |
if accelerator /= Void then |
207 |
l_tt.append (opening_parenthesis) |
208 |
l_tt.append (accelerator.out) |
209 |
l_tt.append (closing_parenthesis) |
210 |
end |
211 |
a_item.set_tooltip (l_tt) |
212 |
end |
213 |
|
214 |
feature {EB_COMMAND_TOOL_BAR_BUTTON, EB_SD_COMMAND_TOOL_BAR_BUTTON} -- Implementation |
215 |
|
216 |
internal_managed_toolbar_items: ARRAYED_LIST [like new_toolbar_item] |
217 |
|
218 |
internal_managed_sd_toolbar_items: ARRAYED_LIST [like new_sd_toolbar_item] |
219 |
|
220 |
managed_toolbar_items: ARRAYED_LIST [like new_toolbar_item] is |
221 |
-- Toolbar items associated with this command. |
222 |
do |
223 |
if internal_managed_toolbar_items = Void then |
224 |
create internal_managed_toolbar_items.make (1) |
225 |
end |
226 |
Result := internal_managed_toolbar_items |
227 |
end |
228 |
|
229 |
managed_sd_toolbar_items: ARRAYED_LIST [like new_sd_toolbar_item] is |
230 |
-- |
231 |
do |
232 |
if internal_managed_sd_toolbar_items = Void then |
233 |
create internal_managed_sd_toolbar_items.make (1) |
234 |
end |
235 |
Result := internal_managed_sd_toolbar_items |
236 |
end |
237 |
|
238 |
Opening_parenthesis: STRING is " (" |
239 |
Closing_parenthesis: STRING is ")"; |
240 |
indexing |
241 |
copyright: "Copyright (c) 1984-2006, Eiffel Software" |
242 |
license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" |
243 |
licensing_options: "http://www.eiffel.com/licensing" |
244 |
copying: "[ |
245 |
This file is part of Eiffel Software's Eiffel Development Environment. |
246 |
|
247 |
Eiffel Software's Eiffel Development Environment is free |
248 |
software; you can redistribute it and/or modify it under |
249 |
the terms of the GNU General Public License as published |
250 |
by the Free Software Foundation, version 2 of the License |
251 |
(available at the URL listed under "license" above). |
252 |
|
253 |
Eiffel Software's Eiffel Development Environment is |
254 |
distributed in the hope that it will be useful, but |
255 |
WITHOUT ANY WARRANTY; without even the implied warranty |
256 |
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
257 |
See the GNU General Public License for more details. |
258 |
|
259 |
You should have received a copy of the GNU General Public |
260 |
License along with Eiffel Software's Eiffel Development |
261 |
Environment; if not, write to the Free Software Foundation, |
262 |
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
263 |
]" |
264 |
source: "[ |
265 |
Eiffel Software |
266 |
356 Storke Road, Goleta, CA 93117 USA |
267 |
Telephone 805-685-1006, Fax 805-685-6869 |
268 |
Website http://www.eiffel.com |
269 |
Customer support http://support.eiffel.com |
270 |
]" |
271 |
|
272 |
end -- class EB_TOOLBARABLE_COMMAND |