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

   listview.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

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\lib\vis\listview.g
   1 /******************************************************************************
   2 *
   3 * Copyright (C) 2004-2007, The Gentee Group. All rights reserved. 
   4 * This file is part of the Gentee open source project - http://www.gentee.com. 
   5 * 
   6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
   7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
   8 * ACCEPTANCE OF THE AGREEMENT.
   9 *
  10 * ID: vis.listview 9.10.07 0.0.A.
  11 *
  12 * Author: Alexander Krivonogov ( gentee )
  13 *
  14 ******************************************************************************/
  15 include {   
  16 //   "app.g"
  17    "..\\gt\\gt.g"
  18    "treeview.g"
  19    
  20 }
  21 /*
  22 type LVItem <inherit=gtitem>
  23 {
  24 
  25 }*/
  26 
  27 type vListViewColumn <inherit=vComp>//gtitem> 
  28 {   
  29    locustr pCaption
  30    uint    pWidth
  31    uint    pOrder
  32    ustr    pAlias
  33    uint    pUseLanguage
  34    
  35    ustr    pImageId   
  36    uint    pSortType
  37    uint    pSorted
  38    uint    pDefSorted
  39    uint    pAdvSortColumn
  40    uint    pVisible
  41 }   
  42 
  43 /*type LVColumnData
  44 {
  45    uint pColumns
  46    uint idx
  47 }*/
  48 
  49 type LVCell <inherit=gtitem>
  50 {
  51 }
  52 
  53 type LVRow <inherit=gtitem index=LVCell>
  54 {
  55 }
  56 
  57 type LVRowData
  58 {
  59    uint pRows
  60    uint idx
  61    //uint visindex
  62 }
  63 
  64 
  65 
  66 type LVCellData
  67 {
  68    uint row
  69    uint column
  70 }
  71 
  72 
  73 type LVRows <inherit=arr index=LVRow>
  74 {
  75    uint pListView 
  76 }
  77 
  78 type LVColumns <index=vListViewColumn>
  79 {
  80    uint pListView  
  81 }
  82 
  83 type LVColOrder <index=vListViewColumn>
  84 {
  85    uint pListView  
  86 }
  87 
  88 type LVSelection <index=LVRow>
  89 {
  90    uint pListView
  91    arr  Items of uint
  92 }
  93 /*
  94 type listdata
  95 {
  96    //uint listview
  97    uint listview //Объект содержащий данный элемент
  98    //uint idx //Номер элемента в окне
  99 //   uint inselections
 100    //uint tag
 101    //uint gttree  
 102 }*/
 103 /*
 104 type eventTVEdit <inherit=onevent> 
 105 {   
 106    ustr NewLabel   
 107    uint flgCancel
 108 }
 109 
 110 method eventTVEdit eventTVEdit.init
 111 {
 112    this.eventtypeid = eventTVEdit
 113    return this
 114 }
 115 
 116 type eventTVBefore <inherit=onevent> 
 117 {   
 118    uint CurItem      
 119    uint flgCancel
 120 }
 121 
 122 method eventTVBefore eventTVBefore.init
 123 {
 124    this.eventtypeid = eventTVBefore
 125    return this
 126 }
 127 
 128 type eventTVAfter <inherit=onevent> 
 129 {   
 130    uint CurItem
 131 }
 132 
 133 method eventTVAfter eventTVAfter.init
 134 {
 135    this.eventtypeid = eventTVAfter
 136    return this
 137 }*/
 138 
 139 /* Компонента vListView, порождена от vCtrl
 140 События
 141    onClick - вызывается при нажатии на кнопку
 142 */
 143 type vListView <inherit = vCtrl>
 144 {
 145    LVColumns  Columns
 146    LVColOrder ColumnsOrder
 147    arr       arOrder of uint
 148    LVRows    Rows
 149    LVSelection Selection
 150    arr sel of uint 
 151 //Hidden Fields   
 152    uint    fConnectGt
 153    uint    pListViewStyle  //Стиль списка
 154    uint    pShowHeader     //Показывать заголовки колонок
 155    uint    pHeaderDragDrop //Перетаскивать колонки  
 156    uint    pGridLines      //Отображение сетки таблицы
 157    uint    pShowSelection  //Всегда показывать выделение   
 158    uint    pLabelEdit      //Возможность редактирования элементов
 159    uint    pBorder         //Показывать рамку
 160    uint    pRowSelect      //Выделение элемента в виде строки
 161    uint    pCheckBoxes     //Галочки у элементов
 162    uint    pMultiSelect    //Выделение нескольких элементов
 163    uint    pEnsureVisible  //Прокручивать до выбранного элемента
 164    uint    pAutoDrag       //Возможность перетаскивать элементы 
 165    
 166    /*uint    pArrangeed         //Сортировать элементы*/
 167    uint    pSelected       //Текущий выбранный элемент
 168    uint    fDrag           //Флаг, находимся в режиме drag'n'drop
 169    uint    fOldDestItem    //Куда перетаскивать текущий элемент
 170    uint    fUpdateOrders   //Флаг пересчитывать порядок колонок
 171    uint    pSortedColumn   //Адрес последней отсортированной колонки
 172    uint    pSortFunc       //Функция для сортировки
 173    uint    pOwnerData      //Получение данных по запросу
 174    
 175    ustr    pSmallImageList
 176    uint    ptrSmallImageList
 177    ustr    pImageList
 178    uint    ptrImageList
 179    uint    numImageList
 180    ustr    pStateImageList
 181    uint    ptrStateImageList
 182 
 183    gt      gttree          //Представление в виде gt
 184    //uint   gtcolumns
 185    uint   gtrows 
 186 //Events   
 187    //onevent onStartEdit
 188    evTVEdit   OnAfterEdit
 189    evTVEdit   OnBeforeEdit
 190    evQuery OnBeforeSelect
 191    evValUint  OnAfterSelect
 192    uint    flgItemChanging
 193    //evItemMoved  OnItemMoved
 194    evBeforeMove OnBeforeMove
 195    evAfterMove  OnAfterMove
 196    
 197    evValColl  OnGetData
 198    
 199    evQuery      OnColumnClick
 200    
 201    uint         flgRowInserting
 202    
 203    uint clrTextBk
 204    uint clrText  
 205    
 206    evValColl     OnItemDraw
 207    evValColl     OnSubItemDraw
 208    evValUint     OnChanged
 209    //evValUint   OnGetLabel
 210    /*eventTVBefore OnBeforeExpand
 211    eventTVAfter  OnAfterExpand
 212    eventTVBefore OnBeforeCollapse
 213    eventTVAfter  OnAfterCollapse*/
 214 }
 215 
 216 extern {
 217    method vListView.Reload()
 218    property LVRow vListView.Selected()
 219    property vListView.Selected( LVRow item )
 220 }
 221 
 222 
 223 
 224 define <export>{
 225 //Стили списка
 226    lvsIcon       = $LVS_ICON      
 227    lvsReport     = $LVS_REPORT    
 228    lvsSmallIcon  = $LVS_SMALLICON 
 229    lvsList       = $LVS_LIST  
 230 
 231 //Стиль vListViewColumn.SortType      
 232    lvstNone = 0
 233    lvstText = 1
 234    lvstValue = 2
 235    lvstSortIndex = 3
 236    lvstEvent = 4
 237    
 238    lvsortNone = 0
 239    lvsortDown = 1
 240    lvsortUp = 2       
 241 }  
 242 
 243 include { "listviewitem.g" }
 244 
 245 extern {
 246 //property uint LVItem.InSelections
 247 //property LVItem.InSelections( uint val )
 248 //property LVItem vListView.Selected()
 249 //property vListView.Selected( LVItem item )
 250 /*property ustr LVItem.Label// <result>
 251 property LVItem LVItem.Child()*/
 252 //property LVItem LVItem.Prev()
 253 //property LVItem LVItem.Next()
 254 //method LVItem.WinSet( uint mask )
 255 //property uint LVItem.Idx 
 256 //property vListView.Selected( LVItem item )
 257 
 258 }
 259 /*------------------------------------------------------------------------------
 260    Public Methods
 261 */
 262 /*method vListView.Clear()
 263 {
 264    .Rows.Clear()
 265    //.Columns.Clear()
 266    //.gttree.clear()
 267    //.WinMsg( $LVM_DELETEALLITEMS )
 268 }*/
 269 
 270 method vListView.Edit()
 271 {
 272    if &(.Selected())
 273    {
 274       .SetFocus()      
 275       .WinMsg( $LVM_EDITLABELW, /*.Selected.Idx()*/.Selected.VisIndex, 0)      
 276    }
 277 }
 278 
 279 /*------------------------------------------------------------------------------
 280    Properties
 281 */
 282 /*Свойство ustr Border - Get Set
 283 Установить, получить наличие рамки у поля ввода
 284 1 - рамка есть
 285 0 - рамки нет
 286 */
 287 property vListView.Border( uint val )
 288 {
 289    .pBorder = val
 290    uint style = GetWindowLong( this.hwnd, $GWL_EXSTYLE )
 291    if val : style |= $WS_EX_CLIENTEDGE
 292    else : style &= ~$WS_EX_CLIENTEDGE
 293    SetWindowLong( this.hwnd, $GWL_EXSTYLE, style )      
 294    SetWindowPos( this.hwnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED | 
 295                   $SWP_NOACTIVATE | $SWP_NOZORDER | $SWP_NOMOVE | $SWP_NOSIZE )
 296 }
 297 
 298 property uint vListView.Border
 299 {   
 300    //.pBorder = ?(GetWindowLong( this.hwnd, $GWL_EXSTYLE ) & $WS_EX_CLIENTEDGE,1,0)
 301    return .pBorder
 302 }
 303 
 304 /*Свойство uint ListViewStyle - Get Set
 305 Установить, получить стиль списка
 306 */
 307 property vListView.ListViewStyle( uint val )
 308 {   
 309    if val != .pListViewStyle
 310    {
 311       .pListViewStyle = val
 312       .SetStyle( $LVS_TYPEMASK, val )
 313    }
 314 }
 315 
 316 property uint vListView.ListViewStyle
 317 { 
 318    return .pListViewStyle
 319 }
 320 
 321 /*Свойство uint OwnerData - Get Set
 322 Установить, получить флаг получения данных по запросу
 323 */
 324 property vListView.OwnerData( uint val )
 325 {   
 326    if val != .pOwnerData
 327    {      
 328       .pOwnerData = val      
 329       .Virtual( $mReCreateWin )            
 330    }
 331 }
 332 
 333 property uint vListView.OwnerData
 334 { 
 335    return .pOwnerData
 336 }
 337 
 338 
 339 /*Свойство uint ShowHeader - Get Set
 340 Показывать/не показывать заголовки колонок
 341 0 - не показывать
 342 1 - показывать 
 343 */
 344 property vListView.ShowHeader( uint val )
 345 {   
 346    if val != .pShowHeader
 347    {
 348       .pShowHeader = val
 349       .SetStyle( $LVS_NOCOLUMNHEADER, !val )
 350    }
 351 }
 352 
 353 property uint vListView.ShowHeader
 354 { 
 355    return .pShowHeader
 356 }
 357 
 358 /*Свойство uint RowSelect - Get Set
 359 Выделение элемента в виде строки
 360 0 - выделять ячейку
 361 1 - выделять строку
 362 */
 363 property vListView.RowSelect( uint val )
 364 {   
 365    if val != .pRowSelect
 366    {
 367       .pRowSelect = val      
 368       .WinMsg( $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, 
 369                $LVS_EX_FULLROWSELECT )
 370    }
 371 }
 372 
 373 property uint vListView.RowSelect
 374 { 
 375    return .pRowSelect
 376 }
 377 
 378 /*Свойство uint CheckBoxes - Get Set
 379 Галочки у элементов
 380 0 - показывать
 381 1 - нет
 382 */
 383 property vListView.CheckBoxes( uint val )
 384 {   
 385    if val != .pCheckBoxes
 386    {
 387       .pCheckBoxes = val      
 388       .WinMsg( $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, 
 389                $LVS_EX_CHECKBOXES  )
 390    }
 391 }
 392 
 393 property uint vListView.CheckBoxes
 394 { 
 395    return .pCheckBoxes
 396 }
 397 /*Свойство uint HeaderDragDrop - Get Set
 398 Возможность перетаскивать колонки
 399 0 - нельзя перетаскивать
 400 1 - можно перетаскивать
 401 */
 402 property vListView.HeaderDragDrop( uint val )
 403 {   
 404    if val != .pHeaderDragDrop
 405    {
 406       .pHeaderDragDrop = val      
 407       .WinMsg( $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, 
 408                $LVS_EX_HEADERDRAGDROP )
 409    }
 410 }
 411 
 412 property uint vListView.HeaderDragDrop
 413 { 
 414    return .pHeaderDragDrop
 415 }
 416 
 417 /*Свойство ustr GreidLines - Get Set
 418 Отображение сетки таблицы
 419 1 - есть
 420 0 - нет
 421 */
 422 property vListView.GridLines( uint val )
 423 {  
 424    if .pGridLines != val
 425    { 
 426       .pGridLines = val
 427       .WinMsg( $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, 
 428                $LVS_EX_GRIDLINES )
 429    }
 430 }
 431 
 432 property uint vListView.GridLines
 433 { 
 434    return .pGridLines
 435 }
 436 
 437 /*Свойство ustr ShowSelection - Get Set
 438 //Всегда показывать выделение
 439 1 - показывать всегда
 440 0 - нет
 441 */
 442 property vListView.ShowSelection( uint val )
 443 {   
 444    if .pShowSelection != val
 445    { 
 446       .pShowSelection = val
 447       .SetStyle( $LVS_SHOWSELALWAYS, val )
 448    }
 449 }
 450 
 451 property uint vListView.ShowSelection
 452 { 
 453    return .pShowSelection
 454 }
 455 
 456 /*Свойство uint MultiSelect - Get Set
 457 //Выделение нескольких элементов
 458 1 - да
 459 0 - нет
 460 */
 461 property vListView.MultiSelect( uint val )
 462 {   
 463    if .pMultiSelect != val
 464    { 
 465       .pMultiSelect = val
 466       .SetStyle( $LVS_SINGLESEL, !val )
 467    }
 468 }
 469 
 470 property uint vListView.MultiSelect
 471 { 
 472    return .pMultiSelect
 473 }
 474 
 475 /*Свойство ustr LabelEdit - Get Set
 476 Установить, получить отображение линеек слева от веток
 477 1 - есть
 478 0 - нет
 479 */
 480 property vListView.LabelEdit( uint val )
 481 {   
 482    .pLabelEdit = val
 483    .SetStyle( $LVS_EDITLABELS , val )
 484 }
 485 
 486 property uint vListView.LabelEdit
 487 { 
 488    return .pLabelEdit
 489 }
 490 
 491 /*Свойство ustr EnsureVisible - Get Set
 492 Прокручивать до выбранного элемента
 493 1 - прокручивать
 494 0 - нет
 495 */
 496 property vListView.EnsureVisible( uint val )
 497 {   
 498    .pEnsureVisible = val   
 499 }
 500 
 501 property uint vListView.EnsureVisible
 502 { 
 503    return .pEnsureVisible
 504 }
 505 
 506 /* Свойство uint vListView.AutoDrag - Get Set
 507 Возможность перетаскивать элементы внутри объекта
 508 */
 509 property uint vListView.AutoDrag()
 510 {
 511    return .pAutoDrag
 512 }
 513 
 514 property vListView.AutoDrag( uint val )
 515 {
 516    this.pAutoDrag = val   
 517 }
 518 /*property uint LVItem.Idx 
 519 {   
 520    uint id 
 521    uint prev = &this
 522    while prev = &prev->LVItem.Prev() 
 523    {
 524       id++
 525    }
 526    return id  
 527 }
 528 
 529 method LVItem.Del()
 530 {
 531    
 532    if &this == .param->listdata.listview->vListView.pSelected 
 533    {
 534       uint newsel 
 535       newsel as .Next
 536       if !&newsel
 537       {
 538          newsel as .Prev
 539       }
 540       //.param->listdata.listview->vListView.pSelected = 0
 541       .param->listdata.listview->vListView.Selected = newsel
 542    }
 543    
 544    if &this && .param->listdata.listview
 545    {   
 546       .param->listdata.listview->vListView.WinMsg( $LVM_DELETEITEM, .Idx )
 547       
 548    }
 549    //if &this != &.param->treedata.treeview->vTreeView.gttree.root()
 550    {   
 551       destroy( .param )
 552       this.del()
 553    }
 554 }
 555 */
 556 /* Свойство ustr Label - Get Set
 557 Устанавливает или определяет заголовок элемента дерева
 558 */
 559 /*property ustr LVItem.Label <result>
 560 { 
 561    result.fromutf8( .get( "name" ) ).ptr()  
 562 }
 563 
 564 property LVItem.Label( ustr val )
 565 {
 566    .set( "name", val.toutf8( "" ) )
 567    .WinSet( $LVIF_TEXT )
 568 }
 569 
 570 
 571 
 572 method vListView.WinInsert( LVItem curitem )
 573 {
 574    uint id
 575    LVITEM li   
 576    
 577    //uint thisdata as .param->listdata   
 578    li.pszText = curitem.Label.ptr()
 579    li.iItem = curitem.Idx   
 580    
 581    
 582    //ti.hParent = thisdata.handle
 583    li.mask = $LVIF_TEXT | $LVIF_PARAM   
 584    li.lParam = &curitem   
 585    
 586    .WinMsg( $LVM_INSERTITEMW, 0, &li )
 587    
 588    //child.WinSet( $TVIF_STATE )   
 589 }
 590 
 591 method LVItem vListView.InsertItem( ustr name, uint tag, LVItem after )
 592 {
 593    if &this
 594    {      
 595       //uint thisdata as .param->treedata
 596        
 597       uint newitem as .gttree.root()->LVItem.insertchild( "", after )->LVItem
 598       uint newitemdata as new( listdata )->listdata
 599       newitemdata.listview = &this
 600       newitem.param = &newitemdata
 601       newitem.set( "name", name.toutf8( "" ) )
 602       newitem.setuint( "tag", tag )
 603       
 604       uint Arrangetype = .getuint( "Arrangetype" )
 605       if Arrangetype & $TVArrange_Arrange
 606       {         
 607          //ti.hInsertAfter = $TVI_Arrange
 608          if Arrangetype == $TVArrange_ArrangeRECURSE 
 609          {
 610             child.setuint( "Arrangetype", Arrangetype )
 611          }         
 612       }
 613       .WinInsert( newitem )
 614                   
 615       return newitem->LVItem
 616    }
 617    return 0->LVItem
 618 }
 619  
 620 method LVItem vListView.InsertFirst( ustr name, uint tag )
 621 {   
 622    return this.InsertItem( name, tag, 0->LVItem ) 
 623 }
 624 
 625 method LVItem vListView.Append( ustr name, uint tag )
 626 {   
 627    return this.InsertItem( name, tag, 0xFFFFFFFF->LVItem )
 628 }
 629 */
 630 /*
 631 method LVItem LVItem.index( uint idx )
 632 {
 633    
 634    return 0->LVItem   
 635 }
 636 */
 637 /*property LVItem vListView.Root
 638 {
 639    if &this
 640    {
 641       return .gttree.root()->LVItem//.items[0]
 642    }
 643    return 0->LVItem
 644 }
 645 
 646 
 647 method LVItem.WinSet( uint mask )
 648 {
 649    LVITEM item
 650    uint   state
 651    
 652    
 653    item.mask = mask
 654    //item.iItem = this.Idx
 655    //if .getuint( "expanded" ) : state |= $TVIS_EXPANDED
 656 //   if .getuint( "bold" ) : state |= $TVIS_BOLD
 657    //if .param->treedata.inselections { state |= $TVIS_SELECTED//$TVIS_DROPHILITED //| $TVIS_CUT
 658    //item.state = state | $TVIS_EXPANDPARTIAL 
 659 //   item.stateMask = $TVIS_BOLD
 660       
 661    ustr val 
 662    item.pszText = val.fromutf8( .get( "name" ) ).ptr()   
 663    .param->listdata.listview->vListView.WinMsg( $LVM_SETITEMTEXTW, this.Idx, &item )   
 664 }
 665 */
 666 
 667 
 668 /* Свойство uint Expand - Get Set
 669 Устанавливает или определяет открытие ветки
 670 0 - ветка закрыта
 671 1 - ветка открыта
 672 */
 673 /*property uint LVItem.Expanded
 674 { 
 675    return .getuint( "expanded" )  
 676 }
 677 
 678 property LVItem.Expanded( uint val )
 679 {
 680    if .getuint( "expanded" ) != val
 681    {
 682       .param->treedata.listview->vListView.WinMsg( $TVM_EXPAND, ?( val, $TVE_EXPAND, $TVE_COLLAPSE ), .param->treedata.handle ) 
 683       .setuint( "expanded", val )
 684    }
 685    //.WinSet( $TVIF_STATE )
 686 }
 687 */
 688 
 689 /* Свойство uint Tag - Get Set
 690 Устанавливает или определяет пользовательский параметр элемента дерева
 691 */
 692 /*property uint LVItem.Tag
 693 { 
 694    return .getuint( "tag" )  
 695 }
 696 
 697 property LVItem.Tag( uint val )
 698 {
 699    .setuint( "tag", val )
 700 }*/
 701 
 702 /* Свойство uint Bold - Get Set
 703 Устанавливает или определяет пользовательский параметр элемента дерева
 704 */
 705 /*property uint LVItem.Bold
 706 { 
 707    return .getuint( "bold" )  
 708 }
 709 
 710 property LVItem.Bold( uint val )
 711 {
 712    .setuint( "bold", val )
 713    .WinSet( $TVIF_STATE )
 714 }
 715 */
 716 /* Свойство uint Checked - Get Set
 717 Устанавливает или определяет пользовательский параметр элемента дерева
 718 *//*
 719 property uint LVItem.Checked
 720 { 
 721    return .getuint( "checked" )  
 722 }
 723 
 724 property LVItem.Checked( uint val )
 725 {
 726    .setuint( "checked", val )
 727    //.WinSet( $TVIF_STATE )
 728 }
 729 
 730 /* Свойство uint ArrangeTYpe - Get Set
 731 Устанавливает или определяет пользовательский параметр элемента дерева
 732 *//*
 733 property uint LVItem.ArrangeType
 734 { 
 735    return .getuint( "Arrangetype" )  
 736 }
 737 
 738 property LVItem.ArrangeType( uint val )
 739 {  
 740    .setuint( "Arrangetype", ?( val & $TVArrange_Arrange, val, $TVArrange_NONE ))
 741    if val & $TVArrange_Arrange
 742    {   
 743       .param->treedata.listview->vListView.WinMsg( $TVM_ArrangeCHILDREN, 0, .param->treedata.handle )
 744    }   
 745    if val & $TVArrange_RECURSE 
 746    {              
 747       foreach child, this
 748       {       
 749          child.ArrangeType = val
 750       }
 751    }
 752    
 753    //.WinSet( $TVIF_STATE )
 754 }
 755 */
 756 /* Свойство uint Parent - Get
 757 Определяет хозяина данной ветки, если ветка в корне то корень, если корень то 0
 758 */
 759 /*property LVItem LVItem.Parent
 760 {    
 761    return this->gtitem.parent()->LVItem 
 762 }*/
 763 
 764 /* Свойство uint Prev - Get
 765 Определяет предыдущий элемент, если он есть, иначе 0
 766 */
 767 /*property LVItem LVItem.Prev
 768 {   
 769    return this->gtitem.getprev()->LVItem
 770    //return this->gtitem.getprev()->LVItem
 771 }*/
 772 
 773 /* Свойство uint Next - Get
 774 Определяет предыдущий элемент, если он есть, иначе 0
 775 */
 776 /*property LVItem LVItem.Next
 777 {    
 778    return this->gtitem.getnext()->LVItem
 779 }*/
 780 
 781 /* Свойство uint LastChild - Get
 782 Определяет последний дочерний элемент, если он есть, иначе 0
 783 */
 784 /*property LVItem LVItem.LastChild
 785 {    
 786    return this->gtitem.lastchild()->LVItem
 787 }*/
 788 
 789 /* Свойство uint Child - Get
 790 Определяет первый дочерний элемент данной ветки, если ветка не имеет дочерних элементов, то 0
 791 */
 792 /*property LVItem LVItem.Child
 793 {    
 794    uint resi as this.child()    
 795    return resi->LVItem 
 796 }*/
 797 
 798 
 799 /*
 800 method LVItem.Update()
 801 {  
 802    //uint owner as this.Parent()
 803    //uint after as this.Prev
 804    
 805    
 806    .param->listdata.listview->vListView.WinInsert( this )     
 807 }
 808 */
 809 /*method LVItem.MoveTo( LVItem dest, uint flag )
 810 {
 811    
 812    if &this.Next() != &dest
 813    {  
 814       uint lv as .param->listdata.listview->vListView 
 815       lv.WinMsg( $LVM_DELETEITEM, .Idx, 0)
 816       
 817             
 818       this.move( dest, flag )
 819       this.Update()
 820       evparItemMoved evpIM
 821       evpIM.SrcItem = &this
 822       evpIM.DestItem = &dest
 823       evpIM.Flag = flag
 824       lv.OnItemMoved.run( evpIM )
 825       
 826    }
 827 }*/
 828 
 829 /* Свойство uint Selected - Get Set
 830 Устанавливает или определяет пользовательский параметр элемента дерева
 831 */
 832 
 833 /* Свойство uint Arrangeed - Get Set
 834 Устанавливает или определяет должны ли сортироваться элементы в дереве
 835 1 - элементы сортируются
 836 0 - элементы не сортируются
 837 *//*
 838 property uint vListView.Arrangeed()
 839 {  
 840    return this.pArrangeed
 841 }
 842 
 843 property vListView.Arrangeed( uint val)
 844 {
 845    if this.pArrangeed != val
 846    {
 847       this.pArrangeed = val
 848       this.Root().ArrangeType = ?( val, $TVArrange_ArrangeRECURSE, $TVArrange_NONE )
 849       
 850    }
 851 }
 852 */
 853 
 854 
 855 
 856 property LVRow vListView.Selected()
 857 {  
 858    return this.pSelected->LVRow//Item
 859 }
 860 
 861 property vListView.Selected( LVRow item )
 862 { 
 863    if this.pSelected != &item || .pOwnerData
 864    {
 865       if this.pSelected || .pOwnerData
 866       {
 867          LVITEM li
 868          li.stateMask = $LVIS_SELECTED         
 869          .WinMsg( $LVM_SETITEMSTATE, /*this.Selected.param->LVRowData.idx*/
 870             ?( .pOwnerData, &this.Selected, this.Selected.VisIndex ), &li )
 871          this.pSelected = 0
 872       }
 873       if &item || .pOwnerData
 874       {
 875       
 876          this.pSelected = &item
 877          LVITEM li
 878          uint visindex = ?( .pOwnerData, &this.Selected, this.Selected.VisIndex )
 879       //li.mask = $LVIF_STATE
 880       //li.iItem = item.Idx 
 881          
 882          li.stateMask = $LVIS_SELECTED | $LVIS_FOCUSED 
 883          li.state = $LVIS_SELECTED | $LVIS_FOCUSED
 884             
 885       //.WinMsg( $LVM_SETSELECTIONMARK, 0,  item.param->listdata.idx )
 886          .WinMsg( $LVM_SETITEMSTATE, /*item.param->LVRowData.idx*/visindex, &li )
 887          if .pEnsureVisible 
 888          {
 889             .WinMsg( $LVM_ENSUREVISIBLE, /*item.param->LVRowData.idx*/visindex, 0 )
 890          }
 891       }
 892       else 
 893       {
 894          //this.pSelected = &item
 895          /*LVITEM li
 896          li.stateMask = $LVIS_SELECTED         
 897          .WinMsg( $LVM_SETITEMSTATE, this.Selected.param->LVRowData.idx, &li )
 898          this.pSelected = 0*/
 899       }
 900    }
 901 }
 902 
 903 
 904 /*Метод vListView.iUpdateImageList()
 905 Обновить ImageList
 906 */
 907 method vListView.iUpdateImgList()
 908 {
 909    .ptrImageList = &.GetImageList( .pImageList, &.numImageList )      
 910    if .ptrImageList
 911    {
 912       .WinMsg( $LVM_SETIMAGELIST, $LVSIL_SMALL, .ptrImageList->ImageList.arrIml[.numImageList].hIml )
 913       .WinMsg( $LVM_SETIMAGELIST, $LVSIL_NORMAL, .ptrImageList->ImageList.arrIml[.numImageList].hIml )
 914    }
 915    else 
 916    {
 917       .WinMsg( $LVM_SETIMAGELIST, $LVSIL_SMALL, 0 )
 918       .WinMsg( $LVM_SETIMAGELIST, $LVSIL_NORMAL, 0 )
 919    }
 920    .Invalidate()
 921 }
 922 
 923 /* Свойство str vListView.ImageList - Get Set
 924 Устанавливает или получает имя списка картинок
 925 */
 926 property ustr vListView.ImageList <result>
 927 {
 928    result = this.pImageList
 929 }
 930 
 931 property vListView.ImageList( ustr val )
 932 {
 933    if val != this.pImageList
 934    { 
 935       this.pImageList = val
 936       .Virtual( $mLangChanged )
 937       //.iUpdateImageList()
 938    }
 939 }
 940 
 941 property vListViewColumn vListView.SortedColumn()
 942 {
 943    return .pSortedColumn->vListViewColumn
 944 }
 945 
 946 method vListView.Reload()
 947 {
 948    /*uint i
 949    for i = *.Columns - 1, int( i ) > 0, i--
 950    {
 951       .Columns[i].Release()
 952    }*/
 953    //.ReloadGTColumn   
 954    /*.gtcolumns = &this.gttree.find( "columns" )
 955    if !.gtcolumns
 956    {
 957       .gtcolumns = &this.gttree.root().insertchild( "columns", 0->gtitem )
 958    }
 959    if !*.gtcolumns->gtitem
 960    {
 961       .gtcolumns->gtitem.insertchild( "", 0->gtitem )  
 962    }*//*
 963    uint index  
 964    
 965    foreach item, this.Comps
 966    {  
 967       item->vListViewColumn.iWinRemove()    
 968    }
 969    
 970    foreach item, this.Comps
 971    {
 972       //.Columns.insert( index )
 973       //.Columns->arr of uint[index] = &item
 974       //item->LVColumn.param->LVColumnData.idx = index
 975       item->vListViewColumn.iWinInsert()
 976       item->vListViewColumn.iWinUpdate( $LVCF_TEXT | $LVCF_WIDTH | $LVCF_ORDER )      
 977       index++
 978    }*/
 979    /*foreach item, .gtcolumns->gtitem
 980    {  
 981       .Columns.insert( index )
 982       .Columns->arr of uint[index] = &item
 983       item->LVColumn.param->LVColumnData.idx = index
 984       item->LVColumn.iWinInsert()
 985       item->LVColumn.iColumnUpdate( $LVCF_TEXT )      
 986       index++      
 987    }*/   
 988    uint sortedcolumn   
 989    if .pSortedColumn
 990    {  
 991       sortedcolumn = .pSortedColumn      
 992       .pSortedColumn = 0
 993    }
 994    uint index
 995    if !.gtrows 
 996    {
 997       .gtrows = &this.gttree.find( "rows" )      
 998       if !.gtrows
 999       {
1000          .gtrows = &this.gttree.root().insertchild( "rows", 0->gtitem )
1001       }
1002    }
1003    else
1004    {
1005       .Rows.iWinClear( 0 )
1006       /*int i
1007       for i = *.Rows - 1, i >= 0, i-- 
1008       {
1009          .Rows[i].Release()
1010       }*/
1011    }
1012    index = 0      
1013    foreach item, .gtrows->gtitem
1014    {   
1015       .Rows.insert( index )       
1016       .Rows->arr of uint[index] = &item
1017       uint data as new( LVRowData )->LVRowData      
1018       item.param = &data
1019       data.pRows = &.Rows
1020       data.idx = index
1021       
1022 //      item->LVRow.param->LVRowData.idx = index
1023       item->LVRow.iWinInsert()             
1024       item->LVRow.iWinUpdate( 0 )            
1025       index++      
1026    }
1027    if sortedcolumn
1028    {        
1029       sortedcolumn->vListViewColumn.iSortUpdate()
1030    }
1031    if *.Rows
1032    {
1033       .Selected = .RowFromVisIndex(0)//.Rows[0]
1034    } 
1035    else
1036    {
1037       .pSelected = 0
1038    }
1039 }
1040 
1041 
1042 method vListView.FromGt( gtitem srcgtitem )
1043 {
1044    str tmp
1045    gtsave gts   
1046    gts.offstep = 3
1047    uint src
1048    src as srcgtitem.findrel( "/rows" )
1049    if &src 
1050    {
1051     //src as srcgtitem 
1052    
1053    src.save( tmp, gts )
1054    
1055    if .gtrows : .gtrows->gtitem.del()
1056    //.gtrows = &this.gttree.root().insertchild( "rows", 0->gtitem )
1057       
1058    .gttree.root().load( tmp, 0->gtitem )
1059    
1060    .Reload()   
1061    
1062    }
1063 }
1064 
1065 
1066 
1067 method vListView.ConnectGt( gtitem gtrows )
1068 {
1069    int i
1070    /*for i = *.Rows - 1, i >= 0, i-- 
1071    {
1072       .Rows[i].Release()
1073    }
1074    */
1075    .Rows.iWinClear( 0 )
1076    
1077    if !.fConnectGt
1078    {
1079       .gtrows->gtitem.del()
1080       .gtrows = 0
1081    }
1082    /*else
1083    {
1084       
1085    }*/
1086    
1087    /**/   
1088    if >rows 
1089    {
1090       .gtrows = >rows
1091       .fConnectGt = 1
1092    }
1093    else
1094    {
1095       .gtrows = 0
1096       .fConnectGt = 0  
1097    }
1098    .Reload()
1099 }
1100 
1101 method vListView.DisconnectGt( )
1102 {
1103    
1104    if .fConnectGt : .ConnectGt( 0->gtitem)
1105    //.gtrows = 0
1106 }
1107 
1108 
1109 method vListView.ToGt()
1110 {
1111 }
1112 
1113 method vListView.DelSelected()
1114 {
1115    int i
1116    for i = *.Selection-1, i >= 0, i--
1117    {
1118       .Selection[i].Del()
1119    }
1120 }
1121 
1122 /*------------------------------------------------------------------------------
1123    Virtual Methods
1124 */
1125 method vListView.mInsert <alias=vListView_mInsert>( vListViewColumn item )
1126 {
1127    if item.TypeIs( vListViewColumn )
1128    {
1129       this->vCtrl.mInsert( item )
1130       item.pOrder = item.CompIndex
1131       .arOrder.insert(item.pIndex)       
1132       .arOrder[item.pIndex] = &item          
1133       item.iWinInsert()               
1134    }
1135 }
1136 
1137 method vListView.mRemove <alias=vListView_mRemove>( vListViewColumn item )
1138 {  
1139    item.iWinRemove()
1140    this->vCtrl.mRemove( item )
1141 }
1142 
1143 method vListView.mPreDel <alias=vListView_mPreDel>()
1144 {  
1145    .DisconnectGt()
1146    this->vCtrl.mPreDel()
1147 }
1148 /*Виртуальный метод vListView vListView.mCreateWin - Создание окна
1149 */
1150 method vListView vListView.mCreateWin <alias=vListView_mCreateWin>()
1151 {
1152    uint exstyle 
1153    uint style =  $WS_CHILD | $WS_CLIPSIBLINGS | .pListViewStyle | $WS_TABSTOP
1154    if .pOwnerData : style |= $LVS_OWNERDATA
1155    if !.pShowHeader : style |= $LVS_NOCOLUMNHEADER
1156    if !.pMultiSelect : style |= $LVS_SINGLESEL
1157    if .pShowSelection : style |= $LVS_SHOWSELALWAYS
1158  //  style |= $LVS_SORTASCENDING 
1159    //if .pLabelEdit     : style |= $LVS_EDITLABELS
1160       
1161    if .pBorder : exstyle |= $WS_EX_CLIENTEDGE    
1162    this.CreateWin( "SysListView32".ustr(), exstyle, style )         
1163    
1164    this->vCtrl.mCreateWin()     
1165 
1166    uint listexstyle 
1167    if .pHeaderDragDrop : listexstyle |= $LVS_EX_HEADERDRAGDROP 
1168    if .pRowSelect : listexstyle |= $LVS_EX_FULLROWSELECT
1169    if .pCheckBoxes : listexstyle |= $LVS_EX_CHECKBOXES
1170    if .pGridLines : listexstyle |= $LVS_EX_GRIDLINES
1171    listexstyle |= $LVS_EX_SUBITEMIMAGES | $LVS_EX_INFOTIP   
1172    if listexstyle : this.WinMsg( $LVM_SETEXTENDEDLISTVIEWSTYLE, listexstyle, listexstyle ) 
1173     
1174    /*LVCOLUMN col
1175    col.mask = $LVCF_SUBITEM
1176    this.WinMsg( $LVM_INSERTCOLUMNW, 0, &col )*/
1177    LVCOLUMN lvc
1178    uint index = 0
1179    lvc.mask = $LVCF_SUBITEM | $LVCF_TEXT
1180    lvc.iSubItem = 0  
1181    lvc.pszText = "".ustr().ptr()
1182    .WinMsg( $LVM_INSERTCOLUMNW, 0, &lvc )
1183    uint i   
1184    for i = *.Columns - 1, int( i ) >= 0, i--
1185    {      
1186       .Columns[i].iWinInsert( )
1187    }   
1188    .Reload()   
1189    .iUpdateImgList()   
1190    /*if .pCheckBoxes 
1191    {        
1192       .Rows[0][0].iWinUpdate( $LVIF_STATE )
1193    }*/                                                                  
1194    return this
1195 }
1196 
1197 /*method uint vListView.wmnotify <alias=vListView_wmnotify>( winmsg wmsg )
1198 {
1199    
1200    uint nmcd as wmsg.lpar->NMCUSTOMDRAW
1201    if nmcd.hdr.code == $NM_CUSTOMDRAW
1202    {            
1203       if nmcd.dwDrawStage == 0x00000001
1204       {  
1205        //  print ("ntf\n" )
1206          
1207          wmsg.flags = 1 
1208          return 0x00000020
1209       }
1210       elif nmcd.dwDrawStage == 0x00010001
1211       {
1212       //print ("ntf\n" )
1213       wmsg.flags = 1
1214       pDrawThemeBackground->stdcall( ThemeData[( $theme_toolbar )], nmcd.hdc, $BP_PUSHBUTTON, $PBS_HOT, nmcd.rc, 0 )
1215       //FillRect( nmcd.hdc, nmcd.rc, GetSysColorBrush(13)  )   
1216       //SetBkColor(nmcd.hdc,0xff00)
1217       //SetTextColor(nmcd.hdc,0xff)       
1218       return 0x4
1219       }
1220       return 1
1221    }
1222    
1223    return 0
1224 }*/
1225 
1226 /*Виртуальный метод uint vListView.mWinNtf - обработка сообщений
1227 */
1228 global {
1229   ustr utt
1230 }
1231 method uint vListView.mWinNtf <alias=vListView_mWinNtf>( winmsg wmsg )//NMHDR ntf )
1232 {
1233    
1234    uint nmlv as wmsg.lpar->NMLISTVIEW //ntf->NMLISTVIEW
1235    
1236    if wmsg.hwnd == .hwnd 
1237    {  
1238       return 1
1239    }
1240       
1241    switch nmlv.hdr.code
1242    {      
1243       /*case $NM_CUSTOMDRAW
1244       {
1245          print ("NTF \(nmlv.hdr.code)\n" )
1246          wmsg.flags = 1 
1247          return 0x00000004     
1248       }*/
1249       case $HDN_BEGINTRACKW
1250       {       
1251          if !.Columns[nmlv.iItem].pVisible
1252          {
1253             wmsg.flags = 1
1254          }   
1255          return 1
1256       }      
1257       case $HDN_ENDTRACKW
1258       {         
1259          nmlv as NMHEADER
1260          if (nmlv.iItem < *.Columns) && (nmlv.pitem->HDITEM.mask & 1 )//HDI_WIDTH
1261          {             
1262             .Columns[nmlv.iItem].pWidth = nmlv.pitem->HDITEM.cxy//.WinMsg( $LVM_GETCOLUMNWIDTH, nmlv.iItem )
1263 //            print( "cols \(wmsg.hwnd) \(nmlv.pitem->HDITEM.lParam) \(nmlv.pitem->HDITEM.iOrder) \(nmlv.pitem->HDITEM.mask) \(.Columns[nmlv.iItem].Name) \(.Columns[nmlv.iItem].pWidth)\n" )
1264             return 1            
1265          }
1266       }   
1267    }   
1268    switch nmlv.hdr.code
1269    {   
1270       /*case $HDN_TRACKW
1271       {      
1272          //wmsg.flags = 1
1273          nmlv as NMHEADER
1274          nmlv.iItem--  
1275          return 1  
1276       }*/
1277       case $HDN_ENDDRAG
1278       {
1279          .fUpdateOrders = 1
1280       }
1281       case $NM_RELEASEDCAPTURE
1282       {
1283          if .fUpdateOrders 
1284          {
1285             .iGetColumnOrders()
1286             .fUpdateOrders = 0
1287          }  
1288       }
1289       /*case $LVN_ITEMACTIVATE
1290       {  
1291          nmlv as NMITEMACTIVATE
1292          this.pSelected = ?( nmlv.lParam, nmlv.lParam, 0 )//?( nmlv.itemNew, nmlv.itemNew.lParam, 0 )
1293          //.OnSelect.Run( this, etvb )
1294       }*/      
1295       case $LVN_ODSTATECHANGED
1296       {
1297          if .pOwnerData
1298          {
1299             nmlv as NMLVODSTATECHANGE
1300             uint i                        
1301             if ( nmlv.uOldState & $LVIS_SELECTED ) && !(nmlv.uNewState & $LVIS_SELECTED)
1302             {  
1303                fornum i = nmlv.iFrom, nmlv.iTo + 1
1304                {
1305                   .Selection.iRemove( i->LVRow )  
1306                }               
1307             }     
1308             elif !( nmlv.uOldState & $LVIS_SELECTED ) && (nmlv.uNewState & $LVIS_SELECTED)
1309             {  
1310                fornum i = nmlv.iFrom, nmlv.iTo + 1
1311                {
1312                   .Selection.iAppend( i->LVRow )  
1313                }
1314             }
1315             evparValUint etva         
1316             etva.val = this.pSelected
1317             etva.sender = &this
1318             .OnAfterSelect.Run( /*this,*/ etva )
1319          }
1320       }
1321       case $LVN_ITEMCHANGED 
1322       {           
1323          if ( nmlv.uOldState & $LVIS_SELECTED ) && !(nmlv.uNewState & $LVIS_SELECTED)
1324          {  
1325             //.Selection.iRemove( .Rows[nmlv.iItem] )
1326             if .pOwnerData 
1327             {
1328                if nmlv.iItem == -1
1329                {
1330                   .Selection.Items.clear()
1331                }
1332                else
1333                {
1334                   .Selection.iRemove( nmlv.iItem->LVRow )
1335                }  
1336             }
1337             else 
1338             {
1339                if nmlv.lParam : .Selection.iRemove( nmlv.lParam->LVRow )
1340             }
1341          }     
1342          elif !( nmlv.uOldState & $LVIS_SELECTED ) && (nmlv.uNewState & $LVIS_SELECTED)
1343          {  
1344             //.Selection.iAppend( .Rows[nmlv.iItem] )
1345             if .pOwnerData 
1346             {            
1347                if nmlv.iItem == -1
1348                {
1349                   .Selection.Items.clear()
1350                   uint i
1351                   fornum i = 0, *.Rows
1352                   {
1353                      .Selection.iAppend( i->LVRow )
1354                   }
1355                }
1356                else
1357                {
1358                   .Selection.iAppend( nmlv.iItem->LVRow )
1359                }  
1360             }
1361             else 
1362             {
1363                if nmlv.lParam : .Selection.iAppend( nmlv.lParam->LVRow )
1364             }
1365          }
1366          if !( nmlv.uOldState & $LVIS_SELECTED ) && nmlv.uNewState & $LVIS_SELECTED
1367          //if nmlv.uOldState & $LVIS_SELECTED != ( nmlv.uNewState & $LVIS_SELECTED ) 
1368          {
1369             /*LVITEM li
1370             li.iItem = .WinMsg( $LVM_GETNEXTITEM, -1, $LVNI_SELECTED )
1371             li.mask = $LVIF_PARAM 
1372             .WinMsg( $LVM_GETITEMW, 0, &li )*/
1373             if nmlv.iItem != -1
1374             {
1375                if .pOwnerData : this.pSelected = nmlv.iItem
1376                else : this.pSelected = nmlv.lParam///*&.Rows[li.iItem]//*/li.lParam               
1377             }
1378             evparValUint etva         
1379             etva.val = this.pSelected
1380             etva.sender = &this
1381             .OnAfterSelect.Run( /*this,*/ etva )
1382          }         
1383          if ( nmlv.uOldState & $LVIS_STATEIMAGEMASK ) != ( nmlv.uNewState & $LVIS_STATEIMAGEMASK )
1384          { 
1385             if nmlv.iItem < *.Rows
1386             {            
1387                //.Rows[nmlv.iItem][0].setuint( "stateindex", ( nmlv.uNewState & $LVIS_STATEIMAGEMASK ) >> 12 )
1388                if !.flgRowInserting
1389                { 
1390                   nmlv.lParam->LVRow[0].setuint( "stateindex", ( nmlv.uNewState & $LVIS_STATEIMAGEMASK ) >> 12 )
1391                   evparValUint etva
1392                   etva.val = nmlv.lParam
1393                   etva.sender = &this
1394                   .OnChanged.Run( etva )  
1395                }
1396             }
1397          }         
1398         /* this.pSelected = ?( nmlv.itemNew, nmlv.itemNew.lParam, 0 )
1399          
1400          eventTVAfter etva         
1401          etva.CurItem = this.pSelected      
1402          .OnBeforeSelect.Run( this, etva )*/
1403       }
1404       
1405       case $LVN_ITEMCHANGING 
1406       {
1407          if nmlv.uChanged & $LVIF_STATE 
1408          {
1409             //wmsg.flags = 1
1410          return 0
1411          }
1412  
1413          /*if nmlv.uChanged & $LVIF_STATE 
1414          {
1415             if nmlv.uOldState & $LVIS_SELECTED != ( nmlv.uNewState & $LVIS_SELECTED )
1416             {
1417                evparTVBefore etvb
1418                etvb.CurItem = nmlv.lParam
1419                .OnBeforeSelect.Run(  etvb )
1420             }
1421          }*/
1422        /*  
1423             \n" )
1424             LVITEM li
1425             li.iItem = .WinMsg( $LVM_GETNEXTITEM, -1, $LVNI_SELECTED )
1426             li.mask = $LVIF_PARAM 
1427             .WinMsg( $LVM_GETITEMW, 0, &li )
1428             return 0
1429          if nmlv.uOldState & $LVIS_FOCUSED && !( nmlv.uNewState & $LVIS_FOCUSED )
1430          {
1431             .flgItemChanging = 1
1432          }
1433          
1434          elif nmlv.uOldState & $LVIS_SELECTED && !( nmlv.uNewState & $LVIS_SELECTED )
1435          {
1436             evparTVBefore etvb
1437             if .flgItemChanging
1438             {
1439                etvb.CurItem = nmlv.lParam
1440             }          
1441             else
1442             {
1443                etvb.CurItem = 0
1444             }
1445             .flgItemChanging = 0
1446             .OnBeforeSelect.Run(  etvb )
1447             return etvb.flgCancel
1448          }
1449             */      
1450       }
1451       /*case $TVN_ITEMEXPANDEDW
1452       {
1453          if nmlv.action & ( $TVE_COLLAPSE | $TVE_EXPAND )
1454          {
1455             nmlv.itemNew.lParam->LVItem.setuint( "expanded", nmlv.action & $TVE_EXPAND )            
1456          }
1457          
1458       }
1459       case $TVN_ITEMEXPANDINGW
1460       {
1461       }*/
1462       case $LVN_BEGINLABELEDITW
1463       {
1464          evparTVEdit etve  
1465          etve.sender = &this       
1466          .OnBeforeEdit.Run( etve )
1467          return etve.flgCancel
1468       }
1469       case $LVN_ENDLABELEDITW
1470       {
1471          nmlv as NMLVDISPINFO
1472          
1473          evparTVEdit etve
1474          if nmlv.item.pszText
1475          {
1476             etve.NewLabel.copy( nmlv.item.pszText )     
1477          }
1478          else
1479          {
1480             etve.flgCancel = 1
1481          }
1482          
1483          
1484          etve.sender = &this
1485          .OnAfterEdit.Run( /*this,*/ etve )         
1486          if !etve.flgCancel 
1487          {          
1488             uint selected as .Selected
1489             if &selected
1490             { 
1491                
1492                selected.set( "name", etve.NewLabel.toutf8( "" ) )
1493             }            
1494             return 1
1495          }         
1496       }
1497       case $LVN_BEGINDRAG
1498       {          
1499          //.Selected = nmlv.lParam->LVItem
1500          /*LVITEM lvitem
1501          lvitem.stateMask = $LVIS_SELECTED
1502          .WinMsg( $LVM_SETITEMSTATE, .Selected.param->LVRowData.idx, &lvitem )                           
1503          */
1504          if .pAutoDrag && !.pSortedColumn
1505          {
1506             SetCapture( .hwnd ); 
1507             .fDrag = 1
1508          }  
1509              
1510       }
1511       case $LVN_COLUMNCLICK
1512       {
1513          evparQuery evq
1514          evq.val = nmlv.iSubItem
1515          .OnColumnClick.Run( evq, this )
1516          if !evq.flgCancel
1517          {
1518             uint curcolumn as .Columns[nmlv.iSubItem]
1519             uint sort = 0
1520             if sort = curcolumn.pSorted
1521             {
1522                if sort == $lvsortDown : sort = $lvsortUp
1523                else : sort = $lvsortDown                  
1524             } 
1525             else
1526             {               
1527                sort = curcolumn.pDefSorted
1528                if !sort : sort = $lvsortDown               
1529             }            
1530             curcolumn.Sorted = sort            
1531          }         
1532       }
1533       case $LVN_GETDISPINFOW
1534       {         
1535          nmlv as NMLVDISPINFO
1536          //print( "getdisp \(nmlv.item.lParam)\n" )
1537          evparValColl evc
1538          utt.clear()
1539          evc.val = %{ nmlv.item.iItem, nmlv.item.iSubItem, utt }
1540          evc.sender = &this
1541          .OnGetData.Run( evc )
1542          //t = "getdispINfo \(nmlv.item.iItem) \(nmlv.item.iSubItem)".ustr()
1543          //nmlv.item.
1544          nmlv.item.pszText = utt.ptr()
1545          //nmlv.item.state = 0
1546       } 
1547       case $NM_CUSTOMDRAW  
1548       {
1549          uint cd as wmsg.lpar->NMLVCUSTOMDRAW
1550          if (.OnItemDraw.id || .OnSubItemDraw.id ) && cd.nmcd.hdr.hwndFrom == this.hwnd 
1551          {            
1552             uint resi = $CDRF_DODEFAULT;
1553             switch( cd.nmcd.dwDrawStage )
1554             {
1555                case $CDDS_PREPAINT
1556                {               
1557                   resi |= $CDRF_NOTIFYSUBITEMDRAW//$CDRF_NOTIFYITEMDRAW                
1558                }
1559                case $CDDS_ITEMPREPAINT | $CDDS_SUBITEM
1560                {  
1561                   cd.nmcd.dwItemSpec 
1562                   cd.clrTextBk = .clrTextBk  
1563                   cd.clrText   = .clrText    
1564                    
1565                   evparValColl evc
1566                   uint item
1567                   if .pOwnerData : item = cd.nmcd.dwItemSpec
1568                   else : item = cd.nmcd.lItemlParam
1569                   evc.val = %{ item, cd.iSubItem, cd.clrText, cd.clrTextBk, cd.nmcd.uItemState }
1570                   evc.sender = &this
1571                   if .OnSubItemDraw.Run( evc )
1572                   {
1573                      cd.clrTextBk = evc.val[2]//->uint//0xFF00
1574                      cd.clrText = evc.val[3]//->uint//GetSysColor(16)
1575                      cd.nmcd.uItemState &= ~$CDIS_SELECTED;
1576                   }               
1577                }  
1578                case $CDDS_ITEMPREPAINT            
1579                {
1580                   //print( "repaint \(cd.nmcd.hdr.hwndFrom) \(this.hwnd) \(cd.nmcd.dwDrawStage) \(.pOwnerData) \(cd.nmcd.dwItemSpec) \(cd.nmcd.lItemlParam)\n" )
1581                   evparValColl evc
1582                   uint item
1583                   if !cd.iSubItem || .pOwnerData
1584                   {
1585                      if .pOwnerData : item = cd.nmcd.dwItemSpec
1586                      else : item = cd.nmcd.lItemlParam
1587                       
1588                      //uint item as cd.nmcd.lItemlParam->TVItem                  
1589                      //if &item && item.getuint( "disabled" ) :
1590                      
1591                      if .WinMsg( $LVM_GETITEMSTATE, cd.nmcd.dwItemSpec, $LVIS_SELECTED )
1592                      {  
1593                         cd.nmcd.uItemState |= $CDIS_SELECTED
1594                         if GetFocus() == .hwnd//cd.nmcd.uItemState & $CDIS_FOCUS
1595                         {
1596                            cd.nmcd.uItemState |= $CDIS_FOCUS
1597                            cd.clrTextBk = GetSysColor(13)
1598                            cd.clrText = GetSysColor(5)
1599                         }
1600                         else
1601                         {
1602                            cd.clrTextBk =  GetSysColor(15) 
1603                            cd.clrText = GetSysColor(18)
1604                         } 
1605                      }
1606                      else :  cd.nmcd.uItemState &= ~$CDIS_SELECTED;
1607                      
1608                      evc.val = %{ item, cd.clrText, cd.clrTextBk, cd.nmcd.uItemState }
1609                      evc.sender = &this                  
1610                      if .OnItemDraw.Run( evc )
1611                      {
1612                         cd.clrText = evc.val[1]//0xFF00
1613                         cd.clrTextBk = evc.val[2]//GetSysColor(16)
1614                         cd.nmcd.uItemState &= ~$CDIS_SELECTED;
1615                      }
1616                      .clrTextBk = cd.clrTextBk
1617                      .clrText   = cd.clrText
1618                      if .OnSubItemDraw.id : resi = $CDRF_NOTIFYSUBITEMDRAW//$CDRF_NOTIFYITEMDRAW
1619                   }
1620                }
1621             }
1622             wmsg.flags = 1   
1623             return resi
1624          }
1625       } 
1626    }
1627    return 0
1628 }
1629 
1630 method uint vListView.mMouse <alias=vListView_mMouse>( evparMouse em )
1631 {
1632    switch em.evmtype
1633    {
1634       case $evmMove
1635       {
1636          if .fDrag 
1637          {         
1638          
1639             POINT point
1640             uint destidx
1641             LVHITTESTINFO lvht
1642              
1643             lvht.pt.x = point.x = em.x
1644             lvht.pt.y = point.y = em.y
1645             //destidx = .WinMsg( $LVM_HITTEST, 0, &lvht)
1646             if ( destidx = .WinMsg( $LVM_HITTEST, 0, &lvht)) != -1// destidx != -1 && destidx != .fOldDestItem 
1647             {
1648                LVITEM lvitem
1649                //lvitem.mask = $LVIF_STATE
1650                lvitem.stateMask = $LVIS_DROPHILITED               
1651                .WinMsg( $LVM_SETITEMSTATE, .fOldDestItem, &lvitem ) 
1652                /*lvitem.state = $LVIS_DROPHILITED
1653                .fOldDestItem = destitem
1654                .WinMsg( $LVM_SETITEMSTATE, .fOldDestItem, &lvitem )               
1655                SetCursor( App.cursorDrag ) 
1656                */
1657                if .Selection.Find( /*.Rows[destidx]*/.RowFromVisIndex( destidx ) ) == -1
1658                { 
1659                   lvitem.state = $LVIS_DROPHILITED
1660                   .fOldDestItem = destidx
1661                   .WinMsg( $LVM_SETITEMSTATE, .fOldDestItem, &lvitem )
1662                   //.WinMsg( $TVM_SELECTITEM, $TVGN_DROPHILITE, dest )
1663                   SetCursor( App.cursorDrag )
1664                }
1665                else 
1666                {
1667                   .fOldDestItem = -1
1668                   //.WinMsg( $TVM_SELECTITEM, $TVGN_DROPHILITE, 0 )
1669                   SetCursor( App.cursorNoDrag )
1670                } 
1671             }
1672             else
1673             {
1674                if int( em.x ) > 0 && int( em.y ) > 0 && em.x < .clloc.width && em.y < .clloc.height
1675                {
1676                   SetCursor( App.cursorDrag )
1677                }
1678                else
1679                {
1680                   SetCursor( App.cursorNoDrag )
1681                }
1682             }
1683             ClientToScreen( .hwnd, point )
1684             //ImageList_DragMove( point.x, point.y )   
1685          }
1686       }
1687       case $evmLUp
1688       {
1689          uint dest
1690          LVHITTESTINFO lvht
1691          if .fDrag
1692          {
1693          
1694             uint destitem as LVRow
1695             uint selected as .pSelected->LVRow
1696             
1697             lvht.pt.x = em.x
1698             lvht.pt.y = em.y
1699             dest = .WinMsg( $LVM_HITTEST, 0, &lvht)
1700             
1701             LVITEM lvitem         
1702             uint flg      
1703             lvitem.stateMask = $LVIS_DROPHILITED
1704             .WinMsg( $LVM_SETITEMSTATE, dest, &lvitem )
1705             .WinMsg( $LVM_SETITEMSTATE, .fOldDestItem, &lvitem )
1706             .fOldDestItem = -1                        
1707             if dest != -1 
1708             {            
1709                
1710                /*LVITEM item
1711                item.mask = $LVIF_PARAM  
1712                item.iItem = dest             
1713                .WinMsg( $LVM_GETITEMW, 0, &item )
1714                */
1715                //destitem as item.lParam->LVRow              
1716                //if &destitem 
1717                {
1718                   destitem as /*.Rows[ dest ]*/.RowFromVisIndex( dest )
1719                   flg = $TREE_BEFORE       
1720                   if .Selection.Find( destitem ) != -1
1721                   {
1722                      destitem as (-1)->LVRow
1723                   } 
1724                   /*foreach zitem, .Selection
1725                   {     
1726                      zitem.MoveTo( destitem, $TREE_BEFORE )
1727                   }*/
1728                   //.fMoving = 0
1729                   //selected.MoveTo( destitem, $TREE_BEFORE )                  
1730                }                             
1731                //.WinMsg( $TVM_SELECTITEM, $TVGN_DROPHILITE, destitem )                                        
1732             }
1733             elif int( em.x ) > 0 && int( em.y ) > 0 && em.x < .clloc.width && em.y < .clloc.height
1734             {
1735                flg = $TREE_LAST
1736                destitem as 0->LVRow//.Rows[*.Rows-1]               
1737               // selected.MoveTo( , $TREE_LAST )
1738             }
1739             //.fMoving = 1
1740             //uint selected as .Selected
1741             ReleaseCapture()      
1742             //destitem as LVRow
1743             if &destitem != -1                  
1744             {                 
1745                .Selection.Arrange()
1746                int i
1747                for i = *.Selection-1, i >= 0, i--
1748                //foreach item, listview.Selection
1749                {
1750                   uint curitem as .Selection[i]
1751                   curitem.MoveTo( destitem, flg )
1752                   destitem as curitem
1753                   flg = $TREE_BEFORE
1754                   //item.Del()
1755                }                         
1756                //.Selected = 0->LVRow
1757                //.Selected = selected
1758             }                        
1759             //ImageList_EndDrag( )            
1760             
1761             //.Selected = selected  
1762             //.fDrag = 0
1763          }
1764       }
1765    }
1766    return this->vCtrl.mMouse( em )   
1767 }
1768 
1769 
1770 method vListView.mPosChanging <alias=vListView_mPosChanging>( eventpos evp )
1771 { 
1772    this->vCtrl.mPosChanging( evp )
1773    /*LVCOLUMN col
1774    col.mask = $LVCF_WIDTH
1775    col.cx = this.clloc.width - 10
1776    this.WinMsg( $LVM_SETCOLUMNW, 0, &col ) */     
1777 }
1778 
1779 
1780 /*Виртуальный метод uint vListView.mLangChanged - Изменение текущего языка
1781 */
1782 method uint vListView.mLangChanged <alias=vListView_mLangChanged>()
1783 {
1784    .iUpdateImgList()   
1785    this->vCtrl.mLangChanged()
1786    return 0  
1787 }
1788 
1789 
1790 func int ListViewSort( uint item1 item2, vListViewColumn column )
1791 {   
1792    uint resi
1793    uint lv as column.Owner->vListView
1794    switch column.pSortType
1795    { 
1796       case $lvstText
1797       {
1798          reserved buf1[512]
1799          reserved buf2[512]      
1800          LVITEM lvi      
1801          
1802          lvi.mask = $LVCF_SUBITEM
1803          lvi.cchTextMax = 256
1804          lvi.iSubItem = column.pIndex   
1805          
1806          lvi.pszText = &buf1   
1807          lv.WinMsg( $LVM_GETITEMTEXTW, item1, &lvi )   
1808          
1809          lvi.pszText = &buf2      
1810          lv.WinMsg( $LVM_GETITEMTEXTW, item2, &lvi )
1811          
1812          resi = CompareStringW( 0, 0, &buf1, -1, &buf2, -1 ) - 2
1813       }
1814       case $lvstValue
1815       {
1816       
1817          uint row1 as lv.RowFromVisIndex( item1 )
1818          uint row2 as lv.RowFromVisIndex( item2 )
1819          ustr value1, value2       
1820          value1.fromutf8( row1[column.Idx].value )
1821          value2.fromutf8( row2[column.Idx].value )            
1822          resi = CompareStringW( 0, 0, value1.ptr(), *value1, value2.ptr(), 
1823                             *value2 ) - 2                                  
1824       }
1825       case $lvstSortIndex
1826       {
1827          
1828       }
1829       case $lvstEvent
1830       {
1831          //resi = lv.OnSort()
1832       }
1833       
1834    }
1835    
1836    if !resi && column.pAdvSortColumn
1837    {  
1838       return  ListViewSort( item1, item2, column.pAdvSortColumn->vListViewColumn )   
1839    }
1840    
1841    if column.pSorted == $lvsortUp : resi = -resi
1842       
1843    return resi 
1844      
1845 }
1846 
1847 /*------------------------------------------------------------------------------
1848    Registration
1849 */
1850 /*Системный метод vListView vListView.init - Инициализация объекта
1851 */   
1852 method vListView vListView.init( )
1853 {   
1854    this.pTypeId = vListView
1855    //this.flgXPStyle = 1  
1856    this.pCanFocus = 1
1857    this.pTabStop = 1      
1858    this.loc.width = 100
1859    this.loc.height = 25
1860    this.pBorder = 1
1861    this.pListViewStyle = $lvsReport
1862    .pShowHeader = 1
1863    .pSortFunc = callback( &ListViewSort, 3 )
1864    /*this.pShowPlusMinus = 1
1865    this.pShowLines = 1
1866    this.pShowRootLines = 1
1867    uint itemdata as new( treedata )->treedata*/
1868    //itemdata.listview = &this
1869    //this.gttree.root().param = &itemdata
1870    //this.gtcolumns = &this.gttree.root().insertchild( "columns", 0->gtitem )
1871    
1872    .Columns.pListView = &this
1873    .ColumnsOrder.pListView = &this
1874 /*   .Columns.Insert( 0 )*/
1875    
1876    this.gtrows = &this.gttree.root().insertchild( "rows", 0->gtitem )
1877    .Rows.pListView = &this
1878    
1879    .Selection.pListView = &this
1880    
1881    //this.items[0].listview = &this
1882    //this.items[0].gti = &this.gti.root()
1883    return this 
1884 }  
1885 
1886 method uint vListView.wmMouse <alias=vListView_wmMouse>( winmsg wmsg )
1887 {  
1888    if .pShowSelection
1889    {
1890       LVHITTESTINFO info
1891       info.pt.x = int( ( &wmsg.lpar )->short )
1892       info.pt.y = int( ( &wmsg.lpar + 2 )->short )
1893       if .WinMsg( $LVM_HITTEST, 0, &info ) == -1
1894       {
1895          SetFocus( this.hwnd )
1896          //( &wmsg.lpar )->short = 5
1897          //( &wmsg.lpar + 2 )->short = 5
1898          wmsg.flags = 1
1899          /*         
1900          info.pt.x = 5         
1901          if .WinMsg( $LVM_HITTEST, 0, &info ) != -1
1902          {              
1903             LVITEM lvi
1904             lvi.mask = $LVIF_STATE
1905             //lvi.iItem = info.iItem
1906             lvi.stateMask = $LVIS_FOCUSED | $LVIS_SELECTED 
1907             lvi.state = $LVIS_FOCUSED | $LVIS_SELECTED 
1908             .WinMsg( $LVM_SETITEMSTATE, info.iItem, &lvi )
1909          }*/
1910       }
1911       else
1912       {
1913          if GetFocus() != this.hwnd : SetFocus( this.hwnd ) 
1914       }
1915    }
1916    return this->vCtrl.wmMouse( wmsg )
1917 }
1918 method uint vListView.wmcapturechange <alias=vListView_wmcapturechanged>( winmsg wmsg )
1919 {  
1920    if wmsg.lpar != .hwnd && .fDrag 
1921    {
1922       SetCursor( App.cursorArrow )
1923       
1924       LVITEM lvitem            
1925       lvitem.stateMask = $LVIS_SELECTED
1926       lvitem.state = $LVIS_SELECTED    
1927       .WinMsg( $LVM_SETITEMSTATE, /*.Selected.Idx*/.Selected.VisIndex, &lvitem )
1928       //.WinMsg( $LVM_SELECTITEM, $TVGN_DROPHILITE, 0 )
1929       .fDrag = 0
1930    } 
1931    return 0
1932 }
1933 
1934 func init_vListView <entry>()
1935 {  
1936    regcomp( vListView, "vListView", vCtrl, $vCtrl_last, 
1937       %{  %{$mCreateWin,    vListView_mCreateWin},
1938           %{$mWinNtf,      vListView_mWinNtf },
1939           %{$mMouse,       vListView_mMouse },
1940           %{$mPosChanging, vListView_mPosChanging },
1941           %{$mInsert,      vListView_mInsert},
1942           %{$mRemove,      vListView_mRemove},
1943           %{$mPreDel,      vListView_mPreDel},
1944           %{$mLangChanged,  vListView_mLangChanged }/*,
1945          /%{$mSetName,      vListView_mSetName}*/
1946       },  
1947        //0->collection
1948       %{ %{ $WM_CAPTURECHANGED, vListView_wmcapturechanged },
1949          %{$WM_LBUTTONDOWN,  vListView_wmMouse},
1950          %{$WM_LBUTTONUP,  vListView_wmMouse},         
1951          %{$WM_LBUTTONDBLCLK,  vListView_wmMouse},                  
1952          %{$WM_RBUTTONDOWN,  vListView_wmMouse},                                    
1953          %{$WM_RBUTTONUP,  vListView_wmMouse},          
1954          %{$WM_RBUTTONDBLCLK,  vListView_wmMouse}
1955 //         %{$WM_NOTIFY  ,   vListView_wmnotify}
1956       }
1957        )
1958    regcomp( vListViewColumn, "vListViewColumn", vComp, $vComp_last,
1959       %{ %{$mLangChanged,  vListViewColumn_mLangChanged },
1960          %{$mPreDel,       vListViewColumn_mPreDel} },
1961        0->collection 
1962         )
1963          
1964 ifdef $DESIGNING {
1965    cm.AddComp( vListView, 1, "Windows", "listview" )
1966    
1967    cm.AddProps( vListView, %{    
1968 /*"TabOrder", uint, 0,
1969 "Border", uint, 0,
1970 "ShowPlusMinus", uint, 0,
1971 "ShowLines", uint, 0,    
1972 "ShowRootLines", uint, 0,*/
1973 "GridLines", uint, 0,
1974 "ShowSelection", uint, 0,
1975 "ShowHeader",    uint, 0,
1976 "ListViewStyle", uint, 0,
1977 "HeaderDragDrop", uint, 0,
1978 "RowSelect", uint, 0,
1979 "CheckBoxes", uint, 0,
1980 "LabelEdit", uint, 0,
1981 "EnsureVisible", uint, 0,
1982 "AutoDrag", uint, 0,
1983 "MultiSelect", uint, 0,
1984 "ImageList", ustr, 0,
1985 "OwnerData", uint, 0
1986 
1987    }) 
1988    cm.AddEvents( vListView, %{
1989 "OnBeforeEdit", "eventTVEdit",
1990 "OnAfterEdit", "eventTVEdit",
1991 /*"OnBeforeSelect", "",*/
1992 //"OnGetLabel",    "evParValUint",
1993 "OnAfterSelect", "evparValUint",
1994 "OnBeforeMove", "evparBeforeMove",
1995 "OnAfterMove", "evparAfterMove",
1996 "OnColumnClick", "evQuery",
1997 "OnGetData", "evparValColl",
1998 "OnItemDraw", "evparValColl",
1999 "OnSubItemDraw", "evparValColl"
2000 /*"OnBeforeExpand", "",
2001 "OnAfterExpand", "",
2002 "OnBeforeCollapse", "",
2003 "OnAfterCollapse", ""
2004 */
2005    })
2006    
2007    cm.AddPropVals( vListView, "ListViewStyle", %{
2008 "lvsIcon"      ,$lvsIcon,          
2009 "lvsReport"    ,$lvsReport,   
2010 "lvsSmallIcon" ,$lvsSmallIcon,
2011 "lvsList"      ,$lvsList 
2012    })     
2013 }
2014       
2015 }
2016 
Редактировать