Class: AGTkVSplittedFrames

Inherits:
AGTkSplittedFrames show all
Defined in:
lib/a-tkcommons.rb

Instance Attribute Summary collapse

Attributes inherited from AGTkSplittedFrames

#frame1, #frame2

Attributes inherited from TkFrameAdapter

#frame

Instance Method Summary collapse

Methods inherited from TkFrameAdapter

#add_moved_by, #attach_frame, #detach_frame, #refresh

Methods included from TkMovable

#moving_do_move_obj, #moving_do_press, #start_moving, #stop_moving

Constructor Details

#initialize(parent = nil, frame = nil, width = 10, slen = 5, perc = false, keys = nil) {|_self| ... } ⇒ AGTkVSplittedFrames

Returns a new instance of AGTkVSplittedFrames.

Yields:

  • (_self)

Yield Parameters:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/a-tkcommons.rb', line 276

def initialize(parent=nil, frame=nil, width=10, slen=5, perc=false, keys=nil)
  super(parent, frame, width, slen, keys)
  #self.place('relheight'=>1, 'relwidth'=>1, 'bordermode'=>'outside' )    
  #self.pack(:expand=>true, :fill=>:both)
  @left_frame = TkFrame.new(self, Arcadia.style('panel')){
    #relief 'flat'
  }
  @frame1 = @left_frame
  if perc
    p_width = TkWinfo.screenwidth(self)
  		x = (p_width/100*width).to_i
  else
    x = width  
  end
  
  @left_frame.place(
    'relx' => 0,
    'x' => 0,
    'y' => '0',
    'relheight' => '1',
    'rely' => 0,
    'bordermode' => 'inside',
    'width' => x
  )
  @left_frame_obj = AGTkObjPlace.new(@left_frame, 'x', nil, false)
  @left_frame_obj.width = x
  @left_frame_obj.height = 0
  @left_frame_obj.relwidth = 0
  @left_frame_obj.relheight = 1

  @splitter_frame = TkFrame.new(self, Arcadia.style('splitter')){
    #relief  'raised'
    #border 1
  }

  @splitter_frame.place(
    'relx' => 0,
    'x' => x,
    'y' => '0',
    'relheight' => '1',
    'rely' => 0,
    'bordermode' => 'inside',
    'width' => @slen
  )
  @splitter_frame.bind_append(
    "ButtonRelease-1",
    proc{do_resize}
  )
  _self = self
  @b_left = TkButton.new(nil, Arcadia.style('button')){
    image TkPhotoImage.new('dat'=>LEFT_SIDE_GIF)
  }

  @b_right = TkButton.new(nil, Arcadia.style('button')){
    image TkPhotoImage.new('dat'=>RIGHT_SIDE_GIF)
  }
  @proc_unplace = proc{
    @b_left.unplace
    @b_right.unplace
  }
  @splitter_frame.bind_append(
    "B1-Motion",
    proc{@splitter_frame.raise;@proc_unplace.call}
  )
  @@last_b_left = nil
  @@last_b_right = nil
  @b_left.bind_append('ButtonPress-1',proc{_self.hide_left;@proc_unplace.call})
  @b_right.bind_append('ButtonPress-1',proc{_self.hide_right;@proc_unplace.call})
  @proc_place = proc{|x,y|
    if !TkWinfo.mapped?(@b_left)
      _x = TkWinfo.pointerx(self) - 10
      _y = TkWinfo.pointery(self) - 20
      if @@last_b_left != nil
        @@last_b_left.unplace
        @@last_b_right.unplace
      end
      @b_left.place('x'=>_x,'y'=>_y,'border'=>'outside')
      @b_right.place('x'=>_x,'y'=>_y+25,'border'=>'outside')
      @b_left.raise
      @b_right.raise
      @@last_b_left = @b_left
      @@last_b_right = @b_right
      if @thread_unplace
        @thread_unplace.kill
      end
      @thread_unplace= Thread.new {
        sleep(5)
        @proc_unplace.call
        kill
      }
    end
  }

  @splitter_frame.bind_append(
  'ButtonPress-1',
  proc{|x,y|
    @thread_place= Thread.new {
      @proc_place.call(x,y)
    }
  }, "%x %y")

