# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # The {Wx::Timer} class allows you to execute code at specified intervals. # Its precision is platform-dependent, but in general will not be better than 1ms nor worse than 1s. # There are three different ways to use this class: # # - You may derive a new class from {Wx::Timer} and override the {Wx::Timer#notify} member to perform the required action. # - You may redirect the notifications to any {Wx::EvtHandler} derived object by using the non-default constructor or {Wx::Timer#set_owner}. Then use the EVT_TIMER macro to connect it to the event handler which will receive {Wx::TimerEvent} notifications. # - You may use a derived class and the EVT_TIMER macro to connect it to an event handler defined in the derived class. If the default constructor is used, the timer object will be its own owner object, since it is derived from {Wx::EvtHandler}. # # In any case, you must start the timer with {Wx::Timer#start} after constructing it before it actually starts sending notifications. It can be stopped later with {Wx::Timer#stop}. # A timer can only be used from the main thread. # # === # # Category: {Wx::Miscellaneous} # @see Wx::StopWatch # # class Timer < EvtHandler # @overload initialize() # Default constructor. # If you use it to construct the object and don't call {Wx::Timer#set_owner} later, you must override {Wx::Timer#notify} method to process the notifications. # @return [Wx::Timer] # @overload initialize(owner, id=-1) # Creates a timer and associates it with owner. # Please see {Wx::Timer#set_owner} for the description of parameters. # @param owner [Wx::EvtHandler] # @param id [Integer] # @return [Wx::Timer] def initialize(*args) end # Returns the ID of the events generated by this timer. # @return [Integer] def get_id; end alias_method :id, :get_id # Returns the current interval for the timer (in milliseconds). # @return [Integer] def get_interval; end alias_method :interval, :get_interval # Returns the current owner of the timer. # If non-NULL this is the event handler which will receive the timer events (see {Wx::TimerEvent}) when the timer is running. # @return [Wx::EvtHandler] def get_owner; end alias_method :owner, :get_owner # Returns true if the timer is one shot, i.e. if it will stop after firing the first notification automatically. # @return [Boolean] def is_one_shot; end alias_method :one_shot?, :is_one_shot # Returns true if the timer is running, false if it is stopped. # @return [Boolean] def is_running; end alias_method :running?, :is_running # This member should be overridden by the user if the default constructor was used and {Wx::Timer#set_owner} wasn't called. # Perform whatever action which is to be taken periodically here. # Notice that throwing exceptions from this method is currently not supported, use event-based timer handling approach if an exception can be thrown while handling timer notifications. # @return [void] def notify; end # Associates the timer with the given owner object. # When the timer is running, the owner will receive timer events (see {Wx::TimerEvent}) with id equal to id specified here. # @param owner [Wx::EvtHandler] # @param id [Integer] # @return [void] def set_owner(owner, id=-1) end alias_method :owner=, :set_owner # (Re)starts the timer. # If milliseconds parameter is -1 (value by default), the previous value is used. Returns false if the timer could not be started, true otherwise (in MS Windows timers are a limited resource). # If oneShot is false (the default), the {Wx::Timer#notify} function will be called repeatedly until the timer is stopped. If true, it will be called only once and the timer will stop automatically. # To make your code more readable you may also use the following symbolic constants: # # - {Wx::TIMER_CONTINUOUS}: Start a normal, continuously running, timer # - {Wx::TIMER_ONE_SHOT}: Start a one shot timer Alternatively, use {Wx::Timer#start_once}. # # If the timer was already running, it will be stopped by this method before restarting it. # @param milliseconds [Integer] # @param oneShot [Boolean] # @return [Boolean] def start(milliseconds=-1, oneShot=Wx::TIMER_CONTINUOUS) end # Starts the timer for a once-only notification. # This is a simple wrapper for {Wx::Timer#start} with {Wx::TIMER_ONE_SHOT} parameter. # @param milliseconds [Integer] # @return [Boolean] def start_once(milliseconds=-1) end # Stops the timer. # @return [void] def stop; end end # Timer end