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_SLIDESORTER_INSERTION_INDICATOR_OVERLAY_HXX 25 #define SD_SLIDESORTER_INSERTION_INDICATOR_OVERLAY_HXX 26 27 #include "model/SlsSharedPageDescriptor.hxx" 28 #include "view/SlsILayerPainter.hxx" 29 #include "controller/SlsTransferableData.hxx" 30 #include "sdxfer.hxx" 31 32 #include <tools/gen.hxx> 33 #include <vcl/bitmapex.hxx> 34 #include <boost/scoped_ptr.hpp> 35 #include <boost/enable_shared_from_this.hpp> 36 #include <vector> 37 38 class OutputDevice; 39 class SdPage; 40 41 namespace sd { namespace slidesorter { 42 class SlideSorter; 43 } } 44 45 namespace sd { namespace slidesorter { namespace model { 46 class PageEnumeration; 47 } } } 48 49 namespace sd { namespace slidesorter { namespace controller { 50 class Transferable; 51 } } } 52 53 namespace sd { namespace slidesorter { namespace view { 54 55 class FramePainter; 56 class LayeredDevice; 57 58 /** The insertion indicator is painted as a vertical or horizonal bar 59 in the space between slides. 60 */ 61 class InsertionIndicatorOverlay 62 : public ILayerPainter, 63 public ::boost::enable_shared_from_this<InsertionIndicatorOverlay> 64 { 65 public: 66 InsertionIndicatorOverlay (SlideSorter& rSlideSorter); 67 virtual ~InsertionIndicatorOverlay (void); 68 69 virtual void SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator); 70 71 void Create (const SdTransferable* pTransferable); 72 73 /** Given a position in model coordinates this method calculates the 74 insertion marker both as an index in the document and as a location 75 used for drawing the insertion indicator. 76 */ 77 void SetLocation (const Point& rPosition); 78 79 Size GetSize (void) const; 80 81 virtual void Paint ( 82 OutputDevice& rDevice, 83 const Rectangle& rRepaintArea); 84 85 bool IsVisible (void) const; 86 void Hide (void); 87 void Show (void); 88 89 Rectangle GetBoundingBox (void) const; 90 91 private: 92 SlideSorter& mrSlideSorter; 93 bool mbIsVisible; 94 const sal_Int32 mnLayerIndex; 95 SharedILayerInvalidator mpLayerInvalidator; 96 // Center of the insertion indicator. 97 Point maLocation; 98 BitmapEx maIcon; 99 Point maIconOffset; 100 ::boost::scoped_ptr<FramePainter> mpShadowPainter; 101 102 void SetPositionAndSize (const Rectangle& rBoundingBox); 103 void SelectRepresentatives ( 104 model::PageEnumeration& rSelection, 105 ::std::vector<model::SharedPageDescriptor>& rDescriptors) const; 106 Point PaintRepresentatives ( 107 OutputDevice& rContent, 108 const Size aPreviewSize, 109 const sal_Int32 nOffset, 110 const ::std::vector<controller::TransferableData::Representative>& rPages) const; 111 void PaintPageCount ( 112 OutputDevice& rDevice, 113 const sal_Int32 nSelectionCount, 114 const Size aPreviewSize, 115 const Point aFirstPageOffset) const; 116 /** Setup the insertion indicator by creating the icon. It consists of 117 scaled down previews of some of the selected pages. 118 */ 119 void Create ( 120 const ::std::vector<controller::TransferableData::Representative>& rPages, 121 const sal_Int32 nSelectionCount); 122 }; 123 124 125 126 } } } // end of namespace ::sd::slidesorter::view 127 128 #endif 129