Class: AgMultiEditorView
- Inherits:
-
Object
- Object
- AgMultiEditorView
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Attribute Summary collapse
-
#usetabs ⇒ Object
readonly
attr_reader :enb.
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
A new instance of AgMultiEditorView.
- #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
def initialize_notabs @frame_notabs = TkFrame.new(@frame.hinner_frame, Arcadia.style(‘panel’)){ pack(‘fill’=>‘both’, :padx=>0, :pady=>0, :expand => ‘yes’) } end.
Constructor Details
#initialize(_parent = nil, _frame = nil, _usetabs = true) ⇒ AgMultiEditorView
Returns a new instance of AgMultiEditorView.
3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 |
# File 'ext/ae-editor/ae-editor.rb', line 3766 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 Attribute Details
#usetabs ⇒ Object (readonly)
attr_reader :enb
3765 3766 3767 |
# File 'ext/ae-editor/ae-editor.rb', line 3765 def usetabs @usetabs end |
Instance Method Details
#add_menu_button(_name, _buffer_string) ⇒ Object
3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 |
# File 'ext/ae-editor/ae-editor.rb', line 3981 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
3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 |
# File 'ext/ae-editor/ae-editor.rb', line 3939 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, @parent) 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
3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 |
# File 'ext/ae-editor/ae-editor.rb', line 3964 def delete_page(_name, _delete_adapter=true) if @usetabs @enb.delete(_name) end adapter_frame = @pages.delete(_name)['frame'] if _delete_adapter frame = adapter_frame.frame adapter_frame.detach_frame adapter_frame.destroy frame.destroy # adapter_frame.frame.destroy if adapter_frame.frame # adapter_frame.destroy end @raised_page = nil if @raised_page == _name Tk.update end |
#exist_buffer?(_name, _sender = self) ⇒ Boolean
3869 3870 3871 3872 3873 3874 3875 3876 3877 |
# File 'ext/ae-editor/ae-editor.rb', line 3869 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
3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 |
# File 'ext/ae-editor/ae-editor.rb', line 3879 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
3890 3891 3892 3893 3894 3895 3896 3897 3898 |
# File 'ext/ae-editor/ae-editor.rb', line 3890 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
3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 |
# File 'ext/ae-editor/ae-editor.rb', line 3779 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
4068 4069 4070 4071 4072 4073 |
# File 'ext/ae-editor/ae-editor.rb', line 4068 def move(_name, _pos) if @usetabs @enb.move(_name,_pos) if _pos else end end |
#move_here(_name) ⇒ Object
3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 |
# File 'ext/ae-editor/ae-editor.rb', line 3832 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
4009 4010 4011 |
# File 'ext/ae-editor/ae-editor.rb', line 4009 def page(_name) @pages[_name] end |
#page_bind(_event, _proc) ⇒ Object
3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 |
# File 'ext/ae-editor/ae-editor.rb', line 3997 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
4013 4014 4015 4016 4017 4018 4019 |
# File 'ext/ae-editor/ae-editor.rb', line 4013 def page_frame(_name) if @usetabs @enb.get_frame(_name) else @pages[_name]['frame'] if @pages[_name] end end |
#page_name(_frame) ⇒ Object
4021 4022 4023 4024 4025 4026 4027 4028 |
# File 'ext/ae-editor/ae-editor.rb', line 4021 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
3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 |
# File 'ext/ae-editor/ae-editor.rb', line 3908 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
3900 3901 3902 3903 3904 3905 3906 |
# File 'ext/ae-editor/ae-editor.rb', line 3900 def pages if @usetabs @enb.pages else @pages.keys end end |
#raise(_page = nil) ⇒ Object
4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 |
# File 'ext/ae-editor/ae-editor.rb', line 4030 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
4057 4058 4059 |
# File 'ext/ae-editor/ae-editor.rb', line 4057 def raised?(_name) @raised_page==_name end |
#root_frame ⇒ Object
3861 3862 3863 3864 3865 3866 3867 |
# File 'ext/ae-editor/ae-editor.rb', line 3861 def root_frame if @usetabs @enb else @frame.hinner_frame end end |
#see(_page) ⇒ Object
4061 4062 4063 4064 4065 4066 |
# File 'ext/ae-editor/ae-editor.rb', line 4061 def see(_page) if @usetabs @enb.see(_page) else end end |
#switch_2_notabs ⇒ Object
3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 |
# File 'ext/ae-editor/ae-editor.rb', line 3818 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
def initialize_notabs
@frame_notabs = TkFrame.new(@frame.hinner_frame, Arcadia.style('panel')){
pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes')
}
end
3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 |
# File 'ext/ae-editor/ae-editor.rb', line 3804 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 |