/[eiffelstudio]/branches/eth/eve/Src/Eiffel/interface/new_graphical/information/outgoing/interface/es_eis_tooltip_handler.e
ViewVC logotype

Contents of /branches/eth/eve/Src/Eiffel/interface/new_graphical/information/outgoing/interface/es_eis_tooltip_handler.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92964 - (show annotations)
Fri Sep 20 05:41:23 2013 UTC (6 years ago) by jasonw
File size: 7916 byte(s)
<<Merged from trunk#92963.>>
1 note
2 description: "EIS tooltip handler"
3 date: "$Date$"
4 revision: "$Revision$"
5
6 class
7 ES_EIS_TOOLTIP_HANDLER
8
9 inherit
10 ANY
11
12 ES_TOOLTIP_HANDLER
13 redefine
14 show_tooltip_possible,
15 show_tooltip,
16 hide_tooltip
17 end
18
19 EV_SHARED_APPLICATION
20 export
21 {NONE} all
22 end
23
24 EB_CONSTANTS
25 export
26 {NONE} all
27 end
28
29 feature -- Operation
30
31 hide_tooltip
32 -- <Precuror>
33 do
34 Precursor
35 last_context := Void
36 end
37
38 feature -- Query
39
40 show_tooltip_possible (a_token: detachable EDITOR_TOKEN): BOOLEAN
41 -- Is it possible to show tooltip?
42 do
43 Result := attached {EIS_LINK_STONE} a_token.pebble
44 end
45
46 visit_eis_resource (a_token: EDITOR_TOKEN)
47 -- Visit resource attached to `a_token'.
48 do
49 if attached {EIS_LINK_STONE} a_token.pebble as l_pebble then
50 if
51 attached {ES_EIS_ENTRY_HELP_CONTEXT} l_pebble.link as l_context
52 then
53 show_help (l_context)
54 end
55 end
56 end
57
58 show_hint_tooltip (a_token: EDITOR_TOKEN; a_x, a_y: INTEGER)
59 -- Visit resource attached to `a_token'.
60 local
61 l_tooltip_window: like tooltip
62 l_widget: like create_tooltip_widget
63 l_rec: EV_RECTANGLE
64 l_screen: EV_SCREEN
65 l_pointer: EV_COORDINATE
66 do
67 create l_screen
68 if attached {EIS_LINK_STONE} a_token.pebble as l_pebble then
69 if
70 attached {ES_EIS_ENTRY_HELP_CONTEXT} l_pebble.link as l_context and then
71 last_context /= l_context
72 then
73 l_tooltip_window := tooltip
74 l_widget := create_hint_tooltip_widget
75 last_context := l_context
76 l_tooltip_window.set_popup_widget (l_widget)
77
78 if attached show_position_callback as l_c and then attached l_c.item ([a_x, a_y]) as l_p then
79 create l_rec.make (l_p.x, l_p.y, 0, 0)
80 else
81 create l_rec.make (l_pointer.x, l_pointer.y, 0, 0)
82 end
83
84 l_tooltip_window.show_on_side (l_rec, 0, 0)
85 end
86 end
87 end
88
89 feature {NONE} -- Implementation
90
91 show_tooltip (a_token: EDITOR_TOKEN)
92 -- Show debug tooltip
93 local
94 l_tooltip_window: like tooltip
95 l_widget: like create_tooltip_widget
96 l_rec: EV_RECTANGLE
97 l_screen: EV_SCREEN
98 l_pointer: EV_COORDINATE
99 do
100 create l_screen
101 l_pointer := l_screen.pointer_position
102 -- Ensure expression has not been changed under the mouse pointer.
103 if attached {EIS_LINK_STONE} a_token.pebble as l_pebble then
104 if
105 attached {ES_EIS_ENTRY_HELP_CONTEXT} l_pebble.link as l_context and then
106 (last_context /= l_context or else not attached tooltip as l_tooltip or else
107 not l_tooltip.is_shown)
108 then
109 l_tooltip_window := tooltip
110 l_widget := create_tooltip_widget (l_context)
111 last_context := l_context
112 l_tooltip_window.set_popup_widget (l_widget)
113
114 if attached show_position_callback as l_c and then attached l_c.item ([l_pointer.x, l_pointer.y]) as l_p then
115 create l_rec.make (l_p.x, l_p.y, 0, 0)
116 else
117 create l_rec.make (l_pointer.x, l_pointer.y, 0, 0)
118 end
119
120 l_tooltip_window.show_on_side (l_rec, 0, 0)
121 end
122 end
123 end
124
125 create_tooltip_widget (a_context: ES_EIS_ENTRY_HELP_CONTEXT): EV_VERTICAL_BOX
126 -- Create object grid
127 require
128 a_context_not_void: a_context /= Void
129 local
130 l_label: EVS_LINK_LABEL
131 l_browser_context: ES_EIS_ENTRY_HELP_CONTEXT
132 l_sep: EV_VERTICAL_SEPARATOR
133 l_hbox: EV_HORIZONTAL_BOX
134 do
135 create Result
136 extend_padding (Result, True)
137
138 create l_hbox
139 Result.extend (l_hbox)
140
141 extend_padding (l_hbox, False)
142
143 create l_label.make_with_text (interface_names.b_open)
144 create l_browser_context.make_from_other (a_context)
145 l_browser_context.set_is_shown_in_es (a_context.is_http_link and then a_context.is_web_browser_tool_usable)
146 l_label.select_actions.extend (agent show_help (l_browser_context))
147 l_hbox.extend (l_label)
148 setup_pointer_actions (l_label)
149
150 extend_padding (l_hbox, False)
151
152 if a_context.is_http_link and then a_context.is_web_browser_tool_usable then
153 create l_sep
154 l_hbox.extend (l_sep)
155 setup_pointer_actions (l_sep)
156
157 extend_padding (l_hbox, False)
158
159 create l_browser_context.make_from_other (a_context)
160 l_browser_context.set_is_shown_in_es (False)
161 create l_label.make_with_text (interface_names.m_open_in_brower)
162 l_label.select_actions.extend (agent show_help (l_browser_context))
163 l_hbox.extend (l_label)
164 setup_pointer_actions (l_label)
165
166 extend_padding (l_hbox, False)
167 end
168
169 extend_padding (Result, True)
170
171 color_propogator.propagate_colors (Result, Void, background_color, Void)
172 ensure
173 Result_not_void: Result /= Void
174 end
175
176 create_hint_tooltip_widget: EV_VERTICAL_BOX
177 -- Create hint tooltip
178 local
179 l_label: EV_LABEL
180 l_hbox: EV_HORIZONTAL_BOX
181 do
182 create Result
183 extend_padding (Result, True)
184
185 create l_hbox
186 Result.extend (l_hbox)
187
188 extend_padding (l_hbox, False)
189
190 create l_label.make_with_text (interface_names.l_press_ctrl_enter_to_open)
191 l_label.set_foreground_color (hint_text_color)
192 l_label.set_font (hint_text_font)
193 l_hbox.extend (l_label)
194
195 extend_padding (l_hbox, False)
196
197 extend_padding (Result, True)
198
199 color_propogator.propagate_colors (Result, Void, background_color, Void)
200 end
201
202 extend_padding (a_list: EV_BOX; a_vertical: BOOLEAN)
203 -- Extend padding
204 local
205 l_padding: EV_CELL
206 do
207 create l_padding
208 if a_vertical then
209 l_padding.set_minimum_height ({ES_UI_CONSTANTS}.label_vertical_padding)
210 else
211 l_padding.set_minimum_width ({ES_UI_CONSTANTS}.label_horizontal_padding)
212 end
213 l_padding.set_background_color (background_color)
214 a_list.extend (l_padding)
215 a_list.disable_item_expand (l_padding)
216 setup_pointer_actions (l_padding)
217 end
218
219 show_help (a_context: HELP_CONTEXT_I)
220 -- Show help
221 local
222 l_providers: SERVICE_CONSUMER [HELP_PROVIDERS_S]
223 l_service: HELP_PROVIDERS_S
224 do
225 hide_tooltip
226 create l_providers
227 if l_providers.is_service_available then
228 l_service := l_providers.service
229 l_service.show_help (a_context)
230 end
231 end
232
233 hint_text_color: EV_COLOR
234 -- Text color of the hint
235 local
236 l_stock: EV_STOCK_COLORS
237 once
238 create l_stock
239 Result := l_stock.dark_gray
240 end
241
242 hint_text_font: EV_FONT
243 -- Text color of the hint
244 local
245 l_label: EV_LABEL
246 once
247 create l_label
248 Result := l_label.font
249 Result.set_shape ({EV_FONT_CONSTANTS}.Shape_italic)
250 end
251
252 background_color: EV_COLOR
253 -- Background color
254 local
255 l_stock: EV_STOCK_COLORS
256 once
257 create l_stock
258 Result := l_stock.white
259 end
260
261 color_propogator: ES_COLOR_PROPAGATOR
262 -- Color propogator
263 once
264 create Result
265 end
266
267 last_context: detachable HELP_CONTEXT_I;
268 -- Last context to show the tooltip
269
270 note
271 copyright: "Copyright (c) 1984-2013, Eiffel Software"
272 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
273 licensing_options: "http://www.eiffel.com/licensing"
274 copying: "[
275 This file is part of Eiffel Software's Eiffel Development Environment.
276
277 Eiffel Software's Eiffel Development Environment is free
278 software; you can redistribute it and/or modify it under
279 the terms of the GNU General Public License as published
280 by the Free Software Foundation, version 2 of the License
281 (available at the URL listed under "license" above).
282
283 Eiffel Software's Eiffel Development Environment is
284 distributed in the hope that it will be useful, but
285 WITHOUT ANY WARRANTY; without even the implied warranty
286 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
287 See the GNU General Public License for more details.
288
289 You should have received a copy of the GNU General Public
290 License along with Eiffel Software's Eiffel Development
291 Environment; if not, write to the Free Software Foundation,
292 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
293 ]"
294 source: "[
295 Eiffel Software
296 5949 Hollister Ave., Goleta, CA 93117 USA
297 Telephone 805-685-1006, Fax 805-685-6869
298 Website http://www.eiffel.com
299 Customer support http://support.eiffel.com
300 ]"
301 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23