1c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c45d927aSAndrew Rist * distributed with this work for additional information 6c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c45d927aSAndrew Rist * software distributed under the License is distributed on an 15c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17c45d927aSAndrew Rist * specific language governing permissions and limitations 18c45d927aSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20c45d927aSAndrew Rist *************************************************************/ 21c45d927aSAndrew Rist 22cdf0e10cSrcweir #ifndef SD_TASKPANE_TITLED_CONTROL_HXX 23cdf0e10cSrcweir #define SD_TASKPANE_TITLED_CONTROL_HXX 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include "taskpane/TaskPaneTreeNode.hxx" 26cdf0e10cSrcweir #include "taskpane/ControlContainer.hxx" 27cdf0e10cSrcweir #include "TitleBar.hxx" 28cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp> 29cdf0e10cSrcweir #include <tools/string.hxx> 30cdf0e10cSrcweir #include <tools/gen.hxx> 31cdf0e10cSrcweir #ifndef SD_WINDOW_HXX 32cdf0e10cSrcweir #include <vcl/window.hxx> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #include <memory> 35cdf0e10cSrcweir #include <boost/function.hpp> 36cdf0e10cSrcweir 37cdf0e10cSrcweir class Window; 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace sd { namespace toolpanel { 40cdf0e10cSrcweir 41cdf0e10cSrcweir class ControlContainer; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** This wrapper adds a title bar to a control. Both title bar and 44cdf0e10cSrcweir control are child windows. 45cdf0e10cSrcweir */ 46cdf0e10cSrcweir class TitledControl 47cdf0e10cSrcweir : public ::Window, 48cdf0e10cSrcweir public TreeNode 49cdf0e10cSrcweir { 50cdf0e10cSrcweir public: 51cdf0e10cSrcweir typedef ::boost::function1<void, TitledControl&> ClickHandler; 52cdf0e10cSrcweir 53cdf0e10cSrcweir /** Create a new descriptor for the given control. 54cdf0e10cSrcweir @param pParent 55cdf0e10cSrcweir The parent window of the new descriptor. 56cdf0e10cSrcweir @param pControl 57cdf0e10cSrcweir The control that is shown when being in the expanded 58cdf0e10cSrcweir state. 59cdf0e10cSrcweir @param rTitle 60cdf0e10cSrcweir String that is shown as title in the title area above the 61cdf0e10cSrcweir control. 62cdf0e10cSrcweir @param rClickHandler 63cdf0e10cSrcweir The typical action of the click handler is to expand the control. 64cdf0e10cSrcweir @param eType 65cdf0e10cSrcweir Type of the title bar. This specifies how the title bar 6630acf5e8Spfg will be formatted. For more information see TitleBar. 67cdf0e10cSrcweir 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir TitledControl ( 70cdf0e10cSrcweir TreeNode* pParent, 71cdf0e10cSrcweir ::std::auto_ptr<TreeNode> pControl, 72cdf0e10cSrcweir const String& rTitle, 73cdf0e10cSrcweir const ClickHandler& rClickHandler, 74cdf0e10cSrcweir TitleBar::TitleBarType eType); 75cdf0e10cSrcweir 76cdf0e10cSrcweir virtual ~TitledControl (void); 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir virtual Size GetPreferredSize (void); 80cdf0e10cSrcweir virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 81cdf0e10cSrcweir virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 82cdf0e10cSrcweir virtual bool IsResizable (void); 83cdf0e10cSrcweir virtual ::Window* GetWindow (void); 84cdf0e10cSrcweir 85cdf0e10cSrcweir virtual void Resize (void); 86cdf0e10cSrcweir virtual void GetFocus (void); 87cdf0e10cSrcweir virtual void KeyInput (const KeyEvent& rEvent); 88cdf0e10cSrcweir 89cdf0e10cSrcweir // void Select (bool bExpansionState); 90cdf0e10cSrcweir 91cdf0e10cSrcweir TitleBar* GetTitleBar (void); 92cdf0e10cSrcweir /** Return the control child. When a control factory has been given and 93cdf0e10cSrcweir the control has not yet been created and the given flag is <TRUE/> 94cdf0e10cSrcweir then the control is created. 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir TreeNode* GetControl (void); 97cdf0e10cSrcweir const TreeNode* GetConstControl () const; 98cdf0e10cSrcweir 99cdf0e10cSrcweir const String& GetTitle (void) const; 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** Expand the control without informing its container. This 10286e1cf34SPedro Giffuni method usually is called by the container as a result of a 103cdf0e10cSrcweir higher level expand command. You may want to use 104cdf0e10cSrcweir ExpandViaContainer() instead. 105cdf0e10cSrcweir @param bExpanded 106cdf0e10cSrcweir When <TRUE/> then the control is expanded, otherwise it is 107cdf0e10cSrcweir collapsed. 108cdf0e10cSrcweir */ 109cdf0e10cSrcweir virtual bool Expand (bool bExpanded = true); 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** Return whether the control is currently expanded (<TRUE/>) or 112cdf0e10cSrcweir not (<FALSE/>). 113cdf0e10cSrcweir */ 114cdf0e10cSrcweir virtual bool IsExpanded (void) const; 115cdf0e10cSrcweir 116cdf0e10cSrcweir /** Returns the value of the control. 117cdf0e10cSrcweir */ 118cdf0e10cSrcweir virtual bool IsExpandable (void) const; 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual void SetEnabledState(bool bFlag); 121cdf0e10cSrcweir 122cdf0e10cSrcweir virtual bool IsShowing (void) const; 123cdf0e10cSrcweir virtual void Show (bool bVisible); 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 126cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject ( 127cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 128cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent); 129cdf0e10cSrcweir 130cdf0e10cSrcweir using Window::GetWindow; 131cdf0e10cSrcweir using Window::Show; 132cdf0e10cSrcweir 133cdf0e10cSrcweir private: 134cdf0e10cSrcweir String msTitle; 135cdf0e10cSrcweir bool mbVisible; 136cdf0e10cSrcweir void* mpUserData; 137cdf0e10cSrcweir ::std::auto_ptr<ClickHandler> mpClickHandler; 138cdf0e10cSrcweir 139*6c3f4600Smseidel // Do not use! Assignment operator is not supported. 140cdf0e10cSrcweir const TitledControl& operator= ( 141cdf0e10cSrcweir const TitledControl& aDescriptor); 142cdf0e10cSrcweir 143cdf0e10cSrcweir void UpdateStates (void); 144cdf0e10cSrcweir 145cdf0e10cSrcweir DECL_LINK(WindowEventListener, VclSimpleEvent*); 146cdf0e10cSrcweir }; 147cdf0e10cSrcweir 148cdf0e10cSrcweir 149cdf0e10cSrcweir /** This standard implementation of the ClickHandler expands, or toggles the 150cdf0e10cSrcweir expansion state, of the control, whose title was clicked. 151cdf0e10cSrcweir */ 152cdf0e10cSrcweir class TitledControlStandardClickHandler 153cdf0e10cSrcweir { 154cdf0e10cSrcweir public: 155cdf0e10cSrcweir /** Create a new instance of this class. 156cdf0e10cSrcweir @param rControlContainer 157cdf0e10cSrcweir The container of which the TitledControl is part of. 158cdf0e10cSrcweir @param eExpansionState 159cdf0e10cSrcweir This specifies whether to always expand the titled control or to 160cdf0e10cSrcweir toggle its expansion state. 161cdf0e10cSrcweir */ 162cdf0e10cSrcweir TitledControlStandardClickHandler ( 163cdf0e10cSrcweir ControlContainer& rControlContainer, 164cdf0e10cSrcweir ControlContainer::ExpansionState eExpansionState); 165cdf0e10cSrcweir void operator () (TitledControl& rTitledControl); 166cdf0e10cSrcweir private: 167cdf0e10cSrcweir ControlContainer& mrControlContainer; 168cdf0e10cSrcweir ControlContainer::ExpansionState meExpansionState; 169cdf0e10cSrcweir }; 170cdf0e10cSrcweir 171cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel 172cdf0e10cSrcweir 173cdf0e10cSrcweir #endif 174*6c3f4600Smseidel 175*6c3f4600Smseidel /* vim: set noet sw=4 ts=4: */ 176