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 SD_TOOLPANEL_PREVIEW_VALUE_SET_HXX 25 #define SD_TOOLPANEL_PREVIEW_VALUE_SET_HXX 26 27 #include <svtools/valueset.hxx> 28 29 30 namespace sd { namespace toolpanel { 31 class TreeNode; 32 } } 33 34 namespace sd { namespace toolpanel { namespace controls { 35 36 37 /** Adapt the svtools valueset to the needs of the master page controlls. 38 */ 39 class PreviewValueSet 40 : public ValueSet 41 { 42 public: 43 PreviewValueSet (TreeNode* pParent); 44 ~PreviewValueSet (void); 45 46 void SetRightMouseClickHandler (const Link& rLink); 47 virtual void Paint (const Rectangle& rRect); 48 virtual void Resize (void); 49 50 /** When a request for the display of a context menu is made to this 51 method then that request is forwarded via the ContextMenuCallback. 52 This way the owning class can handle the context menu without having 53 to be derived from this class. 54 Use SetContextMenuCallback to set or rest the handler. 55 */ 56 virtual void Command (const CommandEvent& rEvent); 57 58 void SetPreviewSize (const Size& rSize); 59 60 sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 61 sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 62 63 /** Set the number of rows and columns according to the current number 64 of items. Call this method when new items have been inserted. 65 */ 66 void Rearrange (bool bForceRequestResize = false); 67 68 /** Set the callback function to which requests for context menus are 69 forewarded. Call with an empty Link to reset the callback 70 function. 71 */ 72 void SetContextMenuCallback (const Link& rLink); 73 74 protected: 75 virtual void MouseButtonDown (const MouseEvent& rEvent); 76 77 private: 78 Link maRightMouseClickHandler; 79 Link maContextMenuCallback; 80 TreeNode* mpParent; 81 Size maPreviewSize; 82 const int mnBorderWidth; 83 const int mnBorderHeight; 84 const int mnMaxColumnCount; 85 86 sal_uInt16 CalculateColumnCount (int nWidth) const; 87 sal_uInt16 CalculateRowCount (sal_uInt16 nColumnCount) const; 88 }; 89 90 } } } // end of namespace ::sd::toolpanel::controls 91 92 #endif 93