class ArcadiaDialogManager

Constants

DialogParams

Public Class Methods

new(_arcadia) click to toggle source
# File lib/a-core.rb, line 2924
def initialize(_arcadia)
  @arcadia = _arcadia
  Arcadia.attach_listener(self, DialogEvent)
end

Public Instance Methods

dialog_params(_event, check_type = true) click to toggle source
# File lib/a-core.rb, line 2929
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) click to toggle source
# File lib/a-core.rb, line 2987
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.button(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) click to toggle source
# File lib/a-core.rb, line 2965
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) click to toggle source
# File lib/a-core.rb, line 2956
def on_dialog(_event)
  case _event
    when SystemDialogEvent
      do_system_dialog(_event)
    when HinnerDialogEvent
      do_hinner_dialog(_event)
  end
end
on_dialog_old(_event) click to toggle source
# File lib/a-core.rb, line 3021
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.messageBox(
  'icon' => icon,
  'type' => tktype,
  'title' => _event.title,
  'message' => _event.msg)
  _event.add_result(self, 'value'=>res)
end