1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sfx2/templatedefaultview.hxx>
#include <sfx2/thumbnailview.hxx>
#include <sfx2/templateviewitem.hxx>
#include <sfx2/sfxresid.hxx>
#include <vcl/builderfactory.hxx>
#include <sfx2/app.hxx>
#include "../doc/doc.hrc"
#define MNI_OPEN 1
#define MNI_EDIT 2
#include <officecfg/Office/Common.hxx>
VCL_BUILDER_FACTORY(TemplateDefaultView)
TemplateDefaultView::TemplateDefaultView( Window* pParent)
: TemplateLocalView(pParent)
, mnTextHeight(30)
{
Rectangle aScreen = Application::GetScreenPosSizePixel(Application::GetDisplayBuiltInScreen());
mnItemMaxSize = std::min(aScreen.GetWidth(),aScreen.GetHeight()) > 800 ? 256 : 192;
ThumbnailView::setItemDimensions( mnItemMaxSize, mnItemMaxSize, mnTextHeight, mnItemPadding );
updateThumbnailDimensions(mnItemMaxSize);
// startcenter specific settings
maFillColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsBackgroundColor::get());
maTextColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsTextColor::get());
maHighlightColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightColor::get());
maHighlightTextColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightTextColor::get());
mfHighlightTransparence = 0.25;
}
void TemplateDefaultView::reload()
{
TemplateLocalView::reload();
// Set preferred width
set_width_request(mnTextHeight + mnItemMaxSize + 2*mnItemPadding);
}
void TemplateDefaultView::showAllTemplates()
{
mnCurRegionId = 0;
maCurRegionName.clear();
insertItems(maAllTemplates, false);
maOpenRegionHdl.Call(nullptr);
}
void TemplateDefaultView::KeyInput( const KeyEvent& rKEvt )
{
ThumbnailView::KeyInput(rKEvt);
}
void TemplateDefaultView::MouseButtonDown( const MouseEvent& rMEvt )
{
if( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
{
size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
ThumbnailViewItem* pItem = ImplGetItem(nPos);
TemplateViewItem* pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
if(pViewItem)
maOpenTemplateHdl.Call(pViewItem);
return;
}
TemplateLocalView::MouseButtonDown(rMEvt);
}
void TemplateDefaultView::createContextMenu()
{
ScopedVclPtrInstance<PopupMenu> pItemMenu;
pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString());
pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString());
deselectItems();
maSelectedItem->setSelection(true);
pItemMenu->SetSelectHdl(LINK(this, TemplateLocalView, ContextMenuSelectHdl));
pItemMenu->Execute(this, Rectangle(maPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
Invalidate();
}
IMPL_LINK(TemplateDefaultView, ContextMenuSelectHdl, Menu*, pMenu, void)
{
sal_uInt16 nMenuId = pMenu->GetCurItemId();
switch(nMenuId)
{
case MNI_OPEN:
maOpenTemplateHdl.Call(maSelectedItem);
break;
case MNI_EDIT:
maEditTemplateHdl.Call(maSelectedItem);
break;
default:
break;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|