bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / inc / taskpane / SlideSorterCacheDisplay.hxx
blob8efd30ed904671296457deffa716bf79f4fcb3a5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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.
29 #ifdef DEBUG
30 //#define USE_SLIDE_SORTER_CACHE_DISPLAY
31 #endif
34 #ifdef USE_SLIDE_SORTER_CACHE_DISPLAY
35 #include <taskpane/TaskPaneTreeNode.hxx>
37 #include <map>
38 #include <vector>
39 #include <memory>
41 class Window;
43 #include "svx/svdpage.hxx"
44 #include "drawdoc.hxx"
47 namespace sd { namespace toolpanel {
49 class TreeNode;
51 /** This panel demonstrates how to create a panel for the task pane.
53 class SlideSorterCacheDisplay
54 : public TreeNode
56 public:
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);
68 enum PageStatus {
69 NONE,
70 IN_QUEUE_PRIORITY_0,
71 IN_QUEUE_PRIORITY_1,
72 IN_QUEUE_PRIORITY_2,
73 RENDERING
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;
87 private:
88 static ::std::map<const SdDrawDocument*, SlideSorterCacheDisplay*> maDisplays;
89 static void AddInstance (const SdDrawDocument* pDocument, SlideSorterCacheDisplay* pControl);
90 static void RemoveInstance (SlideSorterCacheDisplay* pControl);
92 ::Window* mpWindow;
93 sal_Int32 mnPageCount;
94 sal_Int32 mnColumnCount;
95 sal_Int32 mnRowCount;
96 Size maCellSize;
97 sal_Int32 mnHorizontalBorder;
98 sal_Int32 mnVerticalBorder;
99 sal_Int32 mnHorizontalGap;
100 sal_Int32 mnVerticalGap;
102 class PageDescriptor
104 public:
105 PageStatus meStatus;
106 bool mbVisible;
107 bool mbUpToDate;
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
121 namespace {
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;
136 switch (nClass)
138 case 0:
139 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_0; break;
140 case 1:
141 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_1; break;
142 case 2:
143 eStatus = ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_2; break;
144 default:
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)
184 #else
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)
191 #endif
193 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */