tdf#151341 Use lzfse compression instead of bzip2
[LibreOffice.git] / vcl / inc / toolbox.h
blob3dd481de6f01773aeda6cd68178f8b845e0e48df
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_TOOLBOX_H
21 #define INCLUDED_VCL_INC_TOOLBOX_H
23 #include <vcl/toolbox.hxx>
25 #include <optional>
26 #include <vector>
28 #define TB_DROPDOWNARROWWIDTH 11
30 #define TB_MENUBUTTON_SIZE 12
31 #define TB_MENUBUTTON_OFFSET 2
33 namespace vcl { class Window; }
35 struct ImplToolItem
37 VclPtr<vcl::Window> mpWindow; //don't dispose mpWindow - we get copied around
38 bool mbNonInteractiveWindow;
39 void* mpUserData;
40 Image maImage;
41 Degree10 mnImageAngle;
42 bool mbMirrorMode;
43 OUString maText;
44 OUString maQuickHelpText;
45 OUString maHelpText;
46 OUString maCommandStr;
47 OString maHelpId;
48 tools::Rectangle maRect;
49 tools::Rectangle maCalcRect;
50 /// Widget layout may request size; set it as the minimal size (like, the item will always have at least this size).
51 Size maMinimalItemSize;
52 /// The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]
53 Size maItemSize;
54 tools::Long mnSepSize;
55 tools::Long mnDropDownArrowWidth;
56 /// Size of the content (bitmap or text, without dropdown) that we have in the item.
57 Size maContentSize;
58 ToolBoxItemType meType;
59 ToolBoxItemBits mnBits;
60 TriState meState;
61 ToolBoxItemId mnId;
62 bool mbEnabled:1,
63 mbVisible:1,
64 mbEmptyBtn:1,
65 mbShowWindow:1,
66 mbBreak:1,
67 mbVisibleText:1, // indicates if text will definitely be drawn, influences dropdown pos
68 mbExpand:1;
70 ImplToolItem();
71 ImplToolItem( ToolBoxItemId nItemId, Image aImage,
72 ToolBoxItemBits nItemBits );
73 ImplToolItem( ToolBoxItemId nItemId, OUString aTxt,
74 OUString aCommand,
75 ToolBoxItemBits nItemBits );
76 ImplToolItem( ToolBoxItemId nItemId, Image aImage,
77 OUString aTxt,
78 ToolBoxItemBits nItemBits );
80 // returns the size of an item, taking toolbox orientation into account
81 // the default size is the precomputed size for standard items
82 // ie those that are just ordinary buttons (no windows or text etc.)
83 // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons
84 Size GetSize( bool bHorz, bool bCheckMaxWidth, tools::Long maxWidth, const Size& rDefaultSize );
86 // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style
87 void DetermineButtonDrawStyle( ButtonType eButtonType, bool& rbImage, bool& rbText ) const;
89 // returns the rectangle which contains the drop down arrow
90 // or an empty rect if there is none
91 // bHorz denotes the toolbox alignment
92 tools::Rectangle GetDropDownRect( bool bHorz ) const;
94 // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars
95 bool IsClipped() const;
97 // returns sal_True if the toolbar item is currently hidden i.e. they are unchecked in the toolbar Customize menu
98 bool IsItemHidden() const;
100 private:
101 void init(ToolBoxItemId nItemId, ToolBoxItemBits nItemBits, bool bEmptyBtn);
104 namespace vcl
107 struct ToolBoxLayoutData : public ControlLayoutData
109 std::vector< ToolBoxItemId > m_aLineItemIds;
112 } /* namespace vcl */
114 struct ImplToolBoxPrivateData
116 std::optional<vcl::ToolBoxLayoutData> m_pLayoutData;
117 ToolBox::ImplToolItems m_aItems;
119 ImplToolBoxPrivateData();
120 ~ImplToolBoxPrivateData();
122 void ImplClearLayoutData() { m_pLayoutData.reset(); }
124 // called when dropdown items are clicked
125 Link<ToolBox *, void> maDropdownClickHdl;
126 Timer maDropdownTimer { "vcl::ToolBox mpData->maDropdownTimer" }; // for opening dropdown items on "long click"
128 // large or small buttons ?
129 ToolBoxButtonSize meButtonSize;
131 // the optional custom menu
132 VclPtr<PopupMenu> mpMenu;
133 ToolBoxMenuType maMenuType;
135 // called when menu button is clicked and before the popup menu is executed
136 Link<ToolBox *, void> maMenuButtonHdl;
138 // a dummy item representing the custom menu button
139 ImplToolItem maMenubuttonItem;
140 tools::Long mnMenuButtonWidth;
142 Wallpaper maDisplayBackground;
144 bool mbIsLocked:1, // keeps last lock state from ImplDockingWindowWrapper
145 mbAssumeDocked:1, // only used during calculations to override current floating/popup mode
146 mbAssumeFloating:1,
147 mbAssumePopupMode:1,
148 mbKeyInputDisabled:1, // no KEY input if all items disabled, closing/docking will be allowed though
149 mbIsPaintLocked:1, // don't allow paints
150 mbMenubuttonSelected:1, // menu button is highlighted
151 mbMenubuttonWasLastSelected:1, // menu button was highlighted when focus was lost
152 mbNativeButtons:1, // system supports native toolbar buttons
153 mbWillUsePopupMode:1, // this toolbox will be opened in popup mode
154 mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input
157 #endif // INCLUDED_VCL_INC_TOOLBOX_H
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */