OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
listviewctrl.h
Go to the documentation of this file.
1//
2/// \file
3/// Definition of TListViewCtrl class
4//
5// Part of OWLNext - the next generation Object Windows Library
6// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
7// Copyright © 2011 Vidar Hasfjord
8//
9// For more information, including license details, see
10// http://owlnext.sourceforge.net
11//
12
13#if !defined(OWL_LISTVIEWCTRL_H)
14#define OWL_LISTVIEWCTRL_H
15
16#if defined(BI_HAS_PRAGMA_ONCE)
17# pragma once
18#endif
19
20#include <owl/private/defs.h>
21#include <owl/defs.h>
22#include <owl/commctrl.h>
23#include <vector>
24
25namespace owl {
26
27#include <owl/preclass.h>
28
29/// \addtogroup commctrl
30/// @{
31
32class _OWLCLASS TListViewCtrl;
33
34//
35/// Encapsulates structure LVFINDINFO, used to find an item in a \link TListViewCtrl \endlink.
36//
37/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774745.aspx
38//
40 : public LVFINDINFO
41{
42public:
43
44 //
45 /// \name Constructors
46 /// @{
47
49 TLvFindInfo(const LVFINDINFO& info);
50
51 /// @}
52 /// \name Manipulators
53 /// @{
54
55 auto SetString(const tstring& text) -> void;
56 auto SetSubstring(const tstring& text) -> void;
57 auto SetPartial(const tstring& text) -> void;
58 auto SetWrap(bool wrap = true) -> void;
59 auto SetData(LPARAM param) -> void;
60
61 /// @}
62
63protected:
64 //
65 /// String used for searching.
66 //
68
69}; // class TLvFindInfo
70
71//
72/// Encapsulates structure LVHITTESTINFO, used to contain information about a hit test in a \link TListViewCtrl \endlink.
73//
74/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774754.aspx
75//
77 : public LVHITTESTINFO
78{
79public:
80
81 //
82 /// \name Constructors
83 /// @{
84
85 //
86 /// Constructs with a zero point for the hit test.
87 //
89 { Init(); }
90
91 //
92 /// Constructs with a specified point for the hit test.
93 //
94 /// @param[in] p is the point to use.
95 //
96 explicit TLvHitTestInfo(const TPoint& p)
97 { Init(); SetPoint(p); }
98
99 //
100 /// Constructs a copy of another class instance.
101 //
102 /// @param[in] info is the class instance to copy.
103 //
104 explicit TLvHitTestInfo(const LVHITTESTINFO& info)
105 { *static_cast<LVHITTESTINFO*>(this) = info; }
106
107 /// @}
108 /// \name Accessors
109 /// @{
110
111 //
112 /// Retrieves the hit item's index.
113 //
114 /// \return the item index.
115 //
116 auto GetIndex() -> int
117 { return iItem; }
118
119 //
120 /// Retrieves the subitem index for the hit item.
121 //
122 /// \return the subitem index.
123 //
124 auto GetSubItem() -> int
125 { return iSubItem; }
126
127 //
128 /// Retrieves the group index for the hit item.
129 //
130 /// \return the group index.
131 //
132 auto GetGroup() -> int
133 { return iGroup; }
134
135 //
136 /// Retrieves the flags for the hit item.
137 //
138 /// \return the flags.
139 //
140 auto GetFlags() -> uint
141 { return flags; }
142
143 /// @}
144 /// \name Manipulators
145 /// @{
146
147 //
148 /// Sets a point for the hit test.
149 //
150 /// @param[in] p is the point to use.
151 //
152 /// \return none.
153 //
154 auto SetPoint(const TPoint& p) -> void
155 { pt.x = p.x; pt.y = p.y; }
156
157 /// @}
158
159protected:
160
161 void Init()
162 {
163 pt = POINT{0, 0};
164 flags = 0;
165 iItem = iSubItem = iGroup = -1;
166 }
167
168}; // class TLvHitTestInfo
169
170//
171/// Encapsulates structure LVITEM, used to describe an item in a \link TListViewCtrl \endlink.
172//
173/// Contains information about the item's icon, label, state and application-defined value.
174/// This class is a thin encapsulation used to pass or retrieve item attributes.
175/// The class manages an internal text buffer so that the user is freed from manual text
176/// buffer management.
177//
178/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774760.aspx
179//
181 : public LVITEM
182{
183public:
184
185 //
186 /// TListState is used to describe the state of an item.
187 //
189 {
190 Unspecified = 0, ///< Unspecified state
191 Focus = LVIS_FOCUSED, ///< Only one item has focus
192 Selected = LVIS_SELECTED, ///< Marked as selected
193 Cut = LVIS_CUT, ///< Marked for cut & paste
194 DropHilited = LVIS_DROPHILITED, ///< Marked as drop target
195 Activating = LVIS_ACTIVATING, ///< (Ver 4.71) The item is being activated in an LVN_ITEMACTIVATE notification.
196 OverlayMask = LVIS_OVERLAYMASK, ///< Retrieve one-based overlay image index
197 StateImageMask = LVIS_STATEIMAGEMASK, ///< Retrieve one-based state image index
198 };
199
200 //
201 /// Flags for setting the initialisation mask.
202 /// \sa TLvItem::TLvItem, LVITEM::mask, http://msdn.microsoft.com/en-us/library/windows/desktop/bb774760.aspx
203 //
205 {
206 lvifAll = 0xFFFFFFFF
207 };
208
209 //
210 /// \name Constructors
211 /// @{
212
213 explicit TLvItem(uint mask_ = lvifAll, bool allocTextBuffer = true, int bufferSize = 1000);
214 explicit TLvItem(const tstring& text, int subitemIndex = 0);
215 TLvItem(const TListViewCtrl& ctl, int index, int subitemIndex, uint mask_ = lvifAll, int bufferSize = 1000);
216 TLvItem(const LVITEM& item);
217 TLvItem(const TLvItem& item);
218
219 /// @}
220 /// \name Overload operations
221 /// @{
222
223 auto operator =(const LVITEM& item) -> TLvItem&;
224 auto operator =(const TLvItem& item) -> TLvItem&;
225
226 /// @}
227 /// \name Text operations
228 /// @{
229
230 auto GetText() const -> LPCTSTR;
231 auto GetText(LPTSTR buffer, size_t bufferSize) const -> void;
232 auto SetTextBuffer(LPTSTR buffer, int bufferSize) -> void;
233 auto SetText(const tstring& text) -> void;
234
235 /// @}
236 /// \name Index is the 0-based "row"
237 /// @{
238
239 auto GetIndex() const -> int;
240 auto SetIndex(int index) -> void;
241
242 /// @}
243 /// \name Column number
244 /// @{
245
246 auto GetSubItem() const -> int;
247 auto SetSubItem(int subitemIndex) -> void;
248
249 /// @}
250 /// \name Extra data
251 /// @{
252
253 auto GetItemData() const -> LPARAM;
254 auto SetItemData(LPARAM param) -> void;
255
256 /// @}
257 /// \name ImageList index
258 /// @{
259
260 auto GetImageIndex() const -> int;
261 auto SetImageIndex(int image) -> void;
262
263 /// @}
264 /// \name Item state
265 /// @{
266
267 auto GetState() const -> int;
268 auto SetState(TListState state) -> void;
269
270 /// @}
271 /// \name ImageList index for the state image
272 /// @{
273
274 auto GetStateImage() const -> int;
275 auto SetStateImage(int stateIndex) -> void;
276
277 /// @}
278 /// \name Set/Get indent (Version 4.70)
279 /// @{
280
281 auto GetIndent() const -> int;
282 auto SetIndent(int indent) -> void;
283
284 /// @}
285
287
288 typedef std::vector<tchar> TBuffer;
289 TBuffer Buffer;
290
291 void Init();
292
293}; // class TLvItem
294
295//
296/// Encapsulates structure LVCOLUMN, used to pass or retrieve column attributes in a \link TListViewCtrl \endlink.
297//
298/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774743.aspx
299//
301 : public LVCOLUMN
302{
303public:
304
305 //
306 /// TFormat is used to describe the alignment of a column in a list window.
307 //
309 {
310 Unspecified = 0, ///< Unspecified
311 Left = LVCFMT_LEFT, ///< Left aligned
312 Center = LVCFMT_CENTER, ///< Centered
313 Right = LVCFMT_RIGHT, ///< Right aligned
314 };
315
316 //
317 /// Flags for setting the initialisation mask.
318 /// \sa TLvColumn::TLvColumn, LVCOLUMN::mask, https://msdn.microsoft.com/en-us/library/windows/desktop/bb774743.aspx
319 //
321 {
322 lvcfAll = 0xFFFFFFFF
323 };
324
325 //
326 /// \name Constructors
327 /// @{
328
329 explicit TLvColumn(uint mask_ = lvcfAll, int subitemIndex = 0, int bufferSize = 1000);
330 TLvColumn(const tstring& text, int width, TFormat how = Left, int subitemIndex = 0);
331 TLvColumn(const TListViewCtrl& ctl, int index, uint mask_ = lvcfAll, int subitemIndex = 0, int bufferSize = 1000);
332 TLvColumn(const LVCOLUMN& column);
333 TLvColumn(const TLvColumn& column);
334
335 /// @}
336 /// \name Overload operations
337 /// @{
338
339 auto operator =(const LVCOLUMN& column) -> TLvColumn&;
340 auto operator =(const TLvColumn& column) -> TLvColumn&;
341
342 /// @}
343 /// \name Information changing operations
344 /// @{
345
346 auto SetTextBuffer(LPTSTR buffer, int bufferSize) -> void;
347 auto SetText(const tstring& text) -> void;
348 auto SetFormat(TFormat how) -> void;
349 auto SetWidth(int width, const tstring& text = tstring()) -> void;
350 auto SetSubItem(int subitemIndex) -> void;
351
352 /// @}
353 /// \name Information retrieval operations
354 /// @{
355
356 auto GetText() const -> LPCTSTR;
357 auto GetFormat() const -> TFormat;
358 auto GetWidth() const -> int;
359 auto GetSubItem() const -> int;
360
361 /// @}
362 /// \name New IE 3.0 data
363 /// @{
364
365 auto GetImage() const -> int;
366 auto SetImage(int image) -> void;
367 auto GetOrder() const -> int;
368 auto SetOrder(int order) -> void;
369
370 /// @}
371
373
374 //
375 /// Character buffer to hold text.
376 //
377 typedef std::vector<tchar> TBuffer;
378 TBuffer Buffer;
379
380 auto Init() -> void;
381
382}; // class TLvColumn
383
384//
385/// Encapsulates structure LVTILEVIEWINFO, used to pass or retrieve tile view information in a \link TListViewCtrl \endlink.
386//
387/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774768.aspx
388//
390 : public LVTILEVIEWINFO
391{
392public:
393
394 //
395 /// TTileSize describes the sizing of tiles in a list view control.
396 //
398 {
399 FixedWidth = LVTVIF_FIXEDWIDTH, ///< Applies a fixed width to the tiles
400 FixedHeight = LVTVIF_FIXEDHEIGHT, ///< Applies a fixed height to the tiles
401 FixedSize = LVTVIF_FIXEDSIZE, ///< Applies a fixed height and width to the tiles
402 };
403
404 //
405 /// \name Constructors
406 /// @{
407
412 TLvTileViewInfo(const TSize& size, TTileSize fixedSize);
413 TLvTileViewInfo(const TSize& size, TTileSize fixedSize, int lines);
414 TLvTileViewInfo(const TSize& size, TTileSize fixedSize, const TRect& labelMargin);
415 TLvTileViewInfo(const TSize& size, TTileSize fixedSize, int lines, const TRect& labelMargin);
416
417 /// @}
418 /// \name Information changing operations
419 /// @{
420
421 auto SetTileSize(const TSize& size) -> void;
422 auto SetSizeAutomatic() -> void;
423 auto SetSizeFixed(const TSize& size, TTileSize fixedSize) -> void;
424 auto SetMaxTextLines(int lines) -> void;
425 auto RemoveMaxTextLines() -> void;
426 auto SetLabelMargin(const TRect& labelMargin) -> void;
427 auto RemoveLabelMargin() -> void;
428
429 /// @}
430 /// \name Query operations
431 /// @{
432
433 //
434 /// Checks if tile view size is automatic.
435 //
436 /// \return true if tile view size is automatic.
437 //
438 auto IsSizeAutomatic() const -> bool
439 { return dwFlags == LVTVIF_AUTOSIZE; }
440
441 //
442 /// Checks if tile view size is fixed-width.
443 //
444 /// \return true if tile view size is fixed-width.
445 //
446 auto IsSizeFixedWidth() const -> bool
447 { return dwFlags == static_cast<DWORD>(FixedWidth); }
448
449 //
450 /// Checks if tile view size is fixed-height.
451 //
452 /// \return true if tile view size is fixed-height.
453 //
454 auto IsSizeFixedHeight() const -> bool
455 { return dwFlags == static_cast<DWORD>(FixedHeight); }
456
457 //
458 /// Checks if tile view size is fixed-height and fixed-width.
459 //
460 /// \return true if tile view size is fixed-height and fixed-width.
461 //
462 auto IsSizeFixed() const -> bool
463 { return dwFlags == static_cast<DWORD>(FixedSize); }
464
465 /// @}
466 /// \name Information retrieval operations
467 /// @{
468
469 //
470 /// Retrieves the specified coordinates of the label margin.
471 //
472 /// \return the coordinates.
473 //
474 auto GetLabelMargin() const -> TRect
475 { return rcLabelMargin; }
476
477 //
478 /// Retrieves the specified tile size.
479 //
480 /// \return the tile size.
481 //
482 auto GetTileSize() const -> TSize
483 { return sizeTile; }
484
485 //
486 /// Retrieves the specified maximum number of text lines in each item label.
487 //
488 /// \returns the number of lines.
489 //
490 auto GetMaxTextLines() const -> int
491 { return cLines; }
492
493 /// @}
494
495}; // class TLvTileViewInfo
496
497//
498/// Encapsulates structure LVFOOTERINFO, used to pass or retrieve footer information in a \link TListViewCtrl \endlink.
499//
500/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774748.aspx
501//
503 : public LVFOOTERINFO
504{
505public:
506
507 //
508 /// \name Constructors
509 /// @{
510
511 //
512 /// Constructs with zero values.
513 //
515 { memset(static_cast<LVFOOTERINFO*>(this), 0, sizeof(LVFOOTERINFO)); }
516
517 //
518 /// Constructs a copy of another class instance.
519 //
520 /// @param[in] info is the class instance to copy.
521 //
522 TLvFooterInfo(const LVFOOTERINFO& info)
523 { *static_cast<LVFOOTERINFO*>(this) = info; }
524
525 /// @}
526
527 // TODO!! More elaborate methods
528
529}; // class TLvFooterInfo
530
531//
532/// Encapsulates structure LVFOOTERITEM, used to pass or retrieve footer item information in a \link TListViewCtrl \endlink.
533//
534/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774750.aspx
535//
537 : public LVFOOTERITEM
538{
539public:
540
541 //
542 /// TState is used to describe the state of a footer item in a list window control.
543 //
545 {
546 Focus = LVFIS_FOCUSED, ///< Focus state
547 All = LVFIS_FOCUSED, ///< All states
548 };
549
550 //
551 /// \name Constructors
552 /// @{
553
554 //
555 /// Constructs with zero values.
556 //
558 { memset(static_cast<LVFOOTERITEM*>(this), 0, sizeof(LVFOOTERITEM)); }
559
560 //
561 /// Constructs a copy of another class instance.
562 //
563 /// @param[in] item is the class instance to copy.
564 //
565 TLvFooterItem(const LVFOOTERITEM& item)
566 { *static_cast<LVFOOTERITEM*>(this) = item; }
567
568 /// @}
569
570 // TODO!! More elaborate methods
571
572}; // class TLvFooterItem
573
574//
575/// Encapsulates the ListView control, a window that displays a collection of items, each item
576/// consisting of an icon and a label.
577///
578/// List view controls provide several ways of arranging items and displaying individual items.
579/// For example, additional information about each item can be displayed in columns to the right of
580/// the icon and label.
581//
582/// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb774737.aspx
583//
585 : public TControl
586{
587public:
588
589 //
590 /// TArrangeCode is used to describe how to arrange the items in a list window control.
591 //
593 {
594 Default = LVA_DEFAULT, ///< Use default for control style
595 Left = LVA_ALIGNLEFT, ///< Align items to the left edge
596 Top = LVA_ALIGNTOP, ///< Align items to the top edge
597 SnapToGrid = LVA_SNAPTOGRID, ///< Snap icons to nearest grid position
598 };
599
600 //
601 /// Describes the type of image list for use with the list window control.
602 //
604 {
605 Normal = LVSIL_NORMAL, ///< Normal image list.
606 Small = LVSIL_SMALL, ///< Small icons for LVS_SMALLICON
607 State = LVSIL_STATE, ///< State image
608 };
609
610 //
611 /// Describes the type of rectangle boundaries to retrieve.
612 //
614 {
615 Bounds = LVIR_BOUNDS, ///< Entire boundary (icon and label)
616 Icon = LVIR_ICON, ///< Only the icon
617 Label = LVIR_LABEL, ///< Only the label
618 SelectBounds = LVIR_SELECTBOUNDS, ///< Union of Icon+Label but no colmns
619 };
620
621 //
622 /// Describes the next item to retrieve from the current item.
623 /// Can have only one relational property, but can have multiple search states.
624 //
625 /// \note Flags within the DirectionMask are mutually exclusive.
626 /// Flags within the the StateMask are not mutually exclusive.
627 //
629 {
630 // Relational properties
631
632 Above = LVNI_ABOVE, ///< Directly above
633 All = LVNI_ALL, ///< By index
634 Below = LVNI_BELOW, ///< Directly below
635 Previous = LVNI_PREVIOUS, ///< Ordered before
636 ToLeft = LVNI_TOLEFT, ///< Left of
637 ToRight = LVNI_TORIGHT, ///< Right of
638 DirectionMask = LVNI_DIRECTIONMASK, ///< Directional flag mask combining Above, Below, ToLeft, and ToRight
639
640 // Search states
641
642 Cut = LVNI_CUT, ///< Marked for cut & paste
643 DropHilited = LVNI_DROPHILITED, ///< Marked for drop target
644 Focused = LVNI_FOCUSED, ///< Marked as having focus
645 Selected = LVNI_SELECTED, ///< Marked as selected
646 StateMask = LVNI_STATEMASK, ///< State flag mask combining Cut, DropHilited, Focused, and Selected
647
648 // Appearance properties
649
650 VisibleOrder = LVNI_VISIBLEORDER, ///< Search the visible order
651 VisibleOnly = LVNI_VISIBLEONLY, ///< Search the visible items
652 SameGroupOnly = LVNI_SAMEGROUPONLY, ///< Search the current group
653 };
654
655 //
656 /// Describes the type of views.
657 //
659 {
660 Details = LV_VIEW_DETAILS, ///< Detailed view
661 NormalIcon = LV_VIEW_ICON, ///< Icon view
662 List = LV_VIEW_LIST, ///< List view
663 SmallIcon = LV_VIEW_SMALLICON, ///< Small icon view
664 Tile = LV_VIEW_TILE ///< Tile view
665 };
666
667 //
668 /// Describes the behavior for the control when setting the item count.
669 //
671 {
672 Unspecified = 0, ///< No behavior specified.
673 NoInvalidateAll = LVSICF_NOINVALIDATEALL, ///< Do not repaint unless affected items are currently in view.
674 NoScroll = LVSICF_NOSCROLL, ///< Do not change the scroll position.
675 };
676
677 //
678 /// Pure virtual base class for comparing sort items.
679 ///
680 /// \note Application must implement this class to compare two items used for sorting purposes.
681 //
682 /// \sa SortItems
683 /// \sa SortItemsEx
684 //
686 {
687 public:
688 //
689 /// Performs a comparison of two items.
690 //
691 /// @param[in] item1 is either:
692 /// - The value of TLvItem::GetItemData for the first item to be compared when TListViewCtrl::SortItems is used.
693 /// - The index of the first item to be compared when TListViewCtrl::SortItemsEx is used.
694 /// @param[in] item2 is either:
695 /// - The value of TLvItem::GetItemData for the second item to be compared when TListViewCtrl::SortItems is used.
696 /// - The index of the second item to be compared when TListViewCtrl::SortItemsEx is used.
697 /// @param[in] lParam is an application-defined value that will be passed to the comparison function.
698 //
699 /// \return the result of the comparison:
700 /// - < 0 if item1 < item2
701 /// - = 0 if item1 == item2
702 /// - > 0 if item1 > item2
703 //
704 virtual int Compare(LPARAM item1, LPARAM item2, LPARAM lParam) const = 0;
705 };
706
707 //
708 /// \name Constructors
709 /// @{
710
711 TListViewCtrl(TWindow* parent, int id, int x, int y, int w, int h, TModule* module = 0);
712 TListViewCtrl(TWindow* parent, int resourceId, TModule* module = 0);
713
714 /// @}
715 /// \name Column manipulation
716 /// @{
717
718 auto InsertColumn(int colNum, const TLvColumn& column) -> int;
719 auto DeleteColumn(int colNum) -> bool;
720 auto GetColumn(int colNum, TLvColumn& column) const -> bool;
721 auto GetColumnWidth(int colNum) const -> int;
722 auto SetColumn(int colNum, const TLvColumn& column) -> bool;
723 auto SetColumnWidth(int colNum, int width) -> bool;
724
725 /// @}
726 /// \name Item accessors and mutators
727 /// @{
728
729 auto GetItem(TLvItem& item, int index = -1, int subitemIndex = -1) const -> bool;
730 auto GetItem(int index = -1, int subitemIndex = -1) const -> TLvItem;
731 auto SetItem(const TLvItem& item, int index = -1, int subitemIndex = -1) -> bool;
732 auto GetNextItem(int index, uint flags = TNextItemCode::All) const -> int;
733 auto GetItemCount() const -> int;
734 auto SetItemCount(int numItems, TSetItemCountBehavior behavior = Unspecified) -> bool;
735 auto GetItemPosition(int index, TPoint& pt) const -> bool;
736 auto GetItemPosition(int index) const -> TPoint;
737 auto SetItemPosition(int index, const TPoint& pt) -> bool;
738 auto SetItemPosition32(int index, const TPoint& pt) -> void;
739 auto GetItemRect(int index, TRect& rect, TItemRectType type) const -> bool;
740 auto GetItemRect(int index, TItemRectType type) const -> TRect;
741 auto GetItemState(int index, uint mask) const -> TLvItem::TListState;
742 auto SetItemState(int index, TLvItem::TListState state, uint mask) -> bool;
743 auto GetItemText(int index, TLvItem& item) const -> int;
744 auto GetItemText(int index, int subitemIndex, LPTSTR buffer, int bufferSize) const -> int;
745 auto GetItemText(int index, int subitemIndex = 0) const -> tstring;
746 auto SetItemText(int index, const TLvItem& item) -> bool;
747 auto SetItemText(int index, int subitemIndex, LPCTSTR text) -> bool;
748 auto SetItemText(int index, int subitemIndex, const tstring& text) -> bool;
749
750 /// @}
751 /// \name Item insertion and deletion
752 /// @{
753
754 auto AddItem(const TLvItem& item) -> int;
755 auto AddItem(const tstring& text) -> int;
756 auto InsertItem(const TLvItem& item, int index = -1) -> int;
757 auto InsertItem(const tstring& text, int index = 0) -> int;
758 auto DeleteItem(int index) -> bool;
759 auto DeleteAllItems() -> bool;
760
761 /// @}
762 /// \name Find/Sort/Arrange
763 /// @{
764
765 auto FindItem(int index, const TLvFindInfo& findInfo) const -> int;
766 auto SortItems(const TCompareFunc& Comparator, LPARAM lParam = 0) -> bool;
767 auto SortItemsEx(const TCompareFunc& Comparator, LPARAM lParam = 0) -> bool;
768 auto Arrange(TArrangeCode code) -> bool;
769
770 /// @}
771 /// \name Item selection
772 /// @{
773
774 auto IsSelected(int index) const -> bool;
775 auto GetNextSelIndex(int index = -1) const -> int;
776 auto GetSelIndex() const -> int;
777 auto GetSelCount(void) const -> int;
778 auto GetSelIndexes(int* indexes, int maxCount) const -> int;
779 auto GetSelString(tchar* str, int maxChars, int subitemIndex = 0) const -> bool;
780 auto GetSelString(int subitemIndex = 0) const -> tstring;
781 auto GetSelStrings(tchar** strs, int maxCount, int maxChars, int subitemIndex = 0) const -> int;
782 auto SetSel(int index, bool select) -> bool;
783 auto SetSelIndexes(int* indexes, int numSelections, bool select) -> bool;
784 auto SetSelItemRange(bool select, int first, int last) -> bool;
785 auto GetSelectedColumn() const -> int;
786 auto SetSelectedColumn(int colNum) -> void;
787
788 /// @}
789 /// \name Image list manipulation
790 /// @{
791
792 auto CreateDragImage(int index, TPoint* upLeft) -> HIMAGELIST;
793 auto GetImageList(TImageListType type) const -> HIMAGELIST;
794 auto SetImageList(HIMAGELIST list, TImageListType type) -> HIMAGELIST;
795
796 /// @}
797 /// \name Color accessors and manipulation
798 /// @{
799
800 auto GetBkColor() const -> TColor;
801 auto SetBkColor(const TColor& c) -> bool;
802 auto GetTextBkColor() const -> TColor;
803 auto SetTextBkColor(const TColor& c) -> bool;
804 auto GetTextColor() const -> TColor;
805 auto SetTextColor(const TColor& c) -> bool;
806
807 /// @}
808 /// \name Callbacks
809 /// @{
810
811 auto GetCallBackMask() const -> TLvItem::TListState;
812 auto SetCallBackMask(TLvItem::TListState mask) -> bool;
813
814 /// @}
815 /// \name Miscellaneous
816 /// @{
817
818 auto GetTopIndex() const -> int;
819 auto EditLabel(int index) -> HWND;
820 auto GetEditControl() const -> HWND;
821 auto CancelEditLabel() -> void;
822 auto Update(int index) -> bool;
823 auto HitTest(TLvHitTestInfo&) const -> int;
824 auto HitTest(const TPoint&) const -> TLvHitTestInfo;
825 auto Scroll(int dx, int dy) -> bool;
826 auto GetOrigin(TPoint& pt) const -> bool;
827 auto GetStringWidth(LPCTSTR text) const -> int;
828 auto GetStringWidth(const tstring& text) const -> int;
829 auto CalculateColumnWidth(LPCTSTR text, int padding = 12) const -> int;
830 auto CalculateColumnWidth(const tstring& text, int padding = 12) const -> int;
831 auto GetViewRect(TRect& rect) const -> bool;
832 auto IsItemVisible(int index) const -> bool;
833 auto EnsureVisible(int index, bool partialOk) -> bool;
834 auto RedrawItems(int startIndex, int endIndex) -> bool;
835 auto GetCountPerPage() const -> int;
836 auto GetISearchString() const -> tstring;
837 auto GetFocusItem() -> int;
838 auto SetFocusItem(int index, bool focused = true) -> bool;
839
840 /// @}
841 /// \name New commctrl messages - version 4.70
842 /// @{
843
844 auto GetApproxRect(int x = -1, int y = -1, int count = -1) const -> TSize;
845
846 //
847 /// TPoint overload for \link GetApproxRect(int, int, int) const \endlink.
848 //
849 auto GetApproxRect(const TPoint& pt, int count = -1) const -> TSize
850 { return GetApproxRect(pt.x, pt.y, count); }
851
852 auto GetColumnOrder(int count, int* array) const -> bool;
853 auto SetColumnOrder(int count, const int* array) -> bool;
854 auto GetExtStyle() const -> uint32;
855 auto SetExtStyle(uint32 mask, uint32 style) -> uint32;
856 auto GetHeaderCtrl() const -> HWND;
857 auto GetHotCursor() const -> HCURSOR;
858 auto SetHotCursor(HCURSOR cur) -> HCURSOR;
859 auto GetHotItem() const -> int;
860 auto SetHotItem(int index) -> int;
861 auto GetSubItemRect(TRect& rect, int subitemIndex = 0, int index = 0, TItemRectType type = Bounds) const -> bool;
862 auto SubItemHitTest(TLvHitTestInfo& info) const -> int;
863 auto SubItemHitTest(const TPoint&) const -> TLvHitTestInfo;
864 auto GetItemSpacing(bool smallIcon) const -> TSize;
865 auto SetIconSpacing(int x, int y) -> TSize;
866
867 //
868 /// TPoint overload for \link SetIconSpacing(int, int) \endlink.
869 //
870 auto SetIconSpacing(const TPoint& pt) -> TSize
871 { return SetIconSpacing(pt.x, pt.y); }
872
873 //
874 /// Resets the icon spacing to the default spacing.
875 //
876 /// \return the previous icon spacing used.
877 //
879 { return SetIconSpacing(-1, -1); }
880
881 /// @}
882 /// \name New commctrl messages - version 4.71
883 /// @{
884
885 auto GetBkImage(TLvBkImage& bkimg) const -> bool;
886 auto SetBkImage(const TLvBkImage& bkimg) -> bool;
887 auto GetHoverTime() const -> uint32;
888 auto SetHoverTime(uint32 tm) -> uint32;
889 auto GetNumOfWorkAreas() const -> uint;
890 auto GetWorkAreas(int count, TRect* areas) const -> void;
891 auto SetWorkAreas(int count, TRect* areas) -> void;
892 auto GetSelectionMark() const -> int;
893 auto SetSelectionMark(int index) -> int;
894
895 /// @}
896 /// \name New commctrl messages - version 6.00
897 /// @{
898
899 auto GetItemIndexRect(int index, int group, int subitemIndex, TRect& rect, TItemRectType type) const -> bool;
900 auto GetNextItemIndex(int index, int group, uint flags = TNextItemCode::All) const -> int;
901 auto SetItemIndexState(const TLvItem& item, int index, int group) -> bool;
902 auto GetEmptyText() const -> tstring;
903 auto GetFooterInfo(TLvFooterInfo& info) const -> bool;
904 auto GetFooterItems() const -> int;
905 auto GetFooterItem(int index, TLvFooterItem& item) const -> bool;
906 auto GetFooterItemText(int index) const -> std::wstring;
907 auto GetFooterItemState(int index, TLvFooterItem::TState mask = TLvFooterItem::All) const -> TLvFooterItem::TState;
908 auto GetFooterItemRect(int index, TRect& rect) const -> bool;
909 auto GetFooterItemRect(int index) const -> TRect;
910 auto GetFooterRect(TRect& rect) const -> bool;
911 auto GetFooterRect() const -> TRect;
912 auto GetGroupInfo(int groupId, uint mask = 0xFFFFFFFF) -> LVGROUP;
913
914 /// @}
915 /// \name Unicode setting messages
916 /// @{
917
918 auto GetUnicodeFormat() const -> bool;
919 auto SetUnicodeFormat(bool useUnicode = true) -> bool;
920
921 /// @}
922 /// \name Unique item identifier messages
923 /// @{
924
925 //
926 /// Defines the type of a unique identifier for an item.
927 //
929
930 auto MapIndexToId(int index) const -> TItemId;
931 auto MapIdToIndex(TItemId id) const -> int;
932
933 /// @}
934 /// \name Tooltip messages
935 /// @{
936
937 auto GetToolTips() const -> HWND;
938 auto SetToolTips(THandle handle) -> HWND;
939 auto SetInfoTip(LPCWSTR text, int index, int subitemIndex = 0) -> bool;
940 auto SetInfoTip(LPCSTR text, int index, int subitemIndex = 0) -> bool;
941 auto SetInfoTip(const tstring& text, int index, int subitemIndex = 0) -> bool;
942
943 /// @}
944 /// \name View type messages
945 /// @{
946
947 auto GetView() const -> TViewType;
948 auto SetView(TViewType viewType) -> bool;
949
950 /// @}
951 /// \name Tile view messages
952 /// @{
953
954 auto GetTileInfo(PLVTILEINFO lvTileInfo) const -> void;
955 auto GetTileInfo(LVTILEINFO& lvTileInfo) const -> void;
956 auto SetTileInfo(PLVTILEINFO lvTileInfo) -> bool;
957 auto SetTileInfo(LVTILEINFO& lvTileInfo) -> bool;
958 auto GetTileViewInfo(TLvTileViewInfo& tileViewInfo) const -> void;
959 auto SetTileViewInfo(const TLvTileViewInfo& tileViewInfo) -> bool;
960
961 /// @}
962 /// \name Border outline color messages
963 /// @{
964
965 auto GetOutlineColor() const -> TColor;
966 auto SetOutlineColor(const TColor& color) -> TColor;
967
968 /// @}
969
970#if defined(OWL5_COMPAT)
971
972 auto GetOrigin(POINT* pt) const -> bool;
973 auto GetViewRect(RECT* rect) const -> bool;
974 auto GetColumn(int index, LVCOLUMN* column) const -> bool;
975 auto GetItemPosition(int index, POINT* pt) const -> bool;
976 auto GetItemRect(int index, RECT* rect, TItemRectType type) const -> bool;
977 auto DeleteAnItem(int index) -> bool { return DeleteItem(index); }
978 auto FindItem(int index, const TLvFindInfo* findInfo) const -> int;
979
980#endif
981
982protected:
983
984 virtual auto GetWindowClassName() -> TWindowClassName;
985 using TControl::DeleteItem; // Inject virtual overload (DELETEITEMSTRUCT&), otherwise hidden by DeleteItem(int).
986
987private:
988
990 TListViewCtrl& operator=(const TListViewCtrl&);
991}; // class TListViewCtrl
992
993/// @}
994
995#include <owl/posclass.h>
996
997} // owl namespace
998
999#endif
Class wrapper for management of color values.
Definition color.h:245
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
Pure virtual base class for comparing sort items.
virtual int Compare(LPARAM item1, LPARAM item2, LPARAM lParam) const =0
Performs a comparison of two items.
Encapsulates the ListView control, a window that displays a collection of items, each item consisting...
auto ResetIconSpacing() -> TSize
Resets the icon spacing to the default spacing.
TViewType
Describes the type of views.
TImageListType
Describes the type of image list for use with the list window control.
TSetItemCountBehavior
Describes the behavior for the control when setting the item count.
TArrangeCode
TArrangeCode is used to describe how to arrange the items in a list window control.
TItemRectType
Describes the type of rectangle boundaries to retrieve.
TParam1 TItemId
Defines the type of a unique identifier for an item.
TNextItemCode
Describes the next item to retrieve from the current item.
Encapsulates structure LVCOLUMN, used to pass or retrieve column attributes in a TListViewCtrl.
TMaskFlag
Flags for setting the initialisation mask.
TFormat
TFormat is used to describe the alignment of a column in a list window.
std::vector< tchar > TBuffer
Character buffer to hold text.
Encapsulates structure LVFINDINFO, used to find an item in a TListViewCtrl.
tstring Text
String used for searching.
Encapsulates structure LVHITTESTINFO, used to contain information about a hit test in a TListViewCtrl...
TLvHitTestInfo()
Constructs with a zero point for the hit test.
auto GetGroup() -> int
Retrieves the group index for the hit item.
auto GetFlags() -> uint
Retrieves the flags for the hit item.
TLvHitTestInfo(const LVHITTESTINFO &info)
Constructs a copy of another class instance.
auto GetSubItem() -> int
Retrieves the subitem index for the hit item.
auto GetIndex() -> int
Retrieves the hit item's index.
TLvHitTestInfo(const TPoint &p)
Constructs with a specified point for the hit test.
auto SetPoint(const TPoint &p) -> void
Sets a point for the hit test.
Encapsulates structure LVITEM, used to describe an item in a TListViewCtrl.
std::vector< tchar > TBuffer
TListState
TListState is used to describe the state of an item.
TMaskFlag
Flags for setting the initialisation mask.
Encapsulates structure LVTILEVIEWINFO, used to pass or retrieve tile view information in a TListViewC...
TTileSize
TTileSize describes the sizing of tiles in a list view control.
auto IsSizeFixed() const -> bool
Checks if tile view size is fixed-height and fixed-width.
auto GetLabelMargin() const -> TRect
Retrieves the specified coordinates of the label margin.
auto IsSizeAutomatic() const -> bool
Checks if tile view size is automatic.
auto IsSizeFixedHeight() const -> bool
Checks if tile view size is fixed-height.
auto GetMaxTextLines() const -> int
Retrieves the specified maximum number of text lines in each item label.
auto IsSizeFixedWidth() const -> bool
Checks if tile view size is fixed-width.
auto GetTileSize() const -> TSize
Retrieves the specified tile size.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
Definition of classes for CommonControl encapsulation.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
char tchar
Definition defs.h:77
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338