1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_VIEW_SLSLAYOUTER_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_VIEW_SLSLAYOUTER_HXX
23 #include "SlideSorter.hxx"
24 #include "view/SlsPageObjectLayouter.hxx"
25 #include "view/SlsTheme.hxx"
26 #include <sal/types.h>
27 #include <tools/fract.hxx>
28 #include <vcl/mapmod.hxx>
34 namespace sd
{ namespace slidesorter
{ namespace view
{
38 /** Calculate the size and position of page objects displayed by a slide
39 sorter. The layouter takes into account various input values:
40 1.) Size of the window in which the slide sorter is displayed.
41 2.) Desired and minimal and maximal widths of page objects.
42 3.) Minimal and maximal number of columns.
43 4.) Vertical and horizontal gaps between objects in adjacent columns.
44 5.) Borders around every page object.
45 6.) Vertical and horizontal borders between enclosing page and outer
47 From these it calculates various output values:
48 1.) The width of page objects.
49 2.) The number of columns.
50 3.) The size of the enclosing page.
52 <p>Sizes and lengths are all in pixel except where explicitly stated
55 <p>The GetIndex... methods may return indices that are larger than or
56 equal to (zero based) the number of pages. This is so because the
57 number of pages is not known to the class instances. Indices are
58 calculated with reference to the general grid layout of page
64 enum Orientation
{ HORIZONTAL
, VERTICAL
, GRID
};
68 const ::boost::shared_ptr
<Theme
>& rpTheme
);
71 ::boost::shared_ptr
<PageObjectLayouter
> GetPageObjectLayouter() const;
72 /** Set the interval of valid column counts. When nMinimalColumnCount
73 <= nMaximalColumnCount is not fulfilled then the call is ignored.
74 @param nMinimalColumnCount
75 The default value is 1. The question whether higher values make
76 any sense is left to the caller.
77 @param nMaximalColumnCount
78 The default value is 5.
80 void SetColumnCount (sal_Int32 nMinimalColumnCount
,
81 sal_Int32 nMaximalColumnCount
);
83 /** Central method of this class. It takes the input values and
84 calculates the output values. Both given sizes must not be 0 in any
85 dimension or the call is ignored.
87 This defines the generally layout and specifies whether there may
88 be more than one row or more than one column.
90 The size of the window in pixels that the slide sorter is
91 displayed in. This can differ from the size of mpWindow during
92 detection of whether or not the scroll bars should be visible.
93 @param rPreviewModelSize
94 Size of each page in model coordinates.
96 The map mode of this window is adapted to the new layout of the
99 The return value indicates whether the Get... methods can be
100 used to obtain valid values (<TRUE/>).
103 const Orientation eOrientation
,
104 const Size
& rWindowSize
,
105 const Size
& rPreviewModelSize
,
106 const sal_uInt32 nPageCount
);
108 /** Return the number of columns.
110 sal_Int32
GetColumnCount() const;
112 sal_Int32
GetIndex (const sal_Int32 nRow
, const sal_Int32 nColumn
) const;
114 /** Return the scale factor that can be set at the map mode of the
117 Fraction
GetScaleFactor() const;
119 Size
GetPageObjectSize() const;
121 /** Return the bounding box in window coordinates of the nIndex-th page
124 Rectangle
GetPageObjectBox (
125 const sal_Int32 nIndex
,
126 const bool bIncludeBorderAndGap
= false) const;
128 /** Return the bounding box in model coordinates of the page that
129 contains the given amount of page objects.
131 Rectangle
GetTotalBoundingBox() const;
133 /** Return the index of the first fully or partially visible page
134 object. This takes into account only the vertical dimension.
136 The second index may be larger than the number of existing
139 Range
GetRangeOfVisiblePageObjects (const Rectangle
& rVisibleArea
) const;
141 /** Return the index of the page object that is rendered at the given
144 The position is expected to be in model coordinates relative to
146 @param bIncludePageBorders
147 When <TRUE/> then include the page borders into the calculation,
148 i.e. when a point lies in the border of a page object but not on
149 the actual page area the index of that page is returned;
150 otherwise -1 would be returned to indicate that no page object
152 @param bClampToValidRange
153 When <TRUE/> then values outside the valid range [0,mnPageCount)
154 are mapped to 0 (when smaller than 0) or mnPageCount-1 when
155 equal to or larger than mnPageCount.
156 When <FALSE/> then -1 is returned for values outside the valid range.
158 The returned index may be larger than the number of existing
161 sal_Int32
GetIndexAtPoint (
162 const Point
& rModelPosition
,
163 const bool bIncludePageBorders
= false,
164 const bool bClampToValidRange
= true) const;
166 /** Return an object that describes the logical and visual properties of
167 where to do an insert operation when the user would release the
168 mouse button at the given position after a drag operation and of
169 where and how to display an insertion indicator.
170 @param rModelPosition
171 The position in the model coordinate system for which to
172 determine the insertion page index. The position does not have
173 to be over a page object to return a valid value.
174 @param rIndicatorSize
175 The size of the insertion indicator. This size is used to adapt
176 the location when at the left or right of a row or at the top or
179 The model is used to get access to the selection states of the
180 pages. This in turn is used to determine the visual bounding
183 InsertPosition
GetInsertPosition (
184 const Point
& rModelPosition
,
185 const Size
& rIndicatorSize
,
186 model::SlideSorterModel
& rModel
) const;
188 Range
GetValidHorizontalSizeRange() const;
189 Range
GetValidVerticalSizeRange() const;
191 class Implementation
;
194 ::boost::scoped_ptr
<Implementation
> mpImplementation
;
195 VclPtr
<sd::Window
> mpWindow
;
198 /** Collect all values concerning the logical and visual properties of the
199 insertion position that is used for drag-and-drop and copy-and-past.
205 InsertPosition
& operator= (const InsertPosition
& rInsertPosition
);
206 bool operator== (const InsertPosition
& rInsertPosition
) const;
207 bool operator!= (const InsertPosition
& rInsertPosition
) const;
209 void SetLogicalPosition (
210 const sal_Int32 nRow
,
211 const sal_Int32 nColumn
,
212 const sal_Int32 nIndex
,
213 const bool bIsAtRunStart
,
214 const bool bIsAtRunEnd
,
215 const bool bIsExtraSpaceNeeded
);
216 void SetGeometricalPosition(
217 const Point
& rLocation
,
218 const Point
& rLeadingOffset
,
219 const Point
& rTrailingOffset
);
221 sal_Int32
GetRow() const { return mnRow
; }
222 sal_Int32
GetColumn() const { return mnColumn
; }
223 sal_Int32
GetIndex() const { return mnIndex
; }
224 Point
GetLocation() const { return maLocation
; }
225 Point
GetLeadingOffset() const { return maLeadingOffset
; }
226 Point
GetTrailingOffset() const { return maTrailingOffset
; }
227 bool IsAtRunStart() const { return mbIsAtRunStart
; }
228 bool IsAtRunEnd() const { return mbIsAtRunEnd
; }
229 bool IsExtraSpaceNeeded() const { return mbIsExtraSpaceNeeded
; }
235 bool mbIsAtRunStart
: 1;
236 bool mbIsAtRunEnd
: 1;
237 bool mbIsExtraSpaceNeeded
: 1;
239 Point maLeadingOffset
;
240 Point maTrailingOffset
;
243 } } } // end of namespace ::sd::slidesorter::view
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */