]> matita.cs.unibo.it Git - helm.git/commitdiff
added decrease and increase font size fantafeature
authorEnrico Tassi <enrico.tassi@inria.fr>
Thu, 16 Jun 2005 11:55:21 +0000 (11:55 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Thu, 16 Jun 2005 11:55:21 +0000 (11:55 +0000)
helm/matita/buildTimeConf.ml.in
helm/matita/matita.conf.xml.sample
helm/matita/matita.glade
helm/matita/matita.ml
helm/matita/matitaGui.ml
helm/matita/matitaGui.mli
helm/matita/matitaMathView.ml
helm/matita/matitaMathView.mli
helm/matita/tests/record.ma

index 6b35fda1f04b843a420a2b668784aa82c88bde42..b5581fb8e1338315b7a77e78632b7923c71bfe10 100644 (file)
@@ -33,7 +33,8 @@ let base_uri = "cic:/matita";;
 let phrase_sep = ".";;
 let blank_uri = "about:blank";;
 let current_proof_uri = "about:current_proof";;
-let default_script_font = "Monospace 10";;
+let default_font_size = 10;;
+let script_font = "Monospace";;
 let runtime_base_dir = "@RT_BASE_DIR@";;
 
 let images_dir = runtime_base_dir ^ "/icons"
index d28c809d0837844cf0816313df6c57da4b6f2f6e..a425dba55afa8f733fbe9a679a655920413f8eae 100644 (file)
@@ -6,7 +6,7 @@
     <key name="baseuri">cic:/matita/</key>
     <key name="basedir">.matita/xml</key>
     <key name="owner">mario</key>
-<!--     <key name="script_font">Monospace 10</key> -->
+<!--     <key name="font_size">10</key> -->
     <key name="tactics_bar">false</key>
   </section>
   <section name="db">
index 5bb01b0f5da52e737233512773397ebe270694ff..47d8a3d1e1f693422169de66393a058af9338987 100644 (file)
@@ -881,7 +881,7 @@ Copyright (C) 2005,
                              <property name="use_underline">True</property>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image318">
+                               <widget class="GtkImage" id="image334">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-new</property>
                                  <property name="icon_size">1</property>
@@ -902,7 +902,7 @@ Copyright (C) 2005,
                              <accelerator key="o" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image319">
+                               <widget class="GtkImage" id="image335">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-open</property>
                                  <property name="icon_size">1</property>
@@ -923,7 +923,7 @@ Copyright (C) 2005,
                              <accelerator key="s" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image320">
+                               <widget class="GtkImage" id="image336">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-save</property>
                                  <property name="icon_size">1</property>
@@ -943,7 +943,7 @@ Copyright (C) 2005,
                              <property name="use_underline">True</property>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image321">
+                               <widget class="GtkImage" id="image337">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-save-as</property>
                                  <property name="icon_size">1</property>
@@ -970,7 +970,7 @@ Copyright (C) 2005,
                              <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image322">
+                               <widget class="GtkImage" id="image338">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-quit</property>
                                  <property name="icon_size">1</property>
@@ -1005,22 +1005,22 @@ Copyright (C) 2005,
                        <widget class="GtkMenu" id="viewMenu_menu">
 
                          <child>
-                           <widget class="GtkMenuItem" id="newCicBrowserMenuItem">
+                           <widget class="GtkCheckMenuItem" id="tacticsBarMenuItem">
                              <property name="visible">True</property>
-                             <property name="label" translatable="yes">New Cic Browser</property>
+                             <property name="tooltip" translatable="yes">Show/Hide the tactics buttons bar</property>
+                             <property name="label" translatable="yes">View Tactics Bar</property>
                              <property name="use_underline">True</property>
-                             <accelerator key="F3" modifiers="0" signal="activate"/>
+                             <property name="active">True</property>
+                             <accelerator key="F2" modifiers="0" signal="activate"/>
                            </widget>
                          </child>
 
                          <child>
-                           <widget class="GtkCheckMenuItem" id="tacticsBarMenuItem">
+                           <widget class="GtkMenuItem" id="newCicBrowserMenuItem">
                              <property name="visible">True</property>
-                             <property name="tooltip" translatable="yes">Show/Hide the tactics buttons bar</property>
-                             <property name="label" translatable="yes">View Tactics Bar</property>
+                             <property name="label" translatable="yes">New Cic Browser</property>
                              <property name="use_underline">True</property>
-                             <property name="active">True</property>
-                             <accelerator key="F2" modifiers="0" signal="activate"/>
+                             <accelerator key="F3" modifiers="0" signal="activate"/>
                            </widget>
                          </child>
 
@@ -1033,6 +1033,41 @@ Copyright (C) 2005,
                              <accelerator key="F11" modifiers="0" signal="activate"/>
                            </widget>
                          </child>
+
+                         <child>
+                           <widget class="GtkSeparatorMenuItem" id="separator1">
+                             <property name="visible">True</property>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkMenuItem" id="increaseFontSizeMenuItem">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Increase Font Size</property>
+                             <property name="use_underline">True</property>
+                             <signal name="activate" handler="on_increaseFontSizeMenuItem_activate" last_modification_time="Wed, 15 Jun 2005 15:06:29 GMT"/>
+                             <accelerator key="plus" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkMenuItem" id="decreaseFontSizeMenuItem">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Decrease Font Size</property>
+                             <property name="use_underline">True</property>
+                             <signal name="activate" handler="on_decreaseFontSizeMenuItem_activate" last_modification_time="Wed, 15 Jun 2005 15:06:29 GMT"/>
+                             <accelerator key="minus" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkMenuItem" id="normalFontSizeMenuItem">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Normal Font Size</property>
+                             <property name="use_underline">True</property>
+                             <accelerator key="equal" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                           </widget>
+                         </child>
                        </widget>
                      </child>
                    </widget>
index 5433a898b417513c4354286af73ad7b5c26354b2..6c3459c4adfa8a65de0cb1c87b5838abbd7c26fe 100644 (file)
@@ -52,6 +52,19 @@ let gui = MatitaGui.instance ()
 let _ =
   ignore (gui#main#newCicBrowserMenuItem#connect#activate (fun _ ->
     ignore (MatitaMathView.cicBrowser ())));
