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) ⇒ Object
- #exist_buffer?(_name) ⇒ Boolean
- #index(_name) ⇒ Object
-
#initialize(parent = nil, _usetabs = true) ⇒ AgMultiEditorView
constructor
attr_reader :enb.
- #initialize_tabs ⇒ Object
- #move(_name, _pos) ⇒ 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, _usetabs = true) ⇒ AgMultiEditorView
attr_reader :enb
3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 |
# File 'ext/ae-editor/ae-editor.rb', line 3381 def initialize(parent=nil, _usetabs=true) @parent = parent @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
3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 |
# File 'ext/ae-editor/ae-editor.rb', line 3500 def add_page(_name, _file, _title, _image, _raise_proc, _adapter=nil) if @usetabs frame = @enb.insert('end', _name , 'text'=> _title, 'image'=> _image, 'background'=> Arcadia.style("tabpanel")["background"], 'foreground'=> Arcadia.style("tabpanel")["foreground"], 'raisecmd'=>_raise_proc ) else frame = TkFrame.new(@parent.hinner_frame) #.pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes') end if _adapter.nil? adapted_frame = TkFrameAdapter.new(@parent.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) ⇒ Object
3523 3524 3525 3526 3527 3528 3529 3530 |
# File 'ext/ae-editor/ae-editor.rb', line 3523 def delete_page(_name) if @usetabs @enb.delete(_name) end adapter_frame = @pages.delete(_name)['frame'] adapter_frame.frame.destroy if adapter_frame.frame adapter_frame.destroy end |
#exist_buffer?(_name) ⇒ Boolean
3448 3449 3450 3451 3452 3453 3454 |
# File 'ext/ae-editor/ae-editor.rb', line 3448 def exist_buffer?(_name) if @usetabs @enb.index(_name) != -1 else @pages.include?(_name) end end |
#index(_name) ⇒ Object
3456 3457 3458 3459 3460 3461 3462 3463 3464 |
# File 'ext/ae-editor/ae-editor.rb', line 3456 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
3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 |
# File 'ext/ae-editor/ae-editor.rb', line 3393 def initialize_tabs @enb = Tk::BWidget::NoteBook.new(@parent.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
3597 3598 3599 3600 3601 3602 |
# File 'ext/ae-editor/ae-editor.rb', line 3597 def move(_name, _pos) if @usetabs @enb.move(_name,_pos) if _pos else end end |
#page(_name) ⇒ Object
3542 3543 3544 |
# File 'ext/ae-editor/ae-editor.rb', line 3542 def page(_name) @pages[_name] end |
#page_bind(_event, _proc) ⇒ Object
3532 3533 3534 3535 3536 3537 3538 3539 3540 |
# File 'ext/ae-editor/ae-editor.rb', line 3532 def page_bind(_event, _proc) @page_binds[_event] = _proc if @usetabs @enb.tabbind_append("Button-3",_proc) @parent.root.top_text_bind_remove("Button-3") else @parent.root.top_text_bind_append("Button-3", _proc) end end |
#page_frame(_name) ⇒ Object
3546 3547 3548 3549 3550 3551 3552 |
# File 'ext/ae-editor/ae-editor.rb', line 3546 def page_frame(_name) if @usetabs @enb.get_frame(_name) else @pages[_name]['frame'] if @pages[_name] end end |
#page_name(_frame) ⇒ Object
3554 3555 3556 3557 3558 3559 3560 3561 |
# File 'ext/ae-editor/ae-editor.rb', line 3554 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
3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 |
# File 'ext/ae-editor/ae-editor.rb', line 3474 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 @parent.root.top_text(page(_name)['text'], page(_name)['image']) if page(_name) && raised?(_name) title end |
#pages ⇒ Object
3466 3467 3468 3469 3470 3471 3472 |
# File 'ext/ae-editor/ae-editor.rb', line 3466 def pages if @usetabs @enb.pages else @pages.keys end end |
#raise(_page = nil) ⇒ Object
3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 |
# File 'ext/ae-editor/ae-editor.rb', line 3563 def raise(_page=nil) if @usetabs if _page.nil? @raised_page = @enb.raise else @enb.raise(_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] end @raised_page = _page @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
3586 3587 3588 |
# File 'ext/ae-editor/ae-editor.rb', line 3586 def raised?(_name) @raised_page==_name end |
#root_frame ⇒ Object
3440 3441 3442 3443 3444 3445 3446 |
# File 'ext/ae-editor/ae-editor.rb', line 3440 def root_frame if @usetabs @enb else @parent.hinner_frame end end |
#see(_page) ⇒ Object
3590 3591 3592 3593 3594 3595 |
# File 'ext/ae-editor/ae-editor.rb', line 3590 def see(_page) if @usetabs @enb.see(_page) else end end |
#switch_2_notabs ⇒ Object
3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 |
# File 'ext/ae-editor/ae-editor.rb', line 3426 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
3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 |
# File 'ext/ae-editor/ae-editor.rb', line 3412 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 |