summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorRishabh Kumar <kris.kr296@gmail.com>2016-07-04 15:04:39 +0530
committerKatarina Behrens <Katarina.Behrens@cib.de>2016-07-05 07:52:19 +0000
commit0f8ca94774ba66faa2b43af1f904e2886d85bf8a (patch)
tree781edd1b2d47df9fe4a69a1a66eb2e13312a6bc1 /svx
parent308a088211a0df6a75a1f5cd63aa7ee9dcb54536 (diff)
Icon view listbox for XHatchList
Change-Id: I40d39c28bbc217cb63a3857c8a90dba72d196878 Reviewed-on: https://gerrit.libreoffice.org/26896 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/source/tbxctrls/SvxPresetListBox.cxx121
-rw-r--r--svx/source/tbxctrls/tbcontrl.src17
3 files changed, 139 insertions, 0 deletions
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 362cdae46bf0..37b1ef0e6ab6 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -374,6 +374,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/tbxctrls/tbcontrl \
svx/source/tbxctrls/tbxcolorupdate \
svx/source/tbxctrls/SvxColorValueSet \
+ svx/source/tbxctrls/SvxPresetListBox \
svx/source/toolbars/extrusionbar \
svx/source/toolbars/fontworkbar \
svx/source/unodraw/gluepts \
diff --git a/svx/source/tbxctrls/SvxPresetListBox.cxx b/svx/source/tbxctrls/SvxPresetListBox.cxx
new file mode 100644
index 000000000000..6885b70919e0
--- /dev/null
+++ b/svx/source/tbxctrls/SvxPresetListBox.cxx
@@ -0,0 +1,121 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/SvxPresetListBox.hxx>
+#include <svx/xtable.hxx>
+#include <vcl/builderfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/image.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/popupmenuwindow.hxx>
+
+SvxPresetListBox::SvxPresetListBox(vcl::Window* pParent, WinBits nWinStyle)
+ : ValueSet(pParent, nWinStyle)
+{
+ SetEdgeBlending(true);
+ SetExtraSpacing(2);
+}
+
+VCL_BUILDER_DECL_FACTORY(SvxPresetListBox)
+{
+ WinBits nWinBits = WB_TABSTOP;
+
+ OString sBorder = VclBuilder::extractCustomProperty(rMap);
+ if(!sBorder.isEmpty())
+ nWinBits |= WB_BORDER;
+ nWinBits |= (WB_ITEMBORDER| WB_3DLOOK|WB_OWNERDRAWDECORATION|WB_VSCROLL);
+ rRet = VclPtr<SvxPresetListBox>::Create(pParent, nWinBits);
+}
+
+void SvxPresetListBox::Resize()
+{
+ DrawLayout();
+ ValueSet::Resize();
+}
+
+void SvxPresetListBox::Command( const CommandEvent& rEvent )
+{
+ switch(rEvent.GetCommand())
+ {
+ case CommandEventId::ContextMenu:
+ {
+ const sal_uInt16 nIndex = GetSelectItemId();
+ if(nIndex > 0)
+ {
+ Point aPos(rEvent.GetMousePosPixel());
+ ScopedVclPtrInstance<PopupMenu> pMenu(SVX_RES(RID_SVX_PRESET_MENU));
+ FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
+ if(pMenuWindow != nullptr)
+ {
+ pMenuWindow->SetPopupModeFlags(
+ pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose);
+ }
+ pMenu->SetSelectHdl( LINK(this, SvxPresetListBox, OnMenuItemSelected) );
+ pMenu->Execute(this,Rectangle(aPos,Size(1,1)),PopupMenuFlags::ExecuteDown);
+ }
+ }
+ break;
+ default:
+ ValueSet::Command( rEvent );
+ break;
+ }
+}
+
+void SvxPresetListBox::DrawLayout()
+{
+ SetColCount(getColumnCount());
+ SetLineCount(5);
+}
+
+void SvxPresetListBox::FillPresetListBox(XHatchList& pList, sal_uInt32 nStartIndex)
+{
+ const Size aSize(100,60);
+ BitmapEx aBitmap;
+ for(sal_Int32 nIndex = 0; nIndex < pList.Count(); nIndex++, nStartIndex++)
+ {
+ aBitmap = pList.GetBitmapForPreview(nIndex, aSize);
+ InsertItem(nStartIndex, Image(aBitmap), pList.GetHatch( nIndex )->GetName());
+ }
+}
+
+IMPL_LINK_TYPED(SvxPresetListBox, OnMenuItemSelected, Menu*, pMenu, bool)
+{
+ if( pMenu == nullptr )
+ {
+ OSL_ENSURE( pMenu != nullptr, "SvxPresetListBox::OnMenuItemSelected : illegal menu!" );
+ return false;
+ }
+ pMenu->Deactivate();
+ switch(pMenu->GetCurItemId())
+ {
+ default:
+ case RID_SVX_PRESET_RENAME:
+ maRenameHdl.Call(this);
+ break;
+ case RID_SVX_PRESET_DELETE:
+ maDeleteHdl.Call(this);
+ break;
+ }
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src
index c0a5bd4a3f53..8e7a44267f6c 100644
--- a/svx/source/tbxctrls/tbcontrl.src
+++ b/svx/source/tbxctrls/tbcontrl.src
@@ -120,6 +120,23 @@ Menu RID_SVX_STYLE_MENU
};
};
+Menu RID_SVX_PRESET_MENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = RID_SVX_PRESET_RENAME;
+ Text [ en-US ] = "Rename";
+ };
+ MenuItem
+ {
+ Identifier = RID_SVX_PRESET_DELETE;
+ Text [ en-US ] = "Delete";
+ };
+ };
+};
+
String RID_SVXSTR_EXTRAS_CHARBACKGROUND
{
Text [ en-US ] = "Highlight Color" ;