xref: /AOO41X/main/sd/source/ui/inc/taskpane/TitledControl.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SD_TASKPANE_TITLED_CONTROL_HXX
29*cdf0e10cSrcweir #define SD_TASKPANE_TITLED_CONTROL_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "taskpane/TaskPaneTreeNode.hxx"
32*cdf0e10cSrcweir #include "taskpane/ControlContainer.hxx"
33*cdf0e10cSrcweir #include "TitleBar.hxx"
34*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp>
35*cdf0e10cSrcweir #include <tools/string.hxx>
36*cdf0e10cSrcweir #include <tools/gen.hxx>
37*cdf0e10cSrcweir #ifndef SD_WINDOW_HXX
38*cdf0e10cSrcweir #include <vcl/window.hxx>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #include <memory>
41*cdf0e10cSrcweir #include <boost/function.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir class Window;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace sd { namespace toolpanel {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class ControlContainer;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir /** This wrapper adds a title bar to a control.  Both title bar and
50*cdf0e10cSrcweir     control are child windows.
51*cdf0e10cSrcweir */
52*cdf0e10cSrcweir class TitledControl
53*cdf0e10cSrcweir     : public ::Window,
54*cdf0e10cSrcweir       public TreeNode
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir public:
57*cdf0e10cSrcweir     typedef ::boost::function1<void, TitledControl&> ClickHandler;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     /** Create a new descriptor for the given control.
60*cdf0e10cSrcweir         @param pParent
61*cdf0e10cSrcweir             The parent window of the new descriptor.
62*cdf0e10cSrcweir         @param pControl
63*cdf0e10cSrcweir             The control that is shown when being in the expanded
64*cdf0e10cSrcweir             state.
65*cdf0e10cSrcweir         @param rTitle
66*cdf0e10cSrcweir             String that is shown as title in the title area above the
67*cdf0e10cSrcweir             control.
68*cdf0e10cSrcweir         @param rClickHandler
69*cdf0e10cSrcweir             The typical action of the click handler is to expand the control.
70*cdf0e10cSrcweir         @param eType
71*cdf0e10cSrcweir             Type of the title bar.  This specifies how the title bar
72*cdf0e10cSrcweir             will be formated.  For more information see TitleBar.
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     */
75*cdf0e10cSrcweir     TitledControl (
76*cdf0e10cSrcweir         TreeNode* pParent,
77*cdf0e10cSrcweir         ::std::auto_ptr<TreeNode> pControl,
78*cdf0e10cSrcweir         const String& rTitle,
79*cdf0e10cSrcweir         const ClickHandler& rClickHandler,
80*cdf0e10cSrcweir         TitleBar::TitleBarType eType);
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     virtual ~TitledControl (void);
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     virtual Size GetPreferredSize (void);
86*cdf0e10cSrcweir     virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
87*cdf0e10cSrcweir     virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
88*cdf0e10cSrcweir     virtual bool IsResizable (void);
89*cdf0e10cSrcweir     virtual ::Window* GetWindow (void);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     virtual void Resize (void);
92*cdf0e10cSrcweir     virtual void GetFocus (void);
93*cdf0e10cSrcweir     virtual void KeyInput (const KeyEvent& rEvent);
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     //    void Select (bool bExpansionState);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     TitleBar* GetTitleBar (void);
98*cdf0e10cSrcweir     /** Return the control child.  When a control factory has been given and
99*cdf0e10cSrcweir         the control has not yet been created and the given flag is <TRUE/>
100*cdf0e10cSrcweir         then the control is created.
101*cdf0e10cSrcweir     */
102*cdf0e10cSrcweir     TreeNode* GetControl (void);
103*cdf0e10cSrcweir     const TreeNode* GetConstControl () const;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     const String& GetTitle (void) const;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     /** Expand the control without informing its container.  This
108*cdf0e10cSrcweir         method ususally is called by the container as a result of a
109*cdf0e10cSrcweir         higher level expand command.  You may want to use
110*cdf0e10cSrcweir         ExpandViaContainer() instead.
111*cdf0e10cSrcweir         @param bExpanded
112*cdf0e10cSrcweir             When <TRUE/> then the control is expanded, otherwise it is
113*cdf0e10cSrcweir             collapsed.
114*cdf0e10cSrcweir     */
115*cdf0e10cSrcweir     virtual bool Expand (bool bExpanded = true);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     /** Return whether the control is currently expanded (<TRUE/>) or
118*cdf0e10cSrcweir         not (<FALSE/>).
119*cdf0e10cSrcweir     */
120*cdf0e10cSrcweir     virtual bool IsExpanded (void) const;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     /** Returns the value of the control.
123*cdf0e10cSrcweir     */
124*cdf0e10cSrcweir     virtual bool IsExpandable (void) const;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     virtual void SetEnabledState(bool bFlag);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     virtual bool IsShowing (void) const;
129*cdf0e10cSrcweir     virtual void Show (bool bVisible);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
132*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject (
133*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
134*cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible>& rxParent);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	using Window::GetWindow;
137*cdf0e10cSrcweir 	using Window::Show;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir private:
140*cdf0e10cSrcweir     String msTitle;
141*cdf0e10cSrcweir     bool mbVisible;
142*cdf0e10cSrcweir     void* mpUserData;
143*cdf0e10cSrcweir     ::std::auto_ptr<ClickHandler> mpClickHandler;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     /// Do not use! Assignment operator is not supported.
146*cdf0e10cSrcweir     const TitledControl& operator= (
147*cdf0e10cSrcweir         const TitledControl& aDescriptor);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     void UpdateStates (void);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     DECL_LINK(WindowEventListener, VclSimpleEvent*);
152*cdf0e10cSrcweir };
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir /** This standard implementation of the ClickHandler expands, or toggles the
158*cdf0e10cSrcweir     expansion state, of the control, whose title was clicked.
159*cdf0e10cSrcweir */
160*cdf0e10cSrcweir class TitledControlStandardClickHandler
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir public:
163*cdf0e10cSrcweir     /** Create a new instance of this class.
164*cdf0e10cSrcweir         @param rControlContainer
165*cdf0e10cSrcweir             The container of which the TitledControl is part of.
166*cdf0e10cSrcweir         @param eExpansionState
167*cdf0e10cSrcweir             This specifies whether to always expand the titled control or to
168*cdf0e10cSrcweir             toggle its expansion state.
169*cdf0e10cSrcweir     */
170*cdf0e10cSrcweir     TitledControlStandardClickHandler (
171*cdf0e10cSrcweir         ControlContainer& rControlContainer,
172*cdf0e10cSrcweir         ControlContainer::ExpansionState eExpansionState);
173*cdf0e10cSrcweir     void operator () (TitledControl& rTitledControl);
174*cdf0e10cSrcweir private:
175*cdf0e10cSrcweir     ControlContainer& mrControlContainer;
176*cdf0e10cSrcweir     ControlContainer::ExpansionState meExpansionState;
177*cdf0e10cSrcweir };
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir #endif
182