wxruby 1.9.0-i686-linux → 1.9.1-i686-linux

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.
data/lib/wx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wx
2
- WXRUBY_VERSION = '1.9.0'
2
+ WXRUBY_VERSION = '1.9.1'
3
3
  end
data/lib/wxruby2.so CHANGED
Binary file
data/samples/aui/aui.rb CHANGED
@@ -564,7 +564,8 @@ class AuiFrame < Wx::Frame
564
564
  evt_update_ui(ID_VerticalGradient) { | e | on_update_ui(e) }
565
565
  evt_update_ui(ID_HorizontalGradient) { | e | on_update_ui(e) }
566
566
  evt_menu_range( ID_FirstPerspective,
567
- ID_FirstPerspective + @perspectives.length) { | e | }
567
+ ID_FirstPerspective +
568
+ @perspectives.length) { | e | on_restore_perspective(e) }
568
569
  evt_aui_pane_close { | e | on_pane_close(e) }
569
570
  evt_auinotebook_page_close(Wx::ID_ANY) { | e | on_notebook_page_close(e) }
570
571
  end
@@ -800,7 +801,7 @@ class AuiFrame < Wx::Frame
800
801
  def setup_perspectives
801
802
  perspective_all = @mgr.save_perspective
802
803
 
803
- @mgr.get_all_panes.each do | pane |
804
+ @mgr.each_pane do | pane |
804
805
  pane.hide unless pane.is_toolbar
805
806
  end
806
807
 
@@ -935,7 +936,7 @@ class AuiFrame < Wx::Frame
935
936
  end
936
937
 
937
938
 
938
- @mgr.get_all_panes.each do | pane |
939
+ @mgr.each_pane do | pane |
939
940
  maybe_nb = pane.get_window
940
941
  next unless maybe_nb.kind_of?(Wx::AuiNotebook)
941
942
  if e_id == ID_NotebookArtGloss
@@ -1023,8 +1024,8 @@ class AuiFrame < Wx::Frame
1023
1024
  def on_create_perspective
1024
1025
  msg = "Enter a name for the new perspective:"
1025
1026
  dlg = Wx::TextEntryDialog.new(self, msg, "Wx::AUI Test")
1026
- dlg.set_value("Perspective %d" % @perspectives.length + 1)
1027
- return unless dlg.show_modal != Wx::ID_OK
1027
+ dlg.set_value("Perspective %d" % [ @perspectives.length + 1 ] )
1028
+ return unless dlg.show_modal == Wx::ID_OK
1028
1029
  if @perspectives.length.zero?
1029
1030
  @perspectives_menu.append_separator
1030
1031
  end
@@ -60,33 +60,33 @@ class TestVirtualList < Wx::ListCtrl
60
60
  @log.write_text("on_item_deselected: %s" % event.get_index())
61
61
  end
62
62
 
63
- #---------------------------------------------------
64
- # These methods are callbacks for implementing the
65
- # "virtualness" of the list... Normally you would
66
- # determine the text, attributes and/or image based
67
- # on values from some external data source, but for
68
- # this demo we'll just calculate them
69
-
63
+ # These three following methods are callbacks for implementing the
64
+ # "virtualness" of the list; they *must* be defined by any ListCtrl
65
+ # object with the style LC_VIRTUAL.
66
+
67
+ # Normally you would determine the text, attributes and/or image
68
+ # based on values from some external data source, but for this demo
69
+ # we'll just calculate them based on order.
70
70
  def on_get_item_text(item, col)
71
- return "Item %d, column %d" % [item,col]
71
+ return "Item %d, column %d" % [item,col]
72
72
  end
73
73
 
74
- def on_get_item_image(item)
75
- if item % 3 == 0
76
- return @idx1
77
- else
78
- return -1
79
- end
74
+ def on_get_item_column_image(item, col)
75
+ if item % 4 == 0
76
+ return @idx1
77
+ else
78
+ return -1
79
+ end
80
80
  end
81
81
 
82
82
  def on_get_item_attr(item)
83
- if item % 3 == 1
84
- return @attr1
85
- elsif item % 3 == 2
86
- return @attr2
87
- else
88
- return nil
89
- end
83
+ if item % 3 == 1
84
+ return @attr1
85
+ elsif item % 3 == 2
86
+ return @attr2
87
+ else
88
+ return nil
89
+ end
90
90
  end
