Back to index

texmacs  1.0.7.15
tm_frame.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : tm_frame.cpp
00004 * DESCRIPTION: Routines for main TeXmacs frames
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "tm_frame.hpp"
00013 #include "tm_window.hpp"
00014 #include "message.hpp"
00015 
00016 /******************************************************************************
00017 * Constructor and destructor
00018 ******************************************************************************/
00019 
00020 tm_frame_rep::tm_frame_rep ():
00021   full_screen (false), full_screen_edit (false), dialogue_win () {}
00022 tm_frame_rep::~tm_frame_rep () {}
00023 
00024 /******************************************************************************
00025 * Subroutines
00026 ******************************************************************************/
00027 
00028 widget
00029 make_menu_widget (object menu) {
00030   widget w= as_widget (call ("make-menu-widget", menu, 0));
00031   //string s= "(make-menu-widget '" * menu * " 0)";
00032   //widget w= as_widget (eval (s));
00033   if (is_nil (w)) {
00034     array<widget> a (0);
00035     return horizontal_menu (a);
00036   }
00037   return w;
00038 }
00039 
00040 string
00041 icon_bar_name (int which) {
00042   if (which == 0) return "main";
00043   else if (which == 1) return "mode";
00044   else if (which == 2) return "focus";
00045   else return "user";
00046 }
00047 
00048 /******************************************************************************
00049 * Properties of the current window
00050 ******************************************************************************/
00051 
00052 int
00053 tm_frame_rep::get_window_id () {
00054   return get_window () -> serial;
00055 }
00056 
00057 void
00058 tm_frame_rep::set_window_property (scheme_tree what, scheme_tree val) {
00059   get_window () -> set_property (what, val);
00060 }
00061 
00062 void
00063 tm_frame_rep::set_bool_window_property (string what, bool val) {
00064   get_window () -> set_property (what, val? string ("true"): string ("false"));
00065 }
00066 
00067 void
00068 tm_frame_rep::set_int_window_property (string what, int val) {
00069   get_window () -> set_property (what, as_tree (val));
00070 }
00071 
00072 void
00073 tm_frame_rep::set_string_window_property (string what, string val) {
00074   get_window () -> set_property (what, val);
00075 }
00076 
00077 scheme_tree
00078 tm_frame_rep::get_window_property (scheme_tree what) {
00079   return get_window () -> get_property (what);
00080 }
00081 
00082 bool
00083 tm_frame_rep::get_bool_window_property (string what) {
00084   return as_bool (get_window () -> get_property (what));
00085 }
00086 
00087 int
00088 tm_frame_rep::get_int_window_property (string what) {
00089   return as_int (get_window () -> get_property (what));
00090 }
00091 
00092 string
00093 tm_frame_rep::get_string_window_property (string what) {
00094   return as_string (get_window () -> get_property (what));
00095 }
00096 
00097 /******************************************************************************
00098 * Interface
00099 ******************************************************************************/
00100 
00101 void
00102 tm_frame_rep::menu_widget (string menu, widget& w) {
00103   object xmenu= eval ("'" * menu);
00104   w= make_menu_widget (xmenu);
00105 }
00106 
00107 void
00108 tm_frame_rep::menu_main (string menu) {
00109   if (!has_view ()) return;
00110   get_window () -> menu_main (menu);
00111 }
00112 
00113 void
00114 tm_frame_rep::menu_icons (int which, string menu) {
00115   if ((which<0) || (which>3) || (!has_view())) return;
00116   get_window () -> menu_icons (which, menu);
00117 }
00118 
00119 void
00120 tm_frame_rep::side_tools (int which, string tools) {
00121   if ((which<0) || (which>0)|| (!has_view())) return;
00122   get_window () -> side_tools (which, tools);
00123 }
00124 
00125 void
00126 tm_frame_rep::show_header (bool flag) {
00127   if (!has_view ()) return;
00128   get_window () -> set_header_flag (flag);
00129 }
00130 
00131 void
00132 tm_frame_rep::show_icon_bar (int which, bool flag) {
00133   if ((which<0) || (which>3) || (!has_view())) return;
00134   get_window () -> set_icon_bar_flag (which, flag);
00135 }
00136 
00137 void
00138 tm_frame_rep::show_side_tools (int which, bool flag) {
00139   if ((which<0) || (which>0) || (!has_view())) return;
00140   get_window () -> set_side_tools_flag (which, flag);
00141 }
00142 
00143 void
00144 tm_frame_rep::show_footer (bool flag) {
00145   if (!has_view ()) return;
00146   get_window () -> set_footer_flag (flag);
00147 }
00148 
00149 bool
00150 tm_frame_rep::visible_header () {
00151   return get_window () -> get_header_flag ();
00152 }
00153 
00154 bool
00155 tm_frame_rep::visible_icon_bar (int which) {
00156   if ((which<0) || (which>3)) return false;
00157   return get_window () -> get_icon_bar_flag (which);
00158 }
00159 
00160 bool
00161 tm_frame_rep::visible_side_tools (int which) {
00162   if ((which<0) || (which>0)) return false;
00163   return get_window () -> get_side_tools_flag (which);
00164 }
00165 
00166 bool
00167 tm_frame_rep::visible_footer () {
00168   return get_window () -> get_footer_flag ();
00169 }
00170 
00171 void
00172 tm_frame_rep::set_shrinking_factor (int sf) {
00173   if (!has_view ()) return;
00174   get_window () -> set_shrinking_factor (sf);
00175 }
00176 
00177 int
00178 tm_frame_rep::get_shrinking_factor () {
00179   return get_window () -> get_shrinking_factor ();
00180 }
00181 
00182 /******************************************************************************
00183 * Routines concerning the widget
00184 ******************************************************************************/
00185 
00186 void
00187 tm_frame_rep::get_visible (SI& x1, SI& y1, SI& x2, SI& y2) {
00188   get_window () -> get_visible (x1, y1, x2, y2);
00189 }
00190 
00191 void
00192 tm_frame_rep::set_scrollbars (int sb) {
00193   get_window () -> set_scrollbars (sb);
00194 }
00195 
00196 void
00197 tm_frame_rep::scroll_where (SI& x, SI& y) {
00198   get_window () -> get_scroll_pos (x, y);
00199 }
00200 
00201 void
00202 tm_frame_rep::scroll_to (SI x, SI y) {
00203   get_window () -> set_scroll_pos (x, y);
00204 }
00205 
00206 void
00207 tm_frame_rep::get_extents (SI& x1, SI& y1, SI& x2, SI& y2) {
00208   get_window () -> get_extents (x1, y1, x2, y2);
00209 }
00210 
00211 void
00212 tm_frame_rep::set_extents (SI x1, SI y1, SI x2, SI y2) {
00213   get_window () -> set_extents (x1, y1, x2, y2);
00214 }
00215 
00216 void
00217 tm_frame_rep::set_left_footer (string s) {
00218   if (!has_window ()) return;
00219   get_window () -> set_left_footer (s);
00220 }
00221 
00222 void
00223 tm_frame_rep::set_right_footer (string s) {
00224   if (!has_window ()) return;
00225   get_window () -> set_right_footer (s);
00226 }
00227 
00228 void
00229 tm_frame_rep::set_message (tree left, tree right, bool temp) {
00230   if (!has_window ()) return;
00231   get_editor() -> set_message (left, right, temp);
00232 }
00233 
00234 void
00235 tm_frame_rep::recall_message () {
00236   if (!has_window ()) return;
00237   get_editor() -> recall_message ();
00238 }
00239 
00240 void
00241 tm_frame_rep::full_screen_mode (bool on, bool edit) {
00242   if (on && !edit) {
00243     show_header (false);
00244     show_footer (false);
00245   }
00246   else {
00247     show_header (true);
00248     show_footer (true);
00249   }
00250   set_full_screen (get_window () -> win, on);
00251   get_editor () -> full_screen_mode (on && !edit);
00252   full_screen = on;
00253   full_screen_edit = on && edit;
00254 }
00255 
00256 bool
00257 tm_frame_rep::in_full_screen_mode () {
00258   return full_screen && !full_screen_edit;
00259 }
00260 
00261 bool
00262 tm_frame_rep::in_full_screen_edit_mode () {
00263   return full_screen && full_screen_edit;
00264 }