diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-12-13 13:34:29 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-12-13 15:45:54 +0100 |
commit | 7bacb834d36b06030378c64997cc20e852b195f1 (patch) | |
tree | 2312012d1129da634e71288b975543191dc6b65d /sfx2 | |
parent | e4e8f246452da4a81ffd92664c9731e0e195b032 (diff) |
Template Manager: add path controls to overlay and removed name editing
Change-Id: I0d27edff4ba6c25fd9dc85c80ac5e3287fbd4207
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/templatelocalview.hxx | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/templateremoteview.hxx | 7 | ||||
-rw-r--r-- | sfx2/inc/sfx2/templateview.hxx | 22 | ||||
-rw-r--r-- | sfx2/inc/templatedlg.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/control/templateremoteview.cxx | 27 | ||||
-rw-r--r-- | sfx2/source/control/templateview.cxx | 163 | ||||
-rw-r--r-- | sfx2/source/control/templateview.hrc | 4 | ||||
-rw-r--r-- | sfx2/source/control/templateview.src | 22 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 7 |
10 files changed, 42 insertions, 238 deletions
diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx index 9a101f271e99..dac7fedf8634 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -77,8 +77,6 @@ private: virtual void OnItemDblClicked (ThumbnailViewItem *pRegionItem); - DECL_LINK(ChangeNameHdl, TemplateView*); - private: bool mbFilteredResults; // Flag keep track if overlay has been filtered so folders can get filtered too afterwards diff --git a/sfx2/inc/sfx2/templateremoteview.hxx b/sfx2/inc/sfx2/templateremoteview.hxx index bbea147415b5..1d7e49d15002 100644 --- a/sfx2/inc/sfx2/templateremoteview.hxx +++ b/sfx2/inc/sfx2/templateremoteview.hxx @@ -34,8 +34,6 @@ public: virtual void showOverlay (bool bVisible); - void setOverlayChangeNameHdl (const Link &rLink); - bool loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh); const std::vector<TemplateRemoteViewItem*>& getRepositories () const { return maRepositories; } @@ -48,12 +46,7 @@ public: private: - DECL_LINK(ChangeNameHdl, TemplateView*); - -private: - bool mbIsSynced; - Link maChangeNameHdl; std::vector<TemplateRemoteViewItem*> maRepositories; com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv; }; diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index 881c68dc3514..6e81ea491186 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -12,7 +12,8 @@ #include <sfx2/templateproperties.hxx> #include <sfx2/thumbnailview.hxx> -#include <vcl/image.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> class Edit; class TemplateViewItem; @@ -33,37 +34,26 @@ public: const OUString& getName () const { return maName; } - virtual void Paint (const Rectangle &rRect); - void InsertItems (const std::vector<TemplateItemProperties> &rTemplates); void setDblClickHdl (const Link &rLink) { maDblClickHdl = rLink; } - void setChangeNameHdl (const Link &rLink) { maChangeNameHdl = rLink; } - - void setCloseHdl (const Link &rLink) { maCloseHdl = rLink; } + void setCloseHdl (const Link &rLink) { maAllButton.SetClickHdl(rLink); } protected: virtual void Resize (); - virtual void MouseButtonDown (const MouseEvent &rMEvt); - virtual void OnItemDblClicked (ThumbnailViewItem *pItem); - DECL_LINK (ChangeNameHdl, void*); - private: - Image maCloseImg; - bool mbRenderTitle; + Control maButtons; + PushButton maAllButton; + FixedText maFTName; sal_uInt16 mnId; OUString maName; Link maDblClickHdl; - Link maChangeNameHdl; - Link maCloseHdl; - - Edit *mpEditName; }; #endif // TEMPLATEVIEW_HXX diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx index bbdcbda66d22..f24c8e44b301 100644 --- a/sfx2/inc/templatedlg.hxx +++ b/sfx2/inc/templatedlg.hxx @@ -71,8 +71,6 @@ private: DECL_LINK(SearchUpdateHdl, void*); - DECL_LINK(RepositoryChangeNameHdl, void*); - void OnTemplateImport (); void OnTemplateSearch (); void OnTemplateEdit (); diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index ba0c1f232595..749eaa0fbfde 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -89,7 +89,6 @@ TemplateLocalView::TemplateLocalView ( Window* pParent, const ResId& rResId, boo mpDocTemplates(new SfxDocumentTemplates) { mpItemView->SetColor(GetSettings().GetStyleSettings().GetFieldColor()); - mpItemView->setChangeNameHdl(LINK(this,TemplateLocalView,ChangeNameHdl)); } TemplateLocalView::~TemplateLocalView() @@ -690,29 +689,6 @@ void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) showOverlay(true); } -IMPL_LINK(TemplateLocalView, ChangeNameHdl, TemplateView*, pView) -{ - sal_uInt16 nRegionId = pView->getId(); - sal_uInt16 nItemId = nRegionId + 1; - - if (!mpDocTemplates->SetName(pView->getName(),nRegionId,USHRT_MAX)) - return false; - - for (size_t i = 0; i < mItemList.size(); ++i) - { - if (mItemList[i]->mnId == nItemId) - { - mItemList[i]->maTitle = pView->getName(); - mItemList[i]->calculateItemsPosition(mnThumbnailHeight,mnDisplayHeight, - mnItemPadding,mpItemAttrs->nMaxTextLenght,mpItemAttrs); - Invalidate(); - break; - } - } - - return true; -} - static void lcl_updateThumbnails (TemplateLocalViewItem *pItem) { pItem->maPreview1.Clear(); diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx index 4f9f1e0639b3..a04e4712a243 100644 --- a/sfx2/source/control/templateremoteview.cxx +++ b/sfx2/source/control/templateremoteview.cxx @@ -50,7 +50,6 @@ TemplateRemoteView::TemplateRemoteView (Window *pParent, WinBits nWinStyle, bool , mbIsSynced(true) { mpItemView->SetColor(Color(COL_WHITE)); - mpItemView->setChangeNameHdl(LINK(this,TemplateRemoteView,ChangeNameHdl)); Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); Reference< XInteractionHandler > xGlobalInteractionHandler( @@ -110,11 +109,6 @@ void TemplateRemoteView::showOverlay (bool bVisible) } } -void TemplateRemoteView::setOverlayChangeNameHdl(const Link &rLink) -{ - maChangeNameHdl = rLink; -} - bool TemplateRemoteView::loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh) { TemplateRemoteViewItem *pItem = NULL; @@ -312,25 +306,4 @@ void TemplateRemoteView::syncRepositories() const } } -IMPL_LINK (TemplateRemoteView, ChangeNameHdl, TemplateView*, pView) -{ - bool bRet = false; - - // check if there isnt another repository with the same name. - for (size_t i = 0, n = maRepositories.size(); i < n; ++i) - { - if (maRepositories[i]->mnId == pView->getId()) - { - maRepositories[i]->maTitle = pView->getName(); - - bRet = true; - mbIsSynced = false; - maChangeNameHdl.Call(this); - break; - } - } - - return bRet; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index 23f10956b912..2efbbda1019c 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -24,7 +24,7 @@ #include "templateview.hrc" -#define EDIT_HEIGHT 20 +#define EDIT_HEIGHT 30 using namespace basegfx; using namespace basegfx::tools; @@ -33,75 +33,23 @@ using namespace drawinglayer::primitive2d; TemplateView::TemplateView (Window *pParent) : ThumbnailView(pParent,WB_VSCROLL), - maCloseImg(SfxResId(IMG_TEMPLATE_VIEW_CLOSE)), - mbRenderTitle(true), - mnId(0), - mpEditName(new Edit(this, WB_BORDER | WB_HIDE)) + maButtons(this, SfxResId(CONTROL_BUTTONS)), + maAllButton(&maButtons, SfxResId(BTN_ALL_TEMPLATES)), + maFTName(&maButtons, SfxResId(FT_NAME)), + mnId(0) { - mnHeaderHeight = 30; + mnHeaderHeight = maButtons.GetSizePixel().getHeight(); + maAllButton.SetStyle(maAllButton.GetStyle() | WB_FLATBUTTON); } TemplateView::~TemplateView () { - delete mpEditName; } void TemplateView::setName (const OUString &rName) { maName = rName; - mpEditName->SetText(OUString()); -} - -void TemplateView::Paint (const Rectangle &rRect) -{ - ThumbnailView::Paint(rRect); - - int nCount = 0; - int nMaxCount = 1; - - if (mbRenderTitle) - ++nMaxCount; - - Primitive2DSequence aSeq(nMaxCount); - TextLayouterDevice aTextDev; - - // Draw centered region name - Point aPos; - Size aWinSize = GetOutputSizePixel(); - - if (mbRenderTitle) - { - aPos.X() = (aWinSize.getWidth() - aTextDev.getTextWidth(maName,0,maName.getLength()))/2; - aPos.Y() = aTextDev.getTextHeight() + (mnHeaderHeight - aTextDev.getTextHeight())/2; - - basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix( - mpItemAttrs->aFontSize.getX(), mpItemAttrs->aFontSize.getY(), - double( aPos.X() ), double( aPos.Y() ) ) ); - - aSeq[nCount++] = Primitive2DReference( - new TextSimplePortionPrimitive2D(aTextMatrix, - maName,0,maName.getLength(), - std::vector< double >( ), - mpItemAttrs->aFontAttr, - com::sun::star::lang::Locale(), - Color(COL_BLACK).getBColor() ) ); - } - - // Draw close icon - Size aImageSize = maCloseImg.GetSizePixel(); - - aPos.Y() = (mnHeaderHeight - aImageSize.Height())/2; - aPos.X() = aWinSize.Width() - aImageSize.Width() - aPos.Y(); - - aSeq[nCount] = Primitive2DReference( new FillBitmapPrimitive2D( - createTranslateB2DHomMatrix(aPos.X(),aPos.Y()), - FillBitmapAttribute(maCloseImg.GetBitmapEx(), - B2DPoint(0,0), - B2DVector(aImageSize.Width(),aImageSize.Height()), - false) - )); - - mpProcessor->process(aSeq); + maFTName.SetText(maName); } void TemplateView::InsertItems (const std::vector<TemplateItemProperties> &rTemplates) @@ -127,105 +75,26 @@ void TemplateView::InsertItems (const std::vector<TemplateItemProperties> &rTemp void TemplateView::Resize() { - // Set editbox size and position Size aWinSize = GetOutputSize(); - Size aEditSize(aWinSize.getWidth()/2,EDIT_HEIGHT); + // Set the buttons panel and buttons size + Size aPanelSize = maButtons.GetSizePixel(); + int nDeltaW = aWinSize.getWidth() - aPanelSize.getWidth(); + aPanelSize.setWidth(aWinSize.getWidth()); + maButtons.SetSizePixel(aPanelSize); - Point aPos; - aPos.X() = (aWinSize.getWidth() - aEditSize.getWidth())/2; - aPos.Y() = (mnHeaderHeight - aEditSize.getHeight())/2; - - mpEditName->SetPosSizePixel(aPos,aEditSize); + Size aNameSize = maFTName.GetSizePixel(); + aNameSize.setWidth(aNameSize.getWidth() + nDeltaW); + maFTName.SetSizePixel(aNameSize); ThumbnailView::Resize(); } -void TemplateView::MouseButtonDown (const MouseEvent &rMEvt) -{ - if (rMEvt.IsLeft()) - { - // Check if we are editing title - if (mpEditName->IsVisible()) - { - mpEditName->Show(false); - mbRenderTitle = true; - - // Update name if its not empty - OUString aTmp = mpEditName->GetText(); - - if (!aTmp.isEmpty()) - { - PostUserEvent(LINK(this,TemplateView,ChangeNameHdl)); - } - else - { - mpEditName->SetText(OUString()); - Invalidate(); - } - - return; - } - - Size aWinSize = GetOutputSizePixel(); - Size aImageSize = maCloseImg.GetSizePixel(); - - Point aPos; - aPos.Y() = (mnHeaderHeight - aImageSize.Height())/2; - aPos.X() = aWinSize.Width() - aImageSize.Width() - aPos.Y(); - - Rectangle aImgRect(aPos,aImageSize); - - if (aImgRect.IsInside(rMEvt.GetPosPixel())) - { - maCloseHdl.Call(this); - } - else - { - drawinglayer::primitive2d::TextLayouterDevice aTextDev; - aTextDev.setFontAttribute(mpItemAttrs->aFontAttr, - mpItemAttrs->aFontSize.getX(), mpItemAttrs->aFontSize.getY(), - com::sun::star::lang::Locale() ); - - float fTextWidth = aTextDev.getTextWidth(maName,0,maName.getLength()); - - aPos.X() = (aWinSize.getWidth() - fTextWidth)/2; - aPos.Y() = (mnHeaderHeight - aTextDev.getTextHeight())/2; - - Rectangle aTitleRect(aPos,Size(fTextWidth,aTextDev.getTextHeight())); - - if (aTitleRect.IsInside(rMEvt.GetPosPixel())) - { - mbRenderTitle = false; - - Invalidate(); - mpEditName->Show(); - } - } - } - - ThumbnailView::MouseButtonDown(rMEvt); -} - void TemplateView::OnItemDblClicked(ThumbnailViewItem *pItem) { maDblClickHdl.Call(pItem); } -IMPL_LINK_NOARG(TemplateView, ChangeNameHdl) -{ - OUString aTmp = maName; - maName = mpEditName->GetText(); - - if (!maChangeNameHdl.Call(this)) - maName = aTmp; - - mpEditName->SetText(OUString()); - - Invalidate(); - return 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templateview.hrc b/sfx2/source/control/templateview.hrc index dc496f2cae37..e629c3f88fb8 100644 --- a/sfx2/source/control/templateview.hrc +++ b/sfx2/source/control/templateview.hrc @@ -6,4 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#define IMG_TEMPLATE_VIEW_CLOSE 256 +#define BTN_ALL_TEMPLATES 256 +#define CONTROL_BUTTONS 257 +#define FT_NAME 258 diff --git a/sfx2/source/control/templateview.src b/sfx2/source/control/templateview.src index 8252ee9a590b..d2711a7c984b 100644 --- a/sfx2/source/control/templateview.src +++ b/sfx2/source/control/templateview.src @@ -8,10 +8,22 @@ #include "templateview.hrc" -Image IMG_TEMPLATE_VIEW_CLOSE +Control CONTROL_BUTTONS { - ImageBitmap = Bitmap - { - File = "closedoc.png"; - }; + Size = MAP_APPFONT( 290, 17 ); + Border = True; + TabStop = False; +}; + +PushButton BTN_ALL_TEMPLATES +{ + Pos = MAP_APPFONT( 1, 1 ); + Size = MAP_APPFONT( 50, 14 ); + Text [ en-US ] = "All Templates"; +}; + +FixedText FT_NAME +{ + Pos = MAP_APPFONT( 52, 3 ); + Size = MAP_APPFONT( 238, 12 ); }; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 548fdd92e055..e540b0dcdd29 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -211,7 +211,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) mpOnlineView->setOverlayItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl)); mpOnlineView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl)); mpOnlineView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl)); - mpOnlineView->setOverlayChangeNameHdl(LINK(this,SfxTemplateManagerDlg,RepositoryChangeNameHdl)); mpSearchView->SetSizePixel(aThumbSize); mpSearchView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH); @@ -715,12 +714,6 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl) return 0; } -IMPL_LINK_NOARG (SfxTemplateManagerDlg, RepositoryChangeNameHdl) -{ - createRepositoryMenu(); - return 0; -} - void SfxTemplateManagerDlg::OnTemplateImport () { sal_Int16 nDialogType = |