91
91
  end
92
92
 
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2007 wxRuby development team
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+
5
+ begin
6
+ require 'rubygems'
7
+ require 'wx'
8
+ rescue LoadError
9
+ require 'wx'
10
+ end
11
+
12
+ # This sample demonstrates how to dynamically connect and disconnect
13
+ # event handlers, and how to create custom event types and listeners
14
+ # associated with user-defined control classes.
15
+
16
+ # A custom type of event associated with a target control. Note that for
17
+ # user-defined controls, the associated event should inherit from
18
+ # Wx::CommandEvent rather than Wx::Event.
19
+ class TargetHitEvent < Wx::CommandEvent
20
+ # Create a new unique constant identifier, associate this class
21
+ # with events of that identifier, and create a shortcut 'evt_target'
22
+ # method for setting up this handler.
23
+ EVT_HIT_TARGET = Wx::EvtHandler.register_class(self, nil, 'evt_target', 1)
24
+
25
+ def initialize(target, score, distance)
26
+ # The constant id is the arg to super
27
+ super(EVT_HIT_TARGET)
28
+ # client_data should be used to store any information associated
29
+ # with the event.
30
+ self.client_data = { :score => score, :distance => distance }
31
+ self.id = target.get_id
32
+ end
33
+
34
+ # Returns the points score associated with this event
35
+ def score
36
+ client_data[:score]
37
+ end
38
+
39
+ # Returns the distance (in pixels) from the centre of the target
40
+ def distance
41
+ client_data[:distance]
42
+ end
43
+ end
44
+
45
+ # An example of a simple user-written control, which displays a
46
+ # "bulls-eye" like target, and sends events with a score and distance
47
+ class TargetControl < Wx::Window
48
+ TargetCircle = Struct.new(:radius, :score, :brush)
49
+
50
+ def initialize(parent, *args)
51
+ super(parent, *args)
52
+
53
+ # Set up the scores and sizes of the rings
54
+ @radii = [
55
+ TargetCircle[ 0.1, 20, Wx::RED_BRUSH ],
56
+ TargetCircle[ 0.25, 10, Wx::BLUE_BRUSH ],
57
+ TargetCircle[ 0.4, 5, Wx::GREEN_BRUSH ] ]
58
+ evt_paint { | e | on_paint(e) }
59
+ evt_left_down { | e | on_left_down(e) }
60
+ end
61
+
62
+ # What point is at the centre (assuming this control is always square)
63
+ def centre_point
64
+ size.width / 2
65
+ end
66
+
67
+ # Called whenever the target is repainted, draws a series of
68
+ # concentric circles
69
+ def on_paint(evt)
70
+ paint do | dc |
71
+ dc.clear
72
+ @radii.reverse_each do | circ |
73
+ dc.brush = circ.brush
74
+ dc.draw_circle(centre_point, centre_point,
75
+ ( size.width * circ.radius).to_i )
76
+ end
77
+ end
78
+ end
79
+
80
+ # Test if the target was hit, and generate a TargetHitEvent if so
81
+ def on_left_down(evt)
82
+ # quick bit of pythagoras...
83
+ distance = Math.sqrt( ( evt.x - centre_point ) ** 2 +
84
+ ( evt.y - centre_point ) ** 2 )
85
+ # See which target ring, if any, was hit by the event
86
+ @radii.each do | circ |
87
+ if distance < ( size.width * circ.radius)
88
+ # Create an instance of the event
89
+ evt = TargetHitEvent.new(self, circ.score, distance)
90
+ # This sends the event for processing by listeners
91
+ event_handler.process_event(evt)
92
+ break
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ # Container frame for the target control
99
+ class TargetFrame < Wx::Frame
100
+ def initialize(title)
101
+ super(nil, :title => title, :size => [300, 300])
102
+ @tgt = TargetControl.new(self)
103
+ # This user-defined event handling method was set up by
104
+ # EvtHandler.register_class, above
105
+ evt_target(@tgt.get_id) { | e | on_target(e) }
106
+ @listening = true
107
+ evt_size { | e | on_size(e) }
108
+ setup_menus
109
+ create_status_bar
110
+ end
111
+
112
+ # What's done when the target is hit
113
+ def on_target(evt)
114
+ msg = "Target hit for score %i, %.2f pixels from centre" %
115
+ [ evt.score, evt.distance ]
116
+ self.status_text = msg
117
+ end
118
+
119
+ # Keep the target centred and square
120
+ def on_size(evt)
121
+ smaller = [ evt.size.width, evt.size.height ].min
122
+ @tgt.centre
123
+ @tgt.size = Wx::Size.new(smaller, smaller)
124
+ @tgt.refresh
125
+ end
126
+
127
+ # Toggle whether or not we are listening for events from the bulls-eye
128
+ # target
129
+ def on_toggle_connect
130
+ if @listening
131
+ # Remove :evt_target event handler for the @tgt
132
+ disconnect(@tgt.get_id, Wx::ID_ANY, :evt_target)
133
+ menu_bar.check(TOGGLE_LISTEN, false)
134
+ self.status_text = "Ignoring target events"
135
+ @listening = false
136
+ else
137
+ # Restore evt_target event handler for the @tgt
138
+ evt_target(@tgt.get_id) { | e | on_target(e) }
139
+ menu_bar.check(TOGGLE_LISTEN, true)
140
+ self.status_text = ''
141
+ @listening = true
142
+ end
143
+ end
144
+
145
+ def on_about
146
+ msg = sprintf("This is the About dialog of the event handling sample.\n" \
147
+ "Welcome to wxRuby, version %s", Wx::WXRUBY_VERSION)
148
+
149
+ about_dlg = Wx::MessageDialog.new( self, msg, 'About Event Handling',
150
+ Wx::OK|Wx::ICON_INFORMATION )
151
+ about_dlg.show_modal
152
+
153
+ end
154
+
155
+ TOGGLE_LISTEN = 1001
156
+ def setup_menus
157
+ menu_file = Wx::Menu.new
158
+ menu_help = Wx::Menu.new
159
+ menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
160
+ evt_menu(Wx::ID_ABOUT) { on_about }
161
+ menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
162
+ evt_menu(Wx::ID_EXIT) { self.close }
163
+ menu_file.append_check_item(TOGGLE_LISTEN, "L&isten for events",
164
+ "Toggle listening for target events")
165
+ evt_menu(TOGGLE_LISTEN) { on_toggle_connect }
166
+
167
+ menu_bar = Wx::MenuBar.new
168
+ menu_bar.append(menu_file, "&File")
169
+ menu_bar.append(menu_help, "&Help")
170
+
171
+ self.menu_bar = menu_bar
172
+ menu_bar.check(TOGGLE_LISTEN, true)
173
+ end
174
+ end
175
+
176
+ class TargetApp < Wx::App
177
+ def on_init
178
+ TargetFrame.new("Event Handling Sample").show
179
+ return true
180
+ end
181
+ end
182
+
183
+ a = TargetApp.new
184
+ a.main_loop()
@@ -15,20 +15,14 @@ end
15
15
 
