bryan-ash-wx-nobbie 0.0.3.5 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,15 +4,15 @@ module Nobbie
4
4
 
5
5
  class SelectCommand < ComponentAwareCommand #:nodoc:
6
6
  def initialize(path, value)
7
- super(path)
7
+ super(path)
8
8
  @value = value
9
9
  end
10
-
10
+
11
11
  def execute
12
12
  if component.is_a?(Menu)
13
13
  return handle_menu
14
14
  end
15
-
15
+
16
16
  ensure_enabled
17
17
 
18
18
  if component.is_a?(Notebook)
@@ -26,7 +26,7 @@ module Nobbie
26
26
  end
27
27
  nil
28
28
  end
29
-
29
+
30
30
  def describe
31
31
  "Select '#{@value}' in #{@path}"
32
32
  end
@@ -39,8 +39,7 @@ module Nobbie
39
39
  ensure_enabled(id)
40
40
 
41
41
  #todo: should this be a MenuEvent?
42
- #todo: find a way to avoid using APPLICATION_UNDER_TEST
43
- APPLICATION_UNDER_TEST.get_top_window.process_event(CommandEvent.new(EVT_COMMAND_MENU_SELECTED, id))
42
+ TOP_WINDOW.process_event(CommandEvent.new(EVT_COMMAND_MENU_SELECTED, id))
44
43
 
45
44
  return ''
46
45
  end
@@ -63,11 +62,11 @@ module Nobbie
63
62
  highlight {
64
63
  index = component.find_string(@value)
65
64
  handle_value_not_found unless index > -1
66
-
65
+
67
66
  event = CommandEvent.new(EVT_COMMAND_COMBOBOX_SELECTED, component.get_id)
68
67
  component.selection = index
69
68
  event.event_object = component
70
-
69
+
71
70
  #todo: should this use process_event
72
71
  component.command(event)
73
72
  }
@@ -78,20 +77,20 @@ module Nobbie
78
77
  highlight {
79
78
  index = component.find_string(@value)
80
79
  handle_value_not_found unless index > -1
81
-
80
+
82
81
  event_type = (component.is_a?(ListBox) ? EVT_COMMAND_LISTBOX_SELECTED : EVT_COMMAND_CHOICE_SELECTED)
83
-
82
+
84
83
  event = CommandEvent.new(event_type, component.get_id)
85
84
  event.int = 1 #no idea why this works .. but it is needed
86
85
  event.string = @value
87
86
  component.selection = index
88
87
  event.event_object = component
89
-
88
+
90
89
  component.process_event(event)
91
90
  }
92
91
  end
93
92
  end
94
93
 
95
- end
94
+ end
96
95
  end
97
- end
96
+ end
@@ -1,43 +1,41 @@
1
1
  require 'nobbie/wx/command'
2
2
 
3
- command = File.dirname(__FILE__) + File::SEPARATOR + 'command'
4
- Dir.glob("#{command}/**/*.rb") {|f| require "#{f}" }
5
-
6
- require 'nobbie/wx/command_executor'
3
+ command = File.dirname(__FILE__) + '/command'
4
+ Dir.glob("#{command}/**/*.rb") {|file| require "#{file}" }
7
5
 
8
6
  module Nobbie
9
7
  module Wx
10
- module Command
8
+ module Command
11
9
 
12
10
  class Factory
13
11
  def create_type_into_command(path, value)
14
12
  TypeIntoCommand.new(path, value)
15
13
  end
16
-
14
+
17
15
  def create_get_component_command(path)
18
16
  GetComponentCommand.new(path)
19
17
  end
20
-
18
+
21
19
  def create_click_on_command(path)
22
20
  ClickOnCommand.new(path)
23
21
  end
24
-
22
+
25
23
  def create_get_selected_values_command(path)
26
24
  GetSelectedValuesCommand.new(path)
27
25
  end
28
-
26
+
29
27
  def create_select_command(path, value)
30
28
  SelectCommand.new(path, value)
31
29
  end
