• R/O
  • HTTP
  • SSH
  • HTTPS

thirdparty-altwindirstat: Commit

A - since abandoned - fork of WinDirStat which had some interesting changes.

Original home: https://github.com/ariccio/altWinDirStat


Commit MetaInfo

Révision257b99d48873938854575263fc09d40f749211d6 (tree)
l'heure2016-05-09 14:15:21
AuteurAlexander Riccio <alexander@ricc...>
CommiterAlexander Riccio

Message de Log

use more meaningful/verbose names

Change Summary

Modification

--- a/WinDirStat/windirstat/ownerdrawnlistcontrol.h
+++ b/WinDirStat/windirstat/ownerdrawnlistcontrol.h
@@ -536,7 +536,7 @@ namespace {
536536 }
537537
538538 template<size_t count>
539- void draw_proper_text_for_each_column( _In_ COwnerDrawnListItem* const item, _In_ const rsize_t thisLoopSize, _In_ _In_reads_( thisLoopSize ) const column::ENUM_COL( &subitems )[ count ], _In_ HDC hDC, _In_ _In_reads_( thisLoopSize ) const RECT( &rects_draw )[ count ], _In_ const PDRAWITEMSTRUCT pdis, _In_ _In_reads_( thisLoopSize ) int( &focusLefts_temp )[ count ], _In_ const bool showSelectionAlways, _In_ const bool bIsFullRowSelection, _In_ const std::vector<bool>& is_right_aligned_cache, _In_ const COwnerDrawnListCtrl* const owner_drawn_list_ctrl ) {
539+ void draw_proper_text_for_each_column( _In_ COwnerDrawnListItem* const item, _In_ const rsize_t thisLoopSize, _In_ _In_reads_( thisLoopSize ) const column::ENUM_COL( &subitems )[ count ], _In_ HDC hInMemoryDeviceContext, _In_ _In_reads_( thisLoopSize ) const RECT( &rects_draw )[ count ], _In_ const PDRAWITEMSTRUCT pDestinationDrawItemStruct, _In_ _In_reads_( thisLoopSize ) int( &focusLefts_temp )[ count ], _In_ const bool showSelectionAlways, _In_ const bool bIsFullRowSelection, _In_ const std::vector<bool>& is_right_aligned_cache, _In_ const COwnerDrawnListCtrl* const owner_drawn_list_ctrl ) {
540540 for ( size_t i = 0; i < thisLoopSize; i++ ) {
541541 //draw the proper text in each column?
542542
@@ -545,15 +545,15 @@ namespace {
545545 //CTreeListItem draws self FOR NAME column ONLY!
546546 //CDriveItem NEVER draws self.
547547 //CListItem (typeview) draws self ONLY for: NAME, and COLOR.
548- if ( !item->DrawSubitem_( subitems[ i ], hDC, rects_draw[ i ], pdis->itemState, NULL, &focusLefts_temp[ i ], owner_drawn_list_ctrl ) ) {
549- owner_drawn_list_ctrl->DoDrawSubItemBecauseItCannotDrawItself( item, subitems[ i ], hDC, rects_draw[ i ], pdis, showSelectionAlways, bIsFullRowSelection, is_right_aligned_cache );
548+ if ( !item->DrawSubitem_( subitems[ i ], hInMemoryDeviceContext, rects_draw[ i ], pDestinationDrawItemStruct->itemState, NULL, &focusLefts_temp[ i ], owner_drawn_list_ctrl ) ) {
549+ owner_drawn_list_ctrl->DoDrawSubItemBecauseItCannotDrawItself( item, subitems[ i ], hInMemoryDeviceContext, rects_draw[ i ], pDestinationDrawItemStruct, showSelectionAlways, bIsFullRowSelection, is_right_aligned_cache );
550550 }
551551 }
552552 }
553553
554554 //thisLoopSize has essentially the range of RANGE_ENUM_COL, but it's never zero.
555555 template<size_t count>
556- void draw_focus_rects_draw_focus( _In_ _In_range_( 1, 8 ) const rsize_t thisLoopSize, _In_ HDC hMemoryDeviceContext, _In_ _In_reads_( thisLoopSize ) const RECT( &rects_draw )[ count ], _In_ _In_reads_( thisLoopSize ) const int( &focusLefts )[ count ], _In_ HDC hDC, _Inout_ RECT& rcFocus, _In_ const RECT& rcItem ) {
556+ void draw_focus_rects_draw_focus( _In_ _In_range_( 1, 8 ) const rsize_t thisLoopSize, _In_ HDC hMemoryDeviceContext, _In_ _In_reads_( thisLoopSize ) const RECT( &rects_draw )[ count ], _In_ _In_reads_( thisLoopSize ) const int( &focusLefts )[ count ], _In_ HDC pDestinationDeviceContext, _Inout_ RECT& rcFocus, _In_ const RECT& rcItem ) {
557557 //first iteration is a special case, so we handle it outside the loop, and reduce the number of comparisons in the loop
558558 ASSERT( thisLoopSize > 0 );
559559 size_t i = 0;
@@ -561,42 +561,42 @@ namespace {
561561 rcFocus.left = focusLefts[ i ];
562562 }
563563 rcFocus.right = rects_draw[ i ].right;
564- VERIFY( ::BitBlt( hDC, ( rcItem.left + rects_draw[ i ].left ), ( rcItem.top + rects_draw[ i ].top ), ( rects_draw[ i ].right - rects_draw[ i ].left ), ( rects_draw[ i ].bottom - rects_draw[ i ].top ), hMemoryDeviceContext, rects_draw[ i ].left, rects_draw[ i ].top, SRCCOPY ) );
564+ VERIFY( ::BitBlt( pDestinationDeviceContext, ( rcItem.left + rects_draw[ i ].left ), ( rcItem.top + rects_draw[ i ].top ), ( rects_draw[ i ].right - rects_draw[ i ].left ), ( rects_draw[ i ].bottom - rects_draw[ i ].top ), hMemoryDeviceContext, rects_draw[ i ].left, rects_draw[ i ].top, SRCCOPY ) );
565565
566566 //Not vectorized: 1304, loop includes assignments of different sizes
567567 for ( ; i < thisLoopSize; i++ ) {
568568 if ( focusLefts[ i ] > rects_draw[ i ].left ) {
569569
570- VERIFY( ::DrawFocusRect( hDC, &rcFocus ) );
570+ VERIFY( ::DrawFocusRect( pDestinationDeviceContext, &rcFocus ) );
571571 //pdc->DrawFocusRect( &rcFocus );
572572 rcFocus.left = focusLefts[ i ];
573573 }
574574 rcFocus.right = rects_draw[ i ].right;
575- VERIFY( ::BitBlt( hDC, ( rcItem.left + rects_draw[ i ].left ), ( rcItem.top + rects_draw[ i ].top ), ( rects_draw[ i ].right - rects_draw[ i ].left ), ( rects_draw[ i ].bottom - rects_draw[ i ].top ), hMemoryDeviceContext, rects_draw[ i ].left, rects_draw[ i ].top, SRCCOPY ) );
575+ VERIFY( ::BitBlt( pDestinationDeviceContext, ( rcItem.left + rects_draw[ i ].left ), ( rcItem.top + rects_draw[ i ].top ), ( rects_draw[ i ].right - rects_draw[ i ].left ), ( rects_draw[ i ].bottom - rects_draw[ i ].top ), hMemoryDeviceContext, rects_draw[ i ].left, rects_draw[ i ].top, SRCCOPY ) );
576576 }
577577 }
578578
579579 //thisLoopSize has essentially the range of RANGE_ENUM_COL, but it's never zero.
580580 template<size_t count>
581- void draw_focus_rects( _In_ _In_range_( 1, 8 ) const rsize_t thisLoopSize, _In_ HDC hDC, _In_ _In_reads_( thisLoopSize ) const RECT( &rects_draw )[ count ], _In_ _In_reads_( thisLoopSize ) const int( &focusLefts )[ count ], _In_ CDC* pdc, _Inout_ RECT& rcFocus, _In_ const RECT& rcItem, _In_ const bool drawFocus ) {
581+ void draw_focus_rects( _In_ _In_range_( 1, 8 ) const rsize_t thisLoopSize, _In_ HDC hInMemoryDeviceContext, _In_ _In_reads_( thisLoopSize ) const RECT( &rects_draw )[ count ], _In_ _In_reads_( thisLoopSize ) const int( &focusLefts )[ count ], _In_ HDC hDestinationDeviceContext, _Inout_ RECT& rcFocus, _In_ const RECT& rcItem, _In_ const bool drawFocus ) {
582582 if ( drawFocus ) {
583- return draw_focus_rects_draw_focus( thisLoopSize, hDC, rects_draw, focusLefts, pdc->m_hDC, rcFocus, rcItem );
583+ return draw_focus_rects_draw_focus( thisLoopSize, hInMemoryDeviceContext, rects_draw, focusLefts, hDestinationDeviceContext, rcFocus, rcItem );
584584 }
585585 for ( size_t i = 0; i < thisLoopSize; i++ ) {
586586 if ( focusLefts[ i ] > rects_draw[ i ].left ) {
587587 rcFocus.left = focusLefts[ i ];
588588 }
589589 rcFocus.right = rects_draw[ i ].right;
590- VERIFY( ::BitBlt( pdc->m_hDC, ( rcItem.left + rects_draw[ i ].left ), ( rcItem.top + rects_draw[ i ].top ), ( rects_draw[ i ].right - rects_draw[ i ].left ), ( rects_draw[ i ].bottom - rects_draw[ i ].top ), hDC, rects_draw[ i ].left, rects_draw[ i ].top, SRCCOPY ) );
590+ VERIFY( ::BitBlt( hDestinationDeviceContext, ( rcItem.left + rects_draw[ i ].left ), ( rcItem.top + rects_draw[ i ].top ), ( rects_draw[ i ].right - rects_draw[ i ].left ), ( rects_draw[ i ].bottom - rects_draw[ i ].top ), hInMemoryDeviceContext, rects_draw[ i ].left, rects_draw[ i ].top, SRCCOPY ) );
591591 }
592592 }
593593
594594
595595 //The compiler will automatically inline if /Ob2 is on, so we'll ask anyways.
596596 template<size_t count>
597- inline void map_column_number_to_ENUM_and_build_drawable_rect( const rsize_t thisLoopSize, _In_ const INT( &order )[ count ], _Out_ _Out_writes_( thisLoopSize ) column::ENUM_COL( &subitems_temp )[ count ], _Out_ _Out_writes_( thisLoopSize ) RECT( &rects_temp )[ count ], _In_ const PDRAWITEMSTRUCT pdis, _Inout_ const COwnerDrawnListCtrl* const this_ctrl, _Inout_ CHeaderCtrl* thisHeaderCtrl, _In_ const RECT rcItem ) {
597+ inline void map_column_number_to_ENUM_and_build_drawable_rect( const rsize_t thisLoopSize, _In_ const INT( &order )[ count ], _Out_ _Out_writes_( thisLoopSize ) column::ENUM_COL( &subitems_temp )[ count ], _Out_ _Out_writes_( thisLoopSize ) RECT( &rects_temp )[ count ], _In_ const PDRAWITEMSTRUCT pDestinationDrawItemStruct, _Inout_ const COwnerDrawnListCtrl* const this_ctrl, _Inout_ CHeaderCtrl* thisHeaderCtrl, _In_ const RECT rcItem ) {
598598 iterate_over_columns_and_populate_column_fields_( thisLoopSize, order, subitems_temp );
599- build_array_of_rects_from_subitem_rects( thisLoopSize, subitems_temp, rects_temp, pdis, this_ctrl, thisHeaderCtrl );
599+ build_array_of_rects_from_subitem_rects( thisLoopSize, subitems_temp, rects_temp, pDestinationDrawItemStruct, this_ctrl, thisHeaderCtrl );
600600 build_array_of_drawable_rects_by_offsetting_( thisLoopSize, rects_temp, rcItem.left, rcItem.top );
601601 }
602602
@@ -648,24 +648,44 @@ class COwnerDrawnListCtrl : public CListCtrl {
648648 */
649649
650650 protected:
651- virtual void DrawItem( _In_ PDRAWITEMSTRUCT pdis ) override final {
652- const auto item = reinterpret_cast< COwnerDrawnListItem *> ( pdis->itemData );
653- const auto pdc = CDC::FromHandle( pdis->hDC );
651+ virtual void DrawItem( _In_ PDRAWITEMSTRUCT pDestinationDrawItemStruct ) override final {
652+ const auto item = reinterpret_cast< COwnerDrawnListItem *> ( pDestinationDrawItemStruct->itemData );
653+ const auto pCDestinationDeviceContext = CDC::FromHandle( pDestinationDrawItemStruct->hDC );
654654 const auto bIsFullRowSelection = m_showFullRowSelection;
655- ASSERT_VALID( pdc );
655+ ASSERT_VALID( pCDestinationDeviceContext );
656656 //RECT rcItem_temp( pdis->rcItem );
657657
658- const RECT rcItem = adjust_rect_for_grid_by_value( m_showGrid, pdis->rcItem );
658+ const RECT rcItem = adjust_rect_for_grid_by_value( m_showGrid, pDestinationDrawItemStruct->rcItem );
659659
660660 //adjust_rect_for_grid( m_showGrid, rcItem_temp );
661661
662+ //CreateCompatibleDC function: https://msdn.microsoft.com/en-us/library/dd183489.aspx
663+ //If the function succeeds, the return value is the handle to a memory DC.
664+ //If the function fails, the return value is NULL.
665+
666+ //When you no longer need the memory DC, call the DeleteDC function.
667+ //We recommend that you call DeleteDC to delete the DC.
668+ //However, you can also call DeleteObject with the HDC to delete the DC.
669+ ASSERT( pDestinationDrawItemStruct->hDC == pCDestinationDeviceContext->m_hDC );
670+ HDC hInMemoryDeviceContext = ::CreateCompatibleDC( pDestinationDrawItemStruct->hDC );
671+ if ( hInMemoryDeviceContext == NULL ) {
672+ std::terminate( );
673+ abort( );
674+ }
675+ auto guard = WDS_SCOPEGUARD_INSTANCE( [&] {
676+ //DeleteDC function: https://msdn.microsoft.com/en-us/library/dd183533.aspx
677+ //If the function succeeds, the return value is nonzero.
678+ //If the function fails, the return value is zero.
679+ const BOOL deleted = ::DeleteDC( hInMemoryDeviceContext );
680+ if ( deleted == 0 ) {
681+ std::terminate( );
682+ }
683+ } );
662684
663- CDC dcmem; //compiler seems to vectorize this!
664685
665- VERIFY( dcmem.CreateCompatibleDC( pdc ) );
666686 CBitmap bm;
667- VERIFY( bm.CreateCompatibleBitmap( pdc, ( rcItem.right - rcItem.left ), ( rcItem.bottom - rcItem.top ) ) );
668- SelectObject_wrapper sobm( dcmem.m_hDC, bm.m_hObject );
687+ VERIFY( bm.CreateCompatibleBitmap( pCDestinationDeviceContext, ( rcItem.right - rcItem.left ), ( rcItem.bottom - rcItem.top ) ) );
688+ SelectObject_wrapper sobm( hInMemoryDeviceContext, bm.m_hObject );
669689 RECT rect_to_fill_solidly = rcItem;
670690 const tagPOINT point_to_offset_by = { rcItem.left, rcItem.top };
671691 VERIFY( ::OffsetRect( &rect_to_fill_solidly, -( point_to_offset_by.x ), -( point_to_offset_by.y ) ) );
@@ -676,13 +696,13 @@ protected:
676696 //SetBkColor function: https://msdn.microsoft.com/en-us/library/dd162964.aspx
677697 //If the function succeeds, the return value specifies the previous background color as a COLORREF value.
678698 //If the function fails, the return value is CLR_INVALID.
679- const COLORREF set_bk_result = ::SetBkColor( dcmem.m_hDC, GetItemBackgroundColor( pdis->itemID ) );
699+ const COLORREF set_bk_result = ::SetBkColor( hInMemoryDeviceContext, GetItemBackgroundColor( pDestinationDrawItemStruct->itemID ) );
680700 if ( set_bk_result == CLR_INVALID ) {
681701 std::terminate( );
682702 }
683- VERIFY( ::ExtTextOut( dcmem.m_hDC, 0, 0, ETO_OPAQUE, &rect_to_fill_solidly, NULL, 0, NULL ) );
703+ VERIFY( ::ExtTextOut( hInMemoryDeviceContext, 0, 0, ETO_OPAQUE, &rect_to_fill_solidly, NULL, 0, NULL ) );
684704
685- const bool drawFocus = ( pdis->itemState bitand ODS_FOCUS ) != 0 && HasFocus( ) && bIsFullRowSelection; //partially vectorized
705+ const bool drawFocus = ( pDestinationDrawItemStruct->itemState bitand ODS_FOCUS ) != 0 && HasFocus( ) && bIsFullRowSelection; //partially vectorized
686706
687707 const rsize_t stack_array_size = 12;
688708 static_assert( stack_array_size > column::COL_ATTRIBUTES, "we're gonna need a bigger array!" );
@@ -723,7 +743,7 @@ protected:
723743
724744 //build map of column# -> ENUM_COL
725745 //build drawable rect for each column
726- map_column_number_to_ENUM_and_build_drawable_rect( thisLoopSize, order, subitems_temp, rects_temp, pdis, this, thisHeaderCtrl, rcItem );
746+ map_column_number_to_ENUM_and_build_drawable_rect( thisLoopSize, order, subitems_temp, rects_temp, pDestinationDrawItemStruct, this, thisHeaderCtrl, rcItem );
727747
728748 const column::ENUM_COL (&subitems)[ stack_array_size ] = subitems_temp;
729749 const RECT (&rects_draw)[ stack_array_size ] = rects_temp;
@@ -731,14 +751,14 @@ protected:
731751 build_focusLefts_from_drawable_rects( thisLoopSize, rects_draw, focusLefts_temp );
732752
733753
734- draw_proper_text_for_each_column( item, thisLoopSize, subitems, dcmem.m_hDC, rects_draw, pdis, focusLefts_temp, showSelectionAlways, bIsFullRowSelection, is_right_aligned_cache, this );
754+ draw_proper_text_for_each_column( item, thisLoopSize, subitems, hInMemoryDeviceContext, rects_draw, pDestinationDrawItemStruct, focusLefts_temp, showSelectionAlways, bIsFullRowSelection, is_right_aligned_cache, this );
735755
736756 const int (&focusLefts)[ stack_array_size ] = focusLefts_temp;
737757
738- draw_focus_rects( thisLoopSize, dcmem.m_hDC, rects_draw, focusLefts, pdc, rcFocus, rcItem, drawFocus );
758+ draw_focus_rects( thisLoopSize, hInMemoryDeviceContext, rects_draw, focusLefts, pCDestinationDeviceContext->m_hDC, rcFocus, rcItem, drawFocus );
739759
740760 if ( drawFocus ) {
741- pdc->DrawFocusRect( &rcFocus );
761+ pCDestinationDeviceContext->DrawFocusRect( &rcFocus );
742762 }
743763
744764 }
Afficher sur ancien navigateur de dépôt.