16
16
  # The frame or self-contained window for this application
17
17
  class MinimalFrame < Wx::Frame
18
- def initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE)
18
+ def initialize(title)
19
19
 
20
20
  # A main application frame has no parent (nil)
21
- # -1 means this frame will be supplied a default id
22
- super(nil, -1, title, pos, size, style)
21
+ super(nil, :title => title, :size => [ 400, 300 ])
23
22
 
24
- # Set the frame's icon - use .ico on windows, else .xpm
25
- if Wx::PLATFORM == "WXMSW"
26
- set_icon( Wx::Icon.new(local_icon_file("mondrian.ico"),
27
- Wx::BITMAP_TYPE_ICO) )
28
- else
29
- set_icon( Wx::Icon.new(local_icon_file("mondrian.xpm"),
30
- Wx::BITMAP_TYPE_XPM) )
31
- end
23
+ # PNG is a good choice for cross-platofrm icons
24
+ icon_file = File.join( File.dirname(__FILE__), 'mondrian.png')
25
+ self.icon = Wx::Icon.new(icon_file)
32
26
 
33
27
  menu_file = Wx::Menu.new()
34
28
  menu_help = Wx::Menu.new()
@@ -66,11 +60,6 @@ class MinimalFrame < Wx::Frame
66
60
  Wx::OK|Wx::ICON_INFORMATION )
