Class: AGTkToplevel

Inherits:
AGTkContainer show all
Defined in:
ext/ae-rad/lib/tk/al-tk.rb

Direct Known Subclasses

AGTkRoot

Instance Attribute Summary

Attributes inherited from AGTkBaseContainer

#where_x, #where_y

Attributes inherited from AGTk

#canvas, #l_manager, #x0, #x3, #y0, #y3

Attributes inherited from AG

#ag_parent, #i_ag, #i_name, #obj, #obj_class, #persistent, #props, #props_def, #props_kinds, #renderer, #sniffer, #sons

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AGTkContainer

class_sniffer

Methods inherited from AGTkLayoutManaged

#start_properties

Methods inherited from AGTk

#activate, #active_move_tab, class_renderer, class_sniffer, #contains_events, #delete, #getFileName, #has_events, #popup, #update_property

Methods inherited from AG

#activate, active, #add_require, #build_sons, class_renderer, class_sniffer, #defaults, #defaults_values, #del_require, #delete, #fill_defaults_value_from_agobj, #getControlClassName, #getFileName, #getInstanceClass, #getObjClass, #getViewClassName, #get_implementation_block, #get_implementation_code, #get_path_i_name, #has_sons, near_class_wrapped, near_class_wrapper, #new_id, #publish, #publish_def, #publish_del, #publish_mod, publish_property, #register, #retrive_values, #select, #start_properties, #update_property

Constructor Details

#initialize(_ag_parent = nil, _object = nil) ⇒ AGTkToplevel

Returns a new instance of AGTkToplevel.


2370
2371
2372
2373
2374
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2370

def initialize(_ag_parent=nil, _object = nil)
  super(_ag_parent, _object)

  @l_manager.util_bind
end

Class Method Details

.class_wrappedObject


2376
2377
2378
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2376

def AGTkToplevel.class_wrapped
  TkToplevel
end

Instance Method Details

#form2codeObject


2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2380

def form2code
  _title = @i_name+'.rb'
  _text = @renderer.class_code.flatten.join
  
  Arcadia.process_event(OpenBufferEvent.new(self,'title'=>_title, 'text'=>_text))
  meditor = $arcadia['editor']
  if meditor
    _editor = meditor.raised
    code2form = proc{
      Revparsel.new(_editor.text_value)
      meditor.close_editor(_editor, true)
      InspectorContract.instance.raise_last_widget(meditor)
    }
    _editor.insert_popup_menu_item('end',
      :command,
      :label=>'View as form',
      :hidemargin => false,
      :command=> code2form
    )
  end
  
  #EditorContract.instance.open_text(self, 'title'=>_title, 'text'=>_text)
  self.delete
end

#get_implementation_newObject

overloaded


2552
2553
2554
2555
2556
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2552

def get_implementation_new #overloaded
  result = '@',@i_name,' = ', getInstanceClass ,".new\n"
  result = result,'@', @i_ag," = ",self.class, '.new(nil,','@',@i_name,", $arcadia.objects('objic').create(",
  "self,'", $arcadia.objects('objic').active.filename,"'))"
end

#keep_meObject


2405
2406
2407
2408
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2405

def keep_me
  $arcadia['buffers.code.in_memory'][@i_name]=@renderer.class_code.to_s
  self.delete
end

#new_objectObject


2438
2439
2440
2441
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2438

def new_object
  super
  set_obj_exit_protocol
end

#on_close_queryObject


2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2422

def on_close_query
  ans = Tk.messageBox('icon' => 'question', 'type' => 'yesnocancel',
    'title' => 'Exit', 'parent' => @obj,
    'message' => "Do you want shift to code view?")
    
  if ans =='yes'
    form2code
  elsif ans =='no'
    keep_me
  end
end

#passed_object(_obj) ⇒ Object


2444
2445
2446
2447
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2444

def passed_object(_obj)
  super(_obj)
  set_obj_exit_protocol
end

2410
2411
2412
2413
2414
2415
2416
2417
2418
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2410

def popup_items(_popup_menu)
  super(_popup_menu)
  _popup_menu.insert('end',
    :command,
    :label=>'View as code',
    :hidemargin => false,
    :command=> proc{form2code}
  )
end

#propertiesObject


2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2466

