diff --git a/lib/wx/core/choicedlg.rb b/lib/wx/core/choicedlg.rb index dacf5308..8bcb8536 100644 --- a/lib/wx/core/choicedlg.rb +++ b/lib/wx/core/choicedlg.rb @@ -14,9 +14,8 @@ def self.get_single_choice(message, choices, parent = nil, initial_selection: 0, - x: Wx::DEFAULT_COORD, - y: Wx::DEFAULT_COORD) - dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, nil, Wx::CHOICEDLG_STYLE, [x, y]) + pos: Wx::DEFAULT_POSITION) + dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, pos) dialog.selection = initial_selection return dialog.show_modal == Wx::ID_OK ? dialog.get_string_selection : '' @@ -28,9 +27,8 @@ def self.get_single_choice_index(message, choices, parent = nil, initial_selection: 0, - x: Wx::DEFAULT_COORD, - y: Wx::DEFAULT_COORD) - dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, nil, Wx::CHOICEDLG_STYLE, [x, y]) + pos: Wx::DEFAULT_POSITION) + dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, pos) dialog.selection = initial_selection return dialog.show_modal == Wx::ID_OK ? dialog.get_selection : -1 @@ -43,16 +41,15 @@ def self.get_selected_choices(message, choices, parent = nil, initial_selections: [], - x: Wx::DEFAULT_COORD, - y: Wx::DEFAULT_COORD) - dialog = Wx::MultiChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, [x, y]) + pos: Wx::DEFAULT_POSITION) + dialog = Wx::MultiChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, pos) # call this even if selections array is empty and this then (correctly) # deselects the first item which is selected by default dialog.selections = initial_selections if dialog.show_modal != Wx::ID_OK - return [] + return nil end dialog.get_selections diff --git a/lib/wx/doc/functions.rb b/lib/wx/doc/functions.rb index 33fe562e..666819a9 100644 --- a/lib/wx/doc/functions.rb +++ b/lib/wx/doc/functions.rb @@ -158,9 +158,41 @@ def self.get_mouse_state; end # @!group Dialog shortcuts # @return [Array] Selected choices - def self.get_selected_choices(message, caption, choices, - parent = nil, x = Wx::DEFAULT_COORD, y = Wx::DEFAULT_COORD, - centre = true, width = Wx::CHOICE_WIDTH, height = Wx::CHOICE_HEIGHT) end + + # Get the user selection as a string. + # @param [String] message + # @param [String] caption + # @param [Array] choices choice strings + # @param [Wx::Window,nil] parent + # @param [Integer] initial_selection initial choice index + # @param [Wx::Point,Array(Integer,Integer)] pos + # @return [String] selected choice or '' if cancelled + def self.get_single_choice(message, caption, choices, parent = nil, + initial_selection: 0, + pos: Wx::DEFAULT_POSITION) end + + # Get the user selection as an index. + # @param [String] message + # @param [String] caption + # @param [Array] choices choice strings + # @param [Wx::Window,nil] parent + # @param [Integer] initial_selection + # @param [Wx::Point,Array(Integer,Integer)] pos + # @return [Integer] selected choice index or -1 if cancelled + def self.get_single_choice_index(message, caption, choices, parent = nil, + initial_selection: 0, + pos: Wx::DEFAULT_POSITION) end + + # @param [String] message + # @param [String] caption + # @param [Array] choices choice strings + # @param [Wx::Window,nil] parent + # @param [Array] initial_selections array of initial choice indexes + # @param [Wx::Point,Array(Integer,Integer)] pos + # @return [Array,nil] selected choice indexes (can be empty array if none selected) or nil if cancelled + def self.get_selected_choices(message, caption, choices, parent = nil, + initial_selections: [], + pos: Wx::DEFAULT_POSITION) end # Pops up a file selector box. # diff --git a/rakelib/lib/director/dialog.rb b/rakelib/lib/director/dialog.rb index e517b4e9..a6c01d30 100644 --- a/rakelib/lib/director/dialog.rb +++ b/rakelib/lib/director/dialog.rb @@ -144,13 +144,6 @@ def setup when 'wxMultiChoiceDialog' # unnneeded and unwanted for Ruby spec.ignore 'wxMultiChoiceDialog::wxMultiChoiceDialog(wxWindow *,const wxString &,const wxString &,int,const wxString *,long,const wxPoint &)' - # Wx's MultiChoiceDialog offers the possibility of attaching client - # data to each choice. However this would need memory management, and a - # pure ruby implementation is trivial and likely to be more convenient - # on a per-case basis so just ignore this argument for Ruby. - spec.map 'char** clientData' do - map_in ignore: true, code: '$1 = (char **)NULL;' - end spec.do_not_generate(:functions, :enums, :defines) when 'wxDirDialog' when 'wxProgressDialog' diff --git a/rakelib/lib/director/functions.rb b/rakelib/lib/director/functions.rb index 4e161085..62b72319 100644 --- a/rakelib/lib/director/functions.rb +++ b/rakelib/lib/director/functions.rb @@ -208,18 +208,6 @@ def setup wxWindow * wxGetActiveWindow(); // Dialog shortcuts - VOID_INT wxGetSelectedChoices(wxArrayInt& selections, - const wxString& message, - const wxString& caption, - int n, const wxString *choices, - wxWindow *parent = NULL, - int x = wxDefaultCoord, - int y = wxDefaultCoord, - bool centre = true, - int width = wxCHOICE_WIDTH, - int height = wxCHOICE_HEIGHT); - - wxString wxFileSelector (const wxString &message, const wxString &default_path=wxEmptyString, const wxString &default_filename=wxEmptyString,