Class: TkFrameAdapter
- Inherits:
-
TkFrame
- Object
- TkFrame
- TkFrameAdapter
- Defined in:
- lib/a-tkcommons.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#frame ⇒ Object
readonly
include TkMovable.
Instance Method Summary collapse
- #attach_frame(_frame) ⇒ Object
-
#detach_frame ⇒ Object
def add_moved_by(_obj) @movable = true start_moving(_obj, self) end.
-
#initialize(scope_parent = nil, args = nil) ⇒ TkFrameAdapter
constructor
A new instance of TkFrameAdapter.
- #is_pack? ⇒ Boolean
- #is_place? ⇒ Boolean
- #is_undefined? ⇒ Boolean
- #map(_layout_manager = nil) ⇒ Object
- #refresh_layout_manager ⇒ Object
- #unmap(_layout_manager = nil) ⇒ Object
Constructor Details
#initialize(scope_parent = nil, args = nil) ⇒ TkFrameAdapter
Returns a new instance of TkFrameAdapter.
267 268 269 270 271 272 273 274 275 |
# File 'lib/a-tkcommons.rb', line 267 def initialize(scope_parent=nil, args=nil) newargs = Arcadia.style('panel') if !args.nil? newargs.update(args) end super(scope_parent, newargs) @scope_parent = scope_parent #@movable = false end |
Instance Attribute Details
#frame ⇒ Object (readonly)
include TkMovable
266 267 268 |
# File 'lib/a-tkcommons.rb', line 266 def frame @frame end |
Instance Method Details
#attach_frame(_frame) ⇒ Object
295 296 297 298 299 300 301 |
# File 'lib/a-tkcommons.rb', line 295 def attach_frame(_frame) @frame = _frame refresh_layout_manager self.map self.bind("Map", proc{@frame.raise}) self end |
#detach_frame ⇒ Object
def add_moved_by(_obj)
@movable = true
start_moving(_obj, self)
end
282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/a-tkcommons.rb', line 282 def detach_frame if @frame # if @movable # @frame.bind_remove("Configure") # @frame.bind_remove("Map") # @frame.bind_remove("Unmap") # end self.bind_remove("Map") self.unmap(@manager_forced_to_frame) @frame = nil end end |
#is_pack? ⇒ Boolean
315 316 317 |
# File 'lib/a-tkcommons.rb', line 315 def is_pack? @frame_manager == 'pack' end |
#is_place? ⇒ Boolean
311 312 313 |
# File 'lib/a-tkcommons.rb', line 311 def is_place? @frame_manager == 'place' || is_undefined? end |
#is_undefined? ⇒ Boolean
307 308 309 |
# File 'lib/a-tkcommons.rb', line 307 def is_undefined? @frame_manager.nil? || @frame_manager == '' end |
#map(_layout_manager = nil) ⇒ Object
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/a-tkcommons.rb', line 319 def map(_layout_manager=nil) if _layout_manager == "place" || (_layout_manager.nil? && is_place?) if is_undefined? && _layout_manager @frame.place('x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=>1, 'bordermode'=>'outside') @manager_forced_to_frame = "place" end place('in'=>@frame, 'x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=>1, 'bordermode'=>'outside') elsif _layout_manager == "pack" || (_layout_manager.nil? && is_pack?) if is_undefined? && _layout_manager @frame.pack('fill'=>'both', :padx=>0, :pady=>0, 'expand'=>'yes') @manager_forced_to_frame = "pack" end pack('in'=>@frame, 'fill'=>'both', :padx=>0, :pady=>0, 'expand'=>'yes') end end |
#refresh_layout_manager ⇒ Object
303 304 305 |
# File 'lib/a-tkcommons.rb', line 303 def refresh_layout_manager @frame_manager = TkWinfo.manager(@frame) end |
#unmap(_layout_manager = nil) ⇒ Object
335 336 337 338 339 340 341 342 343 |
# File 'lib/a-tkcommons.rb', line 335 def unmap(_layout_manager=nil) if _layout_manager == "place" || (_layout_manager.nil? && is_place?) self.unplace @frame.unplace if @frame && @manager_forced_to_frame == "place" elsif _layout_manager == "pack" || (_layout_manager.nil? && is_pack?) self.unpack @frame.unpack if @frame && @manager_forced_to_frame == "pack" end end |