Class: AgMultiEditorView
- Inherits:
-
Object
- Object
- AgMultiEditorView
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Method Summary collapse
- #add_menu_button(_name, _buffer_string) ⇒ Object
- #add_page(_name, _file, _title, _image, _raise_proc, _adapter = nil) ⇒ Object
- #delete_page(_name, _delete_adapter = true) ⇒ Object
- #exist_buffer?(_name, _sender = self) ⇒ Boolean
- #exist_buffer_in_others?(_name) ⇒ Boolean
- #index(_name) ⇒ Object
-
#initialize(_parent = nil, _frame = nil, _usetabs = true) ⇒ AgMultiEditorView
constructor
attr_reader :enb.
- #initialize_tabs ⇒ Object
- #move(_name, _pos) ⇒ Object
- #move_here(_name) ⇒ Object
- #page(_name) ⇒ Object
- #page_bind(_event, _proc) ⇒ Object
- #page_frame(_name) ⇒ Object
- #page_name(_frame) ⇒ Object
- #page_title(_name, _title = nil, _image = nil) ⇒ Object
- #pages ⇒ Object
- #raise(_page = nil) ⇒ Object
- #raised?(_name) ⇒ Boolean
- #root_frame ⇒ Object
- #see(_page) ⇒ Object
- #switch_2_notabs ⇒ Object
- #switch_2_tabs ⇒ Object
Constructor Details
#initialize(_parent = nil, _frame = nil, _usetabs = true) ⇒ AgMultiEditorView
attr_reader :enb
3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 |
# File 'ext/ae-editor/ae-editor.rb', line 3522 def initialize(_parent=nil, _frame=nil, _usetabs=true) @parent = _parent @frame = _frame @usetabs = _usetabs if @usetabs initialize_tabs end @pages = {} @page_binds = {} @raised_page=nil @raised_page_usetabs=@usetabs end |
Instance Method Details
#add_menu_button(_name, _buffer_string) ⇒ Object
3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 |
# File 'ext/ae-editor/ae-editor.rb', line 3726 def (_name, _buffer_string) @buffer_menu_button = @frame.root.( _name, 'files', nil, 'right', {'relief'=>:flat, 'borderwidth'=>1, 'compound'=> 'left', 'anchor'=>'w', 'font'=> "#{Arcadia.conf('titlelabel.font')} italic", 'activebackground'=>Arcadia.conf('titlelabel.background'), 'foreground' => Arcadia.conf('titlecontext.foreground'), 'textvariable'=> _buffer_string } ) end |
#add_page(_name, _file, _title, _image, _raise_proc, _adapter = nil) ⇒ Object
3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 |
# File 'ext/ae-editor/ae-editor.rb', line 3690 def add_page(_name, _file, _title, _image, _raise_proc, _adapter=nil) # p "add_page _name=#{_name} _file=#{_file}, _title=#{_title}" if @usetabs frame = @enb.insert(0, _name , 'text'=> _title, 'image'=> _image, 'background'=> Arcadia.style("tabpanel")["background"], 'foreground'=> Arcadia.style("tabpanel")["foreground"], 'raisecmd'=>_raise_proc ) else frame = TkFrame.new(@frame.hinner_frame) #.pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes') end if _adapter.nil? adapted_frame = TkFrameAdapter.new(Arcadia.layout.root) # adapted_frame = TkFrameAdapter.new(@frame.hinner_frame) else adapted_frame = _adapter end adapted_frame.attach_frame(frame) adapted_frame.raise @pages[_name]={'frame'=>adapted_frame, 'file'=>_file, 'text'=>_title, 'image' => _image, 'raisecmd'=>_raise_proc} adapted_frame end |
#delete_page(_name, _delete_adapter = true) ⇒ Object
3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 |
# File 'ext/ae-editor/ae-editor.rb', line 3715 def delete_page(_name, _delete_adapter=true) if @usetabs @enb.delete(_name) end adapter_frame = @pages.delete(_name)['frame'] if _delete_adapter adapter_frame.frame.destroy if adapter_frame.frame adapter_frame.destroy end end |
#exist_buffer?(_name, _sender = self) ⇒ Boolean
3620 3621 3622 3623 3624 3625 3626 3627 3628 |
# File 'ext/ae-editor/ae-editor.rb', line 3620 def exist_buffer?(_name, _sender=self) to_ret = false if @usetabs to_ret = @enb.index(_name) != -1 else to_ret = @pages.include?(_name) end to_ret end |
#exist_buffer_in_others?(_name) ⇒ Boolean
3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 |
# File 'ext/ae-editor/ae-editor.rb', line 3630 def exist_buffer_in_others?(_name) to_ret = false @parent.instances.each{|i| if i != @parent to_ret = i.main_frame.exist_buffer?(_name) break if to_ret end } to_ret end |
#index(_name) ⇒ Object
3641 3642 3643 3644 3645 3646 3647 3648 3649 |
# File 'ext/ae-editor/ae-editor.rb', line 3641 def index(_name) if @usetabs @enb.index(_name) else _index = @pages.values.index(@pages[_name]) _index = -1 if _index.nil? _index end end |
#initialize_tabs ⇒ Object
3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 |
# File 'ext/ae-editor/ae-editor.rb', line 3536 def initialize_tabs @enb = Tk::BWidget::NoteBook.new(@frame.hinner_frame, Arcadia.style('tabpanel')){ tabbevelsize 0 internalborderwidth 2 side Arcadia.conf('editor.tabs.side') font Arcadia.conf('editor.tabs.font') pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes') } refresh_after_map = proc{ if !@enb.pages.empty? if @enb.raise.nil? || @enb.raise.strip.length == 0 @enb.raise(@enb.pages[0]) @enb.see(@enb.pages[0]) end end } @enb.bind_append("Map",refresh_after_map) end |
#move(_name, _pos) ⇒ Object
3812 3813 3814 3815 3816 3817 |
# File 'ext/ae-editor/ae-editor.rb', line 3812 def move(_name, _pos) if @usetabs @enb.move(_name,_pos) if _pos else end end |
#move_here(_name) ⇒ Object
3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 |
# File 'ext/ae-editor/ae-editor.rb', line 3583 def move_here(_name) value = nil old_instance = nil @parent.instances.each{|i| if i != @parent value = i.main_frame.page(_name) if value != nil old_instance = i break end end } if value != nil value['frame'].detach_frame editor = old_instance.editor_by_page_name(_name) editor.set_controller(@parent) @parent.register_editor(editor, _name, editor.file) old_instance.close_buffer(_name, true) add_page(_name, value['file'], value['text'], value['image'], proc{@parent.do_buffer_raise(_name, value['text'])}, value['frame']) is_file = value['file'] != nil && File.exists?(value['file']) if is_file @parent.(value['file'], is_file, @parent) else @parent.(value['text'], is_file, @parent) end raise(_name) end end |
#page(_name) ⇒ Object
3753 3754 3755 |
# File 'ext/ae-editor/ae-editor.rb', line 3753 def page(_name) @pages[_name] end |
#page_bind(_event, _proc) ⇒ Object
3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 |
# File 'ext/ae-editor/ae-editor.rb', line 3741 def page_bind(_event, _proc) @page_binds[_event] = _proc if @usetabs @enb.tabbind_append("Button-3",_proc) @frame.root.top_text_bind_remove("Button-3") @buffer_menu_button.bind_remove("Button-3") if @buffer_menu_button else @frame.root.top_text_bind_append("Button-3", _proc) @buffer_menu_button.bind_append("Button-3", _proc) if @buffer_menu_button end end |
#page_frame(_name) ⇒ Object
3757 3758 3759 3760 3761 3762 3763 |
# File 'ext/ae-editor/ae-editor.rb', line 3757 def page_frame(_name) if @usetabs @enb.get_frame(_name) else @pages[_name]['frame'] if @pages[_name] end end |
#page_name(_frame) ⇒ Object
3765 3766 3767 3768 3769 3770 3771 3772 |
# File 'ext/ae-editor/ae-editor.rb', line 3765 def page_name(_frame) res = nil @pages.each{|k,v| res = k if v['frame'] == _frame break if !res.nil? } res end |
#page_title(_name, _title = nil, _image = nil) ⇒ Object
3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 |
# File 'ext/ae-editor/ae-editor.rb', line 3659 def page_title(_name, _title=nil, _image=nil) return nil if _name.nil? or _name.strip.length == 0 @pages[_name]['text'] = _title if _title != nil @pages[_name]['image'] = _image if _image != nil title = _title if @usetabs if _title.nil? && _image.nil? title = @enb.itemcget(_name, 'text') else args = {} if _title != nil args['text']=_title end if _image != nil args['image']=_image end @enb.itemconfigure(_name, args) end else if _title.nil? && _image.nil? title = @pages[_name]['text'] if @pages[_name] end end #@frame.root.top_text(page(_name)['text'], page(_name)['image']) if page(_name) && raised?(_name) if page(_name) && raised?(_name) @frame.root.top_text(@parent.top_text_string, page(_name)['image']) @parent.make_buffer_string(page(_name)['text']) end title end |
#pages ⇒ Object
3651 3652 3653 3654 3655 3656 3657 |
# File 'ext/ae-editor/ae-editor.rb', line 3651 def pages if @usetabs @enb.pages else @pages.keys end end |
#raise(_page = nil) ⇒ Object
3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 |
# File 'ext/ae-editor/ae-editor.rb', line 3774 def raise(_page=nil) if @usetabs if _page.nil? @raised_page = @enb.raise else @enb.raise(_page) @enb.see(_page) @raised_page = _page end else if _page.nil? @raised_page elsif @raised_page != _page || @raised_page_usetabs != @usetabs if @raised_page # @pages[@raised_page]['frame'].unpack if @pages[@raised_page] @pages[@raised_page]['frame'].unmap("pack") if @pages[@raised_page] end @raised_page = _page @pages[_page]['frame'].map("pack") # @pages[_page]['frame'].pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes') @pages[_page]['raisecmd'].call end end @raised_page_usetabs=@usetabs @raised_page end |
#raised?(_name) ⇒ Boolean
3801 3802 3803 |
# File 'ext/ae-editor/ae-editor.rb', line 3801 def raised?(_name) @raised_page==_name end |
#root_frame ⇒ Object
3612 3613 3614 3615 3616 3617 3618 |
# File 'ext/ae-editor/ae-editor.rb', line 3612 def root_frame if @usetabs @enb else @frame.hinner_frame end end |
#see(_page) ⇒ Object
3805 3806 3807 3808 3809 3810 |
# File 'ext/ae-editor/ae-editor.rb', line 3805 def see(_page) if @usetabs @enb.see(_page) else end end |
#switch_2_notabs ⇒ Object
3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 |
# File 'ext/ae-editor/ae-editor.rb', line 3569 def switch_2_notabs raised = raise @usetabs = false @pages.each{|name, value| value['frame'].detach_frame add_page(name, value['file'], value['text'], value['image'], value['raisecmd'], value['frame']) } @enb.destroy raise(raised) @page_binds.each{|event, proc| page_bind(event, proc) } end |
#switch_2_tabs ⇒ Object
3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 |
# File 'ext/ae-editor/ae-editor.rb', line 3555 def switch_2_tabs raised = raise @usetabs = true initialize_tabs @pages.each{|name, value| oldframe = value['frame'].frame value['frame'].detach_frame oldframe.destroy add_page(name, value['file'], value['text'], value['image'], value['raisecmd'], value['frame']) } raise(raised) @page_binds.each{|event, proc| page_bind(event, proc)} end |