32
-
30
+
33
31
  def create_is_chosen_command(path)
34
32
  IsChosenCommand.new(path)
35
33
  end
36
-
34
+
37
35
  def create_choose_command(path)
38
36
  ChooseCommand.new(path)
39
37
  end
40
-
38
+
41
39
  def create_is_enabled_command(path)
42
40
  IsEnabledCommand.new(path)
43
41
  end
@@ -47,6 +45,6 @@ module Nobbie
47
45
  end
48
46
  end
49
47
 
50
- end
48
+ end
51
49
  end
52
- end
50
+ end
@@ -8,6 +8,7 @@ module Nobbie
8
8
  class ComponentReadOnlyException < RuntimeError; end
9
9
 
10
10
  class ElementPathBuilder
11
+
11
12
  def initialize(name)
12
13
  @name = name
13
14
  end
@@ -18,25 +19,25 @@ module Nobbie
18
19
  #todo: make me properly navigate component tree
19
20
  #todo: I should blow up if multiple windows with the same name are found ....
20
21
 
21
- #todo: shouldn''t need to pass AUT.gtw here ... nil should search all
22
- component = Window.find_window_by_name(@name, APPLICATION_UNDER_TEST.get_top_window)
22
+ #todo: shouldn't need to pass top_window here ... nil should search all
23
+ component = Window.find_window_by_name(@name, TOP_WINDOW)
23
24
  return component unless component.nil?
24
25
 
25
- menu_bar = APPLICATION_UNDER_TEST.get_top_window.get_menu_bar
26
+ menu_bar = TOP_WINDOW.get_menu_bar
26
27
  unless menu_bar.nil?
27
28
  component = menu_bar.get_menu(menu_bar.find_menu(@name))
28
29
  end
29
30
 
30
31
  #todo: pull this up ...
31
32
  Kernel.raise(ComponentNotFoundException, "cannot find component with name: #{to_s}") if component.nil?
32
-
33
+
33
34
  component
34
35
  end
35
-
36
+
36
37
  def to_s
37
38
  "'#{@name}'"
38
39
  end
39
40
  end
40
41
 
41
42
  end
42
- end
43
+ end
@@ -4,7 +4,7 @@ module Nobbie
4
4
  class ChoosableOperations
5
5
  def initialize(operations, path)
6
6
  @operations = operations
7
- @path = path
7
+ @path = path
8
8
  end
9
9
 
10
10
  # Chooses the component specified in the path.
@@ -18,14 +18,7 @@ module Nobbie
18
18
  def chosen?
19
19
  execute(@operations.command_factory.create_is_chosen_command(@path))
20
20
  end
21
-
22
- private
23
-
24
- #todo: pullup execute
25
- def execute(command)
26
- Command::Executor.new.execute(command)
27
- end
28
21
  end
29
22
 
30
23
  end
31
- end
24
+ end
@@ -1,10 +1,10 @@
1
1
  module Nobbie
2
2
  module Wx
3
-
3
+
4
4
  class SelectOperations
5
5
  def initialize(operations, path)
6
6
  @operations = operations
7
- @path = path
7
+ @path = path
8
8
  end
9
9
 
10
10
  # Retrieves the currently selected value for the component specified in the path.
@@ -24,14 +24,7 @@ module Nobbie
24
24
  def options
25
25
  execute(@operations.command_factory.create_get_options_command(@path))
26
26
  end
27
-
28
- private
29
-
30
- #todo: pullup execute
31
- def execute(command)
32
- Command::Executor.new.execute(command)
33
- end
34
27
  end
35
28
 
36
29
  end
37
- end
30
+ end
@@ -1,6 +1,4 @@
1
- require 'nobbie/wx/platform'
2
1
  require 'nobbie/wx/command_factory'
3
- require 'nobbie/wx/application_launcher'
4
2
 
5
3
  impl = File.dirname(__FILE__) + File::SEPARATOR + 'impl'
6
4
  Dir.glob("#{impl}/**/*.rb") {|f| require "#{f}" }
