/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/es_figure_world_cell.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/es_figure_world_cell.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: 7805 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Objects that casts the projector in EV_MODEL_WORLD_CELL to EIFFEL_PROJECTOR."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: ""
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EIFFEL_FIGURE_WORLD_CELL
11
12 inherit
13 EV_MODEL_WORLD_CELL
14 redefine
15 projector,
16 on_pointer_button_press_on_drawing_area,
17 on_pointer_button_release_on_drawing_area,
18 initialize,
19 on_mouse_wheel_on_drawing_area,
20 world,
21 set_world
22 end
23
24 EB_RECYCLABLE
25 undefine
26 copy,
27 default_create
28 end
29
30 EB_CONSTANTS
31 undefine
32 copy,
33 default_create
34 end
35
36 OBSERVER
37 rename
38 update as retrieve_preferences
39 undefine
40 default_create,
41 copy
42 end
43
44 EB_SHARED_PREFERENCES
45 undefine
46 default_create,
47 copy
48 end
49
50 create
51 make_with_world,
52 make_with_world_and_tool
53
54 feature {NONE} -- Initialization
55
56 make_with_world_and_tool (a_world: like world; a_tool: like tool) is
57 -- Make an EIFFEL_FIGURE_WORLD_CELL displaying `a_world' inside `a_tool'.
58 require
59 a_world_not_void: a_world /= Void
60 a_tool_not_void: a_tool /= Void
61 do
62 make_with_world (a_world)
63 tool := a_tool
64 ensure
65 set: tool = a_tool
66 end
67
68 initialize is
69 -- Initialize `Current'.
70 do
71 Precursor {EV_MODEL_WORLD_CELL}
72 drawing_area.set_pointer_style (cursors.open_hand_cursor)
73 preferences.diagram_tool_data.add_observer (Current)
74 retrieve_preferences
75 end
76
77 feature -- Access
78
79 projector: EIFFEL_PROJECTOR
80 -- The projector used to project the `world'.
81
82 tool: EB_DIAGRAM_TOOL
83 -- Tool the `world' is displayed in.
84
85 world: EIFFEL_WORLD
86 -- World shown in Current.
87
88 feature -- Element change
89
90 set_world (a_world: like world) is
91 -- Set `world' to `a_world'.
92 do
93 if world /= Void then
94 -- `recycle' former world to avoid memory leak.
95 world.recycle
96 end
97 world := a_world
98 projector.set_world (a_world)
99 end
100
101 feature -- Recycling
102
103 recycle is
104 -- Recycle `Current' and leave `Current' in an unstable state.
105 do
106 preferences.diagram_tool_data.remove_observer (Current)
107 world.recycle
108 end
109
110 feature {NONE} -- Implementation
111
112 on_pointer_button_press_on_drawing_area (ax, ay, button: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; ascreen_x, ascreen_y: INTEGER) is
113 -- Pointer button was pressed in `drawing_area'.
114 do
115 if button = 1 then
116 if projector.is_figure_selected then
117 is_scroll := True
118 elseif not ev_application.ctrl_pressed then
119 drawing_area.set_pointer_style (cursors.closed_hand_cursor)
120 is_hand := True
121 start_x := ax
122 start_y := ay
123 start_horizontal_value := horizontal_scrollbar.value
124 start_vertical_value := vertical_scrollbar.value
125 drawing_area.enable_capture
126 else
127 is_scroll := True
128 end
129 end
130 end
131
132 on_pointer_button_release_on_drawing_area (ax, ay, button: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; ascreen_x, ascreen_y: INTEGER) is
133 -- Pointer button was released over `drawing_area'.
134 do
135 if is_scroll then
136 is_scroll := False
137 end
138 if is_hand then
139 is_hand := False
140 drawing_area.set_pointer_style (cursors.open_hand_cursor)
141 drawing_area.disable_capture
142 end
143 end
144
145 on_mouse_wheel_on_drawing_area (i: INTEGER) is
146 -- User moved mouse wheel.
147 local
148 l_world: EIFFEL_WORLD
149 new_scale_factor, l_scale_factor: DOUBLE
150 l_zoom_selector: EB_ZOOM_SELECTOR
151 new_scale, old_scale: INTEGER
152 l_projector: EIFFEL_PROJECTOR
153 step: INTEGER
154 do
155 if ev_application.ctrl_pressed then
156 if tool /= Void then
157 if i <= -1 then
158 l_world := tool.world
159 l_scale_factor := l_world.scale_factor
160 new_scale_factor := (0.1 + l_scale_factor) / l_scale_factor
161 old_scale := (l_world.scale_factor * 100).rounded
162 l_world.scale (new_scale_factor)
163 tool.crop_diagram
164 l_projector := tool.projector
165 l_projector.full_project
166 new_scale := (l_world.scale_factor * 100).rounded
167 l_zoom_selector := tool.zoom_selector
168 l_zoom_selector.show_as_text (new_scale)
169 tool.history.register_named_undoable (
170 Interface_names.t_Diagram_zoom_in_cmd,
171 [<<agent l_world.scale (new_scale_factor), agent tool.crop_diagram, agent l_zoom_selector.show_as_text (new_scale), agent l_projector.full_project>>],
172 [<<agent l_world.scale (1/new_scale_factor), agent tool.crop_diagram, agent l_zoom_selector.show_as_text (old_scale), agent l_projector.full_project>>])
173 else
174 l_world := tool.world
175 l_scale_factor := l_world.scale_factor
176 new_scale_factor := (0.1 - l_scale_factor) / -l_scale_factor
177 if l_world.scale_factor * new_scale_factor > 0.1 then
178 old_scale := (l_world.scale_factor * 100).rounded
179 l_world.scale (new_scale_factor)
180 tool.crop_diagram
181 l_projector := tool.projector
182 l_projector.full_project
183 new_scale := (l_world.scale_factor * 100).rounded
184 l_zoom_selector := tool.zoom_selector
185 l_zoom_selector.show_as_text (new_scale)
186 tool.history.register_named_undoable (
187 Interface_names.t_Diagram_zoom_out_cmd,
188 [<<agent l_world.scale (new_scale_factor), agent tool.crop_diagram, agent l_zoom_selector.show_as_text (new_scale), agent l_projector.full_project>>],
189 [<<agent l_world.scale (1/new_scale_factor), agent tool.crop_diagram, agent l_zoom_selector.show_as_text (old_scale), agent l_projector.full_project>>])
190 end
191 end
192 end
193 else
194 if ev_application.shift_pressed then
195 step := (horizontal_scrollbar.value_range.count * 0.1).truncated_to_integer
196 if i >= 1 then
197 horizontal_scrollbar.set_value ((horizontal_scrollbar.value - step).max (horizontal_scrollbar.value_range.lower))
198 else
199 horizontal_scrollbar.set_value ((horizontal_scrollbar.value + step).min (horizontal_scrollbar.value_range.upper))
200 end
201 else
202 step := (vertical_scrollbar.value_range.count * 0.1).truncated_to_integer
203 if i >= 1 then
204 vertical_scrollbar.set_value ((vertical_scrollbar.value - step).max (vertical_scrollbar.value_range.lower))
205 else
206 vertical_scrollbar.set_value ((vertical_scrollbar.value + step).min (vertical_scrollbar.value_range.upper))
207 end
208 end
209 end
210 end
211
212 retrieve_preferences is
213 -- Retrieve `scroll_speed' from preferences.
214 local
215 val: INTEGER
216 do
217 val := preferences.diagram_tool_data.diagram_auto_scroll_speed
218 val := val.min(100).max(0)
219 scroll_speed := val / 100
220 end
221
222 indexing
223 copyright: "Copyright (c) 1984-2006, Eiffel Software"
224 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
225 licensing_options: "http://www.eiffel.com/licensing"
226 copying: "[
227 This file is part of Eiffel Software's Eiffel Development Environment.
228
229 Eiffel Software's Eiffel Development Environment is free
230 software; you can redistribute it and/or modify it under
231 the terms of the GNU General Public License as published
232 by the Free Software Foundation, version 2 of the License
233 (available at the URL listed under "license" above).
234
235 Eiffel Software's Eiffel Development Environment is
236 distributed in the hope that it will be useful, but
237 WITHOUT ANY WARRANTY; without even the implied warranty
238 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
239 See the GNU General Public License for more details.
240
241 You should have received a copy of the GNU General Public
242 License along with Eiffel Software's Eiffel Development
243 Environment; if not, write to the Free Software Foundation,
244 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
245 ]"
246 source: "[
247 Eiffel Software
248 356 Storke Road, Goleta, CA 93117 USA
249 Telephone 805-685-1006, Fax 805-685-6869
250 Website http://www.eiffel.com
251 Customer support http://support.eiffel.com
252 ]"
253
254 end -- class EIFFEL_FIGURE_WORLD_CELL

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23