nobody at rubyforge.org
2006-Nov-13 08:31 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:'':'';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>736</dd> <dt>Author</dt> <dd>seanlong</dd> <dt>Date</dt> <dd>2006-11-13 03:31:06 -0500 (Mon, 13 Nov 2006)</dd> </dl> <h3>Log Message</h3> <pre>Fixed crashing bug in on_paint and made the code style more Ruby like.</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2samplesdialogsdialogsrb">trunk/wxruby2/samples/dialogs/dialogs.rb</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2samplesdialogsdialogsrb"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/samples/dialogs/dialogs.rb (735 => 736)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/dialogs/dialogs.rb        2006-11-13 07:21:40 UTC (rev 735) +++ trunk/wxruby2/samples/dialogs/dialogs.rb        2006-11-13 08:31:06 UTC (rev 736) </span><span class="lines">@@ -40,42 +40,42 @@ </span><span class="cx"> DIALOGS_FIND = 24 </span><span class="cx"> DIALOGS_REPLACE = 25 </span><span class="cx"> </span><del>-$myCanvas = nil </del><ins>+$my_canvas = nil </ins><span class="cx"> </span><span class="cx"> class MyModalDialog < Dialog </span><span class="cx"> def initialize(parent) </span><span class="cx"> super(parent, -1, "Modal dialog") </span><span class="cx"> </span><del>- sizerTop = BoxSizer.new(HORIZONTAL) </del><ins>+ sizer_top = BoxSizer.new(HORIZONTAL) </ins><span class="cx"> </span><del>- @m_btnFocused = Button.new(self, -1, "Default button") - @m_btnDelete = Button.new(self, -1, "&Delete button") - btnOk = Button.new(self, ID_CANCEL, "&Close") - sizerTop.add(@m_btnFocused, 0, ALIGN_CENTER | ALL, 5) - sizerTop.add(@m_btnDelete, 0, ALIGN_CENTER | ALL, 5) - sizerTop.add(btnOk, 0, ALIGN_CENTER | ALL, 5) </del><ins>+ @btn_focused = Button.new(self, -1, "Default button") + @btn_delete = Button.new(self, -1, "&Delete button") + btn_ok = Button.new(self, ID_CANCEL, "&Close") + sizer_top.add(@btn_focused, 0, ALIGN_CENTER | ALL, 5) + sizer_top.add(@btn_delete, 0, ALIGN_CENTER | ALL, 5) + sizer_top.add(btn_ok, 0, ALIGN_CENTER | ALL, 5) </ins><span class="cx"> </span><del>- set_auto_layout(TRUE) - set_sizer(sizerTop) </del><ins>+ set_auto_layout(true) + set_sizer(sizer_top) </ins><span class="cx"> </span><del>- sizerTop.set_size_hints(self) - sizerTop.fit(self) </del><ins>+ sizer_top.set_size_hints(self) + sizer_top.fit(self) </ins><span class="cx"> </span><del>- @m_btnFocused.set_focus() - @m_btnFocused.set_default() </del><ins>+ @btn_focused.set_focus() + @btn_focused.set_default() </ins><span class="cx"> </span><del>- evt_button(-1) {|event| onButton(event) } </del><ins>+ evt_button(-1) {|event| on_button(event) } </ins><span class="cx"> end </span><span class="cx"> </span><del>- def onButton(event) </del><ins>+ def on_button(event) </ins><span class="cx"> id = event.get_id </span><span class="cx"> </span><del>- if id == @m_btnDelete.get_id - @m_btnFocused.destroy - @m_btnFocused = nil </del><ins>+ if id == @btn_delete.get_id + @btn_focused.destroy + @btn_focused = nil </ins><span class="cx"> </span><del>- @m_btnDelete.disable() - elsif @m_btnFocused && id == @m_btnFocused.get_id </del><ins>+ @btn_delete.disable() + elsif @btn_focused && id == @btn_focused.get_id </ins><span class="cx"> get_text_from_user("Dummy prompt", "Modal dialog called from dialog", </span><span class="cx"> "", self) </span><span class="cx"> else </span><span class="lines">@@ -89,33 +89,33 @@ </span><span class="cx"> def initialize(parent) </span><span class="cx"> super(parent, -1, "Modeless dialog") </span><span class="cx"> </span><del>- sizerTop = BoxSizer.new(VERTICAL) </del><ins>+ sizer_top = BoxSizer.new(VERTICAL) </ins><span class="cx"> </span><span class="cx"> btn = Button.new(self, DIALOGS_MODELESS_BTN, "Press me") </span><span class="cx"> check = CheckBox.new(self, -1, "Should be disabled") </span><span class="cx"> check.disable() </span><span class="cx"> </span><del>- sizerTop.add(btn, 1, EXPAND | ALL, 5) - sizerTop.add(check, 1, EXPAND | ALL, 5) </del><ins>+ sizer_top.add(btn, 1, EXPAND | ALL, 5) + sizer_top.add(check, 1, EXPAND | ALL, 5) </ins><span class="cx"> </span><del>- set_auto_layout(TRUE) - set_sizer(sizerTop) </del><ins>+ set_auto_layout(true) + set_sizer(sizer_top) </ins><span class="cx"> </span><del>- sizerTop.set_size_hints(self) - sizerTop.fit(self) </del><ins>+ sizer_top.set_size_hints(self) + sizer_top.fit(self) </ins><span class="cx"> </span><del>- evt_button(DIALOGS_MODELESS_BTN) {|event| onButton(event) } </del><ins>+ evt_button(DIALOGS_MODELESS_BTN) {|event| on_button(event) } </ins><span class="cx"> </span><del>- evt_close() {|event| onClose(event) } </del><ins>+ evt_close() {|event| on_close(event) } </ins><span class="cx"> </span><span class="cx"> end </span><span class="cx"> </span><del>- def onButton(event) </del><ins>+ def on_button(event) </ins><span class="cx"> message_box("Button pressed in modeless dialog", "Info", </span><span class="cx"> OK | ICON_INFORMATION, self) </span><span class="cx"> end </span><span class="cx"> </span><del>- def onClose(event) </del><ins>+ def on_close(event) </ins><span class="cx"> if event.can_veto() </span><span class="cx"> message_box("Use the menu item to close self dialog", </span><span class="cx"> "Modeless dialog", </span><span class="lines">@@ -138,11 +138,10 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> def on_paint(event) </span><del>- paint do | dc | - dc.set_text_foreground( get_app.canvas_text_colour ) - dc.set_font( get_app.canvas_font ) - dc.draw_text("Windows common dialogs test application", 10, 10) - end </del><ins>+ dc = PaintDC.new(self) + dc.set_text_foreground( get_app.canvas_text_colour ) + dc.set_font( get_app.canvas_font ) + dc.draw_text("Windows common dialogs test application", 10, 10) </ins><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><span class="lines">@@ -153,57 +152,57 @@ </span><span class="cx"> size) </span><span class="cx"> super(parent, -1, title, pos, size) </span><span class="cx"> </span><del>- @m_dialog = nil </del><ins>+ @dialog = nil </ins><span class="cx"> </span><del>- @m_dlgFind = nil - @m_dlgReplace = nil </del><ins>+ @dlg_find = nil + @dlg_replace = nil </ins><span class="cx"> </span><del>- @m_findData = FindReplaceData.new </del><ins>+ @find_data = FindReplaceData.new </ins><span class="cx"> </span><del>- @s_extDef = "" - @s_index = -1 </del><ins>+ @ext_def = "" + @index = -1 </ins><span class="cx"> </span><span class="cx"> @max = 10 </span><span class="cx"> </span><span class="cx"> create_status_bar() </span><span class="cx"> </span><del>- evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| onChooseColour(event) } - evt_menu(DIALOGS_CHOOSE_FONT) {|event| onChooseFont(event) } - evt_menu(DIALOGS_LOG_DIALOG) {|event| onLogDialog(event) } - evt_menu(DIALOGS_MESSAGE_BOX) {|event| onMessageBox(event) } - evt_menu(DIALOGS_TEXT_ENTRY) {|event| onTextEntry(event) } - evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| onPasswordEntry(event) } - evt_menu(DIALOGS_NUM_ENTRY) {|event| onNumericEntry(event) } - evt_menu(DIALOGS_SINGLE_CHOICE) {|event| onSingleChoice(event) } - evt_menu(DIALOGS_MULTI_CHOICE) {|event| onMultiChoice(event) } - evt_menu(DIALOGS_FILE_OPEN) {|event| onFileOpen(event) } - evt_menu(DIALOGS_FILE_OPEN2) {|event| onFileOpen2(event) } - evt_menu(DIALOGS_FILES_OPEN) {|event| onFilesOpen(event) } - evt_menu(DIALOGS_FILE_SAVE) {|event| onFileSave(event) } - evt_menu(DIALOGS_DIR_CHOOSE) {|event| onDirChoose(event) } - evt_menu(DIALOGS_MODAL) {|event| onModalDlg(event) } - evt_menu(DIALOGS_MODELESS) {|event| onModelessDlg(event) } - evt_menu(DIALOGS_TIP) {|event| onShowTip(event) } - evt_menu(DIALOGS_PROGRESS) {|event| onShowProgress(event) } - evt_menu(DIALOGS_BUSYINFO) {|event| onShowBusyInfo(event) } - evt_menu(DIALOGS_FIND) {|event| onShowFindDialog(event) } - evt_menu(DIALOGS_REPLACE) {|event| onShowReplaceDialog(event) } - evt_find(-1) {|event| onFindDialog(event) } - evt_find_next(-1) {|event| onFindDialog(event) } - evt_find_replace(-1) {|event| onFindDialog(event) } - evt_find_replace_all(-1) {|event| onFindDialog(event) } - evt_find_close(-1) {|event| onFindDialog(event) } - evt_menu(ID_EXIT) {|event| onExit(event) } </del><ins>+ evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| on_choose_colour(event) } + evt_menu(DIALOGS_CHOOSE_FONT) {|event| on_choose_font(event) } + evt_menu(DIALOGS_LOG_DIALOG) {|event| on_log_dialog(event) } + evt_menu(DIALOGS_MESSAGE_BOX) {|event| on_message_box(event) } + evt_menu(DIALOGS_TEXT_ENTRY) {|event| on_text_entry(event) } + evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| on_password_entry(event) } + evt_menu(DIALOGS_NUM_ENTRY) {|event| on_numeric_entry(event) } + evt_menu(DIALOGS_SINGLE_CHOICE) {|event| on_single_choice(event) } + evt_menu(DIALOGS_MULTI_CHOICE) {|event| on_multi_choice(event) } + evt_menu(DIALOGS_FILE_OPEN) {|event| on_file_open(event) } + evt_menu(DIALOGS_FILE_OPEN2) {|event| on_file_open2(event) } + evt_menu(DIALOGS_FILES_OPEN) {|event| on_files_open(event) } + evt_menu(DIALOGS_FILE_SAVE) {|event| on_file_save(event) } + evt_menu(DIALOGS_DIR_CHOOSE) {|event| on_dir_choose(event) } + evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) } + evt_menu(DIALOGS_MODELESS) {|event| on_modeless_dlg(event) } + evt_menu(DIALOGS_TIP) {|event| on_show_tip(event) } + evt_menu(DIALOGS_PROGRESS) {|event| on_show_progress(event) } + evt_menu(DIALOGS_BUSYINFO) {|event| on_show_busy_info(event) } + evt_menu(DIALOGS_FIND) {|event| on_show_find_dialog(event) } + evt_menu(DIALOGS_REPLACE) {|event| on_show_replace_dialog(event) } + evt_find(-1) {|event| on_find_dialog(event) } + evt_find_next(-1) {|event| on_find_dialog(event) } + evt_find_replace(-1) {|event| on_find_dialog(event) } + evt_find_replace_all(-1) {|event| on_find_dialog(event) } + evt_find_close(-1) {|event| on_find_dialog(event) } + evt_menu(ID_EXIT) {|event| on_exit(event) } </ins><span class="cx"> </span><span class="cx"> end </span><span class="cx"> </span><del>- def onChooseColour(event) </del><ins>+ def on_choose_colour(event) </ins><span class="cx"> </span><del>- col = $myCanvas.get_background_colour() </del><ins>+ col = $my_canvas.get_background_colour() </ins><span class="cx"> </span><span class="cx"> data = ColourData.new </span><span class="cx"> data.set_colour(col) </span><del>- data.set_choose_full(TRUE) </del><ins>+ data.set_choose_full(true) </ins><span class="cx"> for i in 0 ... 16 </span><span class="cx"> colour = Colour.new(i*16, i*16, i*16) </span><span class="cx"> data.set_custom_colour(i, colour) </span><span class="lines">@@ -214,14 +213,14 @@ </span><span class="cx"> if dialog.show_modal() == ID_OK </span><span class="cx"> retData = dialog.get_colour_data() </span><span class="cx"> col = retData.get_colour() </span><del>- $myCanvas.set_background_colour(col) - #$myCanvas.clear() - $myCanvas.refresh() </del><ins>+ $my_canvas.set_background_colour(col) + #$my_canvas.clear() + $my_canvas.refresh() </ins><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onChooseFont(event) </del><ins>+ def on_choose_font(event) </ins><span class="cx"> data = FontData.new </span><span class="cx"> data.set_initial_font(Wx::get_app.canvas_font) </span><span class="cx"> data.set_colour(Wx::get_app.canvas_text_colour) </span><span class="lines">@@ -229,21 +228,21 @@ </span><span class="cx"> dialog = FontDialog.new(self, data) </span><span class="cx"> </span><span class="cx"> if dialog.show_modal() == ID_OK </span><del>- retData = dialog.get_font_data() - Wx::get_app.canvas_font = retData.get_chosen_font() - Wx::get_app.canvas_text_colour = retData.get_colour() - font = retData.get_chosen_font </del><ins>+ ret_data = dialog.get_font_data() + Wx::get_app.canvas_font = ret_data.get_chosen_font() + Wx::get_app.canvas_text_colour = ret_data.get_colour() + font = ret_data.get_chosen_font </ins><span class="cx"> msg = "Font = %s, %i pt" % [ font.get_face_name, </span><span class="cx"> font.get_point_size ] </span><span class="cx"> dialog2 = MessageDialog.new(self, msg, "Got font") </span><span class="cx"> dialog2.show_modal() </span><del>- # $myCanvas.refresh() </del><ins>+ # $my_canvas.refresh() </ins><span class="cx"> end </span><span class="cx"> #else: cancelled by the user, don''t change the font </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onLogDialog(event) </del><ins>+ def on_log_dialog(event) </ins><span class="cx"> </span><span class="cx"> # calling yield() (as ~BusyCursor does) shouldn''t result in messages </span><span class="cx"> # being flushed -- test it </span><span class="lines">@@ -263,10 +262,10 @@ </span><span class="cx"> Log::flush_active() </span><span class="cx"> </span><span class="cx"> log_message("And this is the same dialog but with only one message.") </span><del>-        end </del><ins>+         end </ins><span class="cx"> end </span><span class="cx"> </span><del>- def onMessageBox(event) </del><ins>+ def on_message_box(event) </ins><span class="cx"> </span><span class="cx"> dialog = MessageDialog.new(nil, "This is a message box\nA long, long string to test out the message box properly", </span><span class="cx"> "Message box text", NO_DEFAULT|YES_NO|CANCEL|ICON_INFORMATION) </span><span class="lines">@@ -284,7 +283,7 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onNumericEntry(event) </del><ins>+ def on_numeric_entry(event) </ins><span class="cx"> </span><span class="cx"> res = get_number_from_user( "This is some text, actually a lot of text.\n" + </span><span class="cx"> "Even two rows of text.", </span><span class="lines">@@ -302,7 +301,7 @@ </span><span class="cx"> message_box(msg, "Numeric test result", OK | icon, self) </span><span class="cx"> end </span><span class="cx"> </span><del>- def onPasswordEntry(event) </del><ins>+ def on_password_entry(event) </ins><span class="cx"> </span><span class="cx"> pwd = get_password_from_user("Enter password:", </span><span class="cx"> "Password entry dialog", </span><span class="lines">@@ -314,7 +313,7 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onTextEntry(event) </del><ins>+ def on_text_entry(event) </ins><span class="cx"> </span><span class="cx"> dialog = TextEntryDialog.new(self, </span><span class="cx"> "This is a small sample\n" + </span><span class="lines">@@ -329,7 +328,7 @@ </span><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><del>- def onSingleChoice(event) </del><ins>+ def on_single_choice(event) </ins><span class="cx"> </span><span class="cx"> choices = ["One", "Two", "Three", "Four", "Five"] </span><span class="cx"> </span><span class="lines">@@ -348,7 +347,7 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onMultiChoice(event) </del><ins>+ def on_multi_choice(event) </ins><span class="cx"> </span><span class="cx"> choices = [ </span><span class="cx"> "One", "Two", "Three", "Four", "Five", </span><span class="lines">@@ -372,7 +371,7 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onFileOpen(event) </del><ins>+ def on_file_open(event) </ins><span class="cx"> </span><span class="cx"> dialog = FileDialog.new( </span><span class="cx"> self, </span><span class="lines">@@ -400,12 +399,12 @@ </span><span class="cx"> # this shows how to take advantage of specifying a default extension in the </span><span class="cx"> # call to FileSelector: it is remembered after each new call and the next </span><span class="cx"> # one will use it by default </span><del>- def onFileOpen2(event) </del><ins>+ def on_file_open2(event) </ins><span class="cx"> </span><span class="cx"> path = file_selector( </span><span class="cx"> "Select the file to load", </span><span class="cx"> "", "", </span><del>- @s_extDef, </del><ins>+ @ext_def, </ins><span class="cx"> "Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*", </span><span class="cx"> CHANGE_DIR, </span><span class="cx"> self </span><span class="lines">@@ -416,14 +415,14 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> # it is just a sample, would use SplitPath in real program </span><del>- @s_extDef = path[/[^\.]*$/] </del><ins>+ @ext_def = path[/[^\.]*$/] </ins><span class="cx"> </span><span class="cx"> log_message("You selected the file ''%s'', remembered extension ''%s''", </span><del>- path, @s_extDef) </del><ins>+ path, @ext_def) </ins><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onFilesOpen(event) </del><ins>+ def on_files_open(event) </ins><span class="cx"> </span><span class="cx"> dialog = FileDialog.new(self, "Testing open multiple file dialog", </span><span class="cx"> "", "", FILE_SELECTOR_DEFAULT_WILDCARD_STR, </span><span class="lines">@@ -448,7 +447,7 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onFileSave(event) </del><ins>+ def on_file_save(event) </ins><span class="cx"> </span><span class="cx"> dialog = FileDialog.new(self, </span><span class="cx"> "Testing save file dialog", </span><span class="lines">@@ -466,12 +465,12 @@ </span><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><del>- def onDirChoose(event) </del><ins>+ def on_dir_choose(event) </ins><span class="cx"> </span><span class="cx"> # pass some initial dir to DirDialog </span><del>- dirHome = get_home_dir() </del><ins>+ dir_home = get_home_dir() </ins><span class="cx"> </span><del>- dialog = DirDialog.new(self, "Testing directory picker", dirHome) </del><ins>+ dialog = DirDialog.new(self, "Testing directory picker", dir_home) </ins><span class="cx"> </span><span class="cx"> if dialog.show_modal() == ID_OK </span><span class="cx"> log_message("Selected path: %s", dialog.get_path()) </span><span class="lines">@@ -479,50 +478,50 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onModalDlg(event) </del><ins>+ def on_modal_dlg(event) </ins><span class="cx"> dlg = MyModalDialog.new(self) </span><span class="cx"> dlg.show_modal() </span><span class="cx"> end </span><span class="cx"> </span><del>- def onModelessDlg(event) </del><ins>+ def on_modeless_dlg(event) </ins><span class="cx"> show = get_menu_bar().is_checked(event.get_id()) </span><span class="cx"> if show </span><del>- if !@m_dialog - @m_dialog = MyModelessDialog.new(self) </del><ins>+ if !@dialog + @dialog = MyModelessDialog.new(self) </ins><span class="cx"> end </span><del>- @m_dialog.show(TRUE) </del><ins>+ @dialog.show(true) </ins><span class="cx"> else # hide </span><del>- @m_dialog.hide() </del><ins>+ @dialog.hide() </ins><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onShowTip(event) </del><ins>+ def on_show_tip(event) </ins><span class="cx"> </span><del>- if @s_index == -1 - @s_index = rand(5) </del><ins>+ if @index == -1 + @index = rand(5) </ins><span class="cx"> end </span><span class="cx"> </span><span class="cx"> tip_src = File.join( File.dirname(__FILE__), ''tips.txt'') </span><del>- tipProvider = create_file_tip_provider(tip_src, @s_index) </del><ins>+ tip_provider = create_file_tip_provider(tip_src, @index) </ins><span class="cx"> </span><del>- showAtStartup = show_tip(self, tipProvider) </del><ins>+ show_at_startup = show_tip(self, tip_provider) </ins><span class="cx"> </span><del>- if showAtStartup </del><ins>+ if show_at_startup </ins><span class="cx"> message_box("Will show tips on startup", "Tips dialog", </span><span class="cx"> OK | ICON_INFORMATION, self) </span><span class="cx"> end </span><span class="cx"> </span><del>- @s_index = tipProvider.get_current_tip() </del><ins>+ @index = tip_provider.get_current_tip() </ins><span class="cx"> </span><span class="cx"> end </span><span class="cx"> </span><del>- def onExit(event) - close(TRUE) </del><ins>+ def on_exit(event) + close(true) </ins><span class="cx"> end </span><span class="cx"> </span><span class="cx"> </span><del>- def onShowProgress(event) </del><ins>+ def on_show_progress(event) </ins><span class="cx"> </span><span class="cx"> dialog = ProgressDialog.new("Progress dialog example", </span><span class="cx"> "An informative message", </span><span class="lines">@@ -562,7 +561,7 @@ </span><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><del>- def onShowBusyInfo(event) </del><ins>+ def on_show_busy_info(event) </ins><span class="cx"> WindowDisabler.disable(self) do </span><span class="cx"> info = BusyInfo.busy("Working, please wait...", self) do </span><span class="cx"> </span><span class="lines">@@ -574,41 +573,41 @@ </span><span class="cx">         end </span><span class="cx"> end </span><span class="cx"> </span><del>- def onShowReplaceDialog(event) </del><ins>+ def on_show_replace_dialog(event) </ins><span class="cx"> </span><del>- if @m_dlgReplace - #@m_dlgReplace.destroy - @m_dlgReplace = nil </del><ins>+ if @dlg_replace + #@dlg_replace.destroy + @dlg_replace = nil </ins><span class="cx"> else </span><del>- @m_dlgReplace = FindReplaceDialog.new( </del><ins>+ @dlg_replace = FindReplaceDialog.new( </ins><span class="cx"> self, </span><del>- @m_findData, </del><ins>+ @find_data, </ins><span class="cx"> "Find and replace dialog", </span><span class="cx"> FR_REPLACEDIALOG </span><span class="cx"> ) </span><span class="cx"> </span><del>- @m_dlgReplace.show(TRUE) </del><ins>+ @dlg_replace.show(true) </ins><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><del>- def onShowFindDialog(event) </del><ins>+ def on_show_find_dialog(event) </ins><span class="cx"> </span><del>- if @m_dlgFind - @m_dlgFind.destroy - @m_dlgFind = nil </del><ins>+ if @dlg_find + @dlg_find.destroy + @dlg_find = nil </ins><span class="cx"> else </span><del>- @m_dlgFind = FindReplaceDialog.new( </del><ins>+ @dlg_find = FindReplaceDialog.new( </ins><span class="cx"> self, </span><del>- @m_findData, </del><ins>+ @find_data, </ins><span class="cx"> "Find dialog", # just for testing </span><span class="cx"> FR_NOWHOLEWORD </span><span class="cx"> ) </span><span class="cx"> </span><del>- @m_dlgFind.show(TRUE) </del><ins>+ @dlg_find.show(true) </ins><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><del>- def DecodeFindDialogEventFlags(flags) </del><ins>+ def decode_find_dialog_event_flags(flags) </ins><span class="cx"> str = "" </span><span class="cx"> str << ((flags & FR_DOWN) != 0 ? "down" : "up") << ", " \ </span><span class="cx"> << ((flags & FR_WHOLEWORD) != 0 ? "whole words only, " : "") \ </span><span class="lines">@@ -618,7 +617,7 @@ </span><span class="cx"> return str </span><span class="cx"> end </span><span class="cx"> </span><del>- def onFindDialog(event) </del><ins>+ def on_find_dialog(event) </ins><span class="cx"> </span><span class="cx"> type = event.get_event_type() </span><span class="cx"> </span><span class="lines">@@ -626,33 +625,33 @@ </span><span class="cx"> log_message("Find %s''%s'' (flags: %s)", </span><span class="cx"> type == EVT_COMMAND_FIND_NEXT ? "next " : "", </span><span class="cx"> event.get_find_string(), </span><del>- DecodeFindDialogEventFlags(event.get_flags())) </del><ins>+ decode_find_dialog_event_flags(event.get_flags())) </ins><span class="cx"> elsif type == EVT_COMMAND_FIND_REPLACE || type == EVT_COMMAND_FIND_REPLACE_ALL </span><span class="cx"> log_message("Replace %s''%s'' with ''%s'' (flags: %s)", </span><span class="cx"> type == EVT_COMMAND_FIND_REPLACE_ALL ? "all " : "", </span><span class="cx"> event.get_find_string(), </span><span class="cx"> event.get_replace_string(), </span><del>- DecodeFindDialogEventFlags(event.get_flags())) </del><ins>+ decode_find_dialog_event_flags(event.get_flags())) </ins><span class="cx"> elsif type == EVT_COMMAND_FIND_CLOSE </span><span class="cx"> dlg = event.get_dialog() </span><del>- if dlg == @m_dlgFind </del><ins>+ if dlg == @dlg_find </ins><span class="cx"> txt = "Find" </span><del>- idMenu = DIALOGS_FIND - @m_dlgFind = nil - elsif dlg == @m_dlgReplace </del><ins>+ id_menu = DIALOGS_FIND + @dlg_find = nil + elsif dlg == @dlg_replace </ins><span class="cx"> txt = "Replace" </span><del>- idMenu = DIALOGS_REPLACE - @m_dlgReplace = nil </del><ins>+ id_menu = DIALOGS_REPLACE + @dlg_replace = nil </ins><span class="cx"> else </span><span class="cx"> txt = "Unknown" </span><del>- idMenu = -1 </del><ins>+ id_menu = -1 </ins><span class="cx"> log_error("unexpected event") </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> log_message("%s dialog is being closed.", txt) </span><span class="cx"> </span><del>- if idMenu != -1 - get_menu_bar().check(idMenu, FALSE) </del><ins>+ if id_menu != -1 + get_menu_bar().check(id_menu, false) </ins><span class="cx"> end </span><span class="cx"> </span><span class="cx"> dlg.destroy() </span><span class="lines">@@ -709,8 +708,8 @@ </span><span class="cx"> menu_bar.append(file_menu, "&File") </span><span class="cx"> frame.set_menu_bar(menu_bar) </span><span class="cx"> </span><del>- $myCanvas = MyCanvas.new(frame) - $myCanvas.set_background_colour(WHITE) </del><ins>+ $my_canvas = MyCanvas.new(frame) + $my_canvas.set_background_colour(WHITE) </ins><span class="cx"> </span><span class="cx"> frame.centre(BOTH) </span><span class="cx"> </span></span></pre> </div> </div> </body> </html>
Alex Fenton
2006-Nov-13 09:08 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
Hi Sean thanks for patch. Can I ask what the crasher was within on_paint? A recent patch should have fixed the paint method with a block so want to track down if there is still a bug here. I think we are encouraging people to use the block form rather than instantiating a DC directly - hopefully we can use this to abstract away some of the complexity of the different DC classes. thanks alex nobody at rubyforge.org wrote:> > Revision > 736 > Author > seanlong > Date > 2006-11-13 03:31:06 -0500 (Mon, 13 Nov 2006) > > > Log Message > > Fixed crashing bug in on_paint and made the code style more Ruby like.
Sean Long
2006-Nov-13 15:48 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
On 11/13/06, Alex Fenton <alex at pressure.to> wrote:> Hi Sean > > thanks for patch. Can I ask what the crasher was within on_paint? A > recent patch should have fixed the paint method with a block so want to > track down if there is still a bug here.The block form did not work on OS X for me or FreeBSD so I changed it back for now. Where is this functionality being added in a *.i somewhere, I searched a few places and did not see where it was being added.> I think we are encouraging people to use the block form rather than > instantiating a DC directlyI like the block form and will gladly change it back when we have it working correctly. Did a file not get committed that is only on your working copy? Sean
Alex Fenton
2006-Nov-13 16:39 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
Hi Sean Sean Long wrote:> Where is this functionality being added in a *.i > somewhere, I searched a few places and did not see where it was being > added. >It''s now defined in Ruby, not using SWIG/C++. It''s in lib/wx/classes/window.rb - should be getting autoloaded by lib/wx.rb on start up. Looks to be in SVN I think? alex
Sean Long
2006-Nov-13 19:53 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
> It''s now defined in Ruby, not using SWIG/C++. It''s in > lib/wx/classes/window.rb - should be getting autoloaded by lib/wx.rb on > start up. Looks to be in SVN I think?The problem is that I test and run everything as a gem and the lib/wx/classes/ directory is not getting added to the created gem. When I have a minute I will try fixing the rakepackage.rb file. Sean
Alex Fenton
2006-Nov-13 20:54 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
Sean Long wrote:>> It''s now defined in Ruby, not using SWIG/C++. It''s in >> lib/wx/classes/window.rb - should be getting autoloaded by lib/wx.rb on >> start up. Looks to be in SVN I think? >> > > The problem is that I test and run everything as a gem and the > lib/wx/classes/ directory is not getting added to the created gem. > When I have a minute I will try fixing the rakepackage.rb file. >My bad. I fixed the install task but forgot to fix the gem task. The attached patch should do the trick. alex -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: rakepackage_rb.patch Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20061113/5744f92a/attachment.pl
Sean Long
2006-Nov-13 21:30 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
Does: pkg_files.include(''lib/wx/classes/*'') need to be added to create_package_tasks also? Before you sent your solution I did something very similar to your patch and added the line to the create_package_tasks. The version I made added the files correctly to the gem file. I have not done much with gem creation so I will yield to you on this one. Sean On 11/13/06, Alex Fenton <alex at pressure.to> wrote:> Sean Long wrote: > >> It''s now defined in Ruby, not using SWIG/C++. It''s in > >> lib/wx/classes/window.rb - should be getting autoloaded by lib/wx.rb on > >> start up. Looks to be in SVN I think? > >> > > > > The problem is that I test and run everything as a gem and the > > lib/wx/classes/ directory is not getting added to the created gem. > > When I have a minute I will try fixing the rakepackage.rb file. > > > My bad. I fixed the install task but forgot to fix the gem task. > > The attached patch should do the trick. > > alex > > > > > Index: wxruby2/rake/rakepackage.rb > ==================================================================> --- wxruby2/rake/rakepackage.rb (revision 736) > +++ wxruby2/rake/rakepackage.rb (working copy) > @@ -40,7 +40,7 @@ > spec.autorequire = ''wx'' > spec.require_path = ''lib'' > # Platform specific binaries are added in later > - spec.files = [ ''lib/wx.rb'', ''lib/wx/version.rb'' ] + > + spec.files = FileList[ ''lib/**/*'' ].to_a + > FileList[ ''samples/**/*'' ].to_a > > spec.has_rdoc = false > > > _______________________________________________ > Wxruby-development mailing list > Wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development > > >
Alex Fenton
2006-Nov-13 22:12 UTC
[Wxruby-development] [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.
Sean Long wrote:> Does: > > pkg_files.include(''lib/wx/classes/*'') > > need to be added to create_package_tasks also? >Yes, thanks for spotting this. I''m a bit dopey today. Patch committed to fix gem & tarball alex
Apparently Analagous Threads
- [916] branches/wxruby2/wxwidgets_282: More Wx::AUI classes, event hooks and sample
- [918] branches/wxruby2/wxwidgets_282/samples/aui/aui.rb: Fix a couple of little bugs and typos
- [903] branches/wxruby2/wxwidgets_282/samples: Added #!/usr/bin/env ruby to the grid sample.
- [731] trunk/wxruby2/samples/etc/sash.rb: Changed menu events so they call the correct method.
- pictorG