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 SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX
21 #define SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX
23 // Uncomment the define below to activate the slide sorter cache display in
24 // the task pane. Visible slide previews are displayed as large rectangles,
25 // off-screen previews as smaller rectangles. The color shows the state:
26 // green for no action, different shades of yellow for a request being in
27 // the queue, pink for currently being rendered. A diagonal line indicates
28 // that the preview is not up-to-date.
30 //#define USE_SLIDE_SORTER_CACHE_DISPLAY
34 #ifdef USE_SLIDE_SORTER_CACHE_DISPLAY
35 #include <taskpane/TaskPaneTreeNode.hxx>
43 #include "svx/svdpage.hxx"
44 #include "drawdoc.hxx"
47 namespace sd
{ namespace toolpanel
{
51 /** This panel demonstrates how to create a panel for the task pane.
53 class SlideSorterCacheDisplay
57 SlideSorterCacheDisplay (const SdDrawDocument
* pDocument
);
58 virtual ~SlideSorterCacheDisplay (void);
60 void SetParentWindow (::Window
* pParentWindow
);
62 virtual void Paint (const Rectangle
& rBoundingBox
);
63 virtual void Resize (void);
65 static SlideSorterCacheDisplay
* Instance (const SdDrawDocument
* pDocument
);
67 void SetPageCount (sal_Int32 nPageCount
);
75 void SetPageStatus (sal_Int32 nPageIndex
, PageStatus eStatus
);
76 void SetPageVisibility (sal_Int32 nPageIndex
, bool bVisible
);
77 void SetUpToDate (sal_Int32 nPageIndex
, bool bUpToDate
);
79 virtual Size
GetPreferredSize (void);
80 virtual sal_Int32
GetPreferredWidth (sal_Int32 nHeigh
);
81 virtual sal_Int32
GetPreferredHeight (sal_Int32 nWidth
);
82 virtual ::Window
* GetWindow (void);
83 virtual bool IsResizable (void);
84 virtual bool IsExpandable (void) const;
85 virtual bool IsExpanded (void) const;
88 static ::std::map
<const SdDrawDocument
*, SlideSorterCacheDisplay
*> maDisplays
;
89 static void AddInstance (const SdDrawDocument
* pDocument
, SlideSorterCacheDisplay
* pControl
);
90 static void RemoveInstance (SlideSorterCacheDisplay
* pControl
);
93 sal_Int32 mnPageCount
;
94 sal_Int32 mnColumnCount
;
97 sal_Int32 mnHorizontalBorder
;
98 sal_Int32 mnVerticalBorder
;
99 sal_Int32 mnHorizontalGap
;
100 sal_Int32 mnVerticalGap
;
109 typedef ::std::vector
<PageDescriptor
> PageDescriptorList
;
110 PageDescriptorList maPageDescriptors
;
112 Rectangle
GetPageBox (sal_Int32 nPageIndex
);
114 void ProvideSize (sal_Int32 nPageIndex
);
116 void PaintPage (sal_Int32 nPageIndex
);
119 } } // end of namespace ::sd::toolpanel
123 void SscdSetStatus (const SdrPage
* pPage
,
124 ::sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus
)
126 ::sd::toolpanel::SlideSorterCacheDisplay
* pDisplay
127 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
128 dynamic_cast<SdDrawDocument
*>(pPage
->GetModel()));
129 if (pDisplay
!= NULL
)
130 pDisplay
->SetPageStatus((pPage
->GetPageNum()-1)/2, eStatus
);
133 void SscdSetRequestClass (const SdrPage
* pPage
, sal_Int32 nClass
)
135 sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus
;
139 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_0
; break;
141 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_1
; break;
143 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_2
; break;
145 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::NONE
; break;
147 SscdSetStatus(pPage
,eStatus
);
150 void SscdSetVisibility (const SdrModel
* pModel
, sal_Int32 nIndex
, bool bVisible
)
152 ::sd::toolpanel::SlideSorterCacheDisplay
* pDisplay
153 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
154 dynamic_cast<const SdDrawDocument
*>(pModel
));
155 if (pDisplay
!= NULL
)
156 pDisplay
->SetPageVisibility(nIndex
, bVisible
);
161 void SscdSetUpToDate (const SdrPage
* pPage
, bool bUpToDate
)
163 ::sd::toolpanel::SlideSorterCacheDisplay
* pDisplay
164 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
165 dynamic_cast<const SdDrawDocument
*>(pPage
->GetModel()));
166 if (pDisplay
!= NULL
)
167 pDisplay
->SetUpToDate((pPage
->GetPageNum()-1)/2, bUpToDate
);
172 #define SSCD_SET_REQUEST_CLASS(Page,RequestClass) \
173 SscdSetRequestClass(Page,RequestClass)
174 #define SSCD_SET_STATUS(RequestData,Status) \
175 SscdSetStatus(RequestData,::sd::toolpanel::SlideSorterCacheDisplay::Status)
176 #define SSCD_SET_VISIBILITY(Model,Index,Visible) \
177 SscdSetVisibility(Model,Index,Visible)
178 #define SSCD_SET_UPTODATE(Page,UpToDate) \
179 SscdSetUpToDate(Page,UpToDate)
186 #define SSCD_SET_REQUEST_CLASS(Page,RequestClass)
187 #define SSCD_SET_STATUS(RequestData,Status)
188 #define SSCD_SET_VISIBILITY(Model,Index,Visible)
189 #define SSCD_SET_UPTODATE(Page,UpToDate)
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */