Class: VRListview

Inherits:
VRNotifyControl show all
Defined in:
lib/vr/contrib/vrlistviewex.rb,
lib/vr/vrcomctl.rb

Overview

#

VRListview Class

Constant Summary collapse

WINCLASSINFO =
["SysListView32",WStyle::LVS_REPORT,0x200]

Instance Attribute Summary

Attributes inherited from VRNotifyControl

#_vr_notifyarg

Attributes inherited from VRControl

#handlers, #name, #parent

Attributes inherited from VRWinComponent

#parent, #screen

Instance Method Summary collapse

Methods inherited from VRNotifyControl

#_vr_ntfyhandlers, #addFilterArg, #addNotifyHandler, #deleteFilterArg, #deleteNotifyHandler, #notifycontrolinit

Methods inherited from VRControl

Controltype, #add_parentcall, #call_parenthandler, #create, #setFont

Methods inherited from VRWinComponent

#_init, #create, #exwinstyle, #hide, #maximizebox, #maximizebox=, #minimizebox, #minimizebox=, #setscreen, #sizebox, #sizebox=, #tabstop, #tabstop=, #winstyle

Instance Method Details

#addColumn(*args) ⇒ Object



489
490
491
# File 'lib/vr/vrcomctl.rb', line 489

def addColumn(*args)
  insertColumn(30000,*args)   #30000 as a big number. I believe this is enough.
end

#addItem(*args) ⇒ Object



544
545
546
# File 'lib/vr/vrcomctl.rb', line 544

def addItem(*args)
  insertItem(30000,*args)
end

#bkcolor=(color) ⇒ Object



456
457
458
# File 'lib/vr/vrcomctl.rb', line 456

def bkcolor=(color)
  setBkColor(color)
end

#clearColumnsObject



479
480
481
# File 'lib/vr/vrcomctl.rb', line 479

def clearColumns
  while sendMessage(WMsg::LVM_DELETECOLUMN,0,0)!=0 do; end
end

#clearItemsObject



558
559
560
# File 'lib/vr/vrcomctl.rb', line 558

def clearItems
  sendMessage WMsg::LVM_DELETEALLITEM,0,0
end

#countColumnsObject



483
484
485
486
487
# File 'lib/vr/vrcomctl.rb', line 483

def countColumns
  r=0
  while getColumnTextOf(r) do r+=1;  end
  r
end

#countItemsObject



561
562
563
# File 'lib/vr/vrcomctl.rb', line 561

def countItems
  sendMessage WMsg::LVM_GETITEMCOUNT,0,0
end

#countSelectedItemsObject



665
666
667
# File 'lib/vr/vrcomctl.rb', line 665

def countSelectedItems()
  sendMessage WMsg::LVM_GETSELECTED,0,0
end

#deleteColumn(column) ⇒ Object



476
477
478
# File 'lib/vr/vrcomctl.rb', line 476

def deleteColumn(column)
  sendMessage(WMsg::LVM_DELETECOLUMN,column.to_i,0)
end

#deleteItem(idx) ⇒ Object



555
556
557
# File 'lib/vr/vrcomctl.rb', line 555

def deleteItem(idx)
  sendMessage WMsg::LVM_DELETEITEM,idx.to_i,0
end

#eachSelectedItemsObject



656
657
658
659
660
661
662
663
# File 'lib/vr/vrcomctl.rb', line 656

def eachSelectedItems
  n=countItems
  0.upto(n-1) do |i|
    if (getItemStateOf(i)&WConst::LVIS_SELECTED)>0 then
      yield i
    end
  end
end

#ensureVisible(i, partial = true) ⇒ Object



675
676
677
678
# File 'lib/vr/vrcomctl.rb', line 675

def ensureVisible(i,partial=true)
  flag = if partial then 1 else 0 end
  sendMessage WMsg::LVM_ENSUREVISIBLE,i.to_i,flag
end

#extended_selectObject



59
60
61
# File 'lib/vr/contrib/vrlistviewex.rb', line 59

def extended_select
  return !self.winstyle.getter(WStyle::LVS_SINGLESEL)
end

#extended_select=(bool) ⇒ Object



63
64
65
# File 'lib/vr/contrib/vrlistviewex.rb', line 63

def extended_select=(bool)
  self.winstyle.setter(WStyle::LVS_SINGLESEL, !bool)
end

#focused?(idx) ⇒ Boolean

Returns:

  • (Boolean)


654
# File 'lib/vr/vrcomctl.rb', line 654

def focused?(idx) (getItemStateOf(idx)&2)>0 end

#focusedItemObject



589
590
591
# File 'lib/vr/vrcomctl.rb', line 589

