diff options
author | Rishabh Kumar <kris.kr296@gmail.com> | 2016-07-04 15:04:39 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-07-05 07:52:19 +0000 |
commit | 0f8ca94774ba66faa2b43af1f904e2886d85bf8a (patch) | |
tree | 781edd1b2d47df9fe4a69a1a66eb2e13312a6bc1 | |
parent | 308a088211a0df6a75a1f5cd63aa7ee9dcb54536 (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>
-rw-r--r-- | extras/source/glade/libreoffice-catalog.xml.in | 3 | ||||
-rw-r--r-- | include/svx/SvxPresetListBox.hxx | 62 | ||||
-rw-r--r-- | include/svx/dialogs.hrc | 5 | ||||
-rw-r--r-- | svx/Library_svxcore.mk | 1 | ||||
-rw-r--r-- | svx/source/tbxctrls/SvxPresetListBox.cxx | 121 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.src | 17 |
6 files changed, 209 insertions, 0 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 8744ebfb6bde..a822164e04bc 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -385,6 +385,9 @@ <glade-widget-class title="SvxColorValueSet" name="svxcorelo-SvxColorValueSet" generic-name="Set of Value Options" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> + <glade-widget-class title="SvxPresetListBox" name="svxcorelo-SvxPresetListBox" + generic-name="Set of Value Options" parent="GtkDrawingArea" + icon-name="widget-gtk-drawingarea"/> <glade-widget-class title="SwColumnValueSet" name="swuilo-ColumnValueSet" generic-name="Set of Value Options" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> diff --git a/include/svx/SvxPresetListBox.hxx b/include/svx/SvxPresetListBox.hxx new file mode 100644 index 000000000000..228ad2d49eb3 --- /dev/null +++ b/include/svx/SvxPresetListBox.hxx @@ -0,0 +1,62 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SVX_SVXPRESETLISTBOX_HXX +#define INCLUDED_SVX_SVXPRESETLISTBOX_HXX + +#include <svtools/svtdllapi.h> +#include <svx/XPropertyTable.hxx> +#include <vcl/ctrl.hxx> +#include <svtools/valueset.hxx> +#include <svx/xtable.hxx> + +class SVX_DLLPUBLIC SvxPresetListBox : public ValueSet +{ +private: + sal_uInt32 nColCount = 2; + sal_uInt32 nRowCount = 5; + Link<SvxPresetListBox*,void> maRenameHdl; + Link<SvxPresetListBox*,void> maDeleteHdl; + + DECL_LINK_TYPED( OnMenuItemSelected, Menu*, bool ); +public: + SvxPresetListBox(vcl::Window* pParent, WinBits nWinStyle = WB_ITEMBORDER); + + virtual void Resize() override; + virtual void Command( const CommandEvent& rEvt ) override; + sal_uInt32 getColumnCount() const { return nColCount; } + + void setColumnCount( const sal_uInt32 nCount ) { nColCount = nCount; } + void setRowCount( const sal_uInt32 nRow ) { nRowCount = nRow; } + void SetRenameHdl( const Link<SvxPresetListBox*,void>& rLink ) + { + maRenameHdl = rLink; + } + void SetDeleteHdl( const Link<SvxPresetListBox*,void>& rLink ) + { + maDeleteHdl = rLink; + } + void FillPresetListBox(XHatchList& pList, sal_uInt32 nStartIndex = 1); + void DrawLayout(); + +}; + +#endif // INCLUDED_SVX_SVXPRESETLISTBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index da820fcdf734..de9f394cf63c 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -182,6 +182,11 @@ #define RID_SVX_UPDATE_STYLE (RID_SVX_START + 122) #define RID_SVX_MODIFY_STYLE (RID_SVX_START + 123) +// for fill style preset listbox +#define RID_SVX_PRESET_MENU (RID_SVX_START + 124) +#define RID_SVX_PRESET_RENAME (RID_SVX_START + 125) +#define RID_SVX_PRESET_DELETE (RID_SVX_START + 126) + #define RID_SVXCTRL_RECTBTNS (RID_SVX_START + 226) // ResId's for Starone impl. bitmaps 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" ; |