@@ -10,12 +8,21 @@ module Nobbie
10
8
 
11
9
  module Operations
12
10
 
11
+ EXECUTOR = Command::Executor.new
12
+
13
13
  # Types text into the component specified in the path.
14
14
  # Supported components: TextCtrl, ComboBox
15
15
  def type(text, path)
16
16
  execute(command_factory.create_type_into_command(coerce_path(path), text))
17
17
  end
18
18
 
19
+ # Returns the text in the component specified in the path.
20
+ # Supported components: TextCtrl, ComboBox
21
+ def text(path)
22
+ component = component(path)
23
+ component.nil? ? nil : component.value
24
+ end
25
+
19
26
  # Clicks the component specified in the path.
20
27
  # Supported components: Button
21
28
  def click(path)
@@ -60,6 +67,10 @@ module Nobbie
60
67
  Command::Factory.new
61
68
  end
62
69
 
70
+ def execute(command)
71
+ EXECUTOR.execute(command)
72
+ end
73
+
63
74
  private
64
75
 
65
76
  def coerce_path(path)
@@ -74,11 +85,6 @@ module Nobbie
74
85
 
75
86
  Kernel.raise("Unable to coerce path: #{path}")
76
87
  end
77
-
78
- #todo: pull up
79
- def execute(command)
80
- Command::Executor.new.execute(command)
81
- end
82
88
  end
83
89
 
84
90
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  require File.join(File.dirname(__FILE__), 'spec_helper')
3
- require 'nobbie/wx/application_launcher'
3
+ require 'nobbie/wx'
4
4
 
5
5
  describe Nobbie::Wx::ApplicationLauncher do
6
6
 
@@ -10,4 +10,10 @@ describe Nobbie::Wx::ApplicationLauncher do
10
10
  }.should raise_error(RuntimeError, /.*be a.*Wx::App.*/)
11
11
  end
12
12
 
13
+ it "stops the application under test after running it" do
14
+ app_launcher = Nobbie::Wx::ApplicationLauncher.new(Wx::App.new)
15
+ app_launcher.should_receive(:stop)
16
+ app_launcher.run
17
+ end
18
+
13
19
  end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'nobbie/wx'
3
+ require 'nobbie/wx/command/console_reporter'
4
+
5
+ module Nobbie
6
+ module Wx
7
+ module Command
8
+
9
+ describe "ConsoleReporter" do
10
+
11
+ it "behave like a Reporter" do
12
+ ConsoleReporter.new.should be_kind_of(Reporter)
13
+ end
14
+
15
+ it "outputs to STDOUT by default" do
16
+ command = mock('command')
17
+ command.should_receive(:describe).and_return('description')
18
+ command.should_receive(:execute).and_return('result')
19
+
20
+ STDOUT.should_receive(:puts).with(/.*description.*/)
21
+ STDOUT.should_receive(:puts).with(/.*result.*/)
22
+
23
+ reporter = ConsoleReporter.new
24
+ executor = Executor.new(reporter)
25
+ executor.execute(command)
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,54 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'nobbie/wx/command/executor'
3
+
4
+ module Nobbie
5
+ module Wx
6
+ module Command
7
+
8
+ describe "Executor" do
9
+
10
+ before :each do
11
+ @command = mock("command")
12
+ end
13
+
14
+ describe "basic execution" do
15
+
16
+ it "executes a command" do
17
+ @command.should_receive(:execute)
18
+
19
+ @executor = Nobbie::Wx::Command::Executor.new
20
+
21
+ @executor.execute(@command)
22
+ end
23
+
24
+ it "calls 'before' and 'after' hooks" do
25
+ reporter = mock('SilentReporter')
26
+ Reporter.should_receive(:new).and_return(reporter)
27
+ reporter.should_receive(:before_executing_command)
28
+ reporter.should_receive(:after_executing_command)
29
+
30
+ @command.should_receive(:execute)
31
+
32
+ @executor = Nobbie::Wx::Command::Executor.new
33
+
34
+ @executor.execute(@command)
35
+ end
36
+
37
+ it "calls 'before' and 'after' hooks on supplied Reporter" do
38
+ reporter = mock('Reporter')
39
+ reporter.should_receive(:before_executing_command)
40
+ reporter.should_receive(:after_executing_command)
41
+
42
+ @command.should_receive(:execute)
43
+
44
+ @executor = Nobbie::Wx::Command::Executor.new(reporter)
45
+
46
+ @executor.execute(@command)
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'nobbie/wx'
3
+ require 'nobbie/wx/command/reporter'
4
+
5
+ module Nobbie
6
+ module Wx
7
+ module Command
8
+
9
+ describe "Reporter" do
10
+
11
+ it "provides a reporter interface for use by executor" do
12
+ Reporter.method_defined?(:before_executing_command).should be_true
13
+ Reporter.method_defined?(:after_executing_command).should be_true
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -1,8 +1,15 @@
1
1
 