def focusedItem
  getNextItem(0,1)
end

#getColumnFormatOf(column) ⇒ Object



522
523
524
525
526
527
528
529
530
531
# File 'lib/vr/vrcomctl.rb', line 522

def getColumnFormatOf(column)
  p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
                   1,0,0,"",0,0)
  rv=sendMessage WMsg::LVM_GETCOLUMN,column.to_i,p
  if rv!=0 then
    @screen.application.unpack(p,WStruct::LVCOLUMN)[1]
  else
    nil
  end
end

#getColumnTextOf(column) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
# File 'lib/vr/vrcomctl.rb', line 511

def getColumnTextOf(column)
  p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
                   4,0,0,"\0"*128,128,0)
  rv=sendMessage WMsg::LVM_GETCOLUMN,column.to_i,p
  r=@screen.application.unpack(p,WStruct::LVCOLUMN)[3]
  if rv!=0 then
    @screen.application.pointer2string(r)
  else
    nil
  end
end

#getColumnWidthOf(column) ⇒ Object



493
494
495
# File 'lib/vr/vrcomctl.rb', line 493

def getColumnWidthOf(column)
  sendMessage(WMsg::LVM_GETCOLUMNWIDTH,column.to_i,0)
end

#getItemIconOf(idx) ⇒ Object



604
605
606
607
608
609
# File 'lib/vr/vrcomctl.rb', line 604

def getItemIconOf(idx)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        0x2,idx,0,0,0,"",0,0,0)
  sendMessage( WMsg::LVM_GETITEM,0,lvitem )
  @screen.application.unpack(lvitem,WStruct::LVITEM)[7]
end

#getItemLParamOf(idx) ⇒ Object



646
647
648
649
650
651
# File 'lib/vr/vrcomctl.rb', line 646

def getItemLParamOf(idx)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        0x4,idx,0,0,0,"",0,0,0)
  sendMessage( WMsg::LVM_GETITEM,0,lvitem )
  @screen.application.unpack(lvitem,WStruct::LVITEM)[8]
end

#getItemRect(item, code = 0) ⇒ Object



669
670
671
672
673
# File 'lib/vr/vrcomctl.rb', line 669

def getItemRect(item,code=0)
  prc = [code,0,0,0].pack("iiii")
  sendMessage WMsg::LVM_GETITEMRECT,item,prc
  prc.unpack("iiii")
end

#getItemStateOf(idx) ⇒ Object



616
617
618
# File 'lib/vr/vrcomctl.rb', line 616

def getItemStateOf(idx)
  sendMessage WMsg::LVM_GETITEMSTATE,idx.to_i,0xffff
end

#getItemTextOf(idx, subitem = 0, textsize = 128) ⇒ Object



633
634
635
636
637
638
639
# File 'lib/vr/vrcomctl.rb', line 633

def getItemTextOf(idx,subitem=0,textsize=128)
  app=@screen.application
  lvitem=app.arg2cstructStr(WStruct::LVITEM,
                   0,0,subitem,0,0,"\0"*textsize,textsize,0,0)
  sendMessage( WMsg::LVM_GETITEMTEXT,idx,lvitem )
  app.pointer2string(app.unpack(lvitem,WStruct::LVITEM)[5])
end

#getNextItem(start, flag) ⇒ Object



577
578
579
580
581
582
583
584
585
586
587
# File 'lib/vr/vrcomctl.rb', line 577

def getNextItem(start,flag)
  r=sendMessage WMsg::LVM_GETNEXTITEM,start,MAKELPARAM(flag,0)
  case(r)
  when -1
    0
  when 0
    nil
  else
    r
  end
end

#getViewModeObject



443
444
445
# File 'lib/vr/vrcomctl.rb', line 443

def getViewMode
  self.style & 0xfffffff8
end

#grid_linesObject



43
44
45
# File 'lib/vr/contrib/vrlistviewex.rb', line 43

def grid_lines
  return exstyle_getter(WExStyle::LVS_EX_GRIDLINES)
end

#grid_lines=(bool) ⇒ Object



47
48
49
# File 'lib/vr/contrib/vrlistviewex.rb', line 47

def grid_lines=(bool)
  exstyle_setter(WExStyle::LVS_EX_GRIDLINES, bool)
end

#hide_selectionObject



51
52
53
# File 'lib/vr/contrib/vrlistviewex.rb', line 51

def hide_selection
  return !self.winstyle.getter(WStyle::LVS_SHOWSELALWAYS)
end

#hide_selection=(bool) ⇒ Object



55
56
57
# File 'lib/vr/contrib/vrlistviewex.rb', line 55

def hide_selection=(bool)
  self.winstyle.setter(WStyle::LVS_SHOWSELALWAYS, !bool)
