]> matita.cs.unibo.it Git - helm.git/commitdiff
* fixed bug of multiple selections
authorLuca Padovani <luca.padovani@unito.it>
Fri, 30 Jul 2004 08:56:16 +0000 (08:56 +0000)
committerLuca Padovani <luca.padovani@unito.it>
Fri, 30 Jul 2004 08:56:16 +0000 (08:56 +0000)
* minor code cleanup

helm/DEVEL/lablgtkmathview/gMathView.mli
helm/DEVEL/lablgtkmathview/gMathViewAux.ml
helm/DEVEL/lablgtkmathview/gtkMathView.props
helm/DEVEL/lablgtkmathview/test/test.ml

index 9ec204d51ac07ac5fcd6f804d1ccdeb0b6ce3995..bf5b56e2a8a42fe61bc05af3d178f970d4ac5b1c 100644 (file)
@@ -32,15 +32,15 @@ class math_view_signals :
     val after: bool
     val obj: 'b Gtk.obj
     method click :
-      callback:(Gdome.element option -> int -> unit) -> GtkSignal.id
+      callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id
     method element_over :
-      callback:(Gdome.element option -> int -> unit) -> GtkSignal.id
+      callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id
     method select_begin :
-      callback:(Gdome.element option -> int -> unit) -> GtkSignal.id
+      callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id
     method select_over :
-      callback:(Gdome.element option -> int -> unit) -> GtkSignal.id
+      callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id
     method select_end :
-      callback:(Gdome.element option -> int -> unit) -> GtkSignal.id
+      callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id
     method select_abort :
       callback:(unit -> unit) -> GtkSignal.id
   end
index 01465cb0a98ff686f1dae036cf468f3961da999c..8dfb919ba9d26c66494494ba9b5af0be68af5238 100644 (file)
@@ -156,13 +156,13 @@ class single_selection_math_view obj =
 
     ignore
      (self#connect#select_begin
-       (fun (elem : Gdome.element option) _ ->
+       (fun ((elem : Gdome.element option), _, _, _) ->
          if not (same_element root_selected elem) then selection_changed elem ;
          first_selected <- elem)) ;
 
     ignore
      (self#connect#select_over
-       (fun (elem : Gdome.element option) _ ->
+       (fun ((elem : Gdome.element option), _, _, _) ->
          let new_selected =
           match first_selected, elem with
              Some first', Some last' ->
@@ -176,7 +176,7 @@ class single_selection_math_view obj =
              
     ignore
      (self#connect#select_end
-       (fun (elem : Gdome.element option) _ -> first_selected <- None)) ;
+       (fun ((elem : Gdome.element option), _, _, _) -> first_selected <- None)) ;
 
     ignore
      (self#connect#select_abort
@@ -184,7 +184,7 @@ class single_selection_math_view obj =
          first_selected <- None ;
          selection_changed None)) ;
 
-    ignore (self#connect#click (fun _ -> self#set_selection None))
+    ignore (self#connect#click (fun _ -> self#set_selection None))
   end
 ;;
 
@@ -226,8 +226,9 @@ class multi_selection_math_view obj =
     self#thaw
 
    method add_selection (elem : Gdome.element) =
+    List.iter self#unselect selected ;
     selected <- elem::(remove_descendants_of elem selected) ;
-    self#select elem
+    List.iter self#select selected
 
    method get_selections = selected
 
@@ -249,13 +250,13 @@ class multi_selection_math_view obj =
    initializer
     ignore
      (self#connect#select_begin
-       (fun _ state ->
+       (fun (_,_,_,state) ->
          if not (List.mem `CONTROL (Gdk.Convert.modifier state)) then
           self#remove_selections)) ;
 
     ignore
      (self#connect#select_over
-       (fun _ state ->
+       (fun (_,_,_,state) ->
          let c = 
           function
              `SHIFT -> "shift "
@@ -270,7 +271,7 @@ class multi_selection_math_view obj =
 
     ignore
      (self#connect#select_end
-       (fun _ state ->
+       (fun (_,_,_,state) ->
          if not (List.mem `CONTROL (Gdk.Convert.modifier state)) then
           self#remove_selections ;
          match root_selected with
@@ -279,7 +280,7 @@ class multi_selection_math_view obj =
 
     ignore
      (self#connect#click
-       (fun _ -> self#remove_selections))
+       (fun _ -> self#remove_selections))
    end
  ;;
 
index cd4c5b190e593b7d087dc93512c8df567a3b5d64..d26050ce4872c02a495fdb73bd0bcaac06800db1 100644 (file)
@@ -16,9 +16,9 @@ external gdome_element_option_of_boxed_option :
   "ml_gtk_math_view_gdome_element_option_of_boxed_option"
 ;;
 
-external model_event_of_boxed_option model_event :
- Gpointer.boxed -> TElement.t option * gint * gint * gint =
-  "ml_gtk_math_view_model_event_of_boxed"
+external model_event_of_boxed_option :
+ Gpointer.boxed option -> TElement.t option * int * int * int =
+  "ml_gtk_math_view_model_event_of_boxed_option"
 
 let option_element_of_option =
  function
@@ -32,7 +32,7 @@ let option_element_of_boxed_option x =
 
 let model_event_of_boxed model_event =
  let id,x,y,state = model_event_of_boxed_option model_event in
-  option_element_of_boxed_option id,x,y,state
+  option_element_of_option id,x,y,state
 ;;
 
 let gdome_element_option_conv =
index 3561c551c3be3a4512f926efc83840d95eff8ed2..6a54c3463dac5a085865682cd31985a205eb1adb 100644 (file)
@@ -88,7 +88,7 @@ let selection_changed mathview (element : Gdome.element option) =
  flush stdout
 ;;
 
-let element_over mathview (element : Gdome.element option) _ =
+let element_over mathview ((element : Gdome.element option), _, _, _) =
  print_endline ("element_over: " ^
   (match element with
       None -> "element_over on nothing"
@@ -150,7 +150,7 @@ let rec action mathview (element : Gdome.element) =
        end
      | None -> assert false (* every element has a parent *)
 
-let click mathview (element : Gdome.element option) _ =
+let click mathview ((element : Gdome.element option), _, _, _) =
  let module G = Gdome in
   match element with
      None -> print_string "CLICKED ON NOTHING\n" ; flush stdout
@@ -177,7 +177,7 @@ let test_get_selection mathview () =
  let selection =
    match mathview#get_selection with
       Some element -> element#get_tagName#to_string
-    | None -> "no selection!"
+    | None -> "no selection! but there are " ^ (string_of_int (List.length mathview#get_selections)) ^ " multiple selections!"
  in
   print_string ("selection: " ^ selection ^ "\n") ;
   flush stdout