Class: ArcadiaDialogManager

Inherits:
Object
  • Object
show all
Defined in:
lib/a-core.rb

Instance Method Summary collapse

Constructor Details

#initialize(_arcadia) ⇒ ArcadiaDialogManager

Returns a new instance of ArcadiaDialogManager.



1882
1883
1884
1885
# File 'lib/a-core.rb', line 1882

def initialize(_arcadia)
  @arcadia = _arcadia
  Arcadia.attach_listener(self, DialogEvent)
end

Instance Method Details

#on_dialog(_event) ⇒ Object



1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
# File 'lib/a-core.rb', line 1887

def on_dialog(_event)
  type = _event.type
  if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
    type = 'ok'
  end
  res_array = type.split('_')
  if _event.level.nil? || _event.level.length == 0
    icon = 'info'
  else
    icon = _event.level
  end
  tktype = type.gsub('_','').downcase
  
  tkdialog =  Tk::BWidget::MessageDlg.new(
          'icon' => icon,
          'bg' => Arcadia.conf('background'),
          'fg' => Arcadia.conf('foreground'),
          'type' => tktype,
          'title' => _event.title, 
          'message' => _event.msg)
          
  tkdialog.configure('font'=>'courier 6')        
  res = tkdialog.create
  _event.add_result(self, 'value'=>res_array[res.to_i])
end

#on_dialog_old(_event) ⇒ Object



1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
# File 'lib/a-core.rb', line 1914

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