end

#hittest(x, y) ⇒ Object



564
565
566
567
568
569
# File 'lib/vr/vrcomctl.rb', line 564

def hittest(x,y)
  lvhit=@screen.application.arg2cstructStr(WStruct::LVHITTEST,
                        x.to_i,y.to_i,0,0)
  sendMessage WMsg::LVM_HITTEST,0,lvhit
  @screen.application.unpack(lvhit,WStruct::LVHITTEST)[3]
end

#hittest2(x, y) ⇒ Object



570
571
572
573
574
575
# File 'lib/vr/vrcomctl.rb', line 570

def hittest2(x,y)
  lvhit=@screen.application.arg2cstructStr(WStruct::LVHITTEST,
                        x.to_i,y.to_i,0,0)
  sendMessage WMsg::LVM_SUBITEMHITTEST,0,lvhit
  @screen.application.unpack(lvhit,WStruct::LVHITTEST)
end

#iconviewObject



446
# File 'lib/vr/vrcomctl.rb', line 446

def iconview() setViewMode(0) end

#insertColumn(column, title, width = 50, style = 0, textsize = title.size) ⇒ Object



470
471
472
473
474
# File 'lib/vr/vrcomctl.rb', line 470

def insertColumn(column,title,width=50,style=0,textsize=title.size)
  lv=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
                 0xf,style.to_i,width.to_i,title.to_s,textsize,column,0,0)
  sendMessage WMsg::LVM_INSERTCOLUMN,column.to_i,lv
end

#insertItem(index, texts, lparam = 0, textsize = 128) ⇒ Object



533
534
535
536
537
538
539
540
541
542
# File 'lib/vr/vrcomctl.rb', line 533

def insertItem(index,texts,lparam=0,textsize=128)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        0xf,index,0,0,0,texts[0].to_s,textsize,0,lparam)
  item=sendMessage(WMsg::LVM_INSERTITEM,0,lvitem)

  1.upto(texts.size-1) do |subitem|
    setItemTextOf(item,subitem,texts[subitem],textsize)
  end
  item
end

#insertMultiItems(index, multitexts, textsize = 128) ⇒ Object



548
549
550
551
552
553
# File 'lib/vr/vrcomctl.rb', line 548

def insertMultiItems(index,multitexts,textsize=128)
  n=multitexts.size
  0.upto(n-1) do |i|
    insertItem(index+i,*multitexts[i])
  end
end

#listviewObject



449
# File 'lib/vr/vrcomctl.rb', line 449

def listview() setViewMode(3) end

#listviewinitObject



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/vr/vrcomctl.rb', line 416

def listviewinit
  addNotifyHandler(WMsg::LVN_ITEMCHANGED,"itemchanged",
                  MSGTYPE::ARGSTRUCT,WStruct::NM_LISTVIEW)
  addFilterArg WMsg::LVN_ITEMCHANGED,"TFFTFFFF"

  addNotifyHandler(WMsg::LVN_ITEMCHANGING,"itemchanging",
                  MSGTYPE::ARGSTRUCT,WStruct::NM_LISTVIEW)
  addFilterArg WMsg::LVN_ITEMCHANGING,"TFFTFFFF"

  addNotifyHandler(WMsg::LVN_COLUMNCLICK,"columnclick",
                  MSGTYPE::ARGSTRUCT,WStruct::NM_LISTVIEW)
  addFilterArg WMsg::LVN_COLUMNCLICK,"FTFFFFFF"

  addNotifyHandler(WMsg::LVN_BEGINDRAG,"begindrag",
                  MSGTYPE::ARGNONE,nil)

  addNotifyHandler(WMsg::LVN_BEGINRDRAG,"beginrdrag",
                  MSGTYPE::ARGNONE,nil)
end

#lvexstyleObject



466
467
468
# File 'lib/vr/vrcomctl.rb', line 466

def lvexstyle
  sendMessage WMsg::LVM_GETEXTENDEDLISTVIEWSTYLE,0,0
end

#lvexstyle=(sty) ⇒ Object



463
464
465
# File 'lib/vr/vrcomctl.rb', line 463

def lvexstyle=(sty)
  setListviewExStyle(sty)
end

#reportviewObject



447
# File 'lib/vr/vrcomctl.rb', line 447

def reportview() setViewMode(1) end

#row_selectObject

#

Instance Methods



35
36
37
# File 'lib/vr/contrib/vrlistviewex.rb', line 35

def row_select
  return exstyle_getter(WExStyle::LVS_EX_FULLROWSELECT)
end

#row_select=(bool) ⇒ Object



39
40
41
# File 'lib/vr/contrib/vrlistviewex.rb', line 39