+  (* font sizes *)
+  ignore (gui#main#increaseFontSizeMenuItem#connect#activate (fun _ ->
+    gui#increaseFontSize ();
+    MatitaMathView.increase_font_size ();
+    MatitaMathView.update_font_sizes ()));
+  ignore (gui#main#decreaseFontSizeMenuItem#connect#activate (fun _ ->
+    gui#decreaseFontSize ();
+    MatitaMathView.decrease_font_size ();
+    MatitaMathView.update_font_sizes ()));
+  ignore (gui#main#normalFontSizeMenuItem#connect#activate (fun _ ->
+    gui#resetFontSize ();
+    MatitaMathView.reset_font_size ();
+    MatitaMathView.update_font_sizes ()));
   (* disambiguator callback *)
   MatitaDisambiguator.set_choose_uris_callback
     (MatitaGui.interactive_uri_choice ());
index 66cc8b0ffc9ab06aec984c4e205e0ccf720da4ea..cdbfc799a054f28e1743e1e941507e240949d22e 100644 (file)
@@ -77,11 +77,16 @@ class gui () =
       ~packing:main#scriptScrolledWin#add
       ()
   in
+  let default_font_size =
+    Helm_registry.get_opt_default Helm_registry.int
+      ~default:BuildTimeConf.default_font_size "matita.font_size"
+  in
   let source_buffer = source_view#source_buffer in
   object (self)
     val mutable chosen_file = None
     val mutable _ok_not_exists = false
-    val mutable script_fname = None 
+    val mutable script_fname = None
+    val mutable font_size = default_font_size
    
     initializer
         (* glade's check widgets *)
@@ -267,19 +272,7 @@ class gui () =
             "\n";
           advance ());
          (* script monospace font stuff *)  
-      let font =
-        Helm_registry.get_opt_default Helm_registry.string
-          ~default:BuildTimeConf.default_script_font "matita.script_font"
-      in
-(*       let monospace_tag = 
-        source_buffer#create_tag [`FONT_DESC font] 
-      in *)
-      self#sourceView#misc#modify_font_by_name font;
-(*       let _ = 
-        source_buffer#connect#changed ~callback:(fun _ ->
-          let start, stop = source_buffer#bounds in
-          source_buffer#apply_tag monospace_tag start stop)
-      in *)
+      self#updateFontSize ();
         (* debug menu *)
       self#main#debugMenu#misc#hide ();
         (* status bar *)
@@ -381,6 +374,22 @@ class gui () =
       GtkThread.main ();
       !text
 
+    method private updateFontSize () =
+      self#sourceView#misc#modify_font_by_name
+        (sprintf "%s %d" BuildTimeConf.script_font font_size)
+
+    method increaseFontSize () =
+      font_size <- font_size + 1;
+      self#updateFontSize ()
+
+    method decreaseFontSize () =
+      font_size <- font_size - 1;
+      self#updateFontSize ()
+
+    method resetFontSize () =
+      font_size <- default_font_size;
+      self#updateFontSize ()
+
   end
 
 let gui () = 
index 42922140c090de3a7f73ca3b00bd3adf2ffcc719..80c183fac4e78e0032768c43a143b1b30b34f9b3 100644 (file)
@@ -77,6 +77,11 @@ object
   method askText: ?title:string -> ?msg:string -> unit -> string option
 
   method loadScript: string -> unit
