xref: /aoo4110/main/sfx2/inc/sfx2/titledockwin.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SFX_TITLEDOCKWIN_HXX
25 #define SFX_TITLEDOCKWIN_HXX
26 
27 #include "sfx2/dllapi.h"
28 #include "sfx2/dockwin.hxx"
29 
30 #include <vcl/toolbox.hxx>
31 #include <tools/svborder.hxx>
32 
33 //......................................................................................................................
34 namespace sfx2
35 {
36 //......................................................................................................................
37 
38 	//==================================================================================================================
39 	//= TitledDockingWindow
40 	//==================================================================================================================
41     class SFX2_DLLPUBLIC TitledDockingWindow : public SfxDockingWindow
42 	{
43     public:
44         TitledDockingWindow(
45             SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
46             Window* i_pParent, WinBits i_nStyle = 0
47         );
48 
49         TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
50             Window* i_pParent, const ResId& i_rResId
51         );
52 
53         virtual ~TitledDockingWindow();
54 
55         /** sets a title to be displayed in the docking window
56         */
57         void        SetTitle( const String& i_rTitle );
58         /** returns the current title displayed in the docking window
59 
60             Note that if you never called SetTitle before, then this method will not return an empty string,
61             but the window text (Window::GetText), since this is what is displayed as title then.
62         */
63         String      GetTitle() const;
64 
65         /** adds a drop down item to the toolbox. Usually, this is used to add some kind of menu to the toolbox.
66 
67             @param i_rItemText
68                 the text to display for the item
69             @param i_nHelpId
70                 the help ID for the new toolbox item
71             @param i_rCallback
72                 the callback to invoke when the drop item has been clicked
73             @return
74                 the ID of the newly created toolbox item
75         */
AddDropDownToolBoxItem(const String & i_rItemText,const rtl::OString & i_nHelpId,const Link & i_rCallback)76         sal_uInt16  AddDropDownToolBoxItem( const String& i_rItemText, const rtl::OString& i_nHelpId, const Link& i_rCallback )
77         {
78             return impl_addDropDownToolBoxItem( i_rItemText, i_nHelpId, i_rCallback );
79         }
80 
SetEndDockingHdl(const Link & i_rEndDockingHdl)81         void        SetEndDockingHdl( const Link& i_rEndDockingHdl ) { m_aEndDockingHdl = i_rEndDockingHdl; }
GetEndDockingHdl() const82         const Link& GetEndDockingHdl() const { return m_aEndDockingHdl; }
83 
84         /** resets the toolbox. Upon return, the only item in the toolbox is the closer.
85         */
ResetToolBox()86         void    ResetToolBox()
87         {
88             impl_resetToolBox();
89         }
90 
91         /** returns the content window, which is to be used as parent window for any content to be displayed
92             in the docking window.
93         */
GetContentWindow()94         ::Window&       GetContentWindow()          { return m_aContentWindow; }
GetContentWindow() const95         const ::Window& GetContentWindow() const    { return m_aContentWindow; }
96 
GetToolBox()97         ToolBox&        GetToolBox()        { return m_aToolbox; }
GetToolBox() const98         const ToolBox&  GetToolBox() const  { return m_aToolbox; }
99 
100         /** Return the border that is painted around the inner window as
101             decoration.
102         */
GetDecorationBorder(void) const103         SvBorder        GetDecorationBorder (void) const  { return m_aBorder; }
104 
105     protected:
106         // Window overridables
107         virtual void Paint( const Rectangle& i_rArea );
108         virtual void Resize();
109         virtual void StateChanged( StateChangedType i_nType );
110         virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent );
111         virtual void SetText( const String& i_rText );
112 
113         // DockingWindow overridables
114         void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
115 
116         // own overridables
117         virtual void onLayoutDone();
118 
119     protected:
120         /** internal version of ResetToolBox
121         */
122         void    impl_resetToolBox();
123 
124         /** internal version of AddDropDownToolBoxItem
125         */
126         sal_uInt16  impl_addDropDownToolBoxItem( const String& i_rItemText, const rtl::OString& i_nHelpId, const Link& i_rCallback );
127 
128         /** returns the current title.
129 
130             If no title has been set via SetTitle, then the window text (Window::GetText) is returned.
131         */
132         String  impl_getTitle() const;
133 
134     private:
135         DECL_LINK( OnToolboxItemSelected, ToolBox* );
136 
137         void    impl_construct();
138         void    impl_layout();
139         void    impl_scheduleLayout();
140 
141     private:
142         String              m_sTitle;
143         ToolBox             m_aToolbox;
144         Window              m_aContentWindow;
145 
146         Link                m_aEndDockingHdl;
147 
148         /** The border that is painted arround the inner window.  The bevel
149             shadow lines are part of the border, so where the border is 0 no
150             such line is painted.
151         */
152         SvBorder            m_aBorder;
153 
154         /** Remember that a layout is pending, i.e. Resize() has been called
155             since the last Paint().
156         */
157         bool                m_bLayoutPending;
158 
159         /** Height of the title bar.  Calculated in impl_layout().
160         */
161         int                 m_nTitleBarHeight;
162 
163     };
164 
165 //......................................................................................................................
166 } // namespace sfx2
167 //......................................................................................................................
168 
169 #endif // SFX_TITLEDOCKWIN_HXX
170