EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   ctrlci.g

   dialogs.g

   dlgbtns.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   header.g

   images.g

   label.g

   labeled.g

   listviewitem.g

   locustr.g

   menu.g

   panel.g

   picture.g

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   timer.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

source\lib\vis\listviewitem.g
   1 
   2 extern {
   3 //property ustr LVColumn.Label <result>()
   4 property ustr LVCell.Label <result>()
   5 method vListView.iGetColumnOrders()
   6 property vListViewColumn.Order( uint val )
   7 property ustr LVCell.Label <result> ()
   8 method vListViewColumn LVColumns.Find( ustr alias )
   9 method vListViewColumn LVColumns.index( uint idx )
  10 method vListViewColumn.iWinUpdate( uint mask )
  11 operator uint *( LVColumns obj )
  12 method LVCell LVRow.FindCell( ustr alias )
  13 method LVCell LVRow.index( uint colidx )
  14 method LVCell.iWinUpdate( uint mask )
  15 method uint LVRows.first( fordata tfd )
  16 method uint LVRows.next( fordata tfd )
  17 method uint LVRows.eof( fordata tfd )
  18 property uint LVRow.Idx()
  19 method LVRow LVRows.index( uint idx )
  20 property uint LVCell.StateIndex
  21 property uint vListViewColumn.Idx()
  22 method LVRow.iWinUpdate( uint mask )
  23 property uint LVRow.VisIndex
  24 property vListViewColumn.Sorted( uint val )
  25 }
  26 
  27 
  28 method LVRow vListView.RowFromVisIndex( uint visindex )
  29 {
  30    LVITEM lvi
  31    lvi.mask = $LVIF_PARAM
  32    lvi.iItem = visindex 
  33    .WinMsg( $LVM_GETITEMW, 0, &lvi )
  34    return lvi.lParam->LVRow   
  35 }
  36 
  37 method vListViewColumn.iWinInsert()
  38 {
  39    if this.Owner->vListView.hwnd 
  40    {
  41       if .pIndex 
  42       {
  43          LVCOLUMN lvc
  44          uint index = this.pIndex//this.param->LVColumnData.idx
  45          lvc.mask = $LVCF_SUBITEM | $LVCF_TEXT //| $LVCF_WIDTH | $LVCF_ORDER//| $LVCF_IMAGE //| $LVCF_FMT
  46          //lvc.fmt = 0x8000 //$LVCFMT_COL_HAS_IMAGES | $LVCFMT_BITMAP_ON_RIGHT //| 0x400//| 0x8000 
  47          lvc.iSubItem = index  
  48          lvc.pszText = "".ustr().ptr()
  49          //lvc.cx = .pWidth
  50          //lvc.iImage = -1
  51          this.Owner->vListView.WinMsg( $LVM_INSERTCOLUMNW, index, &lvc )
  52          uint header = this.Owner->vListView.WinMsg( $LVM_GETHEADER )
  53          HDITEM hdi
  54          hdi.mask = 0x0004 | //| $HDI_FORMAT      
  55          hdi.fmt = 0x8000
  56          //SendMessage( header, 0x1204/*$HDM_SETITEM*/, index, &hdi )
  57       }
  58       .iWinUpdate( $LVCF_TEXT | $LVCF_WIDTH | $LVCF_ORDER )
  59    }
  60    //this.param->LVColumnData.pColumns->LVColumns.pListView->vListView.WinMsg( $LVM_INSERTCOLUMNW, index, &lvc )
  61 }
  62 
  63 method vListViewColumn.iWinRemove()
  64 {
  65    if .pIndex : this.Owner->vListView.WinMsg( $LVM_DELETECOLUMN, .pIndex )
  66 }
  67 
  68 method vListViewColumn.iWinUpdate( uint mask )
  69 {
  70    if &.Owner
  71    {  
  72       LVCOLUMN lvc
  73       uint listview as .Owner->vListView      
  74       lvc.mask = mask 
  75        
  76       if lvc.mask & $LVCF_FMT
  77       {
  78          if .pSorted == $lvsortDown : lvc.fmt = $HDF_SORTDOWN
  79          elif .pSorted == $lvsortUp : lvc.fmt = $HDF_SORTUP
  80       }      
  81       lvc.pszText = .pCaption->locustr.Text( this ).ptr()
  82       if .pVisible
  83       {
  84          lvc.cx = .pWidth
  85          //lvc.iOrder = .pOrder
  86          uint i
  87          fornum i=0, *listview.Columns
  88          {
  89             if listview.Columns[i].pOrder < .pOrder
  90             {
  91                if listview.Columns[i].pVisible : lvc.iOrder++
  92             }
  93          }
  94       }
  95       else 
  96       {
  97          lvc.cx = 0
  98          uint i         
  99          lvc.iOrder = *listview.Columns - 1
 100          //*listview.Columns - 1
 101       }
 102       
 103 /*      if mask & $LVCF_IMAGE
 104       {      
 105          lvc.iImage = listview.ptrImageList->ImageList.GetImageIdx( listview.numImageList, .pImageId, 0 )
 106           print( "l \(lvc.iImage)\n" )             
 107       }*/    
 108       
 109        
 110       listview.WinMsg( $LVM_SETCOLUMNW, .pIndex, &lvc )
 111       
 112       
 113       //SendMessage( header, 0x1204/*$HDM_SETITEM*/, index, &hdi )
 114       
 115       /*uint header = this.Owner->vListView.WinMsg( $LVM_GETHEADER )
 116       HDITEM hdi
 117       hdi.mask = 0x0004 //| $HDI_FORMAT      
 118       hdi.fmt = 0x8000      
 119       SendMessage( header, 0x1204, .pIndex, &hdi )*/
 120       /*if mask & $LVCF_WIDTH 
 121       {
 122       
 123          listview.WinMsg( $LVM_SETCOLUMNWIDTH, .pIndex, .pWidth )   
 124       }*/
 125    }
 126 }
 127 
 128 method vListViewColumn.init()
 129 {   
 130    this.pTypeId = vListViewColumn
 131    this.pWidth = 50
 132    this.pVisible = 1
 133    this.pDefSorted = $lvsortDown
 134    //this.pAutoLang = 0
 135 }
 136 
 137 
 138 
 139 method vListViewColumn LVColumns.index( uint idx )
 140 {  
 141    uint listview as .pListView->vListView
 142    if &listview
 143    {
 144       return listview.Comps[idx]->vListViewColumn
 145    }
 146    return 0->vListViewColumn
 147 }
 148 
 149 operator uint *( LVColumns obj )
 150 {
 151    uint listview as obj.pListView->vListView
 152    if &listview
 153    {
 154       return *listview.Comps
 155    }
 156    return 0
 157 }
 158 
 159 method vListViewColumn LVColOrder.index( uint idx )
 160 {  
 161    uint listview as .pListView->vListView
 162    if &listview && idx < *.pListView->vListView.Columns
 163    {
 164       return listview.arOrder[idx]->vListViewColumn
 165    }
 166    return 0->vListViewColumn
 167 }
 168 
 169 method vListViewColumn LVColumns.Append()
 170 {  
 171    uint listview as .pListView->vListView
 172    uint item as vListViewColumn
 173    if &listview
 174    {
 175       item as listview.CreateComp( vListViewColumn )->vListViewColumn
 176       item.Order = item.pIndex 
 177    }
 178    return item   
 179 }
 180 
 181 method vListViewColumn LVColumns.Insert( uint index )
 182 {  
 183    uint listview as .pListView->vListView
 184    uint item as vListViewColumn
 185    if &listview
 186    {
 187       item as listview.CreateComp( vListViewColumn )->vListViewColumn            
 188       item.CompIndex = index      
 189       //listview.iGetColumnOrders()            
 190       listview.Reload()     
 191       item.Order = index 
 192    }
 193    return item   
 194 }
 195 
 196 
 197 
 198 /*
 199 method LVColumn LVColumns.Insert( uint index )
 200 {
 201    uint item
 202    uint data
 203    index = min( index, *this )
 204    this.insert( index )
 205    item as .pListView->vListView.gtcolumns->gtitem.insertchild( "", ?( index, this[index-1], 0 )->gtitem )->LVColumn
 206    this->arr of uint [index] = &item
 207    data as new( LVColumnData )->LVColumnData
 208    item.param = &data
 209    data.pColumns = &this
 210    data.idx = index
 211    
 212    item.iWinInsert()  
 213    return item
 214 }
 215 */
 216 
 217 /*
 218 
 219 
 220 method LVColumn.Release()
 221 {   
 222    if .param
 223    {      
 224       uint data as .param->LVColumnData
 225       uint columns as data.pColumns->LVColumns
 226       uint listview as columns.pListView->vListView
 227       
 228       columns.del( data.idx )
 229       listview.WinMsg( $LVM_DELETECOLUMN, data.idx )    
 230       
 231       destroy( &data )
 232       .param = 0
 233    }
 234 }
 235 
 236 method LVColumn.Del()
 237 {
 238    .Release()
 239    .del()   
 240 }
 241 */
 242 /* Свойство ustr Label - Get Set
 243 Устанавливает или определяет заголовок колонки
 244 */
 245 property ustr vListViewColumn.Caption <result>
 246 { 
 247    result = this.pCaption.Value
 248 }
 249 
 250 property vListViewColumn.Caption( ustr val )
 251 {
 252    if val != this.pCaption.Value
 253    {       
 254       this.pCaption.Value = val      
 255       .iWinUpdate( $LVCF_TEXT )
 256    }   
 257 }
 258 
 259 /* Свойство ustr Alias - Get Set
 260 Устанавливает или определяет псевдоним колонки
 261 */
 262 property ustr vListViewColumn.Alias <result>
 263 { 
 264    result = this.pAlias
 265 }
 266 
 267 property vListViewColumn.Alias( ustr val )
 268 {
 269    if this.pAlias != val
 270    {
 271       this.pAlias = val
 272    }   
 273 }
 274 /*
 275 
 276 property uint LVColumn.Idx()
 277 {
 278    if .param : return .param->LVColumnData.idx
 279    return -1
 280 }
 281 
 282 property vListView LVColumn.ListView()
 283 {
 284    if .param : return .param->LVColumnData.pColumns->LVColumns.pListView->vListView
 285    return 0->vListView
 286 }
 287 */
 288 /* Свойство uint Width - Get Set
 289 Устанавливает или определяет псевдоним колонки
 290 */
 291 property uint vListViewColumn.Width
 292 { 
 293    return .pWidth
 294 }
 295 
 296 property vListViewColumn.Width( uint val )
 297 {   
 298    if .pWidth != val
 299    {
 300       .pWidth = val
 301       .iWinUpdate( $LVCF_WIDTH )
 302    }   
 303 }
 304 
 305 
 306 /* Свойство uint Order - Get Set
 307 Устанавливает или определяет порядковый номер колонки при отображении
 308 */
 309 method vListView.iGetColumnOrders()
 310 {
 311    arr arcol[*.Columns] of uint
 312    uint i
 313    LVCOLUMN lvc
 314    
 315    .WinMsg( $LVM_GETCOLUMNORDERARRAY, *.Columns, arcol.ptr() )
 316    fornum i, *.Columns
 317    {
 318      // print( "xxx= \(i) \( arcol[i] )\n" )
 319       uint col as .Columns[arcol[i]]
 320       col.pOrder = i
 321       .arOrder[i] = &col
 322    }
 323    
 324    /*lvc.mask = $LVCF_ORDER
 325    fornum i, *.Columns
 326    {  
 327       uint col as .Columns[i]       
 328       if col.pVisible
 329       {
 330          .WinMsg( $LVM_GETCOLUMNW, i, &lvc )               
 331          col.pOrder = lvc.iOrder
 332       }
 333       .arOrder[col.pOrder] = &col
 334    } */    
 335 }
 336 
 337 /* Свойство uint Visible - Get Set
 338 Устанавливает или определяет видимость колонки
 339 */
 340 property uint vListViewColumn.Visible
 341 { 
 342    return .pVisible
 343 }
 344 
 345 property vListViewColumn.Visible( uint val )
 346 {  
 347    if .pVisible != val
 348    {
 349       .pVisible = val
 350       
 351       .iWinUpdate( $LVCF_WIDTH | $LVCF_ORDER )
 352       .Owner->vListView.iGetColumnOrders()
 353    }   
 354 }
 355 
 356 
 357 property uint vListViewColumn.Order
 358 { 
 359    return .pOrder
 360 }
 361 
 362 property vListViewColumn.Order( uint val )
 363 {   
 364    if .pOrder != val
 365    {
 366       .pOrder = val
 367       .iWinUpdate( $LVCF_ORDER )
 368       .Owner->vListView.iGetColumnOrders()
 369       .Owner->vListView.Invalidate()
 370    }   
 371 }
 372 
 373 /* Свойство str vListViewColumn.Image - Get Set
 374 Усотанавливает или получает картинку
 375 */
 376 /*property ustr vListViewColumn.ImageId <result>
 377 {
 378    result = this.pImageId
 379 }
 380 
 381 property vListViewColumn.ImageId( ustr val )
 382 {
 383    if val != .pImageId
 384    { 
 385       .pImageId = val
 386       //.iUpdateImage()
 387       .iWinUpdate( $LVCF_IMAGE | $LVCF_TEXT  )      
 388    } 
 389 }
 390 */
 391 
 392 /* Свойство str vListViewColumn.AdvSortColumn - Get Set
 393 Указатель на колонку для дополнительной сортировки
 394 */
 395 property vListViewColumn vListViewColumn.AdvSortColumn
 396 {
 397    return this.pAdvSortColumn->vListViewColumn
 398 }
 399 
 400 property vListViewColumn.AdvSortColumn( vListViewColumn val )
 401 {
 402    if &val != .pAdvSortColumn
 403    {  
 404       if &val
 405       {         
 406          uint next = &val
 407          uint lv as .Owner
 408          while next
 409          {
 410             if &next->vListViewColumn.Owner != &lv || next == &this : return
 411             next = next->vListViewColumn.pAdvSortColumn
 412          }
 413       }
 414       .pAdvSortColumn = &val                  
 415    } 
 416 }
 417 
 418 
 419 
 420 // Свойство str vListViewColumn.Sorted - Get Set
 421 //Сортировка колонки
 422 //
 423 property uint vListViewColumn.Sorted 
 424 {
 425    return this.pSorted
 426 }
 427 
 428 method vListViewColumn.iSortUpdate()
 429 {
 430    if .pSorted
 431    {
 432       uint lv as .Owner->vListView
 433       if lv.pSortedColumn && 
 434          lv.pSortedColumn != &this
 435       {
 436          lv.pSortedColumn->vListViewColumn.Sorted = 0          
 437       }         
 438       lv.pSortedColumn = &this
 439       lv.WinMsg( $LVM_SORTITEMSEX, &this, lv.pSortFunc ) 
 440    }           
 441 }
 442 
 443 property vListViewColumn.Sorted( uint val )
 444 {
 445    if val != .Sorted
 446    {  
 447       if .pSortType
 448       {
 449          .pSorted = val
 450          .iWinUpdate( $LVCF_FMT )
 451          .iSortUpdate()
 452       }
 453    }
 454 }
 455 
 456 // Свойство str vListViewColumn.DefSorted - Get Set
 457 //Сортировка колонки по умолчанию
 458 //
 459 property uint vListViewColumn.DefSorted 
 460 {
 461    return this.pDefSorted
 462 }
 463 
 464 property vListViewColumn.DefSorted( uint val )
 465 {
 466    if val != .DefSorted
 467    {       
 468       .pDefSorted = val
 469                  
 470    }
 471 
 472 }
 473 
 474 
 475 /* Свойство str vListViewColumn.SortType - Get Set
 476 Тип сортировки колонки
 477 */
 478 property uint vListViewColumn.SortType
 479 {
 480    return this.pSortType
 481 }
 482 
 483 property vListViewColumn.SortType( uint val )
 484 {
 485    if val != .pSortType
 486    { 
 487       .pSortType = val            
 488    }
 489    //.iUpdateImage()
 490  /*        
 491       this.pCaption.Value = val
 492       .iUpdateCaption()
 493       .iUpdateSize()      
 494    }*/ 
 495 }
 496 /*
 497 method LVColumn LVColumns.GetColumn( ustr alias )
 498 {
 499    uint i
 500    fornum i = 0, *this
 501    {
 502       uint column as this[i]
 503       if column.Alias == alias : return column             
 504    }
 505    return 0->LVColumn  
 506 }
 507 
 508 method uint LVColumns.IndexFromAlias( ustr alias )
 509 {
 510    uint column as .GetColumn( alias )
 511    if &column
 512    {
 513       return column.Idx()
 514    }
 515    return -1
 516 }
 517 */
 518 
 519 method LVRow.iWinInsert()
 520 {
 521    LVITEM lvi
 522    uint index = this.param->LVRowData.idx
 523    lvi.mask = /*$LVCF_SUBITEM |*/ $LVCF_TEXT | $LVIF_PARAM
 524    lvi.iItem = index  
 525    lvi.pszText = "ssss".ustr().ptr()
 526    lvi.lParam = &this   
 527    with this.param->LVRowData.pRows->LVRows.pListView->vListView
 528    {
 529       .flgRowInserting = 1
 530       .WinMsg( $LVM_INSERTITEMW, 0, &lvi )
 531       .flgRowInserting = 0
 532    }
 533 }
 534 
 535 
 536 method LVRows.init()
 537 {
 538    //this->arr.oftype( LVRow )
 539 }
 540 method LVRow LVRows.index( uint idx )
 541 {
 542    return this->arr of uint[idx]->LVRow
 543 }
 544 
 545 method LVRow LVRows.Insert( uint index, gtitem srcitem )
 546 {   
 547    uint item as LVRow
 548    uint data
 549    index = min( index, *this )
 550    this.insert( index )
 551    uint after as ?( index, this[index-1], 0 )->gtitem
 552    uint listview as .pListView->vListView   
 553          
 554    if &srcitem : item as listview.gtrows->gtitem.copy( srcitem, after )->LVRow
 555    else : item as listview.gtrows->gtitem.insertchild( "", after )->LVRow
 556     
 557    this->arr of uint[index] = &item  
 558   
 559    data as new( LVRowData )->LVRowData  
 560    item.param = &data
 561    data.pRows = &this
 562    data.idx = index
 563    
 564    uint i
 565    fornum i = index + 1, *this
 566    {
 567       this[i].param->LVRowData.idx++
 568    }
 569    
 570    item.iWinInsert()  
 571    if &srcitem : item.iWinUpdate( 0 )
 572    if !&listview.Selected: listview.Selected = item
 573    return item
 574 }
 575 
 576 method LVRow LVRows.Insert( uint index )
 577 {
 578    return .Insert( index, 0->gtitem )
 579 }
 580 
 581 method LVRow LVRows.Append( gtitem srcitem )
 582 {
 583    return .Insert( *this, srcitem )
 584 }
 585 
 586 method LVRow LVRows.Append()
 587 {
 588    return .Insert( *this, 0->gtitem )
 589 }
 590 
 591 method LVRows.SetCount( uint count )
 592 {
 593    uint listview as .pListView->vListView
 594    
 595    if listview.pOwnerData
 596    {
 597       listview.WinMsg( $LVM_SETITEMCOUNT, count )      
 598    } 
 599 }
 600 
 601 
 602 
 603 method LVRow.iWinUpdate( uint mask )
 604 {
 605    if .param
 606    {  
 607       LVRow lvr    
 608       uint data as .param->LVRowData
 609       uint rows as data.pRows->LVRows
 610       uint listview as rows.pListView->vListView
 611       uint columns as listview.Columns
 612       uint i
 613       fornum i, *columns
 614       { 
 615          uint cell as LVCell      
 616          if *columns[i].Alias 
 617          {   
 618             cell as .FindCell(columns[i].Alias)
 619 /*                      
 620             uint cell as .findrel( "/" + columns[i].Alias.str() )->LVCell
 621             if &cell
 622             {
 623             LVITEM lvi
 624             lvi.mask = $LVIF_TEXT //mask// | $LVCF_WIDTH
 625             lvi.iItem = data.idx      
 626             lvi.iSubItem = i//column.param->LVColumnData.idx 
 627             lvi.pszText = cell.Label->locustr.Text( listview ).ptr()            
 628             //lvc.cx = 100
 629             listview.WinMsg( $LVM_SETITEMW, 0, &lvi )
 630             }*/
 631          }
 632          else
 633          {
 634             cell as this[i]
 635          }
 636          //evparValUint evu
 637          //evu.val = &cell
 638          //listview.OnGetLabel.Run( evu, listview )
 639          
 640          cell.iWinUpdate( $LVIF_TEXT | $LVIF_STATE )//? ( i, 0, $LVIF_STATE ) )         
 641       }
 642       /*lvr.mask = $LVCF_TEXT//mask// | $LVCF_WIDTH
 643       lvr.pszText = .Label->locustr.Text( listview ).ptr()
 644       //lvc.cx = 100
 645       
 646       */
 647    }
 648 }
 649 
 650 
 651 
 652 method LVRow.Release()
 653 {   
 654    if .param
 655    {      
 656       uint data as .param->LVRowData
 657       uint rows as data.pRows->LVRows
 658       uint listview as rows.pListView->vListView
 659       uint visindex = .VisIndex
 660       if &listview.Selected == &this
 661       {  
 662          uint newsel, newidx
 663          /*if data.idx < *rows - 1 : newsel as rows[data.idx + 1]
 664          elif data.idx > 0 : newsel as rows[data.idx - 1]
 665          else : newsel = 0*/
 666          if visindex < *rows - 1 : newidx = visindex + 1
 667          elif visindex > 0 : newidx = visindex - 1
 668          else : newidx = -1
 669          /*
 670          
 671          newidx = listview.WinMsg( $LVM_GETNEXTITEM, visindex, $LVNI_BELOW )
 672          print( "newidx1 \(newidx )\n" ) 
 673          if newidx == -1 
 674          {
 675              newsel = listview.WinMsg( $LVM_GETNEXTITEM, visindex, $LVNI_ABOVE )
 676          }
 677          print( "newidx2 \(newidx )\n" )*/
 678          if newidx == -1 : newsel = 0
 679          else
 680          {            
 681             listview.RowFromVisIndex( newidx ) 
 682          }
 683                                              
 684          listview.Selected = newsel->LVRow                
 685       }      
 686       uint i
 687       fornum i = data.idx + 1, *rows
 688       {
 689          rows[i].param->LVRowData.idx--
 690       }      
 691       listview.WinMsg( $LVM_DELETEITEM, visindex )
 692       rows.del( data.idx )
 693       destroy( &data )
 694       .param = 0
 695    }
 696 }
 697 
 698 method LVRow.Del()
 699 {   
 700 
 701    .Release()
 702    .del()
 703       
 704 }
 705 
 706 /* Свойство uint Prev - Get
 707 Определяет предыдущий элемент, если он есть, иначе 0
 708 */
 709 property LVRow LVRow.Prev
 710 {   
 711    return this->gtitem.getprev()->LVRow
 712    //return this->gtitem.getprev()->LVRow
 713 }
 714 
 715 /* Свойство uint Next - Get
 716 Определяет предыдущий элемент, если он есть, иначе 0
 717 */
 718 property LVRow LVRow.Next
 719 {    
 720    return this->gtitem.getnext()->LVRow
 721 }
 722 
 723 property uint LVRow.VisIndex
 724 {
 725    LVFINDINFO fi
 726    uint lv as .param->LVRowData.pRows->LVRows.pListView->vListView
 727    fi.flags = $LVFI_PARAM
 728    fi.lParam = &this 
 729    return lv.WinMsg( $LVM_FINDITEMW, -1, &fi )  
 730 }
 731 
 732 method LVRow.MoveTo( LVRow dest, uint flag )
 733 {   
 734 
 735    //if &this.Next() != &dest
 736    {  
 737       uint lv as .param->LVRowData.pRows->LVRows.pListView->vListView 
 738       uint rows as lv.Rows
 739       evparBeforeMove evpB
 740       evpB.CurItem = &this
 741       evpB.DestItem = &dest      
 742       evpB.Flag     = flag
 743       lv.OnBeforeMove.run( evpB )
 744       if !evpB.flgCancel
 745       {            
 746          uint srcidx = .Idx
 747          uint destidx
 748          switch flag
 749          {
 750             case $TREE_BEFORE
 751             { 
 752                destidx = dest.Idx
 753                if destidx > srcidx : destidx--
 754             }
 755             case $TREE_AFTER
 756             {
 757                destidx = dest.Idx
 758                if destidx < srcidx : destidx++  
 759             }
 760             case $TREE_FIRST
 761             {
 762                destidx = 0
 763             }
 764             case $TREE_LAST
 765             {
 766                destidx = *rows - 1            
 767             }
 768          }
 769          lv.WinMsg( $LVM_DELETEITEM, /*.Idx*/.VisIndex, 0)
 770          this.move( dest, flag )
 771          rows.move( srcidx, destidx )
 772          uint i
 773          fornum i = min( srcidx, destidx ), max( srcidx, destidx ) + 1
 774          {
 775             rows[i].param->LVRowData.idx = i
 776          }
 777          //lv.WinMsg( $LVM_INSERTITEM, .Idx
 778          this.iWinInsert()
 779          this.iWinUpdate( 0 )
 780          evparAfterMove evpA
 781          evpA.CurItem = &this
 782          evpA.DestItem = &dest
 783          evpA.Flag = flag
 784          lv.OnAfterMove.run( evpA )
 785          if &lv.Selected == &this
 786          {
 787             lv.Selected = 0->LVRow
 788             lv.Selected = this
 789          }
 790       }
 791    }
 792 }
 793 
 794 method LVCell.iCheck( LVRow row )
 795 {  
 796    if !.param : .param = new( LVCellData )
 797    .param->LVCellData.row = &row
 798    //.param->LVCellData.column = &.Columns[col]   
 799 }
 800 
 801 
 802 method LVCell LVRow.FindCell( ustr alias )
 803 {
 804    uint listview as .param->LVRowData.pRows->LVRows.pListView->vListView
 805    uint col as listview.Columns.Find( alias )
 806    uint cell as .findrel( "/\(alias.str())" )->LVCell
 807    if !&cell 
 808    {
 809       //if &col : cell as this[col.Idx]
 810       //else : cell as .insertchild( alias.str(), (-1)->gtitem )
 811       cell as .insertchild( alias.str(), (-1)->gtitem )
 812    }
 813    if !cell.param 
 814    {
 815       cell.param = new( LVCellData )
 816    }
 817    cell.param->LVCellData.row = &this
 818    cell.param->LVCellData.column = &col      
 819    return cell
 820 }
 821 
 822 method LVCell LVRow.index( uint colidx )
 823 {
 824    uint cell
 825    uint listview as .param->LVRowData.pRows->LVRows.pListView->vListView   
 826    if colidx < *listview.Columns
 827    {          
 828       if *listview.Columns[colidx].Alias
 829       {
 830          return .FindCell( listview.Columns[colidx].Alias )
 831       }      
 832       uint idx
 833       foreach cell, this
 834       {         
 835          if idx == colidx
 836          {         
 837             if !cell.param 
 838             {
 839                cell.param = new( LVCellData )
 840             }            
 841             cell.param->LVCellData.row = &this
 842             cell.param->LVCellData.column = ?( colidx < *listview.Columns, &listview.Columns[ colidx ], 0 )
 843             return cell->LVCell
 844          }
 845          idx++
 846       }
 847       //cell as (-1)->LVCell
 848    }
 849    elif !colidx
 850    {
 851       cell as .child()
 852       if !&cell
 853       {
 854          cell as .insertchild( "", (-1)->gtitem )
 855       }
 856       if !cell.param 
 857       {
 858          cell.param = new( LVCellData )
 859       }
 860       cell.param->LVCellData.row = &this
 861       cell.param->LVCellData.column = ?( colidx < *listview.Columns, &listview.Columns[ colidx ], 0 )
 862       return cell->LVCell  
 863    } 
 864     
 865    return (-1)->LVCell
 866       /*
 867    fornum idx, colidx + 1
 868    {
 869       str alias
 870       if idx < *listview.Columns
 871       {
 872          alias = listview.Columns[idx].pAlias.str() 
 873       }      
 874       cell as .insertchild( alias, cell )      
 875    }
 876 label end   
 877    if !cell.param 
 878    {
 879       cell.param = new( LVCellData )
 880    }
 881    cell.param->LVCellData.row = &this
 882    cell.param->LVCellData.column = ?( colidx < *listview.Columns, &listview.Columns[ colidx ], 0 )      
 883    return cell*/
 884 }
 885 
 886 method LVCell vListView.Cells( uint rowidx, uint colidx )
 887 {
 888    if rowidx < *.Rows
 889    {  
 890       uint row as .Rows[rowidx]
 891       return row[ colidx ]
 892    }
 893    return 0->LVCell
 894    /*
 895    uint row as .Rows[rowidx]
 896    //return 0->LVCell
 897       
 898    uint item as gtitem
 899    if *.Columns && *.Columns[colidx].Alias
 900    {   
 901       item as row.findrel( "/\(.Columns[colidx].Alias.str())" )
 902       if !&item
 903       {
 904          item as row.insertchild( .Columns[colidx].Alias.str(), (-1)->gtitem )
 905       }
 906    }
 907    else
 908    {
 909          uint idx 
 910          foreach item, row
 911          {
 912             if idx == colidx
 913             {
 914                goto end
 915             }
 916             idx++
 917          }
 918          fornum idx, colidx + 1
 919          {
 920             item as row.insertchild( "", item )
 921          }
 922    }
 923 label end
 924    if !item.param : item.param = new( LVCellData )
 925    item.param->LVCellData.row = &row
 926    if *.Columns
 927    {
 928       item.param->LVCellData.column = &.Columns[colidx]      
 929    }
 930    else : item.param->LVCellData.column = 0
 931    return item->LVCell*/
 932 }
 933 
 934 
 935 method LVCell.iWinUpdate( uint mask )
 936 {
 937    if .param 
 938    {
 939       LVITEM lvi    
 940       uint data as .param->LVCellData
 941       uint row as data.row->LVRow
 942       uint listview as row.param->LVRowData.pRows->LVRows.pListView->vListView
 943       
 944       lvi.pszText = .Label.ptr()
 945       if data.column
 946       {
 947          uint column as data.column->vListViewColumn
 948          lvi.iSubItem = column.pIndex//param->LVColumnData.idx
 949          if column.pUseLanguage 
 950          {
 951             lvi.pszText = .Label->locustr.Text( listview ).ptr()
 952          }
 953       }
 954       else  
 955       {
 956          lvi.iSubItem = 0         
 957       }
 958                
 959       uint tname
 960       ustr imgname   
 961       tname as .get( "image" )
 962       if &tname
 963       {      
 964          imgname.fromutf8( tname )
 965          lvi.iImage = listview.ptrImageList->ImageList.GetImageIdx( listview.numImageList, imgname, uint( .get( "disabled", "" ) ) )
 966       }                   
 967       else : lvi.iImage = -1  
 968       //lvi.iImage = 8     
 969       //print( "WinUpdate \(&listview) \( lvi.iItem) \( lvi.iSubItem ) \(.Label->locustr.Text( listview ).str()) \n" )
 970       
 971       lvi.mask = $LVIF_TEXT | $LVIF_IMAGE//mask// | $LVCF_WIDTH
 972       if !lvi.iSubItem
 973       {     
 974          lvi.mask |= $LVIF_STATE
 975          lvi.stateMask |= $LVIS_STATEIMAGEMASK
 976          if listview.pCheckBoxes
 977          {
 978             uint state = .StateIndex()            
 979             if !state : state = 1
 980             lvi.state = state << 12 
 981          }
 982       }      
 983       //lvi.mask |= $LVIF_STATE
 984       lvi.iItem = row.VisIndex/*row.param->LVRowData.idx*/
 985       //lvc.cx = 100      
 986       listview.WinMsg( $LVM_SETITEMW, lvi.iItem, &lvi )
 987       if listview.pSortedColumn
 988       {  
 989          listview.pSortedColumn->vListViewColumn.iSortUpdate()
 990       }
 991    }
 992 }
 993 
 994 property vListViewColumn LVCell.Column()
 995 {
 996    if .param
 997    {        
 998       return .param->LVCellData.column->vListViewColumn
 999    }
1000    return 0->vListViewColumn
1001 }
1002 /* Свойство ustr Label - Get Set
1003 Устанавливает или определяет заголовок колонки
1004 */
1005 property ustr LVCell.Label <result>
1006 { 
1007    uint name as .get( "label" )     
1008    if &name
1009    {
1010       result.fromutf8( name ).ptr()
1011    }        
1012 }
1013 
1014 property LVCell.Label( ustr val )
1015 {   
1016    .set( "label", val.toutf8( "" ) )   
1017    .iWinUpdate( $LVIF_TEXT )   
1018 }
1019 
1020 /* Свойство ustr vToolBarItem.ImageId - Get Set
1021 Устанавливает или получает картинку
1022 */
1023 property ustr LVCell.ImageId <result>
1024 {
1025    result.fromutf8( .get( "image" ) ).ptr()
1026 }
1027 
1028 property LVCell.ImageId( ustr val )
1029 {
1030    //if val != "".ustr().fromutf8( .get( "image" ) )
1031    { 
1032       .set( "image", val.toutf8( "" ) )
1033       .iWinUpdate( $LVIF_IMAGE  )     
1034    }   
1035 }
1036 
1037 
1038 /* Свойство uint StateIndex - Get Set
1039 Устанавливает или определяет состояние ячейки
1040 */
1041 property uint LVCell.StateIndex
1042 { 
1043    return .getuint( "stateindex" )
1044 }
1045 
1046 property LVCell.StateIndex( uint val )
1047 {
1048    .setuint( "stateindex", val )
1049    .iWinUpdate( $LVIF_STATE )
1050 }
1051 
1052 
1053 /* Свойство uint StateIndex - Get Set
1054 Устанавливает или определяет состояние ячейки
1055 */
1056 property uint LVRow.Checked()
1057 {    
1058    uint state = this[0].StateIndex
1059    if state : state--
1060    return state
1061 }
1062 
1063 property LVRow.Checked( uint val )
1064 {   
1065    this[0].StateIndex = val + 1  
1066 }
1067 
1068 /* Свойство ustr Tag - Get Set
1069 Устанавливает или определяет заголовок колонки
1070 */
1071 property uint LVCell.Tag 
1072 { 
1073    return .getuint( "tag" )
1074 }
1075 
1076 property LVCell.Tag( uint val )
1077 {
1078    .setuint( "tag", val )   
1079 }
1080 
1081 property uint LVRow.Tag 
1082 { 
1083    return .getuint( "tag" )
1084 }
1085 
1086 property LVRow.Tag( uint val )
1087 {
1088    .setuint( "tag", val )   
1089 }
1090 
1091 property LVCell LVRow.Item()
1092 {
1093    if .param
1094    {      
1095       return .param->LVRowData.pRows->LVRows.pListView->vListView.Cells( .param->LVRowData.idx, 0 )      
1096    }
1097    return 0->LVCell
1098 }
1099 
1100 /* Свойство ustr Label - Get Set
1101 Устанавливает или определяет заголовок колонки
1102 */
1103 /*property ustr LVRow.Label <result>
1104 { 
1105    uint name as .get( "label" )     
1106    if &name
1107    {
1108       result.fromutf8( name ).ptr()
1109    }        
1110 }
1111 
1112 property LVRow.Label( ustr val )
1113 {
1114    .set( "label", val.toutf8( "" ) )
1115    .iRowUpdate( $LVCF_TEXT )
1116 }*/
1117 property uint LVRow.Idx()
1118 {
1119    if .param
1120    {
1121       return .param->LVRowData.idx
1122    }
1123    return 0 
1124 }
1125 
1126 
1127 operator uint *( LVSelection obj )
1128 {
1129    if obj.pListView->vListView.hwnd
1130    {
1131       return obj.pListView->vListView.WinMsg( $LVM_GETSELECTEDCOUNT )
1132    }
1133    return 0   
1134 }
1135 
1136 
1137 method uint LVSelection.eof( fordata tfd )
1138 {
1139    return tfd.icur >= *.Items
1140 }
1141 
1142 
1143 method uint LVSelection.next( fordata tfd )
1144 {
1145    if ++tfd.icur >= *.Items : return 0   
1146    return .Items[tfd.icur] 
1147 }
1148 
1149 
1150 method uint LVSelection.first( fordata tfd )
1151 {
1152    tfd.icur = 0
1153    if tfd.icur >= *.Items : return 0   
1154    return .Items[tfd.icur] 
1155 }
1156 
1157 method LVRow LVSelection.index( uint idx )
1158 {
1159    if idx < *.Items : return .Items[idx]->LVRow
1160    return 0->LVRow
1161 } 
1162 
1163 method LVSelection.iSelect( uint idx, uint selected )
1164 {
1165    LVITEM lvi   
1166    lvi.stateMask = $LVIS_SELECTED
1167    if selected : lvi.state |= $LVIS_SELECTED   
1168    .pListView->vListView.WinMsg( $LVM_SETITEMSTATE, idx, &lvi )
1169 }
1170 
1171 method LVSelection.iAppend( LVRow row )
1172 {
1173    .Items[.Items.expand(1)] = &row
1174 }
1175 
1176 method uint LVSelection.Find( LVRow row )
1177 {
1178    uint i   
1179    fornum i = 0, *.Items
1180    {      
1181       if .Items[i] == &row : return i
1182    }  
1183    return -1
1184 }
1185 
1186 method LVSelection.iRemove( LVRow row )
1187 {
1188    uint idx = .Find( row )
1189    if idx != -1 : .Items.del( idx )   
1190 }
1191 
1192 
1193 
1194 method LVSelection.Append( LVRow row  )
1195 {
1196    if .pListView->vListView.hwnd : .iSelect( ?( .pListView->vListView.pOwnerData, &row, row.VisIndex ), 1 )
1197    else : .iAppend( row )
1198 }
1199 
1200 method LVSelection.Remove( LVRow row )
1201 {
1202    if .pListView->vListView.hwnd : .iSelect( ?( .pListView->vListView.pOwnerData, &row, row.VisIndex ), 0 )
1203    else : .iRemove( row )   
1204 }
1205 
1206 method LVSelection.Clear()
1207 {  
1208    if .pListView->vListView.hwnd 
1209    {
1210       .iSelect( -1, 0 )
1211    }
1212    else
1213    {      
1214       .Items.clear()      
1215    } 
1216 }
1217 
1218 method LVSelection.SelectAll()
1219 {   
1220    if .pListView->vListView.hwnd 
1221    {
1222       .iSelect( -1, 1 )      
1223    }
1224    else
1225    {  
1226       .Items.clear()
1227       foreach row, .pListView->vListView
1228       {
1229          .Items[.Items.expand( 1 )] = &row
1230       }
1231    } 
1232 }
1233 
1234 method LVSelection.Arrange()
1235 {
1236 
1237    uint rows as .pListView->vListView.Rows
1238    //curitem as root->TVItem
1239    uint index = 0
1240    uint curindex
1241    //while ( curitem as curitem.NextInList )
1242    foreach currow, rows
1243    {
1244    //print("Arrange \(.Find( currow ))\n")
1245       if ( curindex = .Find( currow )) != -1
1246       {           
1247          .Items.move( curindex, index++ ) 
1248       }
1249    }
1250 }
1251 
1252 method uint LVRows.eof( fordata tfd )
1253 {   
1254    return tfd.icur >= *this
1255 }
1256 
1257 
1258 method uint LVRows.next( fordata tfd )
1259 {   
1260    if ++tfd.icur < *this
1261    {   
1262       return &this[tfd.icur]
1263    }
1264    return 0
1265 }
1266 
1267 
1268 method uint LVRows.first( fordata tfd )
1269 {  
1270    tfd.icur = 0   
1271    if tfd.icur < *this
1272    {   
1273       return &this[tfd.icur]
1274    }
1275    return 0  
1276 }
1277 
1278 method LVRows.iWinClear( uint flgdelitem )
1279 {
1280    with .pListView->vListView
1281    {       
1282       .Selected = 0->LVRow               
1283       .Selection.Clear()
1284       .WinMsg( $LVM_DELETEALLITEMS )           
1285       if !.pListView->vListView.pOwnerData && .gtrows
1286       {      
1287          foreach item, .gtrows->gtitem
1288          {  
1289             if item->LVRow.param 
1290             {
1291                destroy( item->LVRow.param )
1292                item->LVRow.param = 0
1293             }
1294             if flgdelitem : item->LVRow.del() 
1295          }
1296       }            
1297    }
1298    .clear()
1299    
1300 }
1301 
1302 method LVRows.Clear()
1303 {   
1304    .iWinClear( 1 )   
1305 //   .pListView->vListView.gtrows->gtitem.del()
1306 //   .pListView->vListView.gtrows = 0
1307 //   .pListView->vListView.Reload()         
1308 }
1309 
1310 method uint LVColumns.eof( fordata tfd )
1311 {   
1312    return tfd.icur >= *this
1313 }
1314 
1315 
1316 method uint LVColumns.next( fordata tfd )
1317 {     
1318    if ++tfd.icur < *this
1319    {   
1320       return &this[tfd.icur]
1321    }
1322    return 0
1323 }
1324 
1325 
1326 method uint LVColumns.first( fordata tfd )
1327 {  
1328    tfd.icur = 0
1329    if tfd.icur < *this
1330    {   
1331       return &this[tfd.icur]
1332    }
1333    return 0   
1334 }
1335 
1336 method vListViewColumn LVColumns.Find( ustr alias )
1337 {
1338    foreach col, this
1339    {
1340       if col.Alias == alias
1341       {
1342          return col 
1343       }
1344    }
1345    return 0->vListViewColumn
1346 }
1347 
1348 property uint vListViewColumn.Idx()
1349 {  
1350    return this.pIndex
1351 }
1352 
1353 method vListViewColumn.mLangChanged <alias=vListViewColumn_mLangChanged>()
1354 {
1355    .iWinUpdate( $LVCF_TEXT )
1356    this->vComp.mLangChanged()
1357    if .pUseLanguage && &.Owner
1358    {
1359       uint listview as .Owner->vListView
1360       uint i
1361       fornum i = 0, *listview.Rows
1362       {
1363          listview.Cells( i, .pIndex ).iWinUpdate( $LVCF_TEXT )
1364       }  
1365    }   
1366 }
1367 
1368 method vListViewColumn.mPreDel <alias=vListViewColumn_mPreDel>()
1369 {  
1370    
1371    uint listview as .Owner->vListView
1372    if listview.pSortedColumn == &this
1373    {
1374       listview.pSortedColumn = 0
1375    }
1376    this->vComp.mPreDel()
1377       
1378 }
1379 
1380 property uint vListViewColumn.UseLanguage()
1381 {
1382    return .pUseLanguage
1383 }
1384 
1385 property vListViewColumn.UseLanguage( uint val)
1386 {  
1387    .AutoLang = val
1388    if .pUseLanguage != val
1389    { 
1390       .pUseLanguage = val
1391       if val : .Virtual( $mLangChanged )
1392    }   
1393 }