#    @splitter_frame.bind_append(
#    "Enter",
#    proc{
#      @color_save = @splitter_frame.background
#      @splitter_frame.background(Arcadia.conf('splitter.highlightbackground'))}
#      #@splitter_frame.background('#9aa6a7')}
#    )
#    @splitter_frame.bind_append(
#      "Leave",
#      proc{
#        @splitter_frame.background(@color_save)
#      }
#    )
  @splitter_frame_obj = AGTkObjPlace.new(@splitter_frame, 'x')
  @splitter_frame_obj.width = @slen
  @splitter_frame_obj.height = 0
  @splitter_frame_obj.relwidth = 0
  @splitter_frame_obj.relheight = 1
  x = x + @slen
  @right_frame = TkFrame.new(self, Arcadia.style('panel')){
    #relief 'flat'
  }
  @frame2 = @right_frame
  @right_frame.place(
    'relwidth' => 1,
    'relx' => 0,
    'x' => x,
    'y' => 0,
    'width' => -x,
    'relheight' => 1,
    'rely' => 0,
    'bordermode' => 'inside'
  )
  @right_frame_obj = AGTkObjPlace.new(@right_frame, 'x', nil, false)
  @right_frame_obj.width = -x
  @right_frame_obj.height = 0
  @right_frame_obj.relwidth = 1
  @right_frame_obj.relheight = 1
  @state = 'middle'
  yield(self) if block_given?
end

Instance Attribute Details

#left_frameObject (readonly)

Returns the value of attribute left_frame.



275
276
277
# File 'lib/a-tkcommons.rb', line 275

def left_frame
  @left_frame
end

#right_frameObject (readonly)

Returns the value of attribute right_frame.



275
276
277
# File 'lib/a-tkcommons.rb', line 275

def right_frame
  @right_frame
end

#splitter_frameObject (readonly)

Returns the value of attribute splitter_frame.



275
276
277
# File 'lib/a-tkcommons.rb', line 275

def splitter_frame
  @splitter_frame
end

Instance Method Details

#do_resizeObject



427
428
429
430
431
432
433
434
# File 'lib/a-tkcommons.rb', line 427

def do_resize
  _x = @splitter_frame_obj.x0
  _w = @splitter_frame_obj.w
  @left_frame_obj.width = _x
  @left_frame_obj.go(_x,0)
  @right_frame_obj.width = - _x - _w
  @right_frame_obj.amove(_x + _w,0)
end

#get_main_xObject



419
420
421
422
423
424
425
# File 'lib/a-tkcommons.rb', line 419

def get_main_x
  if TkWinfo.manager(@parent)=='place'
    return TkPlace.info(@parent)['x'] / 2
  else
    return 20
  end
end

#hide(_name) ⇒ Object



497
498
# File 'lib/a-tkcommons.rb', line 497

def hide(_name)
end

#hide_leftObject



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/a-tkcommons.rb', line 436

def hide_left
  if (@state=='left')
    _w = @last
    @state = 'middle'
    @left_frame_obj.width = _w
    @left_frame_obj.go(_w,0)
  else
    _w = 0
    @state = 'right'
    @last = @left_frame_obj.w
  end
  @left_frame_obj.amove(0,0)
  @left_frame_obj.obj.place_forget if @state=='right'
  @splitter_frame_obj.amove(_w,0)
  @right_frame_obj.width = - _w - @slen
  @right_frame_obj.amove(_w + @slen,0)
end

#hide_rightObject



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/a-tkcommons.rb', line 458

def hide_right
  if (@state=='right')
    _w = @last
    @state = 'middle'
  else
    _w = @right_frame_obj.w + @left_frame_obj.w #+ @slen
    @state = 'left'
    @last = @left_frame_obj.w
  end
  @right_frame_obj.width = - _w - @slen
  @right_frame_obj.amove(_w + @slen,0)
  @right_frame_obj.obj.unplace if @state=='left'
  @splitter_frame_obj.amove(_w,0)
  @left_frame_obj.width = _w
  @left_frame_obj.go(_w,0)
end

#is_left_hide?Boolean

Returns:

  • (Boolean)


454
455
456
# File 'lib/a-tkcommons.rb', line 454

def is_left_hide?
  @left_frame_obj.w == 0
end

#maximize(_frame) ⇒ Object



475
476
477
478
479
480
481
482
483
484
# File 'lib/a-tkcommons.rb', line 475

def maximize(_frame)
  super(_frame)
  case _frame
  when left_frame
    hide_right
  when right_frame
    hide_left
  end
  Tk.update
end

#minimize(_frame) ⇒ Object



486
487
488
489
490
491
492
493
494
495
# File 'lib/a-tkcommons.rb', line 486

def minimize(_frame)
  super(_frame)
  case _frame
  when left_frame
    hide_left
  when right_frame
    hide_right
  end
  Tk.update
end

#show(_name) ⇒ Object



500
501
# File 'lib/a-tkcommons.rb', line 500

def show(_name)
end