+
+    (** {3 Fonts} *)
+  method increaseFontSize: unit -> unit
+  method decreaseFontSize: unit -> unit
+  method resetFontSize: unit -> unit
                                                             
 end
 
index 75541ed9d49f93df76d54668e5c6e8502457410f..9c8ef985b3657261512f356384ac8d67276befda 100644 (file)
@@ -56,6 +56,16 @@ object (self)
   method private script = MatitaScript.instance ()
 end
 
+let cicBrowsers = ref []
+
+let default_font_size () =
+  Helm_registry.get_opt_default Helm_registry.int
+    ~default:BuildTimeConf.default_font_size "matita.font_size"
+let current_font_size = ref ~-1
+let increase_font_size () = incr current_font_size
+let decrease_font_size () = decr current_font_size
+let reset_font_size () = current_font_size := default_font_size ()
+
 class clickableMathView obj =
   let href = Gdome.domString "href" in
   let xref = Gdome.domString "xref" in
@@ -66,6 +76,8 @@ class clickableMathView obj =
     method set_href_callback f = href_callback <- f
 
     initializer
+      current_font_size := default_font_size ();
+      self#set_font_size !current_font_size;
       ignore (self#connect#selection_changed self#choose_selection);
       ignore (self#connect#click (fun (gdome_elt, _, _, _) ->
         match gdome_elt with
@@ -95,6 +107,10 @@ class clickableMathView obj =
       match gdome_elt with
       | Some elt -> aux elt
       | None   -> self#set_selection None
+
+    method update_font_size = 
+      self#set_font_size !current_font_size
+      
   end
 
 let clickableMathView ?hadjustment ?vadjustment ?font_size ?log_verbosity =
@@ -111,7 +127,7 @@ class sequentViewer obj =
     inherit clickableMathView obj
 
     val mutable current_infos = None
-
+    
     method get_selected_terms =
       let selections = self#get_selections in
       list_map_fail
@@ -287,8 +303,6 @@ type term_source =
 
 exception Browser_failure of string
 
-let cicBrowsers = ref []
-
 class type cicBrowser =
 object
   method load: MatitaTypes.mathViewer_entry -> unit
@@ -581,6 +595,10 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
         self#_historyAdd entry
       end
 
+      (** {2 methods accessing underlying GtkMathView} *)
+
+    method updateFontSize = mathView#set_font_size !current_font_size
+
       (** {2 methods used by constructor only} *)
 
     method win = win
@@ -620,8 +638,6 @@ let cicBrowser () =
   let history = new MatitaMisc.browser_history size (`About `Blank) in
   aux history
 
-let refresh_all_browsers () = List.iter (fun b -> b#refresh ()) !cicBrowsers
-
 let default_sequentViewer () = sequentViewer ~show:true ()
 let sequentViewer_instance = MatitaMisc.singleton default_sequentViewer
 
@@ -646,3 +662,10 @@ let mathViewer () =
     method show_uri_list ?(reuse=false) ~entry l =
       (self#get_browser reuse)#load entry
   end
+
+let refresh_all_browsers () = List.iter (fun b -> b#refresh ()) !cicBrowsers
+
+let update_font_sizes () =
+  List.iter (fun b -> b#updateFontSize) !cicBrowsers;
+  (sequentViewer_instance ())#update_font_size
+
index b11befe4eb9f6ea89bcadf58590188ac566b1103..ed57b886c44c7af09a476918b81cde2b50f599b3 100644 (file)
@@ -32,6 +32,8 @@ class type clickableMathView =
 
       (** set hyperlink callback. None disable hyperlink handling *)
     method set_href_callback: (string -> unit) option -> unit
+    
+    method update_font_size: unit
   end
 
 class type sequentViewer =
@@ -93,7 +95,14 @@ val sequentsViewer:
 
 val cicBrowser: unit -> cicBrowser
 
-val refresh_all_browsers: unit -> unit
+(** mathview wide functions *)
+
+val increase_font_size: unit -> unit
+val decrease_font_size: unit -> unit
+val reset_font_size: unit -> unit
+
+val refresh_all_browsers: unit -> unit  (** act on all cicBrowsers *)
+val update_font_sizes: unit -> unit
 
 (** {2 singleton instances} *)
 
index 43e8e5d441c092bb416b3ef0cd73e7a9f47f4e9e..61dec1d7e34671c1ca7a1d890b10f789ab43bec0 100644 (file)
@@ -1,5 +1,7 @@
 record empty : Type \def {}.
 
+inductive True : Prop \def I: True.
+
 record pippo : Type \def 
 {
 a: Set ;