/[eiffelstudio]/trunk/Src/Eiffel/interface/graphical/tools/event_list_service/common/es_clickable_event_list_tool_panel_base.e
ViewVC logotype

Contents of /trunk/Src/Eiffel/interface/graphical/tools/event_list_service/common/es_clickable_event_list_tool_panel_base.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71346 - (show annotations)
Mon Dec 3 19:25:51 2007 UTC (12 years, 1 month ago) by paulb
File size: 8603 byte(s)
Supported optional selection exclusion for EB_GRID_EDITOR_TOKEN_ITEM to mirror that of the same functionality in EV_GRID_LABEL_ITEM.
Supported setting of selection background colors on EB_EDITOR_TOKEN_TEXT.
Updated the error list (and base implementation) tool to set correct grid selection colors and to disable selection for non applicable areas.
Error list is now-multiple select.
1 indexing
2 description: "[
3 A specialized event list service-based {EVENT_LIST_SERVICE_I} tool that support clickable items and tools tips.
4 ]"
5 legal: "See notice at end of class."
6 status: "See notice at end of class.";
7 date: "$date$";
8 revision: "$revision$"
9
10 deferred class
11 ES_CLICKABLE_EVENT_LIST_TOOL_PANEL_BASE
12
13 inherit
14 ES_EVENT_LIST_TOOL_PANEL_BASE
15 redefine
16 build_tool_interface,
17 row_item_text,
18 internal_recycle
19 end
20
21 feature {NONE} -- Initialization
22
23 build_tool_interface (a_widget: ES_GRID)
24 -- Builds the tools user interface elements.
25 -- Note: This function is called prior to showing the tool for the first time.
26 --
27 -- `a_widget': A widget to build the tool interface using.
28 do
29 grid_token_support.synchronize_color_or_font_change_with_editor
30 grid_token_support.enable_grid_item_pnd_support
31 grid_token_support.enable_ctrl_right_click_to_open_new_window
32 grid_token_support.set_context_menu_factory_function (agent (develop_window.menus).context_menu_factory)
33 end
34
35 feature {NONE} -- Clean up
36
37 internal_recycle is
38 -- Recycle tool.
39 do
40 if is_initialized then
41 grid_token_support.desynchronize_color_or_font_change_with_editor
42 end
43 internal_grid_token_support := Void
44 Precursor {ES_EVENT_LIST_TOOL_PANEL_BASE}
45 ensure then
46 internal_grid_token_support_detached: internal_grid_token_support = Void
47 end
48
49 feature {NONE} -- Access
50
51 frozen grid_token_support: EB_EDITOR_TOKEN_GRID_SUPPORT
52 -- Support for using `grid_events' with editor token-based items
53 do
54 Result := internal_grid_token_support
55 if Result = Void then
56 create Result.make_with_grid (grid_events)
57 internal_grid_token_support := Result
58 auto_recycle (internal_grid_token_support)
59 end
60 ensure
61 result_attached: Result /= Void
62 result_consistent: Result = grid_token_support
63 end
64
65 token_generator: EB_EDITOR_TOKEN_GENERATOR
66 -- An editor token generator for generating editor token on grid items
67 once
68 Result := (create {EB_SHARED_WRITER}).token_writer
69 end
70
71 feature {NONE} -- Query
72
73 row_item_text (a_item: EV_GRID_ITEM): STRING_32
74 -- Extracts a string representation of a grid row's cell item.
75 --
76 -- `a_item': Grid item to retrieve string representation for.
77 -- `Result': A string representation of the item or Void if not string representation could be created.
78 local
79 l_editor_item: EB_GRID_EDITOR_TOKEN_ITEM
80 do
81 l_editor_item ?= a_item
82 if l_editor_item /= Void then
83 Result := l_editor_item.text
84 else
85 Result := Precursor {ES_EVENT_LIST_TOOL_PANEL_BASE} (a_item)
86 end
87 end
88
89 feature {NONE} -- Factory
90
91 create_clickable_grid_item (a_line: EIFFEL_EDITOR_LINE): EB_GRID_EDITOR_TOKEN_ITEM
92 -- Create a new grid item to host the context of `a_lines'.
93 --
94 -- `a_line': The editor line containing tokens to render on the resulting grid item.
95 -- `Result': A grid item with the tokens set.
96 require
97 a_line_attached: a_line /= Void
98 local
99 l_lines: ARRAYED_LIST [EIFFEL_EDITOR_LINE]
100 do
101 create l_lines.make (1)
102 l_lines.extend (a_line)
103 Result := create_multiline_clickable_grid_item (l_lines, False)
104 ensure
105 result_attached: Result /= Void
106 end
107
108 create_multiline_clickable_grid_item (a_lines: LIST [EIFFEL_EDITOR_LINE]; a_use_text_wrapping: BOOLEAN): EB_GRID_EDITOR_TOKEN_ITEM
109 -- Create a new grid item to host the context of `a_lines'.
110 --
111 -- `a_lines': The editor lines containing tokens to render on the resulting grid item.
112 -- `Result': A grid item with the tokens set.
113 require
114 a_lines_attached: a_lines /= Void
115 local
116 l_tokens: like tokens_list_from_lines
117 l_shared_writer: EB_SHARED_WRITER
118 do
119 create Result
120 Result.set_text_wrap (a_use_text_wrapping)
121 l_tokens := tokens_list_from_lines (a_lines)
122 if not l_tokens.is_empty then
123 create l_shared_writer
124 Result.set_left_border (4)
125 Result.set_text_with_tokens (tokens_list_from_lines (a_lines))
126 Result.set_overriden_fonts (l_shared_writer.label_font_table, l_shared_writer.label_font_height)
127 end
128 ensure
129 result_attached: Result /= Void
130 end
131
132 create_clickable_tooltip (a_lines: LIST [EIFFEL_EDITOR_LINE]; a_item: EV_GRID_ITEM; a_row: EV_GRID_ROW): EB_EDITOR_TOKEN_TOOLTIP is
133 -- Creates a new clickable tool tip with the context of `a_lines' and attaches itself it `a_item'
134 --
135 -- Note: If `a_item' already had a tool tip created for it, no new tool tip will be created but the same
136 -- one will be returned.
137 --
138 -- `a_lines': The editor lines containing tokens to render on the resulting tool tip.
139 -- `a_item': The tool tip to attached to the item.
140 -- `a_row': The row where the item is to be places
141 -- `Result': A tool tip attached to `a_item'
142 require
143 a_lines_attached: a_lines /= Void
144 a_item_attached: a_item /= Void
145 a_item_is_parented: a_item.is_parented
146 a_item_data_unattached_or_is_tool_tip: a_item.data = Void or else (({EB_EDITOR_TOKEN_TOOLTIP}) #? a_item.data) /= Void
147 local
148 l_tokens: like tokens_list_from_lines
149 l_select_actions: EV_NOTIFY_ACTION_SEQUENCE
150 do
151 Result ?= a_item.data
152 if Result = Void then
153 if grid_events.is_single_item_selection_enabled or grid_events.is_multiple_row_selection_enabled then
154 l_select_actions := a_item.row.select_actions
155 else
156 l_select_actions := a_item.select_actions
157 end
158 create Result.make (a_item.pointer_enter_actions, a_item.pointer_leave_actions, l_select_actions, agent a_item.is_destroyed)
159 Result.enable_pointer_on_tooltip
160 a_item.set_data (Result)
161 end
162
163 l_tokens := tokens_list_from_lines (a_lines)
164 Result.set_tooltip_text (l_tokens)
165 if not l_tokens.is_empty then
166 Result.enable_tooltip
167 else
168 Result.disable_tooltip
169 end
170 ensure
171 result_attached: Result /= Void
172 end
173
174 feature {NONE} -- Basic operations
175
176 tokens_list_from_lines (a_lines: LIST [EIFFEL_EDITOR_LINE]): ARRAYED_LIST [EDITOR_TOKEN]
177 -- Create a list of editor tokens from lines `a_lines'
178 --
179 -- `a_lines': Lines to create a token list from
180 require
181 a_lines_attached: a_lines /= Void
182 not_a_lines_is_empty: not a_lines.is_empty
183 local
184 l_cursor: CURSOR
185 l_eol: EDITOR_TOKEN_EOL
186 l_start: BOOLEAN
187 do
188 create Result.make (20)
189 l_cursor := a_lines.cursor
190 from a_lines.start until a_lines.after loop
191 if not l_start then
192 l_start := a_lines.item.count > 0
193 end
194 if l_start then
195 -- Ensures no blank lines at the beginning of the text
196 Result.append (a_lines.item.content)
197 if not a_lines.islast then
198 Result.extend (create {EDITOR_TOKEN_EOL}.make)
199 end
200 end
201 a_lines.forth
202 end
203 a_lines.go_to (l_cursor)
204
205 if not Result.is_empty then
206 -- Ensures no blank lines at the end of the text
207 l_eol ?= Result.last
208 from Result.finish until Result.before or l_eol = Void loop
209 l_eol ?= Result.item
210 if l_eol /= Void then
211 Result.remove
212 end
213 if not Result.before then
214 Result.back
215 end
216 end
217 end
218 ensure
219 result_attached: Result /= Void
220 a_lines_unmoved: a_lines.cursor.is_equal (old a_lines.cursor)
221 end
222
223 feature {NONE} -- Internal implementation cache
224
225 internal_grid_token_support: like grid_token_support
226 -- Cached version of `grid_token_support'
227 -- Note: Do not use directly!
228
229 ;indexing
230 copyright: "Copyright (c) 1984-2007, Eiffel Software"
231 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
232 licensing_options: "http://www.eiffel.com/licensing"
233 copying: "[
234 This file is part of Eiffel Software's Eiffel Development Environment.
235
236 Eiffel Software's Eiffel Development Environment is free
237 software; you can redistribute it and/or modify it under
238 the terms of the GNU General Public License as published
239 by the Free Software Foundation, version 2 of the License
240 (available at the URL listed under "license" above).
241
242 Eiffel Software's Eiffel Development Environment is
243 distributed in the hope that it will be useful, but
244 WITHOUT ANY WARRANTY; without even the implied warranty
245 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
246 See the GNU General Public License for more details.
247
248 You should have received a copy of the GNU General Public
249 License along with Eiffel Software's Eiffel Development
250 Environment; if not, write to the Free Software Foundation,
251 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
252 ]"
253 source: "[
254 Eiffel Software
255 356 Storke Road, Goleta, CA 93117 USA
256 Telephone 805-685-1006, Fax 805-685-6869
257 Website http://www.eiffel.com
258 Customer support http://support.eiffel.com
259 ]"
260
261 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23