# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # FD_DEFAULT_STYLE = 1 # # FD_OPEN = 1 # # FD_SAVE = 2 # # FD_OVERWRITE_PROMPT = 4 # # FD_NO_FOLLOW = 8 # # FD_FILE_MUST_EXIST = 16 # # FD_CHANGE_DIR = 128 # # FD_PREVIEW = 256 # # FD_MULTIPLE = 512 # # FD_SHOW_HIDDEN = 1024 # Default wildcard string used in {Wx::FileDialog} corresponding to all files. # FILE_SELECTOR_DEFAULT_WILDCARD_STR = "*.*" # This class represents the file chooser dialog. # # The path and filename are distinct elements of a full file pathname. If path is {Wx::EmptyString}, the current directory will be used. If filename is {Wx::EmptyString}, no default filename will be supplied. The wildcard determines what files are displayed in the file selector, and file extension supplies a type extension for the required filename. # The typical usage for the open file dialog is: # ```ruby # class MyFrame # ... # def on_open(event) # if (...current content has not been saved...) # if Wx.message_box('Current content has not been saved! Proceed?', 'Please confirm', # Wx::ICON_QUESTION | Wx::YES_NO, self) == Wx::NO # return # #else: proceed asking to the user the new file to open # end # end # # Wx::FileDialog(self, "Open XYZ file", "", "", # "XYZ files (*.xyz)|*.xyz", Wx::FD_OPEN|Wx::FD_FILE_MUST_EXIST) do |dlg| # return if dlg.show_modal == Wx::ID_CANCEL # the user changed idea...? # # # proceed loading the file chosen by the user # file = File.open(dlg.path, 'r') rescue nil # unless file # Wx.log_error("Cannot open file '#{dlg.path}'.") # return # end # ... # end # end # # end # ``` # # The typical usage for the save file dialog is instead somewhat simpler: # ```ruby # class MyFrame # ... # def on_save_as(event) # Wx::FileDialog(self, "Save XYZ file", "", "", # "XYZ files (*.xyz)|*.xyz", Wx::FD_SAVE|Wx::FD_OVERWRITE_PROMPT) do |dlg| # return if dlg.show_modal == Wx::ID_CANCEL # the user changed idea...? # # # save the current contents in the file # begin # File.open(dlg.path, 'w+') do |f| # # save to file # end # rescue # Wx.log_error("Cannot save current contents in file '#{dlg.path}'.") # return # end # end # ... # end # # end # ``` # # ## Wildcard Filters # # All implementations of the {Wx::FileDialog} provide a wildcard filter. Typing a filename containing wildcards (*, ?) in the filename text item, and clicking on Ok, will result in only those files matching the pattern being displayed. The wildcard may be a specification for multiple types of file with a description for each, such as: # ``` # "BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png" # ``` # # On Mac macOS in the open file dialog the filter choice box is not shown by default. Instead all given wildcards are applied at the same time: So in the above example all bmp, gif and png files are displayed. To enforce the display of the filter choice set the corresponding {Wx::SystemOptions} before calling the file open dialog: # ```ruby # Wx::SystemOptions.set_option(Wx::OSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1) # ``` # But in contrast to Windows and Unix, where the file type choice filters only the selected files, on Mac macOS even in this case the dialog shows all files matching all file types. The files which does not match the currently selected file type are greyed out and are not selectable. # # ## Dialog Customization # # Uniquely among the other standard dialogs, {Wx::FileDialog} can be customized by adding extra controls to it. Moreover, there are two ways to do it: the first one is to define a callback function and use {Wx::FileDialog#set_extra_control_creator} to tell the dialog to call it, while the second one requires defining a class inheriting from {Wx::FileDialogCustomizeHook} and implementing its virtual functions, notably {Wx::FileDialogCustomizeHook#add_custom_controls} where the extra controls have to be created, and finally calling {Wx::FileDialog#set_customize_hook} with this custom hook object. # The first approach is somewhat simpler and more flexible, as it allows to create any kind of custom controls, but is not supported by the "new style" (where "new" means used since Windows Vista, i.e. circa 2007) file dialogs under MSW. Because of this, calling {Wx::FileDialog#set_extra_control_creator} in WXMSW forces the use of old style (Windows XP) dialogs, that may look out of place. The second approach is implemented by the MSW dialogs natively and doesn't suffer from this limitation, so its use is recommended, especially if the few simple control types supported by it (see {Wx::FileDialogCustomize} for more information about the supported controls) are sufficient for your needs. # Both of the approaches to the dialog customization are demonstrated in the Dialogs Sample, please check it for more details. # #
New style file dialogs can only be used in WXMSW when the apartment, COM threading model is used. This is the case by default, but if the application initializes COM on its own using multi-threaded model, old style dialogs are used, at least when they must have a parent, as the new style dialog doesn't support this threading model. #
#wxFD_*
styles for more info.
# @param pos [Array(Integer, Integer), Wx::Point] Dialog position. Not implemented.
# @param size [Array(Integer, Integer), Wx::Size] Dialog size. Not implemented.
# @param name [String] Dialog name. Not implemented.
# @return [Wx::FileDialog]
def initialize(parent, message=Wx::FILE_SELECTOR_PROMPT_STR, defaultDir=(''), defaultFile=(''), wildcard=Wx::FILE_SELECTOR_DEFAULT_WILDCARD_STR, style=Wx::FD_DEFAULT_STYLE, pos=Wx::DEFAULT_POSITION, size=Wx::DEFAULT_SIZE, name=Wx::FILE_DIALOG_NAME_STR) end
# Returns the path of the file currently selected in dialog.
#
# Notice that this file is not necessarily going to be accepted by the user, so calling this function mostly makes sense from an update UI event handler of a custom file dialog extra control to update its state depending on the currently selected file.
# Currently this function is fully implemented under GTK and MSW and always returns an empty string elsewhere.
#
# The path of the currently selected file or an empty string if nothing is selected.
# @see Wx::FileDialog#set_extra_control_creator
# @return [String]
def get_currently_selected_filename; end
alias_method :currently_selected_filename, :get_currently_selected_filename
# Returns the file type filter index currently selected in dialog.
#
# Notice that this file type filter is not necessarily going to be the one finally accepted by the user, so calling this function mostly makes sense from an update UI event handler of a custom file dialog extra control to update its state depending on the currently selected file type filter.
# Currently this function is fully implemented under macOS and MSW and always returns {Wx::NOT_FOUND} elsewhere.
#
# The 0-based index of the currently selected file type filter or {Wx::NOT_FOUND} if nothing is selected.
# @see Wx::FileDialog#set_extra_control_creator
#
# @see Wx::FileDialog#get_filter_index
#
# @see Wx::FileDialog#set_filter_index
# @return [Integer]
def get_currently_selected_filter_index; end
alias_method :currently_selected_filter_index, :get_currently_selected_filter_index
# Returns the default directory.
# @return [String]
def get_directory; end
alias_method :directory, :get_directory
# If functions {Wx::FileDialog#set_extra_control_creator} and {Wx::FileDialog#show_modal} were called, returns the extra window.
#
# Otherwise returns NULL.
# @return [Wx::Window]
def get_extra_control; end
alias_method :extra_control, :get_extra_control
# Returns the default filename.
#
# This function can't be used with dialogs which have the {Wx::FD_MULTIPLE} style, use {Wx::FileDialog#get_filenames} instead. #
#This function can't be used with dialogs which have the {Wx::FD_MULTIPLE} style, use {Wx::FileDialog#get_paths} instead. #
#In order to define a custom hook object, Wx::/filedlgcustomize.h
must be included in addition to the usual Wx::/filedlg.h
header.
#