Class: Wx::Window
- Inherits:
-
Object
- Object
- Wx::Window
- Defined in:
- lib/wx/classes/window.rb
Overview
The base class for all things displayed on screen
Instance Method Summary collapse
- #__old_evt_paint ⇒ Object
-
#evt_paint(meth = nil, &block) ⇒ Object
This modified version of evt_paint sets a variable indicating that a paint event is being handled just before running the event handler.
-
#find_window_by_id(an_id) ⇒ Object
Recursively searches all windows below
selfand returns the first window which has the idan_id. -
#find_window_by_label(a_label) ⇒ Object
Searches all windows below
selfand returns the first window which has the labela_label. -
#find_window_by_name(a_name) ⇒ Object
Searches all windows below
selfand returns the first window which has the namea_nameThis corresponds to the find_window method method in WxWidgets when called with an string. -
#paint_buffered(buffer = nil) ⇒ Object
Provides bufferd drawing facility to reduce flicker for complex drawing commands.
Instance Method Details
#__old_evt_paint ⇒ Object
42 |
# File 'lib/wx/classes/window.rb', line 42 alias :__old_evt_paint :evt_paint |
#evt_paint(meth = nil, &block) ⇒ Object
This modified version of evt_paint sets a variable indicating that a paint event is being handled just before running the event handler. This ensures that any call to Window#paint within the handler will supply a Wx::PaintDC (see swig/Window.i).
47 48 49 50 51 52 53 54 55 |
# File 'lib/wx/classes/window.rb', line 47 def evt_paint(meth = nil, &block) paint_proc = acquire_handler(meth, block) wrapped_block = proc do | event | instance_variable_set("@__painting__", true) paint_proc.call(event) remove_instance_variable("@__painting__") end __old_evt_paint(&wrapped_block) end |
#find_window_by_id(an_id) ⇒ Object
Recursively searches all windows below self and returns the first window which has the id an_id. This corresponds to the find_window method method in WxWidgets when called with an integer.
25 26 27 |
# File 'lib/wx/classes/window.rb', line 25 def find_window_by_id(an_id) Wx::Window.find_window_by_id(an_id, self) end |
#find_window_by_label(a_label) ⇒ Object
Searches all windows below self and returns the first window which has the label a_label.
38 39 40 |
# File 'lib/wx/classes/window.rb', line 38 def find_window_by_label(a_label) Wx:Window.find_window_by_label(a_label, self) end |
#find_window_by_name(a_name) ⇒ Object
Searches all windows below self and returns the first window which has the name a_name This corresponds to the find_window method method in WxWidgets when called with an string.
32 33 34 |
# File 'lib/wx/classes/window.rb', line 32 def find_window_by_name(a_name) Wx::Window.find_window_by_name(a_name, self) end |
#paint_buffered(buffer = nil) ⇒ Object
Provides bufferd drawing facility to reduce flicker for complex drawing commands. Works similar to BufferedDC and BufferedPaintDC in the wxWidgets API, by doing drawing on an in-memory Bitmap, then copying the result in bulk to the screen.
The method may be passed an existing Wx::Bitmap as the buffer, otherwise one will be created.
Works like wxAutoBufferedDC in that additional buffering will only be done on platforms that do not already natively support buffering for the standard PaintDC / ClientDC - Windows, in particular.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/wx/classes/window.rb', line 68 def paint_buffered(buffer = nil) # OS X and GTK do double-buffering natively if self.double_buffered? paint { | dc | yield dc } else # client_size is the window area available for drawing upon c_size = client_size # Create an in-memory buffer if none supplied buffer ||= Wx::Bitmap.new(c_size.width, c_size.height) buffer.draw do | mem_dc | mem_dc.background = Wx::TRANSPARENT_BRUSH mem_dc.clear # Yield the bitmap for the user code to draw upon yield mem_dc paint do | dc | # Copy the buffer to the window dc.blit(0, 0, c_size.width, c_size.height, mem_dc, 0, 0) end end end end |