1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2000, 2010 Oracle and/or its affiliates. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 * 25 ************************************************************************/ 26 27 #ifndef SFX_TITLEDOCKWIN_HXX 28 #define SFX_TITLEDOCKWIN_HXX 29 30 #include "sfx2/dllapi.h" 31 #include "sfx2/dockwin.hxx" 32 33 #include <vcl/toolbox.hxx> 34 #include <tools/svborder.hxx> 35 36 //...................................................................................................................... 37 namespace sfx2 38 { 39 //...................................................................................................................... 40 41 //================================================================================================================== 42 //= TitledDockingWindow 43 //================================================================================================================== 44 class SFX2_DLLPUBLIC TitledDockingWindow : public SfxDockingWindow 45 { 46 public: 47 TitledDockingWindow( 48 SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, 49 Window* i_pParent, WinBits i_nStyle = 0 50 ); 51 52 TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, 53 Window* i_pParent, const ResId& i_rResId 54 ); 55 56 virtual ~TitledDockingWindow(); 57 58 /** sets a title to be displayed in the docking window 59 */ 60 void SetTitle( const String& i_rTitle ); 61 /** returns the current title displayed in the docking window 62 63 Note that if you never called SetTitle before, then this method will not return an empty string, 64 but the window text (Window::GetText), since this is what is displayed as title then. 65 */ 66 String GetTitle() const; 67 68 /** adds a drop down item to the toolbox. Usually, this is used to add some kind of menu to the toolbox. 69 70 @param i_rItemText 71 the text to display for the item 72 @param i_nHelpId 73 the help ID for the new toolbox item 74 @param i_rCallback 75 the callback to invoke when the drop item has been clicked 76 @return 77 the ID of the newly created toolbox item 78 */ 79 sal_uInt16 AddDropDownToolBoxItem( const String& i_rItemText, const rtl::OString& i_nHelpId, const Link& i_rCallback ) 80 { 81 return impl_addDropDownToolBoxItem( i_rItemText, i_nHelpId, i_rCallback ); 82 } 83 84 void SetEndDockingHdl( const Link& i_rEndDockingHdl ) { m_aEndDockingHdl = i_rEndDockingHdl; } 85 const Link& GetEndDockingHdl() const { return m_aEndDockingHdl; } 86 87 /** resets the toolbox. Upon return, the only item in the toolbox is the closer. 88 */ 89 void ResetToolBox() 90 { 91 impl_resetToolBox(); 92 } 93 94 /** returns the content window, which is to be used as parent window for any content to be displayed 95 in the docking window. 96 */ 97 ::Window& GetContentWindow() { return m_aContentWindow; } 98 const ::Window& GetContentWindow() const { return m_aContentWindow; } 99 100 ToolBox& GetToolBox() { return m_aToolbox; } 101 const ToolBox& GetToolBox() const { return m_aToolbox; } 102 103 /** Return the border that is painted around the inner window as 104 decoration. 105 */ 106 SvBorder GetDecorationBorder (void) const { return m_aBorder; } 107 108 protected: 109 // Window overridables 110 virtual void Paint( const Rectangle& i_rArea ); 111 virtual void Resize(); 112 virtual void StateChanged( StateChangedType i_nType ); 113 virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent ); 114 virtual void SetText( const String& i_rText ); 115 116 // DockingWindow overridables 117 void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode ); 118 119 // own overridables 120 virtual void onLayoutDone(); 121 122 protected: 123 /** internal version of ResetToolBox 124 */ 125 void impl_resetToolBox(); 126 127 /** internal version of AddDropDownToolBoxItem 128 */ 129 sal_uInt16 impl_addDropDownToolBoxItem( const String& i_rItemText, const rtl::OString& i_nHelpId, const Link& i_rCallback ); 130 131 /** returns the current title. 132 133 If no title has been set via SetTitle, then the window text (Window::GetText) is returned. 134 */ 135 String impl_getTitle() const; 136 137 private: 138 DECL_LINK( OnToolboxItemSelected, ToolBox* ); 139 140 void impl_construct(); 141 void impl_layout(); 142 void impl_scheduleLayout(); 143 144 private: 145 String m_sTitle; 146 ToolBox m_aToolbox; 147 Window m_aContentWindow; 148 149 Link m_aEndDockingHdl; 150 151 /** The border that is painted arround the inner window. The bevel 152 shadow lines are part of the border, so where the border is 0 no 153 such line is painted. 154 */ 155 SvBorder m_aBorder; 156 157 /** Remember that a layout is pending, i.e. Resize() has been called 158 since the last Paint(). 159 */ 160 bool m_bLayoutPending; 161 162 /** Height of the title bar. Calculated in impl_layout(). 163 */ 164 int m_nTitleBarHeight; 165 166 }; 167 168 //...................................................................................................................... 169 } // namespace sfx2 170 //...................................................................................................................... 171 172 #endif // SFX_TITLEDOCKWIN_HXX 173