# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # Common base class for single line text entry fields. # # This class is not a control itself, as it doesn't derive from {Wx::Window}. Instead it is used as a base class by other controls, notably {Wx::TextCtrl} and {Wx::ComboBox} and gathers the methods common to both of them. # # Category: {Wx::Controls} # @see Wx::TextCtrl # @see Wx::ComboBox # # # # @note In wxRuby this is a mixin module instead of a (base) class. module TextEntry # @overload set_margins(pt) # Attempts to set the control margins. # # When margins are given as {Wx::Point}, x indicates the left and y the top margin. Use -1 to indicate that an existing value should be used. # true if setting of all requested margins was successful. # @param pt [Array(Integer, Integer), Wx::Point] # @return [Boolean] # @overload set_margins(left, top=-1) # Attempts to set the control margins. # # When margins are given as {Wx::Point}, x indicates the left and y the top margin. Use -1 to indicate that an existing value should be used. # true if setting of all requested margins was successful. # @param left [Integer] # @param top [Integer] # @return [Boolean] def set_margins(*args) end alias_method :margins=, :set_margins # Appends the text to the end of the text control. # #
# Remark: #

After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired, the programmer should use {Wx::TextEntry#get_insertion_point} and {Wx::TextEntry#set_insertion_point}. #

#
# @see Wx::TextEntry#write_text # @param text [String] Text to write to the text control. # @return [void] def append_text(text) end # @overload auto_complete(choices) # Call this function to enable auto-completion of the text typed in a single-line text control using the given choices. # # true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform. # @see Wx::TextEntry#auto_complete_file_names # @param choices [Array] # @return [Boolean] # @overload auto_complete(completer) # Enable auto-completion using the provided completer object. # # This method should be used instead of {Wx::TextEntry#auto_complete} overload taking the array of possible completions if the total number of strings is too big as it allows returning the completions dynamically, depending on the text already entered by user and so is more efficient. # The specified completer object will be used to retrieve the list of possible completions for the already entered text and will be deleted by {Wx::TextEntry} itself when it's not needed any longer. # Notice that you need to include Wx::/textcompleter.h in order to define your class inheriting from {Wx::TextCompleter}. # # true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform. # @see Wx::TextCompleter # @param completer [Wx::TextCompleter] The object to be used for generating completions if non-NULL. If it is NULL, auto-completion is disabled. The {Wx::TextEntry} object takes ownership of this pointer and will delete it in any case (i.e. even if this method returns false). # @return [Boolean] def auto_complete(*args) end # Call this function to enable auto-completion of the text typed in a single-line text control using all valid file system paths. # # Notice that currently this function is only implemented in WXMSW port and does nothing under the other platforms. # # true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform. # @see Wx::TextEntry#auto_complete # @return [Boolean] def auto_complete_file_names; end # Call this function to enable auto-completion of the text using the file system directories. # # Unlike {Wx::TextEntry#auto_complete_file_names} which completes both file names and directories, this function only completes the directory names. # Notice that currently this function is only implemented in WXMSW port and does nothing under the other platforms. # # true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform. # @see Wx::TextEntry#auto_complete # @return [Boolean] def auto_complete_directories; end # Returns true if the selection can be copied to the clipboard. # @return [Boolean] def can_copy; end alias_method :can_copy?, :can_copy # Returns true if the selection can be cut to the clipboard. # @return [Boolean] def can_cut; end alias_method :can_cut?, :can_cut # Returns true if the contents of the clipboard can be pasted into the text control. # # On some platforms (Motif, GTK) this is an approximation and returns true if the control is editable, false otherwise. # @return [Boolean] def can_paste; end alias_method :can_paste?, :can_paste # Returns true if there is a redo facility available and the last operation can be redone. # @return [Boolean] def can_redo; end alias_method :can_redo?, :can_redo # Returns true if there is an undo facility available and the last operation can be undone. # @return [Boolean] def can_undo; end alias_method :can_undo?, :can_undo # Sets the new text control value. # # It also marks the control as not-modified which means that IsModified() would return false immediately after the call to {Wx::TextEntry#change_value}. # The insertion point is set to the start of the control (i.e. position 0) by this function. # This functions does not generate the {Wx::EVT_TEXT} event but otherwise is identical to {Wx::TextEntry#set_value}. # See User Generated Events vs Programmatically Generated Events for more information. # @param value [String] The new value to set. It may contain newline characters if the text control is multi-line. # @return [void] def change_value(value) end # Clears the text in the control. # # Note that this function will generate a {Wx::EVT_TEXT} event, i.e. its effect is identical to calling SetValue(""). # @return [void] def clear; end # Copies the selected text to the clipboard. # @return [void] def copy; end # Copies the selected text to the clipboard and removes it from the control. # @return [void] def cut; end # Convert all text entered into the control to upper case. # # Call this method to ensure that all text entered into the control is converted on the fly to upper case. If the control is not empty, its existing contents is also converted to upper case. # @return [void] def force_upper; end # Returns the insertion point, or cursor, position. # # This is defined as the zero based index of the character position to the right of the insertion point. For example, if the insertion point is at the end of the single-line text control, it is equal to {Wx::TextEntry#get_last_position}. # Notice that insertion position is, in general, different from the index of the character the cursor position at in the string returned by {Wx::TextEntry#get_value}. While this is always the case for the single line controls, multi-line controls can use two characters "\\r\\n" as line separator (this is notably the case under MSW) meaning that indices in the control and its string value are offset by 1 for every line. # Hence to correctly get the character at the current cursor position, taking into account that there can be none if the cursor is at the end of the string, you could do the following: # # ```ruby # def get_current_char(txt_ctrl) # pos = txt_ctrl.get_insertion_point # return '' if pos == txt_ctrl.get_last_position # # txt_ctrl.get_range(pos, pos + 1) # end # ``` # @return [Integer] def get_insertion_point; end alias_method :insertion_point, :get_insertion_point # Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control. # @return [Wx::TextPos] def get_last_position; end alias_method :last_position, :get_last_position # Returns the string containing the text starting in the positions from and up to to in the control. # # The positions must have been returned by another {Wx::TextCtrl} method. Please note that the positions in a multiline {Wx::TextCtrl} do not correspond to the indices in the string returned by {Wx::TextEntry#get_value} because of the different new line representations (CR or CR LF) and so this method should be used to obtain the correct results instead of extracting parts of the entire value. It may also be more efficient, especially if the control contains a lot of data. # @param from [Integer] # @param to [Integer] # @return [String] def get_range(from, to) end alias_method :range, :get_range # Gets the current selection span. # # If the returned values are equal, there was no selection. Please note that the indices returned may be used with the other {Wx::TextCtrl} methods but don't necessarily represent the correct indices into the string returned by {Wx::TextEntry#get_value} for multiline controls under Windows (at least,) you should use {Wx::TextEntry#get_string_selection} to get the selected text. # @return [Array(Integer,Integer)] def get_selection; end alias_method :selection, :get_selection # Gets the text currently selected in the control. # # If there is no selection, the returned string is empty. # @return [String] def get_string_selection; end alias_method :string_selection, :get_string_selection # Gets the contents of the control. # # Notice that for a multiline text control, the lines will be separated by (Unix-style) \n characters, even under Windows where they are separated by a \r\n sequence in the native control. # @return [String] def get_value; end alias_method :value, :get_value # Returns true if the controls contents may be edited by user (note that it always can be changed by the program). # # In other words, this functions returns true if the control hasn't been put in read-only mode by a previous call to {Wx::TextEntry#set_editable}. # @return [Boolean] def is_editable; end alias_method :editable?, :is_editable # Returns true if the control is currently empty. # # This is the same as Wx::TextEntry#get_value.empty() but can be much more efficient for the multiline controls containing big amounts of text. # @return [Boolean] def is_empty; end alias_method :empty?, :is_empty # Pastes text from the clipboard to the text item. # @return [void] def paste; end # If there is a redo facility and the last operation can be redone, redoes the last operation. # # Does nothing if there is no redo facility. # @return [void] def redo_; end # Removes the text starting at the first given position up to (but not including) the character at the last position. # # This function puts the current insertion point position at to as a side effect. # @param from [Integer] The first position. # @param to [Integer] The last position. # @return [void] def remove(from, to) end # Replaces the text starting at the first position up to (but not including) the character at the last position with the given text. # # This function puts the current insertion point position at to as a side effect. # @param from [Integer] The first position. # @param to [Integer] The last position. # @param value [String] The value to replace the existing text with. # @return [void] def replace(from, to, value) end # Makes the text item editable or read-only, overriding the {Wx::TE_READONLY} flag. # # # @see Wx::TextEntry#is_editable # @param editable [Boolean] If true, the control is editable. If false, the control is read-only. # @return [void] def set_editable(editable) end alias_method :editable=, :set_editable # Sets the insertion point at the given position. # @param pos [Integer] Position to set, in the range from 0 to {Wx::TextEntry#get_last_position} inclusive. # @return [void] def set_insertion_point(pos) end alias_method :insertion_point=, :set_insertion_point # Sets the insertion point at the end of the text control. # # This is equivalent to calling {Wx::TextCtrl#set_insertion_point} with {Wx::TextCtrl#get_last_position} argument. # @return [void] def set_insertion_point_end; end # This function sets the maximum number of characters the user can enter into the control. # # In other words, it allows limiting the text value length to len not counting the terminating NUL character. # If len is 0, the previously set max length limit, if any, is discarded and the user may enter as much text as the underlying native text control widget supports (typically at least 32Kb). If the user tries to enter more characters into the text control when it already is filled up to the maximal length, a {Wx::EVT_TEXT_MAXLEN} event is sent to notify the program about it (giving it the possibility to show an explanatory message, for example) and the extra input is discarded. # Note that in WXGTK this function may only be used with single line text controls. # @param len [Integer] # @return [void] def set_max_length(len) end alias_method :max_length=, :set_max_length # Selects the text starting at the first position up to (but not including) the character at the last position. # # If both parameters are equal to -1 all text in the control is selected. # Notice that the insertion point will be moved to from by this function. # @see Wx::TextEntry#select_all # @param from [Integer] The first position. # @param to [Integer] The last position. # @return [void] def set_selection(from, to) end # Selects all text in the control. # # # @see Wx::TextEntry#set_selection # @return [void] def select_all; end # Deselects selected text in the control. # @return [void] def select_none; end # Sets a hint shown in an empty unfocused text control. # # The hints are usually used to indicate to the user what is supposed to be entered into the given entry field, e.g. a common use of them is to show an explanation of what can be entered in a {Wx::SearchCtrl}. # The hint is shown (usually greyed out) for an empty control until it gets focus and is shown again if the control loses it and remains empty. It won't be shown once the control has a non-empty value, although it will be shown again if the control contents is cleared. Because of this, it generally only makes sense to use hints with the controls which are initially empty. # Notice that hints are known as cue banners under MSW or placeholder strings under macOS. # #
# Remark: #

Currently implemented natively on Windows (Vista and later only), macOS and GTK+ (3.2 and later). #

#
# # For the platforms without native hints support, the implementation has several known limitations. Notably, the hint display will not be properly updated if you change {Wx::TextEntry} contents programmatically when the hint is displayed using methods other than {Wx::TextEntry#set_value} or {Wx::TextEntry#change_value} or others which use them internally (e.g. {Wx::TextEntry#clear}). In other words, currently you should avoid calling methods such as {Wx::TextEntry#write_text} or {Wx::TextEntry#replace} when using hints and the text control is empty. If you bind to the control's focus and {Wx::EVT_TEXT} events, you must call {Wx::Event#skip} on them so that the generic implementation works correctly. # Another limitation is that hints are ignored for the controls with {Wx::TE_PASSWORD} style. # #
# Remark: #

Hints can be used for single line text controls under all platforms, but only MSW and GTK+ 2 support them for multi-line text controls, they are ignored for them under the other platforms. #

#
# @param hint [String] # @return [Boolean] def set_hint(hint) end alias_method :hint=, :set_hint # Returns the current hint string. # # See {Wx::TextEntry#set_hint} for more information about hints. # @return [String] def get_hint; end alias_method :hint, :get_hint # Returns the margins used by the control. # # The x field of the returned point is the horizontal margin and the y field is the vertical one. # #
# Remark: #

If given margin cannot be accurately determined, its value will be set to -1. On some platforms you cannot obtain valid margin values until you have called {Wx::TextEntry#set_margins}. #

#
# @see Wx::TextEntry#set_margins # @return [Wx::Point] def get_margins; end alias_method :margins, :get_margins # Sets the new text control value. # # It also marks the control as not-modified which means that IsModified() would return false immediately after the call to {Wx::TextEntry#set_value}. # The insertion point is set to the start of the control (i.e. position 0) by this function unless the control value doesn't change at all, in which case the insertion point is left at its original position. # Note that, unlike most other functions changing the controls values, this function generates a {Wx::EVT_TEXT} event. To avoid this you can use {Wx::TextEntry#change_value} instead. # @param value [String] The new value to set. It may contain newline characters if the text control is multi-line. # @return [void] def set_value(value) end alias_method :value=, :set_value # If there is an undo facility and the last operation can be undone, undoes the last operation. # # Does nothing if there is no undo facility. # @return [void] def undo; end # Writes the text into the text control at the current insertion position. # #
# Remark: #

Newlines in the text string are the only control characters allowed, and they will cause appropriate line breaks. See operator<<() and {Wx::TextEntry#append_text} for more convenient ways of writing to the window. After the write operation, the insertion point will be at the end of the inserted text, so subsequent write operations will be appended. To append text after the user may have interacted with the control, call {Wx::TextCtrl#set_insertion_point_end} before writing. #

#
# @param text [String] Text to write to the text control. # @return [void] def write_text(text) end end # TextEntry # Base class for custom text completer objects. # # Custom completer objects used with {Wx::TextEntry#auto_complete} must derive from this class and implement its pure virtual method returning the completions. You would typically use a custom completer when the total number of completions is too big for performance to be acceptable if all of them need to be returned at once but if they can be generated hierarchically, i.e. only the first component initially, then the second one after the user finished entering the first one and so on. # When inheriting from this class you need to implement its two pure virtual methods. This allows returning the results incrementally and may or not be convenient depending on where do they come from. If you prefer to return all the completions at once, you should inherit from {Wx::TextCompleterSimple} instead. # class TextCompleter < ::Object # Function called to start iteration over the completions for the given prefix. # # This function could start a database query, for example, if the results are read from a database. # Notice that under some platforms (currently MSW only) it is called from another thread context and so the appropriate synchronization mechanism should be used to access any data also used by the main UI thread. # # true to continue with calling {Wx::TextCompleter#get_next} or false to indicate that there are no matches and {Wx::TextCompleter#get_next} shouldn't be called at all. # @param prefix [String] The prefix for which completions are to be generated. # @return [Boolean] def start(prefix) end # Called to retrieve the next completion. # # All completions returned by this function should start with the prefix passed to the last call to {Wx::TextCompleter#start}. # Notice that, as {Wx::TextCompleter#start}, this method is called from a worker thread context under MSW. # The next completion or an empty string to indicate that there are no more of them. # @return [String] def get_next; end alias_method :next_, :get_next end # TextCompleter # A simpler base class for custom completer objects. # # This class may be simpler to use than the base {Wx::TextCompleter} as it allows to implement only a single virtual method instead of two of them (at the price of storing all completions in a temporary array). # Here is a simple example of a custom completer that completes the names of some chess pieces. Of course, as the total list here has only four items it would have been much simpler to just specify the array containing all the completions in this example but the same approach could be used when the total number of completions is much higher provided the number of possibilities for each word is still relatively small: # ```ruby # class MyTextCompleter < Wx::TextCompleterSimple # # def get_completions(prefix) # firstWord = prefix.split(' ').shift # if firstWord == 'white' # ['white pawn', 'white rook'] # elsif firstWord == 'black' # ['black king', 'black queen'] # else # ['white', 'black'] # end # end # # end # ... # text_ctrl = ... # text_ctrl.auto_complete(MyTextCompleter.new) # ``` # class TextCompleterSimple < TextCompleter # Pure virtual method returning all possible completions for the given prefix. # # The custom completer should examine the provided prefix and return all the possible completions for it in the output array res. # Please notice that the returned values should start with the prefix, otherwise they will be simply ignored, making adding them to the array in the first place useless. # Notice that this function may be called from thread other than main one (this is currently always the case under MSW) so the appropriate synchronization mechanism should be used to protect the shared data. # @param prefix [String] The possibly empty prefix that the user had already entered. # @return [Array] def get_completions(prefix) end alias_method :completions, :get_completions end # TextCompleterSimple end