def properties
  super
  publish_mod('layout_man','name'=>'manager',
    'default'=> 'none',
    'get'=> proc{'none'},
    'set'=> proc{},
    'def'=> proc{""},
    'type'=> ''
  )
  publish_del('place')
  publish_del('pack')
  publish_del('property','state')
  publish('property','name'=>'geometry',
    'get'=> proc{ TkWinfo.geometry(@obj)},
    'set'=> proc{|g|  Tk.tk_call('wm', 'geometry', @obj, g )},
    'def'=> proc{|x| "Tk.tk_call('wm', 'geometry', self, #{x} )"},
    'start'=> '245x180+300+230'
  )
  publish('property','name'=>'icon',
    'get'=> proc{Tk.tk_call('wm', 'iconbitmap', @obj, nil)},
    'set'=> proc{|i|  Tk.tk_call('wm', 'iconbitmap', @obj, i )},
    'def'=> proc{|x| "Tk.tk_call('wm', 'iconbitmap', self, #{x} )"},
    'type'=> TkType::TkagFile
  )
  publish('property','name'=>'title',
    'get'=> proc{ Tk.tk_call('wm', 'title', @obj)},
    'set'=> proc{|t|  Tk.tk_call('wm', 'title', @obj, t )},
    'def'=> proc{|x| "Tk.tk_call('wm', 'title', self, #{x} )"},
    'start'=>'...hello'
  )
  publish('property',TkProperties::container(@obj))
  publish('property',TkProperties::borderwidth(@obj))
  publish('property',TkProperties::cursor(@obj))
  publish('property',TkProperties::highlightbackground(@obj))
  publish('property',TkProperties::highlightcolor(@obj))
  publish('property',TkProperties::highlightthickness(@obj))
  publish('property',TkProperties::relief(@obj))
  publish('property',TkProperties::takefocus(@obj))
  publish('property',TkProperties::padx(@obj))
  publish('property',TkProperties::pady(@obj))
  publish('property',TkProperties::height(@obj))
  publish('property',TkProperties::width(@obj))
  publish('property','name'=>'class',
    'get'=> proc{@obj.cget('class')},
    'set'=> proc{ |r| rewind_by_property('class',r) },
    'kind'=>'on-create'
  )
  publish('property','name'=>'colormap',
    'get'=> proc{@obj.cget('colormap')},
    'set'=> proc{|t| @obj.configure('colormap'=>t)},
    'def'=> ""
  )

  publish('property','name'=>'menu',
    'get'=> proc{@obj.cget('menu')},
    'set'=> proc{|t| @obj.configure('menu'=>t)},
    'def'=> ""
  )
  
  publish('property','name'=>'screen',
    'get'=> proc{@obj.cget('screen')},
    'set'=> proc{|t| rewind_by_property('screen',t) },
    'def'=> "",
    'kind'=>'on-create'
  )

  publish('property','name'=>'use',
    'get'=> proc{@obj.cget('use')},
    'set'=> proc{ |r| rewind_by_property('use',r) },
    'kind'=>'on-create'
  )

  publish('property','name'=>'visual',
    'get'=> proc{@obj.cget('visual')},
    'set'=> proc{|r| rewind_by_property('visual',r) },
    'def'=> "",
    'kind'=>'on-create',
    'type'=> EnumType.new('','best', 'directcolor', 'grayscale','greyscale', 
      'pseudocolor', 'staticcolor', 'staticgray', 'staticgrey', 'truecolor', 'default')
  )

  publish('winfo','name'=>'server','get'=> proc{TkWinfo.server(@obj)}, 'def'=> 'nodef')
  publish('winfo','name'=>'screen','get'=> proc{TkWinfo.screen(@obj)}, 'def'=> 'nodef')

end

#rewind_by_property(_name, _val) ⇒ Object


2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2449

def rewind_by_property(_name, _val)
  msg = "To modify "+_name+" must create new Toplevel: do you want to procede ?"
  if Tk.messageBox('icon' => 'warning', 'type' => 'okcancel',
    'title' => '(Arcadia) '+_name, 'message' => msg) == 'cancel'
    return
  end
  _rewind_code = @renderer.class_code(2,_name=> _val).to_s
  begin
    Revparsel.new(_rewind_code)
    #$arcadia.objects('objic').del(@object_inspector)
  rescue => exc
    _editor = $arcadia.objects('editor').open_tab(@i_name)
    _editor.text_insert('end', _rewind_code)
    raise
  end 
end

#set_obj_exit_protocolObject


2434
2435
2436
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 2434

def set_obj_exit_protocol
  @obj.protocol( "WM_DELETE_WINDOW", proc{on_close_query})
end