Class: Okayu::AppFrame

Inherits:
Wx::Frame
  • Object
show all
Defined in:
lib/views/app_frame.rb

Instance Method Summary collapse

Constructor Details

#initialize(title, left = nil, top = nil, width = nil, height = nil) ⇒ AppFrame

Returns a new instance of AppFrame.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/views/app_frame.rb', line 10

def initialize(title, left=nil, top=nil, width=nil, height=nil)
  if UserInfo.left
    left   = UserInfo.left   unless left
    top    = UserInfo.top    unless top
    width  = UserInfo.width  unless width
    height = UserInfo.height unless height
  else
    left   = 100 unless left
    top    = 100 unless top
    width  = 500 unless width
    height = 430 unless height
  end
  
  super(nil, -1, title, Wx::Point.new(left, top), Wx::Size.new(width, height))
  file_menu = Wx::Menu.new
  file_menu.append(NEW_TAB, "新しいタブ(&T)\tCtrl+T", "新しいタブを開きます")
  file_menu.append(NEW_URL, "新しいURLを開く(&L)\tCtrl+L", "新しいURLを開きます")
  file_menu.append(CLOSE_TAB, "タブを閉じる(&C)\tCtrl+W", "現在のタブを閉じます")
  file_menu.append(Wx::ID_EXIT, "終了(&X)", "おかゆを終了します")

  connection_menu = Wx::Menu.new
  connection_menu.append(LOGIN, "ログイン(&L)", "ログインします")

  menu_bar = Wx::MenuBar.new
  menu_bar.append(file_menu, "ファイル(&F)")
  menu_bar.append(connection_menu, "接続(&C)")

  set_menu_bar(menu_bar)

  @status_bar = Wx::StatusBar.new(self, Wx::ID_ANY)
  set_status_bar(@status_bar)

  rect = get_client_rect
  @panel = MainPanel.new(self, rect.x, rect.y, rect.width, rect.height)

  evt_menu(NEW_TAB){on_new_tab}
  evt_menu(NEW_URL){on_new_url}
  evt_menu(CLOSE_TAB){on_close_tab}
  evt_menu(LOGIN){on_connect}
  evt_menu(Wx::ID_EXIT){|event| on_quit(event)}

  evt_move{|event| on_move(event)}
  evt_size{|event| on_size(event)}
end

Instance Method Details

#on_close_tabObject



59
60
61
# File 'lib/views/app_frame.rb', line 59

def on_close_tab
  @panel.close_tab
end

#on_connectObject



67
68
69
70
71
72
73
# File 'lib/views/app_frame.rb', line 67

def on_connect
   = LoginDialog.new(self)
  .show_modal
  if Client.connected?
    @status_bar.set_status_text '接続してるかも'
  end
end

#on_move(event) ⇒ Object



75
76
77
78
79
# File 'lib/views/app_frame.rb', line 75

def on_move event
  position = get_position
  UserInfo.left = position.x
  UserInfo.top  = position.y
end

#on_new_tabObject



55
56
57
# File 'lib/views/app_frame.rb', line 55

def on_new_tab
  @panel.create_tab
end

#on_new_urlObject



63
64
65
# File 'lib/views/app_frame.rb', line 63

def on_new_url
  @panel.get_current_page.on_new_url
end

#on_quit(event) ⇒ Object



89
90
91
# File 'lib/views/app_frame.rb', line 89

def on_quit event
  close(TRUE)
end

#on_size(event) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/views/app_frame.rb', line 81

def on_size event
  @panel.set_size(get_client_size)
  
  size = get_size
  UserInfo.width = size.width
  UserInfo.height = size.height
end