Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : */
9 : :
10 : : #ifndef __SFX2_TEMPLATEABSTRACTVIEW_HXX__
11 : : #define __SFX2_TEMPLATEABSTRACTVIEW_HXX__
12 : :
13 : : #include <sfx2/thumbnailview.hxx>
14 : :
15 : : //template thumbnail item defines
16 : : #define TEMPLATE_ITEM_MAX_WIDTH 192
17 : : #define TEMPLATE_ITEM_MAX_HEIGHT 160
18 : : #define TEMPLATE_ITEM_PADDING 5
19 : : #define TEMPLATE_ITEM_SPACE 30
20 : : #define TEMPLATE_ITEM_MAX_TEXT_LENGTH 20
21 : : #define TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT 128
22 : :
23 : : //template thumbnail image defines
24 : : #define TEMPLATE_THUMBNAIL_MAX_HEIGHT 128 - 2*TEMPLATE_ITEM_PADDING
25 : : #define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING
26 : :
27 : : class TemplateView;
28 : : class SfxDocumentTemplates;
29 : :
30 : : enum FILTER_APPLICATION
31 : : {
32 : : FILTER_APP_NONE,
33 : : FILTER_APP_WRITER,
34 : : FILTER_APP_CALC,
35 : : FILTER_APP_IMPRESS,
36 : : FILTER_APP_DRAW
37 : : };
38 : :
39 : : // Display template items depending on the generator application
40 : : class ViewFilter_Application
41 : : {
42 : : public:
43 : :
44 : 0 : ViewFilter_Application (FILTER_APPLICATION App)
45 : 0 : : mApp(App)
46 : 0 : {}
47 : :
48 : : bool operator () (const ThumbnailViewItem *pItem);
49 : :
50 : : private:
51 : :
52 : : FILTER_APPLICATION mApp;
53 : : };
54 : :
55 : 0 : class ViewFilter_Keyword
56 : : {
57 : : public:
58 : :
59 : 0 : ViewFilter_Keyword (const OUString &rKeyword)
60 : 0 : : maKeyword(rKeyword)
61 : 0 : {}
62 : :
63 : : bool operator () (const ThumbnailViewItem *pItem);
64 : :
65 : : private:
66 : :
67 : : OUString maKeyword;
68 : : };
69 : :
70 : : class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView
71 : : {
72 : : public:
73 : :
74 : : TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren);
75 : :
76 : : TemplateAbstractView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
77 : :
78 : : virtual ~TemplateAbstractView ();
79 : :
80 : : // Fill view with template folders thumbnails
81 : : virtual void Populate () = 0;
82 : :
83 : : virtual void reload () = 0;
84 : :
85 : : virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp) = 0;
86 : :
87 : : virtual void showOverlay (bool bVisible) = 0;
88 : :
89 : : void setItemDimensions (long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding);
90 : :
91 : : sal_uInt16 getOverlayRegionId () const;
92 : :
93 : : const OUString& getOverlayName () const;
94 : :
95 : : // Check if the overlay is visible or not.
96 : : bool isOverlayVisible () const;
97 : :
98 : : void deselectOverlayItems ();
99 : :
100 : : void deselectOverlayItem (const sal_uInt16 nItemId);
101 : :
102 : : void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*,
103 : : const ThumbnailViewItem*) > &func);
104 : :
105 : : virtual void filterTemplatesByKeyword (const OUString &rKeyword);
106 : :
107 : 0 : void setOverlayItemStateHdl (const Link &aLink) { maOverlayItemStateHdl = aLink; }
108 : :
109 : : void setOverlayDblClickHdl (const Link &rLink);
110 : :
111 : : void setOverlayCloseHdl (const Link &rLink);
112 : :
113 : : static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height);
114 : :
115 : : static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height);
116 : :
117 : : protected:
118 : :
119 : : virtual void Resize();
120 : :
121 : : virtual void Paint( const Rectangle& rRect );
122 : :
123 : : virtual void DrawItem (ThumbnailViewItem *pItem);
124 : :
125 : : virtual void OnSelectionMode (bool bMode);
126 : :
127 : : DECL_LINK(OverlayItemStateHdl, const ThumbnailViewItem*);
128 : :
129 : : protected:
130 : :
131 : : TemplateView *mpItemView;
132 : : Link maOverlayItemStateHdl;
133 : : };
134 : :
135 : : #endif // __SFX2_TEMPLATEABSTRACTVIEW_HXX__
136 : :
137 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|