LibreOffice Module vcl (master)  1
treelistentry.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
25 
26 #include <vcl/dllapi.h>
27 #include <tools/solar.h>
28 #include <tools/color.hxx>
31 #include <o3tl/typed_flags_set.hxx>
32 
33 #include <optional>
34 #include <vector>
35 #include <memory>
36 
37 // flags related to the model
38 enum class SvTLEntryFlags
39 {
40  NONE = 0x0000,
41  CHILDREN_ON_DEMAND = 0x0001,
42  DISABLE_DROP = 0x0002,
43  // is set if RequestingChildren has not set any children
44  NO_NODEBMP = 0x0004,
45  // is set if this is a separator line
46  IS_SEPARATOR = 0x0008,
47  // entry had or has children
48  HAD_CHILDREN = 0x0010,
49  SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
50 };
51 namespace o3tl
52 {
53  template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
54 }
55 
57 {
58  friend class SvTreeList;
59  friend class SvListView;
60  friend class SvTreeListBox;
61 
62  typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
63 
68  sal_uInt32 mnExtraIndent;
69  ItemsType m_Items;
70  void* pUserData;
73  std::optional<Color> mxTextColor;
74 
75 private:
76  void ClearChildren();
77  void SetListPositions();
78  void InvalidateChildrensListPositions();
79 
80  SvTreeListEntry(const SvTreeListEntry& r) = delete;
81  void operator=(SvTreeListEntry const&) = delete;
82 
83 public:
84  static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
85 
87  virtual ~SvTreeListEntry();
88 
89  bool HasChildren() const;
90  bool HasChildListPos() const;
91  sal_uLong GetChildListPos() const;
92 
93  SvTreeListEntries& GetChildEntries() { return m_Children; }
94  const SvTreeListEntries& GetChildEntries() const { return m_Children; }
95 
96  void Clone(SvTreeListEntry* pSource);
97 
98  size_t ItemCount() const;
99 
100  // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
101  // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
102  // FOR THE ITEM!
103  void AddItem(std::unique_ptr<SvLBoxItem> pItem);
104  void ReplaceItem(std::unique_ptr<SvLBoxItem> pNewItem, size_t nPos);
105  const SvLBoxItem& GetItem( size_t nPos ) const;
106  SvLBoxItem& GetItem( size_t nPos );
107  const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const;
108  SvLBoxItem* GetFirstItem(SvLBoxItemType eType);
109  size_t GetPos( const SvLBoxItem* pItem ) const;
110  void* GetUserData() const { return pUserData;}
111  void SetUserData( void* pPtr );
112  void EnableChildrenOnDemand( bool bEnable=true );
113  bool HasChildrenOnDemand() const;
114 
115  SvTLEntryFlags GetFlags() const { return nEntryFlags;}
116  void SetFlags( SvTLEntryFlags nFlags );
117 
118  void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
119  const Color& GetBackColor() const { return maBackColor; }
120 
121  void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
122  std::optional<Color> const & GetTextColor() const { return mxTextColor; }
123 
124  void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
125  sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
126 
127  SvTreeListEntry* NextSibling() const;
128  SvTreeListEntry* PrevSibling() const;
129  SvTreeListEntry* LastSibling() const;
130 };
131 
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Color & GetBackColor() const
std::vector< std::unique_ptr< SvLBoxItem > > ItemsType
SvTLEntryFlags GetFlags() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
SvTLEntryFlags
sal_uInt32 GetExtraIndent() const
SvLBoxItemType
SvTreeListEntries m_Children
void SetBackColor(const Color &rColor)
std::optional< Color > const & GetTextColor() const
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
Control & operator=(const Control &)=delete
void * GetUserData() const
SvLBoxItem * GetItem(SvTreeListEntry *, tools::Long nX, SvLBoxTab **ppTab)
SvTLEntryFlags nEntryFlags
SvTreeListEntries & GetChildEntries()
sal_uInt32 mnExtraIndent
const SvTreeListEntries & GetChildEntries() const
sal_uLong nListPos
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
void SetExtraIndent(sal_uInt32 nExtraIndent)
std::optional< Color > mxTextColor
void SetTextColor(std::optional< Color > xColor)
SvTreeListEntry * pParent
std::vector< std::unique_ptr< SvTreeListEntry > > SvTreeListEntries