Class: AGTk

Inherits:
AG
  • Object
show all
Defined in:
ext/ae-rad/lib/tk/al-tk.rb

Direct Known Subclasses

AGTkLayoutManaged

Instance Attribute Summary collapse

Attributes inherited from AG

#ag_parent, #i_ag, #i_name, #obj, #obj_class, #persistent, #props, #props_def, #props_kinds, #renderer, #sniffer, #sons

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AG

active, #add_require, #build_sons, #defaults, #defaults_values, #del_require, #fill_defaults_value_from_agobj, #getControlClassName, #getInstanceClass, #getObjClass, #getViewClassName, #get_implementation_block, #get_implementation_code, #get_implementation_new, #get_path_i_name, #has_sons, near_class_wrapped, near_class_wrapper, #new_id, #passed_object, #publish, #publish_def, #publish_del, #publish_mod, publish_property, #register, #retrive_values, #select, #start_properties

Constructor Details

#initialize(_ag_parent = nil, _object = nil) ⇒ AGTk

Returns a new instance of AGTk.


905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 905

def initialize(_ag_parent = nil, _object = nil)
  #Tk.update if _object != nil && _ag_parent == nil
  super(_ag_parent, _object)
  if (defined? @obj)
    if @ag_parent != nil
      ppress = proc{
        @l_manager.deactivate_last
      }
      prelease = proc{
        @l_manager.activate
      }
      @obj.bind_append("ButtonPress-1", ppress)
      @obj.bind_append("ButtonRelease-1", prelease)
      @parent = TkWinfo.parent(@obj)
    end
    @l_manager = AGTkLManager.new(self, _object == nil)
  end
  popup
  build_sons if _object != nil
end

Instance Attribute Details

#canvasObject (readonly)

Returns the value of attribute canvas


902
903
904
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 902

def canvas
  @canvas
end

#l_managerObject (readonly)

Returns the value of attribute l_manager


902
903
904
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 902

def l_manager
  @l_manager
end

#x0Object

Returns the value of attribute x0


902
903
904
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 902

def x0
  @x0
end

#x3Object

Returns the value of attribute x3


902
903
904
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 902

def x3
  @x3
end

#y0Object

Returns the value of attribute y0


902
903
904
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 902

def y0
  @y0
end

#y3Object

Returns the value of attribute y3


902
903
904
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 902

def y3
  @y3
end

Class Method Details

.class_rendererObject


1023
1024
1025
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1023

def AGTk.class_renderer
  AGTkRenderer
end

.class_snifferObject


1027
1028
1029
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1027

def AGTk.class_sniffer
  AGTkSniffer
end

.class_wrappedObject


1019
1020
1021
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1019

def AGTk.class_wrapped
  nil
end

Instance Method Details

#activateObject

def updatep(_family, prop, value, _call_from_inspector=false)

  if _call_from_inspector && ['place','pack','grid','layout_man'].include?(_family)
    @l_manager.deactivate
  end
  super(_family, prop,value, _call_from_inspector)
  if _call_from_inspector && _family == 'place'
    @l_manager.place_manager.initx0x3
  end
  if _call_from_inspector && ['place','pack','grid','layout_man'].include?(_family)
    @l_manager.activate
  end
  Tk.update
end

1070
1071
1072
1073
1074
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1070

def activate
  super
  @l_manager.activate if defined? @l_manager
  self
end

#active_move_tabObject


982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 982

def active_move_tab
  @obj.bind("Enter",
    proc{@canvas_of_move = TkCanvas.new(@obj)
      _lx = 30
      _ly = 43
      _x = (@x3 - @x0)/2 - _lx/2
      _y = (@y3 - @y0)/2 - _ly/2
      TkcImage.new(@canvas_of_move, _lx/2, _ly/2){
        image  TkAllPhotoImage.new('file' => 'skull.bmp')
      }
      @canvas_of_move.configure('cursor'=>'draft_small')
      @canvas_of_move.place('x' => _x ,
        'y' => _y,
        'width' => _lx,
        'height' => _ly
      )
      @canvas_of_move.bind("1", proc{|e| do_press(e.x, e.y)})
      @canvas_of_move.bind("B1-Motion", proc{|x, y| do_movobj(x,y)},"%x %y")
      @canvas_of_move.bind_append("ButtonPress-1", proc{@l_manager.deactivate_last})
      @canvas_of_move.bind_append("ButtonPress-1", proc{|e| do_press(e.x, e.y)})
      @canvas_of_move.bind("ButtonRelease-1", proc{ @l_manager.activate })
    }
  )
  @obj.bind("Leave", proc{@canvas_of_move.destroy})
  @obj.bind("Motion", proc{|x, y| @canvas_of_move.place('x' =>x - 5, 'y' => y - 5)},"%x %y")
end

#contains_eventsObject


1035
1036
1037
1038
1039
1040
1041
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1035

def contains_events
  result =  has_events
  self.sons.each{|son|
    result = result || son.contains_events
  }
  return result
end

#deleteObject

def retrive_values

  @props['layout_man']['manager']['value'] = @props['layout_man']['manager']['get'].call
end

1047
1048
1049
1050
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1047

def delete
  @l_manager.deactivate if defined? @l_manager
  super()
end

#getFileNameObject


1052
1053
1054
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1052

def getFileName
  __FILE__
end

#has_eventsObject


1031
1032
1033
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1031

def has_events
  result =  defined?(@persistent) && @persistent['events'] != nil
end

#new_objectObject


1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1009

def new_object
  if self.class.class_wrapped
    if @ag_parent
      @obj = self.class.class_wrapped.new(@ag_parent.obj)
    else
      @obj = self.class.class_wrapped.new
    end
  end
end

959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 959

def popup
  if @obj
    _parent = nil
    if @ag_parent != nil
      _parent = @ag_parent.obj
    end
    @obj.bind("Button-3", proc{|x,y|
      popup_menu = TkMenu.new(
      :parent=>_parent,
      :tearoff=>0,
      :relief=>'groove',
      :title => @obj.class.to_s
      )
      popup_items(popup_menu)
      _x = TkWinfo.pointerx(@obj)
      _y = TkWinfo.pointery(@obj)
      popup_menu.popup(_x,_y)
      @obj.callback_break
    },
    "%x %y")
  end
end

943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 943

def popup_items(_popup_menu)
  _popup_menu.insert('end',
    :command,
    :label=>self.class.class_wrapped.to_s,
    :background => 'white',
    :hidemargin => false
  )

  _popup_menu.insert('end',
    :command,
    :label=>'Delete',
    :hidemargin => false,
    :command=> proc{self.delete}
  )
end

#propertiesObject


926
927
928
929
930
931
932
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 926

def properties
  super
  publish('winfo','name'=>'path','get'=> proc{@obj.path}, 'def'=> 'nodef')
  publish('winfo','name'=>'id','get'=> proc{TkWinfo.id(@obj)}, 'def'=> 'nodef')
  publish('winfo','name'=>'parent','get'=> proc{TkWinfo.parent(@obj)}, 'def'=> 'nodef')

end

#update_property(_sender, _family, _name, _value) ⇒ Object


934
935
936
937
938
939
940
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 934

def update_property(_sender, _family,_name,_value)
  super
  if _sender != self && ['x','y','width','height','text'].include?(_name)
    @l_manager.refresh
  end

end