Class: AutoItX3::ListView

Inherits:
Control
  • Object
show all
Defined in:
lib/AutoItX3/control.rb

Overview

A list view is a list which can contain many different columns of data.

Constant Summary collapse

LIST =

Ordinary list view

"list"
DETAILS =

Detailed view

"details"
SMALL_ICONS =

View with small icons

"smallicons"
LARGE_ICONS =

View with large icons

"largeicons"

Instance Method Summary collapse

Methods inherited from Control

#click, #disable, #enable, #enabled?, #focus, from_control, functions, functions=, #handle, #hide, #initialize, #move, #rect, #send_command_to_control, #send_keys, #show, #text, #text=, #visible?

Constructor Details

This class inherits a constructor from AutoItX3::Control

Instance Method Details

#change_view(view) ⇒ Object

Changes the view of self. Possible values of view are all constants of the ListView class.



466
467
468
# File 'lib/AutoItX3/control.rb', line 466

def change_view(view)
  send_command_to_list_view("ViewChange", view)
end

#clear_selectionObject Also known as: select_none

AutoItX3::ListView#clear_selection ==> nil

AutoItX3::ListView#select_none ==> nil

Clears the selection.



454
455
456
# File 'lib/AutoItX3/control.rb', line 454

def clear_selection
  send_command_to_list_view("SelectClear")
end

#deselect(from, to = "") ⇒ Object

Deselects the given item(s).



382
383
384
# File 'lib/AutoItX3/control.rb', line 382

def deselect(from, to = "")
  send_command_to_list_view("DeSelect", from, to)
end

#find(string, sub_item = "") ⇒ Object

Searches for string and sub_item in self and returns the index of the found list item or false if it isn’t found.



388
389
390
391
392
393
394
395
# File 'lib/AutoItX3/control.rb', line 388

def find(string, sub_item = "")
  res = send_command_to_list_view("FindItem", string, sub_item).to_i
  if res == -1
    false
  else
    res
  end
end

#invert_selectionObject

Inverts the selection.



460
461
462
# File 'lib/AutoItX3/control.rb', line 460

def invert_selection
  send_command_to_list_view("SelectInvert")
end

#item_countObject Also known as: size, length

call-seq:

item_count ==> anInteger
size ==> anInteger
length ==> anInteger

Returns the number of items in self.



403
404
405
# File 'lib/AutoItX3/control.rb', line 403

def item_count
  send_command_to_list_view("GetItemCount").to_i
end

#num_selectedObject

Returns the number of selected items.



416
417
418
# File 'lib/AutoItX3/control.rb', line 416

def num_selected
  send_command_to_list_view("GetSelectedCount").to_i
end

#num_subitemsObject

Returns the number of subitems in self.



421
422
423
# File 'lib/AutoItX3/control.rb', line 421

def num_subitems
  send_command_to_list_view("GetSubItemCount").to_i
end

#select(from, to = "") ⇒ Object

Selects the given item(s).



441
442
443
# File 'lib/AutoItX3/control.rb', line 441

def select(from, to = "")
  send_command_to_list_view("Select", from, to)
end

#select_allObject

Selects all items in self.



446
447
448
# File 'lib/AutoItX3/control.rb', line 446

def select_all
  send_command_to_list_view("SelectAll")
end

#selectedObject

Returns the inices of the selected items in an array which is empty if none is selected.



411
412
413
# File 'lib/AutoItX3/control.rb', line 411

def selected
  send_command_to_list_view("GetSelected", 1).split("|")
end

#selected?(item) ⇒ Boolean

Returns wheather or not item is selected.

Returns:

  • (Boolean)


436
437
438
# File 'lib/AutoItX3/control.rb', line 436

def selected?(item)
  send_command_to_list_view("IsSelected", item).to_i == 1
end

#send_command_to_list_view(command, arg1 = "", arg2 = "") ⇒ Object

Sends cmd to self. This method is only used internally.

Raises:



372
373
374
375
376
377
378
379
# File 'lib/AutoItX3/control.rb', line 372

def send_command_to_list_view(command, arg1 = "", arg2 = "")
  Control.functions[__method__] ||= AU3_Function.new("ControlListView", 'SSSSSSPI')
  buffer = " " * BUFFER_SIZE
  buffer.wide!
  Control.functions[__method__].call(@title.wide, @text.wide, @c_id.wide, command.wide, arg1.to_s.wide, arg2.to_s.wide, buffer, BUFFER_SIZE - 1)
  raise(Au3Error, "Unknown error occured when sending '#{command}' to '#{@c_id}' in '#{@title}'! Maybe an invalid window?") if AutoItX3.last_error == 1
  buffer.normal.strip
end

#text_at(item, subitem = "") ⇒ Object Also known as: []

call-seq:

AutoItX3::ListView#text_at( item [, subitem ] ) ==> aString
AutoItX3::ListView#[ item [, subitem ] ] ==> aString

Returns the text at the given position.



430
431
432
# File 'lib/AutoItX3/control.rb', line 430

def text_at(item, subitem = "")
  send_command_to_list_view("GetText", item, subitem)
end