67
61
  about_dlg.show_modal
68
62
  end
69
-
70
- # utility function to find an icon relative to this ruby script
71
- def local_icon_file(icon_name)
72
- File.join( File.dirname(__FILE__), icon_name)
73
- end
74
63
  end
75
64
 
76
65
  # Wx::App is the container class for any wxruby app - only a single
@@ -79,13 +68,12 @@ class MinimalApp < Wx::App
79
68
  # This method is called when main_loop is entered; it should set up
80
69
  # the application's and display initial GUI windows.
81
70
  def on_init
82
- frame = MinimalFrame.new("Minimal wxRuby App",
83
- Wx::Point.new(50, 50),
84
- Wx::Size.new(450, 340))
85
- set_app_name('Minimal')
86
- # This is required, and on_init must return a true value else the
87
- # app will not start
88
- frame.show()
71
+ self.app_name = 'Minimal'
72
+ frame = MinimalFrame.new("Minimal wxRuby App")
73
+ # This is required,
74
+ frame.show
75
+ # on_init must return a true value else the app will not start
76
+ true
89
77
  end
90
78
  end
91
79
 
Binary file
@@ -24,12 +24,6 @@ class MyFrame < Frame
24
24
  def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE)
25
25
  super(nil,-1,title,pos,size,style)
26
26
 
27
- if Wx::PLATFORM == "WXMSW"
28
- set_icon(Icon.new("mondrian.ico",BITMAP_TYPE_ICO))
29
- else
30
- set_icon(Icon.new("mondrian.xpm",BITMAP_TYPE_XPM))
31
- end
32
-
33
27
  menuFile = Menu.new()
34
28
  menuFile.append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program")
35
29
 
@@ -51,23 +45,23 @@ class MyFrame < Frame
51
45
  create_status_bar(2)
52
46
  set_status_text("Welcome to wxRuby!")
53
47
 
54
- @sci = Wx::Scintilla.new(self)
48
+ @sci = Wx::StyledTextCtrl.new(self)
55
49
 
56
50
  font = Font.new(10, TELETYPE, NORMAL, NORMAL)
57
- @sci.style_set_font(SCI_STYLE_DEFAULT, font);
51
+ @sci.style_set_font(STC_STYLE_DEFAULT, font);
58
52
 
59
53
  @ws_visible = false
60
54
  @eol_visible = false
61
- @sci.set_edge_mode(SCI_EDGE_LINE)
55
+ @sci.set_edge_mode(STC_EDGE_LINE)
62
56
 
63
- line_num_margin = @sci.text_width(SCI_STYLE_LINENUMBER, "_99999")
57
+ line_num_margin = @sci.text_width(STC_STYLE_LINENUMBER, "_99999")
64
58
  @sci.set_margin_width(0, line_num_margin)
65
59
 
66
- @sci.style_set_foreground(SCI_STYLE_DEFAULT, BLACK);
67
- @sci.style_set_background(SCI_STYLE_DEFAULT, WHITE);
68
- @sci.style_set_foreground(SCI_STYLE_LINENUMBER, LIGHT_GREY);
69
- @sci.style_set_background(SCI_STYLE_LINENUMBER, WHITE);
70
- @sci.style_set_foreground(SCI_STYLE_INDENTGUIDE, LIGHT_GREY);
60
+ @sci.style_set_foreground(STC_STYLE_DEFAULT, BLACK);
61
+ @sci.style_set_background(STC_STYLE_DEFAULT, WHITE);
62
+ @sci.style_set_foreground(STC_STYLE_LINENUMBER, LIGHT_GREY);
63
+ @sci.style_set_background(STC_STYLE_LINENUMBER, WHITE);
64
+ @sci.style_set_foreground(STC_STYLE_INDENTGUIDE, LIGHT_GREY);
71
65
 
72
66
  @sci.set_tab_width(4)
73
67
  @sci.set_use_tabs(false)
@@ -76,7 +70,7 @@ class MyFrame < Frame
76
70
  @sci.set_indent(4)
77
71
  @sci.set_edge_column(80)
78
72
 
