Line data Source code
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 _SV_TOOLBOX_H
21 : #define _SV_TOOLBOX_H
22 :
23 : #include <tools/gen.hxx>
24 : #include <tools/string.hxx>
25 : #include <tools/solar.h>
26 : #include <vcl/image.hxx>
27 : #include <vcl/toolbox.hxx>
28 : #include <vcl/controllayout.hxx>
29 : #include <vcl/ImageListProvider.hxx>
30 :
31 : #include <vector>
32 :
33 : #define TB_DROPDOWNARROWWIDTH 11
34 :
35 : #define TB_MENUBUTTON_SIZE 12
36 : #define TB_MENUBUTTON_OFFSET 2
37 :
38 : #define TB_SMALLIMAGESIZE 16
39 :
40 : #define TB_LARGEIMAGESIZE 26
41 : #define TB_LARGEIMAGESIZE_INDUSTRIAL 24
42 : #define TB_LARGEIMAGESIZE_CRYSTAL 22
43 : #define TB_LARGEIMAGESIZE_OXYGEN 22
44 :
45 : class Window;
46 :
47 : // ----------------
48 : // - ImplToolItem -
49 : // ----------------
50 :
51 : struct ImplToolItem
52 : {
53 : Window* mpWindow;
54 : void* mpUserData;
55 : Image maImage;
56 : Image maHighImage;
57 : long mnImageAngle;
58 : bool mbMirrorMode;
59 : XubString maText;
60 : XubString maQuickHelpText;
61 : XubString maHelpText;
62 : String maCommandStr;
63 : OString maHelpId;
64 : Rectangle maRect;
65 : Rectangle maCalcRect;
66 : /// Widget layout may request size; set it as the minimal size (like, the item will always have at least this size).
67 : Size maMinimalItemSize;
68 : /// The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]
69 : Size maItemSize;
70 : long mnSepSize;
71 : long mnDropDownArrowWidth;
72 : /// Size of the content (bitmap or text, without dropdown) that we have in the item.
73 : Size maContentSize;
74 : ToolBoxItemType meType;
75 : ToolBoxItemBits mnBits;
76 : TriState meState;
77 : sal_uInt16 mnId;
78 : sal_Bool mbEnabled:1,
79 : mbVisible:1,
80 : mbEmptyBtn:1,
81 : mbShowWindow:1,
82 : mbBreak:1,
83 : mbVisibleText:1; // indicates if text will definitely be drawn, influences dropdown pos
84 :
85 : ImplToolItem();
86 : ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
87 : ToolBoxItemBits nItemBits );
88 : ImplToolItem( sal_uInt16 nItemId, const XubString& rTxt,
89 : ToolBoxItemBits nItemBits );
90 : ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
91 : const XubString& rTxt,
92 : ToolBoxItemBits nItemBits );
93 : ~ImplToolItem();
94 :
95 : ImplToolItem( const ImplToolItem& );
96 : ImplToolItem& operator=(const ImplToolItem&);
97 :
98 : // returns the size of a item, taking toolbox orientation into account
99 : // the default size is the precomputed size for standard items
100 : // ie those that are just ordinary buttons (no windows or text etc.)
101 : // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons
102 : Size GetSize( sal_Bool bHorz, sal_Bool bCheckMaxWidth, long maxWidth, const Size& rDefaultSize );
103 :
104 : // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style
105 : void DetermineButtonDrawStyle( ButtonType eButtonType, sal_Bool& rbImage, sal_Bool& rbText ) const;
106 :
107 : // returns the rectangle which contains the drop down arrow
108 : // or an empty rect if there is none
109 : // bHorz denotes the toolbox alignment
110 : Rectangle GetDropDownRect( sal_Bool bHorz ) const;
111 :
112 : // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars
113 : sal_Bool IsClipped() const;
114 :
115 : private:
116 : void init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits, sal_Bool bEmptyBtn);
117 : };
118 :
119 : namespace vcl
120 : {
121 :
122 0 : struct ToolBoxLayoutData : public ControlLayoutData
123 : {
124 : std::vector< sal_uInt16 > m_aLineItemIds;
125 : std::vector< sal_uInt16 > m_aLineItemPositions;
126 : };
127 :
128 :
129 : } /* namespace vcl */
130 :
131 :
132 : struct ImplToolBoxPrivateData
133 : {
134 : vcl::ToolBoxLayoutData* m_pLayoutData;
135 : std::vector< ImplToolItem > m_aItems;
136 :
137 : ImplToolBoxPrivateData();
138 : ~ImplToolBoxPrivateData();
139 :
140 83641 : void ImplClearLayoutData() { delete m_pLayoutData; m_pLayoutData = NULL; }
141 :
142 : // called when dropdown items are clicked
143 : Link maDropdownClickHdl;
144 : Timer maDropdownTimer; // for opening dropdown items on "long click"
145 :
146 : // large or small buttons ?
147 : ToolBoxButtonSize meButtonSize;
148 :
149 : // the optional custom menu
150 : PopupMenu* mpMenu;
151 : sal_uInt16 maMenuType;
152 : sal_uIntPtr mnEventId;
153 :
154 : // called when menu button is clicked and before the popup menu is executed
155 : Link maMenuButtonHdl;
156 :
157 : // a dummy item representing the custom menu button
158 : ImplToolItem maMenubuttonItem;
159 : long mnMenuButtonWidth;
160 :
161 : Wallpaper maDisplayBackground;
162 :
163 : // support for highcontrast
164 : vcl::IImageListProvider* mpImageListProvider;
165 : vcl::ImageListType meImageListType;
166 :
167 : sal_Bool mbIsLocked:1, // keeps last lock state from ImplDockingWindowWrapper
168 : mbAssumeDocked:1, // only used during calculations to override current floating/popup mode
169 : mbAssumeFloating:1,
170 : mbAssumePopupMode:1,
171 : mbKeyInputDisabled:1, // no KEY input if all items disabled, closing/docking will be allowed though
172 : mbIsPaintLocked:1, // don't allow paints
173 : mbMenubuttonSelected:1, // menu button is highlighted
174 : mbPageScroll:1, // determines if we scroll a page at a time
175 : mbNativeButtons:1, // system supports native toolbar buttons
176 : mbWillUsePopupMode:1, // this toolbox will be opened in popup mode
177 : mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input
178 : };
179 :
180 :
181 : #endif // _SV_TOOLBOX_H
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|