Class: AgMultiEditorView
- Inherits:
-
Object
- Object
- AgMultiEditorView
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Method Summary collapse
- #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
3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 |
# File 'ext/ae-editor/ae-editor.rb', line 3339 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_page(_name, _file, _title, _image, _raise_proc, _adapter = nil) ⇒ Object
3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 |
# File 'ext/ae-editor/ae-editor.rb', line 3506 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
3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 |
# File 'ext/ae-editor/ae-editor.rb', line 3531 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
3437 3438 3439 3440 3441 3442 3443 3444 3445 |
# File 'ext/ae-editor/ae-editor.rb', line 3437 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
3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 |
# File 'ext/ae-editor/ae-editor.rb', line 3447 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
3458 3459 3460 3461 3462 3463 3464 3465 3466 |
# File 'ext/ae-editor/ae-editor.rb', line 3458 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
3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 |
# File 'ext/ae-editor/ae-editor.rb', line 3353 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
3611 3612 3613 3614 3615 3616 |
# File 'ext/ae-editor/ae-editor.rb', line 3611 def move(_name, _pos) if @usetabs @enb.move(_name,_pos) if _pos else end end |
#move_here(_name) ⇒ Object
3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 |
# File 'ext/ae-editor/ae-editor.rb', line 3400 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
3552 3553 3554 |
# File 'ext/ae-editor/ae-editor.rb', line 3552 def page(_name) @pages[_name] end |
#page_bind(_event, _proc) ⇒ Object
3542 3543 3544 3545 3546 3547 3548 3549 3550 |
# File 'ext/ae-editor/ae-editor.rb', line 3542 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") else @frame.root.top_text_bind_append("Button-3", _proc) end end |
#page_frame(_name) ⇒ Object
3556 3557 3558 3559 3560 3561 3562 |
# File 'ext/ae-editor/ae-editor.rb', line 3556 def page_frame(_name) if @usetabs @enb.get_frame(_name) else @pages[_name]['frame'] if @pages[_name] end end |
#page_name(_frame) ⇒ Object
3564 3565 3566 3567 3568 3569 3570 3571 |
# File 'ext/ae-editor/ae-editor.rb', line 3564 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
3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 |
# File 'ext/ae-editor/ae-editor.rb', line 3476 def page_title(_name, _title=nil, _image=nil) @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
3468 3469 3470 3471 3472 3473 3474 |
# File 'ext/ae-editor/ae-editor.rb', line 3468 def pages if @usetabs @enb.pages else @pages.keys end end |
#raise(_page = nil) ⇒ Object
3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 |
# File 'ext/ae-editor/ae-editor.rb', line 3573 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
3600 3601 3602 |
# File 'ext/ae-editor/ae-editor.rb', line 3600 def raised?(_name) @raised_page==_name end |
#root_frame ⇒ Object
3429 3430 3431 3432 3433 3434 3435 |
# File 'ext/ae-editor/ae-editor.rb', line 3429 def root_frame if @usetabs @enb else @frame.hinner_frame end end |
#see(_page) ⇒ Object
3604 3605 3606 3607 3608 3609 |
# File 'ext/ae-editor/ae-editor.rb', line 3604 def see(_page) if @usetabs @enb.see(_page) else end end |
#switch_2_notabs ⇒ Object
3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 |
# File 'ext/ae-editor/ae-editor.rb', line 3386 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
3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 |
# File 'ext/ae-editor/ae-editor.rb', line 3372 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 |