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 #ifndef INCLUDED_VCL_TREELISTENTRY_HXX
21 #define INCLUDED_VCL_TREELISTENTRY_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <tools/solar.h>
25 #include <tools/color.hxx>
26 #include <vcl/treelistbox.hxx>
27 #include <vcl/treelistentries.hxx>
28 #include <o3tl/typed_flags_set.hxx>
29 
30 #include <boost/optional.hpp>
31 #include <vector>
32 #include <memory>
33 
34 // flags related to the model
35 enum class SvTLEntryFlags
36 {
37  NONE = 0x0000,
38  CHILDREN_ON_DEMAND = 0x0001,
39  DISABLE_DROP = 0x0002,
40  // is set if RequestingChildren has not set any children
41  NO_NODEBMP = 0x0004,
42  // entry had or has children
43  HAD_CHILDREN = 0x0010,
44  SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
45 };
46 namespace o3tl
47 {
48  template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x8017> {};
49 }
50 
52 {
53  friend class SvTreeList;
54  friend class SvListView;
55  friend class SvTreeListBox;
56 
57  typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
58 
63  ItemsType m_Items;
64  void* pUserData;
68 
69 private:
70  void ClearChildren();
71  void SetListPositions();
72  void InvalidateChildrensListPositions();
73 
74  SvTreeListEntry(const SvTreeListEntry& r) = delete;
75  void operator=(SvTreeListEntry const&) = delete;
76 
77 public:
78  static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
79 
81  virtual ~SvTreeListEntry();
82 
83  bool HasChildren() const;
84  bool HasChildListPos() const;
85  sal_uLong GetChildListPos() const;
86 
87  SvTreeListEntries& GetChildEntries() { return m_Children; }
88  const SvTreeListEntries& GetChildEntries() const { return m_Children; }
89 
90  void Clone(SvTreeListEntry* pSource);
91 
92  size_t ItemCount() const;
93 
94  // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
95  // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
96  // FOR THE ITEM!
97  void AddItem(std::unique_ptr<SvLBoxItem> pItem);
98  void ReplaceItem(std::unique_ptr<SvLBoxItem> pNewItem, size_t nPos);
99  const SvLBoxItem& GetItem( size_t nPos ) const;
100  SvLBoxItem& GetItem( size_t nPos );
101  const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const;
102  SvLBoxItem* GetFirstItem(SvLBoxItemType eType);
103  size_t GetPos( const SvLBoxItem* pItem ) const;
104  void* GetUserData() const { return pUserData;}
105  void SetUserData( void* pPtr );
106  void EnableChildrenOnDemand( bool bEnable=true );
107  bool HasChildrenOnDemand() const;
108 
109  SvTLEntryFlags GetFlags() const { return nEntryFlags;}
110  void SetFlags( SvTLEntryFlags nFlags );
111 
112  void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
113  const Color& GetBackColor() const { return maBackColor; }
114 
115  void SetTextColor( boost::optional<Color> xColor ) { mxTextColor = xColor; }
116  boost::optional<Color> const & GetTextColor() const { return mxTextColor; }
117 
118  SvTreeListEntry* GetParent() const { return pParent; }
119 
120  SvTreeListEntry* NextSibling() const;
121  SvTreeListEntry* PrevSibling() const;
122  SvTreeListEntry* LastSibling() const;
123 };
124 
125 #endif
126 
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define ITEM_NOT_FOUND
const Color & GetBackColor() const
void SetTextColor(boost::optional< Color > xColor)
std::vector< std::unique_ptr< SvLBoxItem > > ItemsType
SvTLEntryFlags GetFlags() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
SvLBoxItem * GetItem(SvTreeListEntry *, long nX, SvLBoxTab **ppTab)
SvTLEntryFlags
SvLBoxItemType
SvTreeListEntry * GetParent() const
SvTreeListEntries m_Children
void SetBackColor(const Color &rColor)
boost::optional< Color > mxTextColor
boost::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
SvTLEntryFlags nEntryFlags
SvTreeListEntries & GetChildEntries()
const SvTreeListEntries & GetChildEntries() const
sal_uLong nListPos
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
SvTreeListEntry * pParent
std::vector< std::unique_ptr< SvTreeListEntry > > SvTreeListEntries