def row_select=(bool)
  exstyle_setter(WExStyle::LVS_EX_FULLROWSELECT, bool)
end

#selected?(idx) ⇒ Boolean

Returns:

  • (Boolean)


653
# File 'lib/vr/vrcomctl.rb', line 653

def selected?(idx) (getItemStateOf(idx)&1)>0 end

#selectItem(idx, flag) ⇒ Object



619
620
621
622
623
624
625
626
# File 'lib/vr/vrcomctl.rb', line 619

def selectItem(idx,flag)
  if flag then
    s = getItemStateOf(idx) | WConst::LVIS_SELECTED
  else
    s = getItemStateOf(idx) & (~ WConst::LVIS_SELECTED)
  end
  setItemStateOf(idx,s)
end

#setBkColor(color) ⇒ Object



452
453
454
# File 'lib/vr/vrcomctl.rb', line 452

def setBkColor(color)
  sendMessage WMsg::LVM_SETBKCOLOR,0,color.to_i
end

#setColumnFormatOf(column, format) ⇒ Object



506
507
508
509
510
# File 'lib/vr/vrcomctl.rb', line 506

def setColumnFormatOf(column,format)
  p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
                   1,format,0,"",0,0)
  sendMessage WMsg::LVM_SETCOLUMN,column.to_i,p
end

#setColumnTextOf(column, text) ⇒ Object



501
502
503
504
505
# File 'lib/vr/vrcomctl.rb', line 501

def setColumnTextOf(column,text)
  p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
                   4,0,0,text,text.size,0)
  sendMessage WMsg::LVM_SETCOLUMN,column.to_i,p
end

#setColumnWidthOf(column, width) ⇒ Object



497
498
499
# File 'lib/vr/vrcomctl.rb', line 497

def setColumnWidthOf(column,width)
  sendMessage(WMsg::LVM_SETCOLUMNWIDTH,column.to_i,width.to_i)
end

#setImagelist(imagelist, itype = 0) ⇒ Object



593
594
595
596
597
# File 'lib/vr/vrcomctl.rb', line 593

def setImagelist(imagelist,itype=0)
  raise "not Imagelist" unless imagelist.is_a?(SWin::Imagelist)
  self.properties["imagelist"]=imagelist
  sendMessage WMsg::LVM_SETIMAGELIST,itype,imagelist.himagelist
end

#setItemIconOf(idx, imageid) ⇒ Object



599
600
601
602
603
# File 'lib/vr/vrcomctl.rb', line 599

def setItemIconOf(idx,imageid)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        2,idx,0,0,0xffff,"",0,imageid.to_i,0) # 2=LVIF_IMAGE
  sendMessage WMsg::LVM_SETITEM,idx.to_i,lvitem
end

#setItemLParamOf(idx, lparam) ⇒ Object



641
642
643
644
645
# File 'lib/vr/vrcomctl.rb', line 641

def setItemLParamOf(idx,lparam)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        0x4,idx,0,0,0,"",0,0,lparam.to_i)
  sendMessage WMsg::LVM_SETITEM,0,lvitem
end

#setItemStateOf(idx, state) ⇒ Object



611
612
613
614
615
# File 'lib/vr/vrcomctl.rb', line 611

def setItemStateOf(idx,state)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        0,0,0,state,0xffff,"",0,0,0)
  sendMessage WMsg::LVM_SETITEMSTATE,idx.to_i,lvitem
end

#setItemTextOf(idx, subitem, text, textsize = text.size) ⇒ Object



628
629
630
631
632
# File 'lib/vr/vrcomctl.rb', line 628

def setItemTextOf(idx,subitem,text,textsize=text.size)
  lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
                        0,0,subitem,0,0,text.to_s,textsize,0,0)
  sendMessage WMsg::LVM_SETITEMTEXT,idx.to_i,lvitem
end

#setListviewExStyle(sty, mask = 0xffffffff) ⇒ Object



460
461
462
# File 'lib/vr/vrcomctl.rb', line 460

def setListviewExStyle(sty,mask=0xffffffff)
  sendMessage WMsg::LVM_SETEXTENDEDLISTVIEWSTYLE,mask,sty
end

#setViewMode(mode) ⇒ Object



440
441
442
# File 'lib/vr/vrcomctl.rb', line 440

def setViewMode(mode)
  self.style = (self.style & 0xfffffff8) + (mode&3)
end

#smalliconviewObject



448
# File 'lib/vr/vrcomctl.rb', line 448

def smalliconview() setViewMode(2) end

#vrinitObject



435
436
437
438
# File 'lib/vr/vrcomctl.rb', line 435

def vrinit
  super
  listviewinit
end