Class: WindowState::WindowPlacement
- Inherits:
-
Object
- Object
- WindowState::WindowPlacement
- Includes:
- Windows::Window
- Defined in:
- lib/windowstate.rb
Instance Attribute Summary collapse
-
#data_encoded ⇒ Object
readonly
Returns the value of attribute data_encoded.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #data=(array) ⇒ Object
- #get ⇒ Object
-
#initialize(handle) ⇒ WindowPlacement
constructor
A new instance of WindowPlacement.
- #inspect ⇒ Object
- #set ⇒ Object
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(handle) ⇒ WindowPlacement
Returns a new instance of WindowPlacement.
40 41 42 |
# File 'lib/windowstate.rb', line 40 def initialize(handle) @handle = handle end |
Instance Attribute Details
#data_encoded ⇒ Object (readonly)
Returns the value of attribute data_encoded.
24 25 26 |
# File 'lib/windowstate.rb', line 24 def data_encoded @data_encoded end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
24 25 26 |
# File 'lib/windowstate.rb', line 24 def handle @handle end |
#title ⇒ Object
Returns the value of attribute title.
24 25 26 |
# File 'lib/windowstate.rb', line 24 def title @title end |
Class Method Details
.get(handle) ⇒ Object
27 28 29 30 31 |
# File 'lib/windowstate.rb', line 27 def self.get(handle) wp = new(handle) wp.get wp end |
.json_create(o) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/windowstate.rb', line 33 def self.json_create(o) wp = new(o['data'][0]) wp.title = o['data'][1] wp.data = o['data'][2] wp end |
Instance Method Details
#data ⇒ Object
59 60 61 |
# File 'lib/windowstate.rb', line 59 def data data_encoded.unpack("L11") end |
#data=(array) ⇒ Object
63 64 65 |
# File 'lib/windowstate.rb', line 63 def data=(array) @data_encoded = array.pack("L11") end |
#get ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/windowstate.rb', line 44 def get wp_buffer = [44].pack("L") + '\0' * 40 title_buffer = "\0" * 200 GetWindowPlacement(handle, wp_buffer) @data_encoded = wp_buffer GetWindowText(handle, title_buffer, 200) @title = title_buffer.strip end |
#inspect ⇒ Object
74 75 76 |
# File 'lib/windowstate.rb', line 74 def inspect "#<WindowState::WindowPlacement:0x%08x @handle=%i, @title=\"%s\", data=%s>" % [object_id, handle, title, data] end |
#set ⇒ Object
55 56 57 |
# File 'lib/windowstate.rb', line 55 def set SetWindowPlacement(handle, data_encoded) end |
#to_json(*a) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/windowstate.rb', line 67 def to_json(*a) { 'json_class' => self.class.name, 'data' => [handle, title, data] }.to_json(*a) end |