Branch data 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 SFX_TITLEDOCKWIN_HXX
21 : : #define SFX_TITLEDOCKWIN_HXX
22 : :
23 : : #include "sfx2/dllapi.h"
24 : : #include "sfx2/dockwin.hxx"
25 : :
26 : : #include <vcl/toolbox.hxx>
27 : : #include <tools/svborder.hxx>
28 : :
29 : : //......................................................................................................................
30 : : namespace sfx2
31 : : {
32 : : //......................................................................................................................
33 : :
34 : : //==================================================================================================================
35 : : //= TitledDockingWindow
36 : : //==================================================================================================================
37 : : class SFX2_DLLPUBLIC TitledDockingWindow : public SfxDockingWindow
38 : : {
39 : : public:
40 : : TitledDockingWindow(
41 : : SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
42 : : Window* i_pParent, WinBits i_nStyle = 0
43 : : );
44 : :
45 : : TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
46 : : Window* i_pParent, const ResId& i_rResId
47 : : );
48 : :
49 : : virtual ~TitledDockingWindow();
50 : :
51 : : /** sets a title to be displayed in the docking window
52 : : */
53 : : void SetTitle( const String& i_rTitle );
54 : :
55 : : /** adds a drop down item to the toolbox. Usually, this is used to add some kind of menu to the toolbox.
56 : :
57 : : @param i_rItemText
58 : : the text to display for the item
59 : : @param i_nHelpId
60 : : the help ID for the new toolbox item
61 : : @param i_rCallback
62 : : the callback to invoke when the drop item has been clicked
63 : : @return
64 : : the ID of the newly created toolbox item
65 : : */
66 : 26 : sal_uInt16 AddDropDownToolBoxItem( const String& i_rItemText, const rtl::OString& i_nHelpId, const Link& i_rCallback )
67 : : {
68 : 26 : return impl_addDropDownToolBoxItem( i_rItemText, i_nHelpId, i_rCallback );
69 : : }
70 : :
71 : 26 : void SetEndDockingHdl( const Link& i_rEndDockingHdl ) { m_aEndDockingHdl = i_rEndDockingHdl; }
72 : : const Link& GetEndDockingHdl() const { return m_aEndDockingHdl; }
73 : :
74 : : /** resets the toolbox. Upon return, the only item in the toolbox is the closer.
75 : : */
76 : 26 : void ResetToolBox()
77 : : {
78 : 26 : impl_resetToolBox();
79 : 26 : }
80 : :
81 : : /** returns the content window, which is to be used as parent window for any content to be displayed
82 : : in the docking window.
83 : : */
84 : 0 : ::Window& GetContentWindow() { return m_aContentWindow; }
85 : : const ::Window& GetContentWindow() const { return m_aContentWindow; }
86 : :
87 : : ToolBox& GetToolBox() { return m_aToolbox; }
88 : : const ToolBox& GetToolBox() const { return m_aToolbox; }
89 : :
90 : : /** Return the border that is painted around the inner window as
91 : : decoration.
92 : : */
93 : : SvBorder GetDecorationBorder (void) const { return m_aBorder; }
94 : :
95 : : protected:
96 : : // Window overridables
97 : : virtual void Paint( const Rectangle& i_rArea );
98 : : virtual void Resize();
99 : : virtual void StateChanged( StateChangedType i_nType );
100 : : virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent );
101 : : virtual void SetText( const String& i_rText );
102 : :
103 : : // DockingWindow overridables
104 : : void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
105 : :
106 : : // own overridables
107 : : virtual void onLayoutDone();
108 : :
109 : : protected:
110 : : /** internal version of ResetToolBox
111 : : */
112 : : void impl_resetToolBox();
113 : :
114 : : /** internal version of AddDropDownToolBoxItem
115 : : */
116 : : sal_uInt16 impl_addDropDownToolBoxItem( const String& i_rItemText, const rtl::OString& i_nHelpId, const Link& i_rCallback );
117 : :
118 : : /** returns the current title.
119 : :
120 : : If no title has been set via SetTitle, then the window text (Window::GetText) is returned.
121 : : */
122 : : String impl_getTitle() const;
123 : :
124 : : private:
125 : : DECL_LINK( OnToolboxItemSelected, ToolBox* );
126 : :
127 : : void impl_construct();
128 : : void impl_layout();
129 : : void impl_scheduleLayout();
130 : :
131 : : private:
132 : : String m_sTitle;
133 : : ToolBox m_aToolbox;
134 : : Window m_aContentWindow;
135 : :
136 : : Link m_aEndDockingHdl;
137 : :
138 : : /** The border that is painted arround the inner window. The bevel
139 : : shadow lines are part of the border, so where the border is 0 no
140 : : such line is painted.
141 : : */
142 : : SvBorder m_aBorder;
143 : :
144 : : /** Remember that a layout is pending, i.e. Resize() has been called
145 : : since the last Paint().
146 : : */
147 : : bool m_bLayoutPending;
148 : :
149 : : /** Height of the title bar. Calculated in impl_layout().
150 : : */
151 : : int m_nTitleBarHeight;
152 : :
153 : : };
154 : :
155 : : //......................................................................................................................
156 : : } // namespace sfx2
157 : : //......................................................................................................................
158 : :
159 : : #endif // SFX_TITLEDOCKWIN_HXX
160 : :
161 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|