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.



1894
1895
1896
1897
# File 'lib/a-core.rb', line 1894

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

Instance Method Details

#on_dialog(_event) ⇒ Object



1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
# File 'lib/a-core.rb', line 1899

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



1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
# File 'lib/a-core.rb', line 1926

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