forked from meitinger/windirstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathownerdrawnlistcontrol.h
146 lines (125 loc) · 5.42 KB
/
ownerdrawnlistcontrol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// ownerdrawnlistcontrol.h - Declaration of COwnerDrawnListControl and COwnerDrawnListItem
//
// WinDirStat - Directory Statistics
// Copyright (C) 2003-2004 Bernhard Seifert
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: bseifert@users.sourceforge.net, bseifert@daccord.net
//
// Last modified: $Date: 2004/11/12 22:14:16 $
#pragma once
#include "sortinglistcontrol.h"
class COwnerDrawnListItem;
class COwnerDrawnListControl;
//
// COwnerDrawnListItem. An item in a COwnerDrawnListControl.
// Some columns (subitems) may be owner drawn (DrawSubitem() returns true),
// COwnerDrawnListControl draws the texts (GetText()) of all others.
// DrawLabel() draws a standard label (width image, text, selection and focus rect)
//
class COwnerDrawnListItem: public CSortingListItem
{
public:
COwnerDrawnListItem();
virtual ~COwnerDrawnListItem();
// This text is drawn, if DrawSubitem returns false
virtual CString GetText(int subitem) const = 0;
// This color is used for the current item
virtual COLORREF GetItemTextColor() const { return GetSysColor(COLOR_WINDOWTEXT); }
// Returnvalue is true, if the item draws itself.
// width != NULL -> only determine width, do not draw.
// If focus rectangle shall not begin leftmost, set *focusLeft
// to the left edge of the desired focus rectangle.
virtual bool DrawSubitem(int subitem, CDC *pdc, CRect rc, UINT state, int *width, int *focusLeft) const =0;
virtual void DrawAdditionalState(CDC * /*pdc*/, const CRect& /*rcLabel*/) const {}
void DrawSelection(COwnerDrawnListControl *list, CDC *pdc, CRect rc, UINT state) const;
protected:
void DrawLabel(COwnerDrawnListControl *list, CImageList *il, CDC *pdc, CRect& rc, UINT state, int *width, int *focusLeft, bool indent = true) const;
void DrawPercentage(CDC *pdc, CRect rc, double fraction, COLORREF color) const;
};
//
// COwnerDrawnListControl. Must be report view. Deals with COwnerDrawnListItems.
// Can have a grid or not (own implementation, don't set LVS_EX_GRIDLINES). Flicker-free.
//
class COwnerDrawnListControl: public CSortingListControl
{
DECLARE_DYNAMIC(COwnerDrawnListControl)
public:
COwnerDrawnListControl(LPCTSTR name, int rowHeight);
virtual ~COwnerDrawnListControl();
void OnColumnsInserted();
virtual void SysColorChanged();
int GetRowHeight();
void ShowGrid(bool show);
void ShowStripes(bool show);
void ShowFullRowSelection(bool show);
bool IsFullRowSelection();
COLORREF GetWindowColor();
COLORREF GetStripeColor();
COLORREF GetNonFocusHighlightColor();
COLORREF GetNonFocusHighlightTextColor();
COLORREF GetHighlightColor();
COLORREF GetHighlightTextColor();
bool IsItemStripeColor(int i);
bool IsItemStripeColor(const COwnerDrawnListItem *item);
COLORREF GetItemBackgroundColor(int i);
COLORREF GetItemBackgroundColor(const COwnerDrawnListItem *item);
COLORREF GetItemSelectionBackgroundColor(int i);
COLORREF GetItemSelectionBackgroundColor(const COwnerDrawnListItem *item);
COLORREF GetItemSelectionTextColor(int i);
COwnerDrawnListItem *GetItem(int i);
int FindListItem(const COwnerDrawnListItem *item);
int GetTextXMargin();
int GetGeneralLeftIndent();
void AdjustColumnWidth(int col);
CRect GetWholeSubitemRect(int item, int subitem);
bool HasFocus();
bool IsShowSelectionAlways();
protected:
void InitializeColors();
virtual void DrawItem(LPDRAWITEMSTRUCT pdis);
int GetSubItemWidth(COwnerDrawnListItem *item, int subitem);
bool IsColumnRightAligned(int col);
int m_rowHeight; // Height of an item
bool m_showGrid; // Whether to draw a grid
bool m_showStripes; // Whether to show stripes
bool m_showFullRowSelection; // Whether to draw full row selection
int m_yFirstItem; // Top of a first list item
COLORREF m_windowColor; // The default background color if !m_showStripes
COLORREF m_stripeColor; // The stripe color, used for every other item if m_showStripes
DECLARE_MESSAGE_MAP()
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnHdnDividerdblclick(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
};
// $Log: ownerdrawnlistcontrol.h,v $
// Revision 1.9 2004/11/12 22:14:16 bseifert
// Eliminated CLR_NONE. Minor corrections.
//
// Revision 1.8 2004/11/12 00:47:42 assarbad
// - Fixed the code for coloring of compressed/encrypted items. Now the coloring spans the full row!
//
// Revision 1.7 2004/11/08 00:46:26 assarbad
// - Added feature to distinguish compressed and encrypted files/folders by color as in the Windows 2000/XP explorer.
// Same rules apply. (Green = encrypted / Blue = compressed)
//
// Revision 1.6 2004/11/07 23:28:14 assarbad
// - Partial implementation for coloring of compressed/encrypted files
//
// Revision 1.5 2004/11/05 16:53:07 assarbad
// Added Date and History tag where appropriate.
//