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