Class: ArcadiaDialogManager
- Inherits:
-
Object
- Object
- ArcadiaDialogManager
- Defined in:
- lib/a-core.rb
Defined Under Namespace
Classes: DialogParams
Instance Method Summary collapse
- #dialog_params(_event, check_type = true) ⇒ Object
- #do_hinner_dialog(_event) ⇒ Object
- #do_system_dialog(_event) ⇒ Object
-
#initialize(_arcadia) ⇒ ArcadiaDialogManager
constructor
A new instance of ArcadiaDialogManager.
- #on_dialog(_event) ⇒ Object
- #on_dialog_old(_event) ⇒ Object
Constructor Details
#initialize(_arcadia) ⇒ ArcadiaDialogManager
Returns a new instance of ArcadiaDialogManager.
2454 2455 2456 2457 |
# File 'lib/a-core.rb', line 2454 def initialize(_arcadia) @arcadia = _arcadia Arcadia.attach_listener(self, DialogEvent) end |
Instance Method Details
#dialog_params(_event, check_type = true) ⇒ Object
2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 |
# File 'lib/a-core.rb', line 2459 def dialog_params(_event, check_type = true) ret = DialogParams.new if _event ret.type = _event.type if check_type && !_event.class::TYPE_PATTERNS.include?(_event.type) ret.type = 'ok' end ret.res_array = ret.type.split('_') if _event.level.nil? || _event.level.length == 0 ret.level = 'info' else ret.level = _event.level end if _event.msg && _event.msg.length > _event.class::MSG_MAX_CHARS ret.msg = _event.msg[0.._event.class::MSG_MAX_CHARS]+' ...' else ret.msg = _event.msg end if _event.title && _event.title.length > _event.class::TITLE_MAX_CHARS ret.title = _event.title[0.._event.class::TITLE_MAX_CHARS]+' ...' else ret.title = _event.title end end ret end |
#do_hinner_dialog(_event) ⇒ Object
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 |
# File 'lib/a-core.rb', line 2517 def do_hinner_dialog(_event) par = dialog_params(_event, false) dialog_frame = HinnerDialog.new max_width = 0 par.res_array.each{|v| l = v.length max_width = l if l > max_width } res = nil par.res_array.reverse_each{|value| # Tk::BWidget::Button.new(dialog_frame, Arcadia.style('button')){ Arcadia.wf.(dialog_frame){ command proc{res = value;dialog_frame.release} text value.capitalize #helptext value.capitalize width max_width*2 pack('side' =>'right','padx'=>5, 'pady'=>5) }.hint=value.capitalize } Tk::BWidget::Label.new(dialog_frame,Arcadia.style('label')){ text par.msg helptext _event.title }.pack('side' =>'right','padx'=>5, 'pady'=>5) Tk::BWidget::Label.new(dialog_frame,Arcadia.style('label')){ compound 'left' Tk::Anigif.image(self, "#{Dir.pwd}/ext/ae-subprocess-inspector/process.res") }.pack('side' =>'right','padx'=>10) dialog_frame.show_modal _event.add_result(self, 'value'=>res) end |
#do_system_dialog(_event) ⇒ Object
2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 |
# File 'lib/a-core.rb', line 2495 def do_system_dialog(_event) par = dialog_params(_event) tktype = par.type.gsub('_','').downcase tkdialog = Tk::BWidget::MessageDlg.new( 'icon' => par.level, 'bg' => Arcadia.conf('background'), 'fg' => Arcadia.conf('foreground'), 'type' => tktype, 'title' => _event.title, 'message' => par.msg) tkdialog.configure('font'=>'courier 6') res = tkdialog.create if _event.level == 'error' if _event.exception != nil Arcadia.runtime_error(_event.exception, _event.title) else Arcadia.runtime_error_msg(_event.msg, _event.title) end end _event.add_result(self, 'value'=>par.res_array[res.to_i]) end |
#on_dialog(_event) ⇒ Object
2486 2487 2488 2489 2490 2491 2492 2493 |
# File 'lib/a-core.rb', line 2486 def on_dialog(_event) case _event when SystemDialogEvent do_system_dialog(_event) when HinnerDialogEvent do_hinner_dialog(_event) end end |
#on_dialog_old(_event) ⇒ Object
2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 |
# File 'lib/a-core.rb', line 2551 def on_dialog_old(_event) type = _event.type if !DialogEvent::TYPE_PATTERNS.include?(_event.type) type = 'ok' end icon = _event.level tktype = type.gsub('_','').downcase res = Tk.( 'icon' => icon, 'type' => tktype, 'title' => _event.title, 'message' => _event.msg) _event.add_result(self, 'value'=>res) end |