Class: Wx::DPIChangedEvent
- Defined in:
- lib/wx/doc/gen/events.rb
Overview
Event sent when the display scale factor or pixel density (measured in dots-per-inch, or DPI) of the monitor a window is on changes.
The event is sent to each TopLevelWindow affected by the change, and all its children recursively (post-order traversal). For example, this event is sent to the window when it is moved, by the user, from a display using some DPI value to another display using a different DPI value. It also sent to all program windows on the given display if its DPI changes due to a change in the system settings. If you define an event handler for this event, you should almost always call event.Skip()
in it in order to allow the base class handler to execute, as many controls rely on processing this event in order to update their appearance when the DPI changes. However the default handler for the top level window itself only sets the new window size, by scaling the current size by the DPI ratio e.g. doubling it if the DPI has changed from normal to “high”, i.e. 200%, one and also ensuring that the window is still bigger than its best size, as returned by Window#get_best_size. Note that in some cases this may cause the window size to grow unexpectedly and you may prefer to call Window#set_size in your handler of this event for the top level window and not call event.Skip()
to prevent the default handler from resizing the window. Currently this event is generated by WXMSW port if only and only if the MSW application runs under Windows 10 Creators Update (v1703) or later and is marked as being “per-monitor DPI aware”, i.e. contains a dpiAwareness tag with the value “PerMonitorV2” in its manifest (see Microsoft “Application Manifests” documentation for more details).
Events using this class
The following event-handler methods redirect the events to member method or handler blocks for DPIChangedEvent events. Event handler methods:
-
EvtHandler#evt_dpi_changed(meth = nil, &block): Process a EVT_DPI_CHANGED event.
Category: Events
Instance Method Summary collapse
-
#get_new_dpi ⇒ Wx::Size
(also: #new_dpi)
Returns the new DPI.
-
#get_old_dpi ⇒ Wx::Size
(also: #old_dpi)
Returns the old DPI.
-
#scale(sz) ⇒ Wx::Size
Rescale a value in pixels to match the new DPI.
-
#scale_x(x) ⇒ Integer
Rescale horizontal component to match the new DPI.
-
#scale_y(y) ⇒ Integer
Rescale vertical component to match the new DPI.
Methods inherited from Event
#clone, #get_event_category, #get_event_object, #get_event_type, #get_id, #get_skipped, #get_timestamp, #initialize, #is_command_event, #resume_propagation, #set_event_object, #set_event_type, #set_id, #set_timestamp, #should_propagate, #skip, #stop_propagation
Methods inherited from Object
#clone, #dup, #initialize, #is_same_as, #un_share
Constructor Details
This class inherits a constructor from Wx::Event
Instance Method Details
#get_new_dpi ⇒ Wx::Size Also known as: new_dpi
Returns the new DPI.
2411 |
# File 'lib/wx/doc/gen/events.rb', line 2411 def get_new_dpi; end |
#get_old_dpi ⇒ Wx::Size Also known as: old_dpi
Returns the old DPI.
2406 |
# File 'lib/wx/doc/gen/events.rb', line 2406 def get_old_dpi; end |
#scale(sz) ⇒ Wx::Size
Rescale a value in pixels to match the new DPI.
This is a convenience function to use in EVT_DPI_CHANGED event handlers, as they often need to update some sizes to the new DPI. It simply calls mul_div_int32 with new and old DPI values, but is more readable and less error-prone. For example, the returned value will be twice bigger than the original one when switching from normal (96) DPI to high (2x, 192) DPI.
2420 |
# File 'lib/wx/doc/gen/events.rb', line 2420 def scale(sz) end |
#scale_x(x) ⇒ Integer
Rescale horizontal component to match the new DPI.
This is the same as #scale, but for the horizontal component only.
2427 |
# File 'lib/wx/doc/gen/events.rb', line 2427 def scale_x(x) end |
#scale_y(y) ⇒ Integer
Rescale vertical component to match the new DPI.
This is the same as #scale, but for the vertical component only.
2434 |
# File 'lib/wx/doc/gen/events.rb', line 2434 def scale_y(y) end |