1
2 /******************************************************************************
3 * MODULE : tm_frame.cpp
4 * DESCRIPTION: Routines for main TeXmacs frames
5 * COPYRIGHT : (C) 1999 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12 #include "tm_frame.hpp"
13 #include "tm_window.hpp"
14 #include "message.hpp"
15
16 /******************************************************************************
17 * Constructor and destructor
18 ******************************************************************************/
19
tm_frame_rep()20 tm_frame_rep::tm_frame_rep ():
21 full_screen (false), full_screen_edit (false), dialogue_win () {}
~tm_frame_rep()22 tm_frame_rep::~tm_frame_rep () {}
23
24 /******************************************************************************
25 * Subroutines
26 ******************************************************************************/
27
28 widget
make_menu_widget(object menu)29 make_menu_widget (object menu) {
30 widget w= as_widget (call ("make-menu-widget", menu, 0));
31 //string s= "(make-menu-widget '" * menu * " 0)";
32 //widget w= as_widget (eval (s));
33 if (is_nil (w)) {
34 array<widget> a (0);
35 return horizontal_menu (a);
36 }
37 return w;
38 }
39
40 string
icon_bar_name(int which)41 icon_bar_name (int which) {
42 if (which == 0) return "main";
43 else if (which == 1) return "mode";
44 else if (which == 2) return "focus";
45 else return "user";
46 }
47
48 /******************************************************************************
49 * Properties of the current window
50 ******************************************************************************/
51
52 int
get_window_serial()53 tm_frame_rep::get_window_serial () {
54 return concrete_window () -> serial;
55 }
56
57 void
set_window_property(scheme_tree what,scheme_tree val)58 tm_frame_rep::set_window_property (scheme_tree what, scheme_tree val) {
59 concrete_window () -> set_property (what, val);
60 }
61
62 void
set_bool_window_property(string what,bool val)63 tm_frame_rep::set_bool_window_property (string what, bool val) {
64 concrete_window () -> set_property (what, val? string ("true"): string ("false"));
65 }
66
67 void
set_int_window_property(string what,int val)68 tm_frame_rep::set_int_window_property (string what, int val) {
69 concrete_window () -> set_property (what, as_tree (val));
70 }
71
72 void
set_string_window_property(string what,string val)73 tm_frame_rep::set_string_window_property (string what, string val) {
74 concrete_window () -> set_property (what, val);
75 }
76
77 scheme_tree
get_window_property(scheme_tree what)78 tm_frame_rep::get_window_property (scheme_tree what) {
79 return concrete_window () -> get_property (what);
80 }
81
82 bool
get_bool_window_property(string what)83 tm_frame_rep::get_bool_window_property (string what) {
84 return as_bool (concrete_window () -> get_property (what));
85 }
86
87 int
get_int_window_property(string what)88 tm_frame_rep::get_int_window_property (string what) {
89 return as_int (concrete_window () -> get_property (what));
90 }
91
92 string
get_string_window_property(string what)93 tm_frame_rep::get_string_window_property (string what) {
94 return as_string (concrete_window () -> get_property (what));
95 }
96
97 /******************************************************************************
98 * Interface
99 ******************************************************************************/
100
101 void
menu_widget(string menu,widget & w)102 tm_frame_rep::menu_widget (string menu, widget& w) {
103 object xmenu= eval ("'" * menu);
104 w= make_menu_widget (xmenu);
105 }
106
107 void
menu_main(string menu)108 tm_frame_rep::menu_main (string menu) {
109 if (!has_current_view ()) return;
110 concrete_window () -> menu_main (menu);
111 }
112
113 void
menu_icons(int which,string menu)114 tm_frame_rep::menu_icons (int which, string menu) {
115 if ((which<0) || (which>3) || (!has_current_view())) return;
116 concrete_window () -> menu_icons (which, menu);
117 }
118
119 void
side_tools(int which,string tools)120 tm_frame_rep::side_tools (int which, string tools) {
121 if ((which<0) || (which>0)|| (!has_current_view())) return;
122 concrete_window () -> side_tools (which, tools);
123 }
124
125 void
bottom_tools(int which,string tools)126 tm_frame_rep::bottom_tools (int which, string tools) {
127 if ((which<0) || (which>0)|| (!has_current_view())) return;
128 concrete_window () -> bottom_tools (which, tools);
129 }
130
131 void
show_header(bool flag)132 tm_frame_rep::show_header (bool flag) {
133 if (!has_current_view ()) return;
134 concrete_window () -> set_header_flag (flag);
135 }
136
137 void
show_icon_bar(int which,bool flag)138 tm_frame_rep::show_icon_bar (int which, bool flag) {
139 if ((which<0) || (which>3) || (!has_current_view())) return;
140 concrete_window () -> set_icon_bar_flag (which, flag);
141 }
142
143 void
show_side_tools(int which,bool flag)144 tm_frame_rep::show_side_tools (int which, bool flag) {
145 if ((which<0) || (which>0) || (!has_current_view())) return;
146 concrete_window () -> set_side_tools_flag (which, flag);
147 }
148
149 void
show_bottom_tools(int which,bool flag)150 tm_frame_rep::show_bottom_tools (int which, bool flag) {
151 if ((which<0) || (which>0) || (!has_current_view())) return;
152 concrete_window () -> set_bottom_tools_flag (which, flag);
153 }
154
155 void
show_footer(bool flag)156 tm_frame_rep::show_footer (bool flag) {
157 if (!has_current_view ()) return;
158 concrete_window () -> set_footer_flag (flag);
159 }
160
161 bool
visible_header()162 tm_frame_rep::visible_header () {
163 return concrete_window () -> get_header_flag ();
164 }
165
166 bool
visible_icon_bar(int which)167 tm_frame_rep::visible_icon_bar (int which) {
168 if ((which<0) || (which>3)) return false;
169 return concrete_window () -> get_icon_bar_flag (which);
170 }
171
172 bool
visible_side_tools(int which)173 tm_frame_rep::visible_side_tools (int which) {
174 if ((which<0) || (which>0)) return false;
175 return concrete_window () -> get_side_tools_flag (which);
176 }
177
178 bool
visible_bottom_tools(int which)179 tm_frame_rep::visible_bottom_tools (int which) {
180 if ((which<0) || (which>0)) return false;
181 return concrete_window () -> get_bottom_tools_flag (which);
182 }
183
184 bool
visible_footer()185 tm_frame_rep::visible_footer () {
186 return concrete_window () -> get_footer_flag ();
187 }
188
189 void
set_window_zoom_factor(double zoom)190 tm_frame_rep::set_window_zoom_factor (double zoom) {
191 if (!has_current_view ()) return;
192 if (zoom >= 10.0) zoom= 10.0;
193 if (zoom <= 0.1) zoom= 0.1;
194 zoom= normal_zoom (zoom);
195 concrete_window () -> set_window_zoom_factor (zoom);
196 }
197
198 double
get_window_zoom_factor()199 tm_frame_rep::get_window_zoom_factor () {
200 return concrete_window () -> get_window_zoom_factor ();
201 }
202
203 /******************************************************************************
204 * Routines concerning the widget
205 ******************************************************************************/
206
207 void
get_visible(SI & x1,SI & y1,SI & x2,SI & y2)208 tm_frame_rep::get_visible (SI& x1, SI& y1, SI& x2, SI& y2) {
209 concrete_window () -> get_visible (x1, y1, x2, y2);
210 }
211
212 void
set_scrollbars(int sb)213 tm_frame_rep::set_scrollbars (int sb) {
214 concrete_window () -> set_scrollbars (sb);
215 }
216
217 void
scroll_where(SI & x,SI & y)218 tm_frame_rep::scroll_where (SI& x, SI& y) {
219 concrete_window () -> get_scroll_pos (x, y);
220 }
221
222 void
scroll_to(SI x,SI y)223 tm_frame_rep::scroll_to (SI x, SI y) {
224 concrete_window () -> set_scroll_pos (x, y);
225 }
226
227 void
get_extents(SI & x1,SI & y1,SI & x2,SI & y2)228 tm_frame_rep::get_extents (SI& x1, SI& y1, SI& x2, SI& y2) {
229 concrete_window () -> get_extents (x1, y1, x2, y2);
230 }
231
232 void
set_extents(SI x1,SI y1,SI x2,SI y2)233 tm_frame_rep::set_extents (SI x1, SI y1, SI x2, SI y2) {
234 concrete_window () -> set_extents (x1, y1, x2, y2);
235 }
236
237 void
set_left_footer(string s)238 tm_frame_rep::set_left_footer (string s) {
239 if (!has_current_window ()) return;
240 concrete_window () -> set_left_footer (s);
241 }
242
243 void
set_right_footer(string s)244 tm_frame_rep::set_right_footer (string s) {
245 if (!has_current_window ()) return;
246 concrete_window () -> set_right_footer (s);
247 }
248
249 void
set_message(tree left,tree right,bool temp)250 tm_frame_rep::set_message (tree left, tree right, bool temp) {
251 if (!has_current_window ()) return;
252 get_current_editor() -> set_message (left, right, temp);
253 }
254
255 void
recall_message()256 tm_frame_rep::recall_message () {
257 if (!has_current_window ()) return;
258 get_current_editor() -> recall_message ();
259 }
260
261 void
full_screen_mode(bool on,bool edit)262 tm_frame_rep::full_screen_mode (bool on, bool edit) {
263 if (on && !edit) {
264 show_header (false);
265 show_footer (false);
266 }
267 else {
268 show_header (true);
269 show_footer (true);
270 }
271 set_full_screen (concrete_window () -> win, on);
272 get_current_editor () -> full_screen_mode (on && !edit);
273 full_screen = on;
274 full_screen_edit = on && edit;
275 }
276
277 bool
in_full_screen_mode()278 tm_frame_rep::in_full_screen_mode () {
279 return full_screen && !full_screen_edit;
280 }
281
282 bool
in_full_screen_edit_mode()283 tm_frame_rep::in_full_screen_edit_mode () {
284 return full_screen && full_screen_edit;
285 }
286