79
- @sci.set_lexer(SCI_LEX_RUBY)
73
+ @sci.set_lexer(STC_LEX_RUBY)
80
74
  @sci.style_clear_all
81
75
  @sci.style_set_foreground(2, RED)
82
76
  @sci.style_set_foreground(3, GREEN)
@@ -91,17 +85,17 @@ class MyFrame < Frame
91
85
  @sci.set_property("fold.preprocessor", "1")
92
86
 
93
87
  @sci.set_margin_width(1, 0)
94
- @sci.set_margin_type(1, SCI_MARGIN_SYMBOL)
95
- @sci.set_margin_mask(1, SCI_MASK_FOLDERS)
88
+ @sci.set_margin_type(1, STC_MARGIN_SYMBOL)
89
+ @sci.set_margin_mask(1, STC_MASK_FOLDERS)
96
90
  @sci.set_margin_width(1, 20)
97
91
 
98
- @sci.marker_define(SCI_MARKNUM_FOLDER, SCI_MARK_PLUS)
99
- @sci.marker_define(SCI_MARKNUM_FOLDEROPEN, SCI_MARK_MINUS)
100
- @sci.marker_define(SCI_MARKNUM_FOLDEREND, SCI_MARK_EMPTY)
101
- @sci.marker_define(SCI_MARKNUM_FOLDERMIDTAIL, SCI_MARK_EMPTY)
102
- @sci.marker_define(SCI_MARKNUM_FOLDEROPENMID, SCI_MARK_EMPTY)
103
- @sci.marker_define(SCI_MARKNUM_FOLDERSUB, SCI_MARK_EMPTY)
104
- @sci.marker_define(SCI_MARKNUM_FOLDERTAIL, SCI_MARK_EMPTY)
92
+ @sci.marker_define(STC_MARKNUM_FOLDER, STC_MARK_PLUS)
93
+ @sci.marker_define(STC_MARKNUM_FOLDEROPEN, STC_MARK_MINUS)
94
+ @sci.marker_define(STC_MARKNUM_FOLDEREND, STC_MARK_EMPTY)
95
+ @sci.marker_define(STC_MARKNUM_FOLDERMIDTAIL, STC_MARK_EMPTY)
96
+ @sci.marker_define(STC_MARKNUM_FOLDEROPENMID, STC_MARK_EMPTY)
97
+ @sci.marker_define(STC_MARKNUM_FOLDERSUB, STC_MARK_EMPTY)
98
+ @sci.marker_define(STC_MARKNUM_FOLDERTAIL, STC_MARK_EMPTY)
105
99
  @sci.set_fold_flags(16)
106
100
 
107
101
  @sci.set_margin_sensitive(1,1)
@@ -110,8 +104,8 @@ class MyFrame < Frame
110
104
  evt_menu(Minimal_About) {onAbout}
111
105
  evt_menu(Toggle_Whitespace) {onWhitespace}
112
106
  evt_menu(Toggle_EOL) {onEOL}
113
- evt_sci_charadded {|evt| onCharadded(evt)}
114
- evt_sci_marginclick {|evt| onMarginClick(evt)}
107
+ evt_stc_charadded(@sci.get_id) {|evt| onCharadded(evt)}
108
+ evt_stc_marginclick(@sci.get_id) {|evt| onMarginClick(evt)}
115
109
 
116
110
  end
117
111
 
@@ -130,7 +124,7 @@ class MyFrame < Frame
130
124
 
131
125
  def onWhitespace
132
126
  @ws_visible = !@ws_visible
133
- @sci.set_view_white_space(@ws_visible ? SCI_WS_VISIBLEALWAYS : SCI_WS_INVISIBLE)
127
+ @sci.set_view_white_space(@ws_visible ? STC_WS_VISIBLEALWAYS : STC_WS_INVISIBLE)
134
128
  end
135
129
 
136
130
  def onEOL
@@ -102,7 +102,7 @@ class IConvFrame < Wx::Frame
102
102
 
103
103
  sizer.add(ctrl_sizer, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2)
104
104
  construct_menus()
105
- panel.set_sizer( sizer )
105
+ panel.set_sizer_and_fit( sizer )
106
106
  end
107
107
 
108
108
  # Prompt the user to specify a file whose contents should be loaded