/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_link_tool_command.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_link_tool_command.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 9497 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description : "Command to change links layout."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date : "$Date$"
6 revision : "$Revision$"
7
8 class
9 EB_LINK_TOOL_COMMAND
10
11 inherit
12 EB_CONTEXT_DIAGRAM_COMMAND
13 redefine
14 new_toolbar_item,
15 menu_name,
16 initialize
17 end
18
19 EB_CONTEXT_DIAGRAM_TOGGLE_COMMAND
20
21 create
22 make
23
24 feature {NONE} -- Initialization
25
26 initialize is
27 -- Initialize default values.
28 do
29 create accelerator.make_with_key_combination (
30 create {EV_KEY}.make_with_code ({EV_KEY_CONSTANTS}.key_r),
31 True, False, False)
32 accelerator.actions.extend (agent execute)
33 end
34
35 feature -- Basic operations
36
37 execute is
38 -- Perform on the whole diagram.
39 local
40 l_all_saved_edges: like all_saved_edges
41 l_world: EIFFEL_WORLD
42 do
43 if is_sensitive then
44 l_all_saved_edges := all_saved_edges
45 l_world := tool.world
46 if not l_world.is_right_angles then
47 l_world.enable_right_angles
48 l_world.apply_right_angles
49 enable_select
50 history.register_named_undoable (
51 interface_names.t_diagram_put_right_angles_cmd,
52 [<<agent l_world.enable_right_angles, agent l_world.apply_right_angles, agent enable_select>>],
53 [<<agent l_world.disable_right_angles, agent undo_apply_right_angles (l_all_saved_edges), agent disable_select>>])
54 else
55 l_world.disable_right_angles
56 l_world.remove_right_angles
57 disable_select
58 history.register_named_undoable (
59 interface_names.t_diagram_remove_right_angles_cmd,
60 [<<agent l_world.disable_right_angles, agent l_world.remove_right_angles, agent disable_select>>],
61 [<<agent l_world.enable_right_angles, agent l_world.apply_right_angles, agent enable_select>>])
62 end
63 current_button.set_tooltip (tooltip + shortcut_string)
64 end
65 end
66
67 execute_with_link_stone (a_stone: LINK_STONE) is
68 -- Change `a_stone' layout as the user wants.
69 local
70 lf: EIFFEL_LINK_FIGURE
71 x_pos, y_pos: INTEGER
72 client_stone: CLIENT_STONE
73 screen: EV_SCREEN
74 do
75 if a_stone.source.world = tool.world then
76 create link_tool_dialog
77 link_tool_dialog.set_link_tool_command (Current)
78
79 -- Save current link midpoints.
80 lf := a_stone.source
81 link_tool_dialog.set_link_figure (lf)
82 saved_edges := lf.edges
83
84 create screen
85 x_pos := screen.pointer_position.x - link_tool_dialog.width // 2
86 y_pos := screen.pointer_position.y - link_tool_dialog.height // 2
87 link_tool_dialog.set_position (x_pos, y_pos)
88
89 link_tool_dialog.preset (tool.world.is_labels_shown)
90
91 client_stone ?= a_stone
92 if client_stone /= Void then
93 link_tool_dialog.set_strings (client_stone.source.feature_names)
94 link_tool_dialog.set_for_client_link
95 else
96 --| FIXME: `disable_user_resize' makes the development window
97 --| go to the background when closing `link_tool_dialog'.
98 link_tool_dialog.set_maximum_size (link_tool_dialog.width, link_tool_dialog.height)
99 end
100
101 link_tool_dialog.show_relative_to_window (tool.develop_window.window)
102 end
103 end
104
105 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOGGLE_TOOL_BAR_BUTTON is
106 -- Create a new toolbar button for this command.
107 do
108 create Result.make (Current)
109 current_button := Result
110 initialize_toolbar_item (Result, display_text)
111 Result.select_actions.extend (agent execute)
112 Result.drop_actions.extend (agent execute_with_link_stone)
113 end
114
115 feature {EB_LINK_TOOL_DIALOG} -- Implementation
116
117 on_dialog_closed is
118 -- The user made his mind.
119 local
120 lf: EIFFEL_LINK_FIGURE
121 new_edges: LIST [EG_EDGE]
122 do
123 check
124 saved_edges_not_void: saved_edges /= Void
125 end
126 lf := link_tool_dialog.link_figure
127
128 -- We need to check that `lf' is still on the diagram.
129 if lf.world /= Void then
130 if not link_tool_dialog.cancelled then
131 if not lf.is_reflexive then
132 if not link_tool_dialog.reset_selected then
133 lf.hide
134 project
135 if link_tool_dialog.handle_left_selected then
136 lf.put_handle_left
137 elseif link_tool_dialog.handle_right_selected then
138 lf.put_handle_right
139 elseif link_tool_dialog.two_handles_left_selected then
140 lf.put_two_handles_left
141 elseif link_tool_dialog.two_handles_right_selected then
142 lf.put_two_handles_right
143 end
144 lf.show
145 project
146 end
147
148 new_edges := lf.edges
149 if link_tool_dialog.handle_left_selected then
150 history.register_named_undoable (
151 Interface_names.t_Diagram_put_one_handle_left_cmd,
152 [<<agent lf.reset, agent lf.retrieve_edges (new_edges)>>],
153 [<<agent lf.reset, agent lf.retrieve_edges (saved_edges)>>])
154 elseif link_tool_dialog.handle_right_selected then
155 history.register_named_undoable (
156 Interface_names.t_Diagram_put_one_handle_right_cmd,
157 [<<agent lf.reset, agent lf.retrieve_edges (new_edges)>>],
158 [<<agent lf.reset, agent lf.retrieve_edges (saved_edges)>>])
159 elseif link_tool_dialog.two_handles_left_selected then
160 history.register_named_undoable (
161 Interface_names.t_Diagram_put_two_handles_left_cmd,
162 [<<agent lf.reset, agent lf.retrieve_edges (new_edges)>>],
163 [<<agent lf.reset, agent lf.retrieve_edges (saved_edges)>>])
164 elseif link_tool_dialog.two_handles_right_selected then
165 history.register_named_undoable (
166 Interface_names.t_Diagram_put_two_handles_right_cmd,
167 [<<agent lf.reset, agent lf.retrieve_edges (new_edges)>>],
168 [<<agent lf.reset, agent lf.retrieve_edges (saved_edges)>>])
169 elseif link_tool_dialog.reset_selected then
170 history.do_named_undoable (
171 Interface_names.t_Diagram_remove_handles_cmd,
172 agent lf.reset,
173 agent lf.retrieve_edges (saved_edges))
174 end
175 end
176 else
177 if link_tool_dialog.applied then
178 lf.reset
179 lf.retrieve_edges (saved_edges)
180 project
181 end
182 end
183 end
184 link_tool_dialog.destroy
185 end
186
187 project is
188 -- Call the projector.
189 do
190 tool.projector.project
191 end
192
193 feature -- Access
194
195 tooltip: STRING is
196 -- Tooltip for the toolbar button.
197 do
198 if current_button.is_selected then
199 Result := Interface_names.f_diagram_remove_right_angles
200 else
201 Result := Interface_names.f_diagram_put_right_angles
202 end
203 end
204
205 feature {NONE} -- Implementation
206
207 current_stone: LINK_STONE
208 -- Last dropped stone.
209
210 pixmap: EV_PIXMAP is
211 -- Pixmap representing the command.
212 do
213 Result := pixmaps.icon_pixmaps.diagram_force_right_angles_icon
214 end
215
216 pixel_buffer: EV_PIXEL_BUFFER is
217 -- Pixel buffer representing the command.
218 do
219 Result := pixmaps.icon_pixmaps.context_link_icon_buffer
220 end
221
222 menu_name: STRING is
223 -- Name of the menu entry
224 do
225 Result := Interface_names.m_diagram_link_tool
226 end
227
228 name: STRING is "Link_tool"
229 -- Name of the command. Used to store the command in the
230 -- preferences.
231
232 link_tool_dialog: EB_LINK_TOOL_DIALOG
233 -- Associated widget.
234
235 saved_edges: LIST [EG_EDGE]
236 -- Backup of previous link midpoints.
237
238 all_saved_edges: LIST [TUPLE [EIFFEL_LINK_FIGURE, LIST [EG_EDGE]]] is
239 --
240 local
241 l_edges: LIST [EG_LINK_FIGURE]
242 l_item: EIFFEL_LINK_FIGURE
243 do
244 l_edges := tool.world.flat_links
245 create {ARRAYED_LIST [TUPLE [EIFFEL_LINK_FIGURE, LIST [EG_EDGE]]]} Result.make (l_edges.count)
246 from
247 l_edges.start
248 until
249 l_edges.after
250 loop
251 l_item ?= l_edges.item
252 if l_item /= Void then
253 Result.extend ([l_item, l_item.edges])
254 end
255 l_edges.forth
256 end
257 ensure
258 Result_not_void: Result /= Void
259 end
260
261 undo_apply_right_angles (edge_lists: like all_saved_edges) is
262 --
263 local
264 l_item: TUPLE [EIFFEL_LINK_FIGURE, LIST [EG_EDGE]]
265 l_figure: EIFFEL_LINK_FIGURE
266 l_saved_edges: LIST [EG_EDGE]
267 do
268 from
269 edge_lists.start
270 until
271 edge_lists.after
272 loop
273 l_item := edge_lists.item
274 l_figure ?= l_item.item (1)
275 l_saved_edges ?= l_item.item (2)
276 l_figure.reset
277 l_figure.retrieve_edges (l_saved_edges)
278 edge_lists.forth
279 end
280 end
281
282 feature {EB_CONTEXT_EDITOR} -- Implementation
283
284 current_button: EB_COMMAND_TOGGLE_TOOL_BAR_BUTTON;
285 -- Current toggle button.
286
287 indexing
288 copyright: "Copyright (c) 1984-2006, Eiffel Software"
289 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
290 licensing_options: "http://www.eiffel.com/licensing"
291 copying: "[
292 This file is part of Eiffel Software's Eiffel Development Environment.
293
294 Eiffel Software's Eiffel Development Environment is free
295 software; you can redistribute it and/or modify it under
296 the terms of the GNU General Public License as published
297 by the Free Software Foundation, version 2 of the License
298 (available at the URL listed under "license" above).
299
300 Eiffel Software's Eiffel Development Environment is
301 distributed in the hope that it will be useful, but
302 WITHOUT ANY WARRANTY; without even the implied warranty
303 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
304 See the GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public
307 License along with Eiffel Software's Eiffel Development
308 Environment; if not, write to the Free Software Foundation,
309 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
310 ]"
311 source: "[
312 Eiffel Software
313 356 Storke Road, Goleta, CA 93117 USA
314 Telephone 805-685-1006, Fax 805-685-6869
315 Website http://www.eiffel.com
316 Customer support http://support.eiffel.com
317 ]"
318
319 end -- class EB_LINK_TOOL_COMMAND

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23