2
- $LOAD_PATH.unshift '../lib'
2
+ TEST = File.dirname(__FILE__)
3
+
4
+ $LOAD_PATH.unshift "#{TEST}/../lib"
3
5
 
4
6
  require 'rubygems'
5
- require 'nobbie/wx/acceptance_test'
6
- require_all_in_directory [File.dirname(__FILE__), 'suite'].join(File::SEPARATOR)
7
+ require 'nobbie/wx'
8
+ require 'test/unit'
9
+
10
+ Dir.glob("#{TEST}/suite/**/*.rb") { |file| require file }
11
+
12
+ Nobbie::Wx::Operations::EXECUTOR =
13
+ Nobbie::Wx::Command::Executor.new(Nobbie::Wx::Command::ConsoleReporter.new)
7
14
 
8
- APPLICATION_UNDER_TEST = ExampleApp.new
15
+ Nobbie::Wx::ApplicationLauncher.new(ExampleApp.new).run
@@ -5,110 +5,108 @@ require 'wx_sugar'
5
5
  include Wx
6
6
 
7
7
  class TestFrame < Frame
8
- def initialize(*args)
9
- super
10
-
11
- #todo: sort out all this :minsize => true stuff out .. need some way to specify defaults
12
-
13
- panel = add(Panel, :proportion => 1)
14
- panel.arrange_vertically(:padding => 4)
15
-
16
- test_notebook = name('test_notebook', panel.add(Notebook, :minsize => true, :proportion => 2))
17
-
18
- test_notebook.add_page(name('type', test_notebook.add(Panel) {|p| p.arrange_vertically
19
- listen(:text, name('text_ctrl', p.add(TextCtrl[:value => 'text_ctrl'], :minsize => true)), :update)
20
- listen(:text, name('readonly_text_ctrl', p.add(TextCtrl[:value => 'readonly_text_ctrl', :style => TE_READONLY], :minsize => true)), :update)
21
- listen(:text, disable(name('disabled_text_ctrl', p.add(TextCtrl[:value => 'disabled_text_ctrl'], :minsize => true))), :update)
22
-
23
- listen(:text, name('combo_box', p.add(ComboBox[:value => 'combo_box'], :minsize => true)), :update)
24
- readonly_combo_box = name('readonly_combo_box', p.add(ComboBox[:style => CB_READONLY], :minsize => true))
25
- readonly_combo_box.append('readonly_combo_box')
26
- readonly_combo_box.selection = 0
27
- listen(:text, readonly_combo_box, :update)
28
- listen(:text, disable(name('disabled_combo_box', p.add(ComboBox[:value => 'disabled_combo_box'], :minsize => true))), :update)
29
- }), 'type')
30
-
31
- test_notebook.add_page(name('click', test_notebook.add(Panel, :minsize => true) {|p| p.arrange_vertically
32
- listen(:button, name('button', p.add(Button[:label => 'regular_button'], :minsize => true)), :update)
33
- listen(:button, name('labelled_button_name', p.add(Button[:label => 'labelled_button'], :minsize => true)), :update)
34
- listen(:button, disable(name('disabled_button', p.add(Button[:label => 'disabled_button'], :minsize => true))), :update)
35
- name('static_text', p.add(StaticText[:label => 'static_text'], :minsize => true))
36
- }), 'click')
37
-
38
- test_notebook.add_page(name('selection', test_notebook.add(Panel) {|p| p.arrange_vertically
39
- notebook = name('notebook', p.add(Notebook, :minsize => true))
40
- notebook.add_page(name('notebook_page1', notebook.add(Panel)), 'notebook_page1')
41
- notebook.add_page(name('notebook_page2', notebook.add(Panel)), 'notebook_page2')
42
- notebook.evt_notebook_page_changing(notebook.get_id()) {|e| update(e) }
43
-
44
- disabled_notebook = disable(name('disabled_notebook', p.add(Notebook, :minsize => true)))
45
- disabled_notebook.add_page(name('disabled_notebook_page1', disabled_notebook.add(Panel)), 'disabled_notebook_page1')
46
- disabled_notebook.add_page(name('disabled_notebook_page2', disabled_notebook.add(Panel)), 'disabled_notebook_page2')
47
- disabled_notebook.evt_notebook_page_changing(disabled_notebook.get_id()) {|e| update(e) }
48
-
49
- #todo: make me have a visible name on screen
50
- combo_box_with_items = name('combo_box_with_items', p.add(ComboBox, :minsize => true))
51
- combo_box_with_items.append('combo_box_item')
52
- listen(:combobox, combo_box_with_items, :update)
53
-
54
- disabled_combo_box_with_items = disable(name('disabled_combo_box_with_items', p.add(ComboBox, :minsize => true)))
55
- disabled_combo_box_with_items.append('disabled_combo_box_item1')
56
- disabled_combo_box_with_items.append('disabled_combo_box_item2')
57
- listen(:combobox, disabled_combo_box_with_items, :update)
58
-
59
- list_box_with_items = name('list_box_with_items', p.add(ListBox, :minsize => true))
60
- list_box_with_items.append('list_box_item')
61
- listen(:listbox, list_box_with_items, :update)
62
-
63
- disabled_list_box_with_items = disable(name('disabled_list_box_with_items', p.add(ListBox, :minsize => true)))
64
- disabled_list_box_with_items.append('disabled_list_box_item1')
65
- disabled_list_box_with_items.append('disabled_list_box_item2')
66
- listen(:listbox, disabled_list_box_with_items, :update)
67
-
68
- choice_with_items = name('choice_with_items', p.add(Choice, :minsize => true))
69
- choice_with_items.append('choice_item')
70
- listen(:choice, choice_with_items, :update)
71
-
72
- disabled_choice_with_items = disable(name('disabled_choice_with_items', p.add(Choice, :minsize => true)))
73
- disabled_choice_with_items.append('disabled_choice_item1')
74
- disabled_choice_with_items.append('disabled_choice_item2')
75
- listen(:choice, disabled_choice_with_items, :update)
76
-
77
- }), 'selection')
78
-
79
- test_notebook.add_page(name('choose', test_notebook.add(Panel) {|p| p.arrange_vertically
80
- #todo: make me have a visible name on screen
81
- listen(:radiobutton, name('radio_button', p.add(RadioButton, :minsize => true)), :update)
82
-
83
- #todo: make me have a visible name on screen
84
- listen(:radiobutton, disable(name('disabled_radio_button', p.add(RadioButton, :minsize => true))), :update)
85
-
86
- #todo: make me have a visible name on screen
87
- listen(:checkbox, name('check_box', p.add(CheckBox, :minsize => true)), :update)
88
-
89
- #todo: make me have a visible name on screen
90
- listen(:checkbox, disable(name('disabled_check_box', p.add(CheckBox, :minsize => true))), :update)
91
-
92
- }), 'choose')
93
-
94
- @log = name('log', panel.add(TextCtrl[:style => TE_READONLY | TE_MULTILINE], :minsize => true, :proportion => 1))
95
-
96
- menu_bar = MenuBar.new
97
- file_menu = Menu.new
98
-
99
- #todo: remove these crappy id's ... there must be a nice sugary way to build menu's
100
- file_new = file_menu.append(101, "&New...\tCtrl+N")
101
- file_disabled = file_menu.append(102, "&disabled")
102
-
103
- menu_bar.append(file_menu, '&File')
104
- set_menu_bar(menu_bar)
105
-
106
- #todo: make disable() handle menus ...
107
- menu_bar.enable(102, false)
108
-
109
- #todo: make update() handle menus ...
110
- listen(:menu, @file_new) {|e| log('file_new') }
111
- end
8
+ def initialize(*args)
9
+ super
10
+
11
+ #todo: sort out all this :minsize => true stuff out .. need some way to specify defaults
12
+
13
+ panel = add(Panel, :proportion => 1)
14
+ panel.arrange_vertically(:padding => 4)
15
+
16
+ test_notebook = name('test_notebook', panel.add(Notebook, :minsize => true, :proportion => 2))
17
+
18
+ test_notebook.add_page(name('type', test_notebook.add(Panel) {|p| p.arrange_vertically
19
+ evt_text(name('text_ctrl', p.add(TextCtrl[:value => 'text_ctrl'], :minsize => true)), :update)
20
+ evt_text(name('readonly_text_ctrl', p.add(TextCtrl[:value => 'readonly_text_ctrl', :style => TE_READONLY], :minsize => true)), :update)
21
+ evt_text(disable(name('disabled_text_ctrl', p.add(TextCtrl[:value => 'disabled_text_ctrl'], :minsize => true))), :update)
22
+
23
+ evt_text(name('combo_box', p.add(ComboBox[:value => 'combo_box'], :minsize => true)), :update)
24
+ readonly_combo_box = name('readonly_combo_box', p.add(ComboBox[:style => CB_READONLY], :minsize => true))
25
+ readonly_combo_box.append('readonly_combo_box')
26
+ readonly_combo_box.selection = 0
27
+ evt_text(readonly_combo_box, :update)
28
+ evt_text(disable(name('disabled_combo_box', p.add(ComboBox[:value => 'disabled_combo_box'], :minsize => true))), :update)
29
+ }), 'type')
30
+
31
+ test_notebook.add_page(name('click', test_notebook.add(Panel, :minsize => true) {|p| p.arrange_vertically
32
+ evt_button(name('button', p.add(Button[:label => 'regular_button'], :minsize => true)), :update)
33
+ evt_button(name('labelled_button_name', p.add(Button[:label => 'labelled_button'], :minsize => true)), :update)
34
+ evt_button(disable(name('disabled_button', p.add(Button[:label => 'disabled_button'], :minsize => true))), :update)
35
+ name('static_text', p.add(StaticText[:label => 'static_text'], :minsize => true))
36
+ }), 'click')
37
+
38
+ test_notebook.add_page(name('selection', test_notebook.add(Panel) {|p| p.arrange_vertically
39
+ notebook = name('notebook', p.add(Notebook, :minsize => true))
40
+ notebook.add_page(name('notebook_page1', notebook.add(Panel)), 'notebook_page1')
41
+ notebook.add_page(name('notebook_page2', notebook.add(Panel)), 'notebook_page2')
42
+ notebook.evt_notebook_page_changing(notebook.get_id()) {|e| update(e) }
43
+
44
+ disabled_notebook = disable(name('disabled_notebook', p.add(Notebook, :minsize => true)))
45
+ disabled_notebook.add_page(name('disabled_notebook_page1', disabled_notebook.add(Panel)), 'disabled_notebook_page1')
46
+ disabled_notebook.add_page(name('disabled_notebook_page2', disabled_notebook.add(Panel)), 'disabled_notebook_page2')
47
+ disabled_notebook.evt_notebook_page_changing(disabled_notebook.get_id()) {|e| update(e) }
48
+
49
+ #todo: make me have a visible name on screen
50
+ combo_box_with_items = name('combo_box_with_items', p.add(ComboBox, :minsize => true))
51
+ combo_box_with_items.append('combo_box_item')
52
+ evt_combobox(combo_box_with_items, :update)
53
+
54
+ disabled_combo_box_with_items = disable(name('disabled_combo_box_with_items', p.add(ComboBox, :minsize => true)))
55
+ disabled_combo_box_with_items.append('disabled_combo_box_item1')
56
+ disabled_combo_box_with_items.append('disabled_combo_box_item2')
57
+ evt_combobox(disabled_combo_box_with_items, :update)
58
+
59
+ list_box_with_items = name('list_box_with_items', p.add(ListBox, :minsize => true))
60
+ list_box_with_items.append('list_box_item')
61
+ evt_listbox(list_box_with_items, :update)
62
+
63
+ disabled_list_box_with_items = disable(name('disabled_list_box_with_items', p.add(ListBox, :minsize => true)))
64
+ disabled_list_box_with_items.append('disabled_list_box_item1')
65
+ disabled_list_box_with_items.append('disabled_list_box_item2')
66
+ evt_listbox(disabled_list_box_with_items, :update)
67
+
68
+ choice_with_items = name('choice_with_items', p.add(Choice, :minsize => true))
69
+ choice_with_items.append('choice_item')
70
+ evt_choice(choice_with_items, :update)
71
+
72
+ disabled_choice_with_items = disable(name('disabled_choice_with_items', p.add(Choice, :minsize => true)))
73
+ disabled_choice_with_items.append('disabled_choice_item1')
74
+ disabled_choice_with_items.append('disabled_choice_item2')
75
+ evt_choice(disabled_choice_with_items, :update)
76
+ }), 'selection')
77
+
78
+ test_notebook.add_page(name('choose', test_notebook.add(Panel) {|p| p.arrange_vertically
79
+ #todo: make me have a visible name on screen
80
+ evt_radiobutton(name('radio_button', p.add(RadioButton, :minsize => true)), :update)
81
+
82
+ #todo: make me have a visible name on screen
83
+ evt_radiobutton(disable(name('disabled_radio_button', p.add(RadioButton, :minsize => true))), :update)
84
+
85
+ #todo: make me have a visible name on screen
86
+ evt_checkbox(name('check_box', p.add(CheckBox, :minsize => true)), :update)
87
+
88
+ #todo: make me have a visible name on screen
89
+ evt_checkbox(disable(name('disabled_check_box', p.add(CheckBox, :minsize => true))), :update)
90
+ }), 'choose')
91
+
92
+ @log = name('log', panel.add(TextCtrl[:style => TE_READONLY | TE_MULTILINE], :minsize => true, :proportion => 1))
93
+
94
+ menu_bar = MenuBar.new
95
+ file_menu = Menu.new
96
+
97
+ #todo: remove these crappy id's ... there must be a nice sugary way to build menu's
98
+ file_new = file_menu.append(101, "&New...\tCtrl+N")
99
+ file_disabled = file_menu.append(102, "&disabled")
100
+
101
+ menu_bar.append(file_menu, '&File')
102
+ set_menu_bar(menu_bar)
103
+
104
+ #todo: make disable() handle menus ...
105
+ menu_bar.enable(102, false)
106
+
107
+ #todo: make update() handle menus ...
108
+ evt_menu(file_new) {|e| log('file_new') }
109
+ end
112
110
 
113
111
  def on_init
114
112
  self.update
@@ -136,8 +134,16 @@ class TestFrame < Frame
136
134
  end
137
135
 
138
136
  class ExampleApp < App
137
+
138
+ def initialize(visible = true)
139
+ super()
140
+ @visible = visible
141
+ end
142
+
139
143
  def on_init
140
- TestFrame.new(nil, :title => 'test', :size => [1024, 768])
144
+ test_frame = TestFrame.new(nil, :title => 'test', :size => [1024, 768])
145
+ test_frame.show if @visible
146
+ self
141
147
  end
142
148
  end
143
149