1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SV_TOOLBOX_H 29 #define _SV_TOOLBOX_H 30 31 #include <tools/gen.hxx> 32 #include <tools/string.hxx> 33 #include <vcl/sv.h> 34 #include <vcl/image.hxx> 35 #include <vcl/toolbox.hxx> 36 #include <vcl/controllayout.hxx> 37 #include <vcl/ImageListProvider.hxx> 38 39 #include <vector> 40 41 #define TB_DROPDOWNARROWWIDTH 11 42 43 #define TB_MENUBUTTON_SIZE 12 44 #define TB_MENUBUTTON_OFFSET 2 45 46 #define TB_SMALLIMAGESIZE 16 47 48 #define TB_LARGEIMAGESIZE 26 49 #define TB_LARGEIMAGESIZE_INDUSTRIAL 24 50 51 class Window; 52 53 // ---------------- 54 // - ImplToolItem - 55 // ---------------- 56 57 struct ImplToolItem 58 { 59 Window* mpWindow; 60 void* mpUserData; 61 Image maImage; 62 Image maHighImage; 63 long mnImageAngle; 64 bool mbMirrorMode; 65 XubString maText; 66 XubString maQuickHelpText; 67 XubString maHelpText; 68 String maCommandStr; 69 rtl::OString maHelpId; 70 Rectangle maRect; 71 Rectangle maCalcRect; 72 // the overall horizontal item size, including one or more of [image size + textlength + dropdown arrow] 73 Size maItemSize; 74 long mnSepSize; 75 long mnDropDownArrowWidth; 76 ToolBoxItemType meType; 77 ToolBoxItemBits mnBits; 78 TriState meState; 79 sal_uInt16 mnId; 80 sal_Bool mbEnabled:1, 81 mbVisible:1, 82 mbEmptyBtn:1, 83 mbShowWindow:1, 84 mbBreak:1, 85 mbVisibleText:1; // indicates if text will definitely be drawn, influences dropdown pos 86 87 ImplToolItem(); 88 ImplToolItem( sal_uInt16 nItemId, const Image& rImage, 89 ToolBoxItemBits nItemBits ); 90 ImplToolItem( sal_uInt16 nItemId, const XubString& rTxt, 91 ToolBoxItemBits nItemBits ); 92 ImplToolItem( sal_uInt16 nItemId, const Image& rImage, 93 const XubString& rTxt, 94 ToolBoxItemBits nItemBits ); 95 ~ImplToolItem(); 96 97 ImplToolItem( const ImplToolItem& ); 98 ImplToolItem& operator=(const ImplToolItem&); 99 100 // returns the size of a item, taking toolbox orientation into account 101 // the default size is the precomputed size for standard items 102 // ie those that are just ordinary buttons (no windows or text etc.) 103 // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons 104 Size GetSize( sal_Bool bHorz, sal_Bool bCheckMaxWidth, long maxWidth, const Size& rDefaultSize ); 105 106 // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style 107 void DetermineButtonDrawStyle( ButtonType eButtonType, sal_Bool& rbImage, sal_Bool& rbText ) const; 108 109 // returns the rectangle which contains the drop down arrow 110 // or an empty rect if there is none 111 // bHorz denotes the toolbox alignment 112 Rectangle GetDropDownRect( sal_Bool bHorz ) const; 113 114 // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars 115 sal_Bool IsClipped() const; 116 }; 117 118 namespace vcl 119 { 120 121 struct ToolBoxLayoutData : public ControlLayoutData 122 { 123 std::vector< sal_uInt16 > m_aLineItemIds; 124 std::vector< sal_uInt16 > m_aLineItemPositions; 125 }; 126 127 128 } /* namespace vcl */ 129 130 131 struct ImplToolBoxPrivateData 132 { 133 vcl::ToolBoxLayoutData* m_pLayoutData; 134 std::vector< ImplToolItem > m_aItems; 135 136 ImplToolBoxPrivateData(); 137 ~ImplToolBoxPrivateData(); 138 139 void ImplClearLayoutData() { delete m_pLayoutData; m_pLayoutData = NULL; } 140 141 // called when dropdown items are clicked 142 Link maDropdownClickHdl; 143 Timer maDropdownTimer; // for opening dropdown items on "long click" 144 145 // large or small buttons ? 146 ToolBoxButtonSize meButtonSize; 147 148 // the optional custom menu 149 PopupMenu* mpMenu; 150 sal_uInt16 maMenuType; 151 sal_uIntPtr mnEventId; 152 153 // called when menu button is clicked and before the popup menu is executed 154 Link maMenuButtonHdl; 155 156 // a dummy item representing the custom menu button 157 ImplToolItem maMenubuttonItem; 158 long mnMenuButtonWidth; 159 160 Wallpaper maDisplayBackground; 161 162 // support for highcontrast 163 vcl::IImageListProvider* mpImageListProvider; 164 vcl::ImageListType meImageListType; 165 166 sal_Bool mbIsLocked:1, // keeps last lock state from ImplDockingWindowWrapper 167 mbAssumeDocked:1, // only used during calculations to override current floating/popup mode 168 mbAssumeFloating:1, 169 mbAssumePopupMode:1, 170 mbKeyInputDisabled:1, // no KEY input if all items disabled, closing/docking will be allowed though 171 mbIsPaintLocked:1, // don't allow paints 172 mbMenubuttonSelected:1, // menu button is highlighted 173 mbPageScroll:1, // determines if we scroll a page at a time 174 mbNativeButtons:1, // system supports native toolbar buttons 175 mbWillUsePopupMode:1, // this toolbox will be opened in popup mode 176 mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input 177 }; 178 179 180 #endif // _SV_TOOLBOX_H 181