1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlideSorterCacheDisplay.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX
32 #define SD_TASKPANE_SLIDE_SORTER_CACHE_DISPLAY_HXX
34 // Uncomment the define below to activate the slide sorter cache display in
35 // the task pane. Visible slide previews are displayed as large rectangles,
36 // off-screen previews as smaller rectangles. The color shows the state:
37 // green for no action, different shades of yellow for a request being in
38 // the queue, pink for currently being rendered. A diagonal line indicates
39 // that the preview is not up-to-date.
41 //#define USE_SLIDE_SORTER_CACHE_DISPLAY
45 #ifdef USE_SLIDE_SORTER_CACHE_DISPLAY
46 #include <taskpane/TaskPaneTreeNode.hxx>
54 #include "svx/svdpage.hxx"
55 #include "drawdoc.hxx"
58 namespace sd
{ namespace toolpanel
{
63 /** This panel demonstrates how to create a panel for the task pane.
65 class SlideSorterCacheDisplay
69 SlideSorterCacheDisplay (const SdDrawDocument
* pDocument
);
70 virtual ~SlideSorterCacheDisplay (void);
72 void SetParentWindow (::Window
* pParentWindow
);
74 virtual void Paint (const Rectangle
& rBoundingBox
);
75 virtual void Resize (void);
77 static std::auto_ptr
<ControlFactory
> CreateControlFactory (const SdDrawDocument
* pDocument
);
79 static SlideSorterCacheDisplay
* Instance (const SdDrawDocument
* pDocument
);
81 void SetPageCount (sal_Int32 nPageCount
);
89 void SetPageStatus (sal_Int32 nPageIndex
, PageStatus eStatus
);
90 void SetPageVisibility (sal_Int32 nPageIndex
, bool bVisible
);
91 void SetUpToDate (sal_Int32 nPageIndex
, bool bUpToDate
);
93 virtual Size
GetPreferredSize (void);
94 virtual sal_Int32
GetPreferredWidth (sal_Int32 nHeigh
);
95 virtual sal_Int32
GetPreferredHeight (sal_Int32 nWidth
);
96 virtual ::Window
* GetWindow (void);
97 virtual bool IsResizable (void);
98 virtual bool IsExpandable (void) const;
99 virtual bool IsExpanded (void) const;
102 static ::std::map
<const SdDrawDocument
*, SlideSorterCacheDisplay
*> maDisplays
;
103 static void AddInstance (const SdDrawDocument
* pDocument
, SlideSorterCacheDisplay
* pControl
);
104 static void RemoveInstance (SlideSorterCacheDisplay
* pControl
);
107 sal_Int32 mnPageCount
;
108 sal_Int32 mnColumnCount
;
109 sal_Int32 mnRowCount
;
111 sal_Int32 mnHorizontalBorder
;
112 sal_Int32 mnVerticalBorder
;
113 sal_Int32 mnHorizontalGap
;
114 sal_Int32 mnVerticalGap
;
123 typedef ::std::vector
<PageDescriptor
> PageDescriptorList
;
124 PageDescriptorList maPageDescriptors
;
126 Rectangle
GetPageBox (sal_Int32 nPageIndex
);
128 void ProvideSize (sal_Int32 nPageIndex
);
130 void PaintPage (sal_Int32 nPageIndex
);
133 } } // end of namespace ::sd::toolpanel
137 void SscdSetStatus (const SdrPage
* pPage
,
138 ::sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus
)
140 ::sd::toolpanel::SlideSorterCacheDisplay
* pDisplay
141 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
142 dynamic_cast<SdDrawDocument
*>(pPage
->GetModel()));
143 if (pDisplay
!= NULL
)
144 pDisplay
->SetPageStatus((pPage
->GetPageNum()-1)/2, eStatus
);
147 void SscdSetRequestClass (const SdrPage
* pPage
, sal_Int32 nClass
)
149 sd::toolpanel::SlideSorterCacheDisplay::PageStatus eStatus
;
153 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_0
; break;
155 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_1
; break;
157 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::IN_QUEUE_PRIORITY_2
; break;
159 eStatus
= ::sd::toolpanel::SlideSorterCacheDisplay::NONE
; break;
161 SscdSetStatus(pPage
,eStatus
);
164 void SscdSetVisibility (const SdrModel
* pModel
, sal_Int32 nIndex
, bool bVisible
)
166 ::sd::toolpanel::SlideSorterCacheDisplay
* pDisplay
167 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
168 dynamic_cast<const SdDrawDocument
*>(pModel
));
169 if (pDisplay
!= NULL
)
170 pDisplay
->SetPageVisibility(nIndex
, bVisible
);
175 void SscdSetUpToDate (const SdrPage
* pPage
, bool bUpToDate
)
177 ::sd::toolpanel::SlideSorterCacheDisplay
* pDisplay
178 = ::sd::toolpanel::SlideSorterCacheDisplay::Instance(
179 dynamic_cast<const SdDrawDocument
*>(pPage
->GetModel()));
180 if (pDisplay
!= NULL
)
181 pDisplay
->SetUpToDate((pPage
->GetPageNum()-1)/2, bUpToDate
);
186 #define SSCD_SET_REQUEST_CLASS(Page,RequestClass) \
187 SscdSetRequestClass(Page,RequestClass)
188 #define SSCD_SET_STATUS(RequestData,Status) \
189 SscdSetStatus(RequestData,::sd::toolpanel::SlideSorterCacheDisplay::Status)
190 #define SSCD_SET_VISIBILITY(Model,Index,Visible) \
191 SscdSetVisibility(Model,Index,Visible)
192 #define SSCD_SET_UPTODATE(Page,UpToDate) \
193 SscdSetUpToDate(Page,UpToDate)
200 #define SSCD_SET_REQUEST_CLASS(Page,RequestClass)
201 #define SSCD_SET_STATUS(RequestData,Status)
202 #define SSCD_SET_VISIBILITY(Model,Index,Visible)
203 #define SSCD_SET_UPTODATE(Page,UpToDate)