2010-01-27 11:41:30 +01:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* $RCSfile: baseprimitive2d.hxx,v $
|
|
|
|
*
|
|
|
|
* $Revision: 1.8 $
|
|
|
|
*
|
|
|
|
* last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $
|
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2010-03-02 15:54:17 +01:00
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2010-01-27 11:41:30 +01:00
|
|
|
#include "view/SlsPageObjectPainter.hxx"
|
|
|
|
|
|
|
|
#include "model/SlsPageDescriptor.hxx"
|
|
|
|
#include "view/SlideSorterView.hxx"
|
|
|
|
#include "view/SlsPageObjectLayouter.hxx"
|
|
|
|
#include "view/SlsLayouter.hxx"
|
2010-02-12 13:58:24 +01:00
|
|
|
#include "view/SlsTheme.hxx"
|
2010-04-27 11:31:16 +02:00
|
|
|
#include "view/SlsButtonBar.hxx"
|
2010-03-02 15:54:17 +01:00
|
|
|
#include "SlsFramePainter.hxx"
|
2010-01-27 11:41:30 +01:00
|
|
|
#include "cache/SlsPageCache.hxx"
|
|
|
|
#include "controller/SlsProperties.hxx"
|
|
|
|
#include "Window.hxx"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/vclenum.hxx>
|
2010-02-12 13:58:24 +01:00
|
|
|
#include <vcl/virdev.hxx>
|
2010-05-26 13:35:57 +02:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2010-01-27 11:41:30 +01:00
|
|
|
|
|
|
|
using namespace ::drawinglayer::primitive2d;
|
|
|
|
|
|
|
|
namespace sd { namespace slidesorter { namespace view {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
UINT8 Blend (
|
|
|
|
const UINT8 nValue1,
|
|
|
|
const UINT8 nValue2,
|
|
|
|
const double nWeight)
|
|
|
|
{
|
|
|
|
const double nValue (nValue1*(1-nWeight) + nValue2 * nWeight);
|
|
|
|
if (nValue < 0)
|
|
|
|
return 0;
|
|
|
|
else if (nValue > 255)
|
|
|
|
return 255;
|
|
|
|
else
|
|
|
|
return (UINT8)nValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt8 ClampColorChannel (const double nValue)
|
|
|
|
{
|
|
|
|
if (nValue <= 0)
|
|
|
|
return 0;
|
|
|
|
else if (nValue >= 255)
|
|
|
|
return 255;
|
|
|
|
else
|
|
|
|
return sal_uInt8(nValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt8 CalculateColorChannel(
|
|
|
|
const double nColor1,
|
|
|
|
const double nColor2,
|
|
|
|
const double nAlpha1,
|
|
|
|
const double nAlpha2,
|
|
|
|
const double nAlpha0)
|
|
|
|
{
|
|
|
|
if (nAlpha0 == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const double nColor0 ((nAlpha1*nColor1 + nAlpha1*nAlpha2*nColor1 + nAlpha2*nColor2) / nAlpha0);
|
|
|
|
return ClampColorChannel(255 * nColor0);
|
|
|
|
}
|
|
|
|
|
2010-02-12 15:51:03 +01:00
|
|
|
} // end of anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-12 13:58:24 +01:00
|
|
|
//===== PageObjectPainter =====================================================
|
|
|
|
|
2010-01-27 11:41:30 +01:00
|
|
|
PageObjectPainter::PageObjectPainter (
|
|
|
|
const SlideSorter& rSlideSorter)
|
|
|
|
: mrLayouter(rSlideSorter.GetView().GetLayouter()),
|
|
|
|
mpPageObjectLayouter(),
|
|
|
|
mpCache(rSlideSorter.GetView().GetPreviewCache()),
|
|
|
|
mpProperties(rSlideSorter.GetProperties()),
|
2010-02-12 13:58:24 +01:00
|
|
|
mpTheme(rSlideSorter.GetTheme()),
|
2010-05-27 11:04:10 +02:00
|
|
|
mpPageNumberFont(Theme::GetFont(Theme::Font_PageNumber, *rSlideSorter.GetContentWindow())),
|
2010-04-08 14:47:08 +02:00
|
|
|
mpShadowPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_RawShadow))),
|
2010-05-31 17:48:57 +02:00
|
|
|
mpFocusBorderPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_FocusBorder))),
|
2010-02-12 13:58:24 +01:00
|
|
|
maNormalBackground(),
|
|
|
|
maSelectionBackground(),
|
2010-02-23 18:31:24 +01:00
|
|
|
maFocusedSelectionBackground(),
|
2010-03-23 12:50:14 +01:00
|
|
|
maMouseOverBackground(),
|
2010-04-23 17:06:10 +02:00
|
|
|
msUnhideString(mpTheme->GetString(Theme::String_Unhide)),
|
|
|
|
mrButtonBar(rSlideSorter.GetView().GetButtonBar())
|
2010-01-27 11:41:30 +01:00
|
|
|
{
|
2010-05-31 17:48:57 +02:00
|
|
|
// Replace the color (not the alpha values) in the focus border with a
|
|
|
|
// color derived from the current selection color.
|
|
|
|
Color aColor (mpTheme->GetColor(Theme::Color_Selection));
|
|
|
|
USHORT nHue, nSat, nBri;
|
|
|
|
aColor.RGBtoHSB(nHue, nSat, nBri);
|
|
|
|
aColor = Color::HSBtoRGB(nHue, 28, 65);
|
|
|
|
mpFocusBorderPainter->AdaptColor(aColor, true);
|
2010-02-12 13:58:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PageObjectPainter::~PageObjectPainter (void)
|
|
|
|
{
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectPainter::PaintPageObject (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
const model::SharedPageDescriptor& rpDescriptor)
|
|
|
|
{
|
|
|
|
// The page object layouter is quite volatile. It may have been replaced
|
|
|
|
// since the last call. Update it now.
|
|
|
|
mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
|
|
|
|
if ( ! mpPageObjectLayouter)
|
|
|
|
{
|
|
|
|
OSL_ASSERT(mpPageObjectLayouter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-12 13:58:24 +01:00
|
|
|
// Turn off antialiasing to avoid the bitmaps from being shifted by
|
|
|
|
// fractions of a pixel and thus show blurry edges.
|
|
|
|
const USHORT nSavedAntialiasingMode (rDevice.GetAntialiasing());
|
|
|
|
rDevice.SetAntialiasing(nSavedAntialiasingMode & ~ANTIALIASING_ENABLE_B2DDRAW);
|
2010-01-27 11:41:30 +01:00
|
|
|
|
|
|
|
PaintBackground(rDevice, rpDescriptor);
|
|
|
|
PaintPreview(rDevice, rpDescriptor);
|
|
|
|
PaintPageNumber(rDevice, rpDescriptor);
|
|
|
|
PaintTransitionEffect(rDevice, rpDescriptor);
|
2010-04-23 17:06:10 +02:00
|
|
|
mrButtonBar.Paint(rDevice, rpDescriptor);
|
2010-02-12 13:58:24 +01:00
|
|
|
|
|
|
|
rDevice.SetAntialiasing(nSavedAntialiasingMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-23 12:50:14 +01:00
|
|
|
void PageObjectPainter::NotifyResize (const bool bForce)
|
2010-02-12 13:58:24 +01:00
|
|
|
{
|
2010-04-23 17:06:10 +02:00
|
|
|
(void)bForce;
|
|
|
|
maNormalBackground.SetEmpty();
|
|
|
|
maSelectionBackground.SetEmpty();
|
|
|
|
maFocusedSelectionBackground.SetEmpty();
|
|
|
|
maFocusedBackground.SetEmpty();
|
|
|
|
maMouseOverBackground.SetEmpty();
|
|
|
|
maMouseOverSelectedAndFocusedBackground.SetEmpty();
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-17 13:32:10 +01:00
|
|
|
void PageObjectPainter::SetTheme (const ::boost::shared_ptr<view::Theme>& rpTheme)
|
|
|
|
{
|
|
|
|
mpTheme = rpTheme;
|
2010-03-24 15:49:18 +01:00
|
|
|
NotifyResize(true);
|
2010-02-17 13:32:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-27 11:41:30 +01:00
|
|
|
void PageObjectPainter::PaintBackground (
|
|
|
|
OutputDevice& rDevice,
|
2010-04-23 17:06:10 +02:00
|
|
|
const model::SharedPageDescriptor& rpDescriptor)
|
2010-01-27 11:41:30 +01:00
|
|
|
{
|
|
|
|
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
|
|
|
|
rpDescriptor,
|
2010-05-31 17:48:57 +02:00
|
|
|
PageObjectLayouter::FocusIndicator,
|
2010-03-10 17:33:53 +01:00
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
2010-01-27 11:41:30 +01:00
|
|
|
|
2010-04-23 17:06:10 +02:00
|
|
|
const Bitmap& rBackground (GetBackgroundForState(rpDescriptor, rDevice));
|
|
|
|
rDevice.DrawBitmap(aBox.TopLeft(), rBackground);
|
2010-05-26 13:35:57 +02:00
|
|
|
|
|
|
|
// Fill the interior of the preview area with the default background
|
|
|
|
// color of the page.
|
|
|
|
SdPage* pPage = rpDescriptor->GetPage();
|
|
|
|
if (pPage != NULL)
|
|
|
|
{
|
|
|
|
rDevice.SetFillColor(pPage->GetPageBackgroundColor(NULL));
|
|
|
|
rDevice.SetLineColor(pPage->GetPageBackgroundColor(NULL));
|
|
|
|
const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
|
|
|
|
rpDescriptor,
|
|
|
|
PageObjectLayouter::Preview,
|
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
|
|
|
rDevice.DrawRect(aPreviewBox);
|
|
|
|
}
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectPainter::PaintPreview (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
const model::SharedPageDescriptor& rpDescriptor) const
|
|
|
|
{
|
2010-03-19 15:06:39 +01:00
|
|
|
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
|
2010-01-27 11:41:30 +01:00
|
|
|
rpDescriptor,
|
|
|
|
PageObjectLayouter::Preview,
|
2010-03-10 17:33:53 +01:00
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
2010-01-27 11:41:30 +01:00
|
|
|
|
|
|
|
if (mpCache != NULL)
|
|
|
|
{
|
|
|
|
const SdrPage* pPage = rpDescriptor->GetPage();
|
|
|
|
mpCache->SetPreciousFlag(pPage, true);
|
|
|
|
|
2010-05-26 13:35:57 +02:00
|
|
|
const Bitmap aPreview (GetPreviewBitmap(rpDescriptor, &rDevice));
|
|
|
|
if ( ! aPreview.IsEmpty())
|
|
|
|
if (aPreview.GetSizePixel() != aBox.GetSize())
|
|
|
|
rDevice.DrawBitmap(aBox.TopLeft(), aBox.GetSize(), aPreview);
|
|
|
|
else
|
|
|
|
rDevice.DrawBitmap(aBox.TopLeft(), aPreview);
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
2010-04-23 17:06:10 +02:00
|
|
|
}
|
2010-03-02 15:54:17 +01:00
|
|
|
|
2010-03-12 11:01:36 +01:00
|
|
|
|
2010-03-10 17:33:53 +01:00
|
|
|
|
2010-04-23 17:06:10 +02:00
|
|
|
|
|
|
|
Bitmap PageObjectPainter::CreateMarkedPreview (
|
|
|
|
const Size& rSize,
|
2010-04-27 13:24:04 +02:00
|
|
|
const Bitmap& rPreview,
|
2010-04-23 17:06:10 +02:00
|
|
|
const BitmapEx& rOverlay,
|
2010-05-26 13:35:57 +02:00
|
|
|
const OutputDevice* pReferenceDevice) const
|
2010-04-23 17:06:10 +02:00
|
|
|
{
|
2010-05-26 13:35:57 +02:00
|
|
|
::boost::scoped_ptr<VirtualDevice> pDevice;
|
|
|
|
if (pReferenceDevice != NULL)
|
|
|
|
pDevice.reset(new VirtualDevice(*pReferenceDevice));
|
|
|
|
else
|
|
|
|
pDevice.reset(new VirtualDevice());
|
|
|
|
pDevice->SetOutputSizePixel(rSize);
|
2010-04-23 17:06:10 +02:00
|
|
|
|
2010-05-26 13:35:57 +02:00
|
|
|
pDevice->DrawBitmap(Point(0,0), rSize, rPreview);
|
2010-04-23 17:06:10 +02:00
|
|
|
|
|
|
|
// Paint bitmap tiled over the preview to mark it as excluded.
|
|
|
|
const sal_Int32 nIconWidth (rOverlay.GetSizePixel().Width());
|
|
|
|
const sal_Int32 nIconHeight (rOverlay.GetSizePixel().Height());
|
|
|
|
if (nIconWidth>0 && nIconHeight>0)
|
|
|
|
{
|
|
|
|
for (sal_Int32 nX=0; nX<rSize.Width(); nX+=nIconWidth)
|
|
|
|
for (sal_Int32 nY=0; nY<rSize.Height(); nY+=nIconHeight)
|
2010-05-26 13:35:57 +02:00
|
|
|
pDevice->DrawBitmapEx(Point(nX,nY), rOverlay);
|
|
|
|
}
|
|
|
|
return pDevice->GetBitmap(Point(0,0), rSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap PageObjectPainter::GetPreviewBitmap (
|
|
|
|
const model::SharedPageDescriptor& rpDescriptor,
|
|
|
|
const OutputDevice* pReferenceDevice) const
|
|
|
|
{
|
|
|
|
const SdrPage* pPage = rpDescriptor->GetPage();
|
2010-06-14 18:48:50 +02:00
|
|
|
const bool bIsExcluded (rpDescriptor->HasState(model::PageDescriptor::ST_Excluded));
|
2010-05-26 13:35:57 +02:00
|
|
|
|
|
|
|
if (bIsExcluded)
|
|
|
|
{
|
|
|
|
Bitmap aMarkedPreview (mpCache->GetMarkedPreviewBitmap(pPage,false));
|
|
|
|
const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
|
|
|
|
rpDescriptor,
|
|
|
|
PageObjectLayouter::Preview,
|
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
|
|
|
if (aMarkedPreview.IsEmpty() || aMarkedPreview.GetSizePixel()!=aPreviewBox.GetSize())
|
|
|
|
{
|
|
|
|
aMarkedPreview = CreateMarkedPreview(
|
|
|
|
aPreviewBox.GetSize(),
|
|
|
|
mpCache->GetPreviewBitmap(pPage,true),
|
|
|
|
mpTheme->GetIcon(Theme::Icon_HideSlideOverlay),
|
|
|
|
pReferenceDevice);
|
|
|
|
mpCache->SetMarkedPreviewBitmap(pPage, aMarkedPreview);
|
|
|
|
}
|
|
|
|
return aMarkedPreview;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return mpCache->GetPreviewBitmap(pPage,false);
|
2010-03-02 15:54:17 +01:00
|
|
|
}
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectPainter::PaintPageNumber (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
const model::SharedPageDescriptor& rpDescriptor) const
|
|
|
|
{
|
2010-02-17 13:32:10 +01:00
|
|
|
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
|
2010-01-27 11:41:30 +01:00
|
|
|
rpDescriptor,
|
|
|
|
PageObjectLayouter::PageNumber,
|
2010-03-10 17:33:53 +01:00
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
2010-01-27 11:41:30 +01:00
|
|
|
|
|
|
|
// Paint the page number.
|
|
|
|
OSL_ASSERT(rpDescriptor->GetPage()!=NULL);
|
|
|
|
const sal_Int32 nPageNumber ((rpDescriptor->GetPage()->GetPageNum() - 1) / 2 + 1);
|
|
|
|
const String sPageNumber (String::CreateFromInt32(nPageNumber));
|
2010-02-12 13:58:24 +01:00
|
|
|
rDevice.SetFont(*mpPageNumberFont);
|
2010-05-27 11:04:10 +02:00
|
|
|
rDevice.SetTextColor(Color(mpTheme->GetColor(Theme::Color_PageNumber)));
|
2010-02-17 13:32:10 +01:00
|
|
|
rDevice.DrawText(aBox, sPageNumber, TEXT_DRAW_RIGHT | TEXT_DRAW_VCENTER);
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectPainter::PaintTransitionEffect (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
const model::SharedPageDescriptor& rpDescriptor) const
|
|
|
|
{
|
2010-02-12 13:58:24 +01:00
|
|
|
const SdPage* pPage = rpDescriptor->GetPage();
|
|
|
|
if (pPage!=NULL && pPage->getTransitionType() > 0)
|
|
|
|
{
|
|
|
|
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
|
|
|
|
rpDescriptor,
|
|
|
|
PageObjectLayouter::TransitionEffectIndicator,
|
2010-03-10 17:33:53 +01:00
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
2010-02-12 13:58:24 +01:00
|
|
|
|
|
|
|
rDevice.DrawBitmapEx(
|
|
|
|
aBox.TopLeft(),
|
|
|
|
mpPageObjectLayouter->GetTransitionEffectIcon().GetBitmapEx());
|
|
|
|
}
|
2010-01-27 11:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-23 17:06:10 +02:00
|
|
|
Bitmap& PageObjectPainter::GetBackgroundForState (
|
2010-03-24 15:49:18 +01:00
|
|
|
const model::SharedPageDescriptor& rpDescriptor,
|
2010-04-23 17:06:10 +02:00
|
|
|
const OutputDevice& rReferenceDevice)
|
2010-03-24 15:49:18 +01:00
|
|
|
{
|
2010-05-28 13:26:19 +02:00
|
|
|
enum State { None = 0x00, Selected = 0x01, MouseOver = 0x02, Focused = 0x04 };
|
|
|
|
const State eState (State(
|
|
|
|
(rpDescriptor->HasState(model::PageDescriptor::ST_Selected) ? Selected : None)
|
|
|
|
| (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) ? MouseOver : None)
|
|
|
|
| (rpDescriptor->HasState(model::PageDescriptor::ST_Focused) ? Focused : None)));
|
|
|
|
|
|
|
|
switch (eState)
|
2010-04-23 17:06:10 +02:00
|
|
|
{
|
2010-05-28 13:26:19 +02:00
|
|
|
case MouseOver | Selected | Focused:
|
2010-04-23 17:06:10 +02:00
|
|
|
return GetBackground(
|
|
|
|
maMouseOverSelectedAndFocusedBackground,
|
|
|
|
Theme::Gradient_MouseOverSelectedAndFocusedPage,
|
2010-05-28 13:26:19 +02:00
|
|
|
rReferenceDevice,
|
2010-05-31 17:48:57 +02:00
|
|
|
true);
|
2010-05-28 13:26:19 +02:00
|
|
|
|
|
|
|
case MouseOver | Selected:
|
|
|
|
case MouseOver | Focused:
|
|
|
|
case MouseOver:
|
2010-04-23 17:06:10 +02:00
|
|
|
return GetBackground(
|
|
|
|
maMouseOverBackground,
|
|
|
|
Theme::Gradient_MouseOverPage,
|
2010-05-28 13:26:19 +02:00
|
|
|
rReferenceDevice,
|
2010-06-14 18:02:38 +02:00
|
|
|
(eState & Focused)!=0);
|
2010-05-28 13:26:19 +02:00
|
|
|
|
|
|
|
case Selected | Focused:
|
2010-04-23 17:06:10 +02:00
|
|
|
return GetBackground(
|
|
|
|
maFocusedSelectionBackground,
|
|
|
|
Theme::Gradient_SelectedAndFocusedPage,
|
2010-05-28 13:26:19 +02:00
|
|
|
rReferenceDevice,
|
2010-05-31 17:48:57 +02:00
|
|
|
true);
|
2010-05-28 13:26:19 +02:00
|
|
|
|
|
|
|
case Selected:
|
2010-04-23 17:06:10 +02:00
|
|
|
return GetBackground(
|
|
|
|
maSelectionBackground,
|
|
|
|
Theme::Gradient_SelectedPage,
|
2010-05-28 13:26:19 +02:00
|
|
|
rReferenceDevice,
|
2010-05-31 17:48:57 +02:00
|
|
|
false);
|
2010-05-28 13:26:19 +02:00
|
|
|
|
|
|
|
case Focused:
|
|
|
|
return GetBackground(
|
|
|
|
maFocusedBackground,
|
|
|
|
Theme::Gradient_FocusedPage,
|
|
|
|
rReferenceDevice,
|
2010-05-31 17:48:57 +02:00
|
|
|
true);
|
2010-05-28 13:26:19 +02:00
|
|
|
|
|
|
|
case None:
|
|
|
|
default:
|
|
|
|
return GetBackground(
|
|
|
|
maNormalBackground,
|
|
|
|
Theme::Gradient_NormalPage,
|
|
|
|
rReferenceDevice,
|
2010-05-31 17:48:57 +02:00
|
|
|
false);
|
2010-03-24 15:49:18 +01:00
|
|
|
}
|
2010-03-23 12:50:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-23 17:06:10 +02:00
|
|
|
Bitmap& PageObjectPainter::GetBackground(
|
|
|
|
Bitmap& rBackground,
|
|
|
|
Theme::GradientColorType eType,
|
2010-05-28 13:26:19 +02:00
|
|
|
const OutputDevice& rReferenceDevice,
|
2010-05-31 17:48:57 +02:00
|
|
|
const bool bHasFocusBorder)
|
2010-02-12 13:58:24 +01:00
|
|
|
{
|
2010-04-23 17:06:10 +02:00
|
|
|
if (rBackground.IsEmpty())
|
2010-05-31 17:48:57 +02:00
|
|
|
rBackground = CreateBackgroundBitmap(rReferenceDevice, eType, bHasFocusBorder);
|
2010-04-23 17:06:10 +02:00
|
|
|
return rBackground;
|
2010-02-12 13:58:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap PageObjectPainter::CreateBackgroundBitmap(
|
|
|
|
const OutputDevice& rReferenceDevice,
|
2010-05-28 13:26:19 +02:00
|
|
|
const Theme::GradientColorType eColorType,
|
2010-05-31 17:48:57 +02:00
|
|
|
const bool bHasFocusBorder) const
|
2010-02-12 13:58:24 +01:00
|
|
|
{
|
2010-05-31 17:48:57 +02:00
|
|
|
const Size aSize (mpPageObjectLayouter->GetSize(
|
|
|
|
PageObjectLayouter::FocusIndicator,
|
|
|
|
PageObjectLayouter::WindowCoordinateSystem));
|
|
|
|
const Rectangle aPageObjectBox (mpPageObjectLayouter->GetBoundingBox(
|
|
|
|
Point(0,0),
|
|
|
|
PageObjectLayouter::PageObject,
|
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
2010-02-12 13:58:24 +01:00
|
|
|
VirtualDevice aBitmapDevice (rReferenceDevice);
|
|
|
|
aBitmapDevice.SetOutputSizePixel(aSize);
|
|
|
|
|
2010-06-14 18:02:38 +02:00
|
|
|
// Fill the background with the background color of the slide sorter.
|
|
|
|
aBitmapDevice.SetFillColor(mpTheme->GetColor(Theme::Color_Background));
|
|
|
|
aBitmapDevice.SetLineColor(mpTheme->GetColor(Theme::Color_Background));
|
|
|
|
aBitmapDevice.DrawRect(Rectangle(Point(0,0), aSize));
|
|
|
|
|
|
|
|
// Paint the slide area with a linear gradient that starts some pixels
|
2010-02-12 13:58:24 +01:00
|
|
|
// below the top and ends some pixels above the bottom.
|
2010-05-31 17:48:57 +02:00
|
|
|
const sal_Int32 nHeight (aPageObjectBox.GetHeight());
|
|
|
|
const sal_Int32 nDefaultConstantSize(nHeight/4);
|
2010-02-12 13:58:24 +01:00
|
|
|
const sal_Int32 nMinimalGradientSize(40);
|
|
|
|
const sal_Int32 nY1 (
|
|
|
|
::std::max<sal_Int32>(
|
|
|
|
0,
|
|
|
|
::std::min<sal_Int32>(
|
|
|
|
nDefaultConstantSize,
|
|
|
|
(nHeight - nMinimalGradientSize)/2)));
|
|
|
|
const sal_Int32 nY2 (nHeight-nY1);
|
2010-02-12 15:40:43 +01:00
|
|
|
const Color aTopColor(mpTheme->GetGradientColor(eColorType, Theme::Fill1));
|
|
|
|
const Color aBottomColor(mpTheme->GetGradientColor(eColorType, Theme::Fill2));
|
2010-05-31 17:48:57 +02:00
|
|
|
const sal_Int32 nTop (aPageObjectBox.Top());
|
2010-02-12 13:58:24 +01:00
|
|
|
for (sal_Int32 nY=0; nY<nHeight; ++nY)
|
|
|
|
{
|
|
|
|
if (nY<=nY1)
|
|
|
|
aBitmapDevice.SetLineColor(aTopColor);
|
|
|
|
else if (nY>=nY2)
|
|
|
|
aBitmapDevice.SetLineColor(aBottomColor);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Color aColor (aTopColor);
|
|
|
|
aColor.Merge(aBottomColor, 255 * (nY2-nY) / (nY2-nY1));
|
|
|
|
aBitmapDevice.SetLineColor(aColor);
|
|
|
|
}
|
2010-05-31 17:48:57 +02:00
|
|
|
aBitmapDevice.DrawLine(
|
|
|
|
Point(aPageObjectBox.Left(), nY+nTop),
|
|
|
|
Point(aPageObjectBox.Right(), nY+nTop));
|
2010-02-12 13:58:24 +01:00
|
|
|
}
|
|
|
|
|
2010-05-31 17:48:57 +02:00
|
|
|
// Paint the simple border and, for some backgrounds, the focus border.
|
|
|
|
if (bHasFocusBorder)
|
|
|
|
mpFocusBorderPainter->PaintFrame(aBitmapDevice, aPageObjectBox);
|
|
|
|
else
|
|
|
|
PaintBorder(aBitmapDevice, eColorType, aPageObjectBox);
|
2010-02-12 13:58:24 +01:00
|
|
|
|
|
|
|
// Get bounding box of the preview around which a shadow is painted.
|
|
|
|
// Compensate for the border around the preview.
|
2010-02-17 13:32:10 +01:00
|
|
|
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
|
2010-03-10 17:33:53 +01:00
|
|
|
Point(0,0),
|
2010-02-12 13:58:24 +01:00
|
|
|
PageObjectLayouter::Preview,
|
2010-03-10 17:33:53 +01:00
|
|
|
PageObjectLayouter::ModelCoordinateSystem));
|
2010-02-17 13:32:10 +01:00
|
|
|
Rectangle aFrameBox (aBox.Left()-1,aBox.Top()-1,aBox.Right()+1,aBox.Bottom()+1);
|
|
|
|
mpShadowPainter->PaintFrame(aBitmapDevice, aFrameBox);
|
|
|
|
|
2010-02-12 13:58:24 +01:00
|
|
|
return aBitmapDevice.GetBitmap (Point(0,0),aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-23 18:31:24 +01:00
|
|
|
void PageObjectPainter::PaintBorder (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
const Theme::GradientColorType eColorType,
|
2010-05-31 17:48:57 +02:00
|
|
|
const Rectangle& rBox) const
|
2010-02-23 18:31:24 +01:00
|
|
|
{
|
|
|
|
rDevice.SetFillColor();
|
2010-05-31 17:48:57 +02:00
|
|
|
const sal_Int32 nBorderWidth (1);
|
2010-05-28 13:26:19 +02:00
|
|
|
for (int nIndex=0; nIndex<nBorderWidth; ++nIndex)
|
|
|
|
{
|
2010-05-31 17:48:57 +02:00
|
|
|
const int nDelta (nIndex);
|
2010-05-28 13:26:19 +02:00
|
|
|
rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border2));
|
|
|
|
rDevice.DrawLine(
|
|
|
|
Point(rBox.Left()-nDelta, rBox.Top()-nDelta),
|
|
|
|
Point(rBox.Left()-nDelta, rBox.Bottom()+nDelta));
|
|
|
|
rDevice.DrawLine(
|
|
|
|
Point(rBox.Left()-nDelta, rBox.Bottom()+nDelta),
|
|
|
|
Point(rBox.Right()+nDelta, rBox.Bottom()+nDelta));
|
|
|
|
rDevice.DrawLine(
|
|
|
|
Point(rBox.Right()+nDelta, rBox.Bottom()+nDelta),
|
|
|
|
Point(rBox.Right()+nDelta, rBox.Top()-nDelta));
|
|
|
|
|
|
|
|
rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border1));
|
|
|
|
rDevice.DrawLine(
|
|
|
|
Point(rBox.Left()-nDelta, rBox.Top()-nDelta),
|
|
|
|
Point(rBox.Right()+nDelta, rBox.Top()-nDelta));
|
|
|
|
}
|
2010-02-23 18:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-27 11:41:30 +01:00
|
|
|
} } } // end of namespace sd::slidesorter::view
|