/* -*- 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 .
*/
// set screenshot image at DrawingArea, resize, set event listener if (mxPicture)
{
maAllChildren = mrParentDialog.collect_screenshot_data();
// to make clear that maParentDialogBitmap is a background image, adjust // luminance a bit for maDimmedDialogBitmap - other methods may be applied
maDimmedDialogBitmap.Adjust(-15, 0, 0, 0, 0);
// initially set image for picture control
mxVirtualBufferDevice->DrawBitmapEx(Point(0, 0), maDimmedDialogBitmap);
// set size for picture control, this will re-layout so that // the picture control shows the whole dialog
maPicture.SetOutputSizePixel(maParentDialogSize);
mxPicture->set_size_request(maParentDialogSize.Width(), maParentDialogSize.Height());
mxPicture->queue_draw();
}
// set some test text at VclMultiLineEdit and make read-only - only // copying content to clipboard is allowed if (mxText)
{
mxText->set_size_request(400, mxText->get_height_rows(10));
OUString aHelpId = mrParentDialog.get_help_id();
Size aSizeCm = Application::GetDefaultDevice()->PixelToLogic(maParentDialogSize, MapMode(MapUnit::MapCM));
maMainMarkupText = lcl_ParagraphWithImage( aHelpId, aSizeCm );
mxText->set_text( maMainMarkupText );
mxText->set_editable(false);
}
// set click handler for save button if (mxSave)
{
mxSave->connect_clicked(LINK(this, ScreenshotAnnotationDlg_Impl, saveButtonHandler));
}
}
IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&, void)
{ // 'save screenshot...' pressed, offer to save maParentDialogBitmap // as PNG image, use *.id file name as screenshot file name offering // get a suggestion for the filename from buildable name
OUString aDerivedFileName = mrParentDialog.get_buildable_name();
// grow in pixels to be a little bit 'outside'. This also // ensures that getWidth()/getHeight() ain't 0.0 (see division below) staticconstdouble fGrowTopLeft(1.5); staticconstdouble fGrowBottomRight(0.5);
aB2DRange.expand(aB2DRange.getMinimum() - basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft));
aB2DRange.expand(aB2DRange.getMaximum() + basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight));
// edge rounding in pixel. Need to convert, value for // createPolygonFromRect is relative [0.0 .. 1.0] staticconstdouble fEdgeRoundPixel(8.0); const basegfx::B2DPolygon aPolygon(
basegfx::utils::createPolygonFromRect(
aB2DRange,
fEdgeRoundPixel / aB2DRange.getWidth(),
fEdgeRoundPixel / aB2DRange.getHeight()));
mxVirtualBufferDevice->SetLineColor(rColor);
// try to use transparency if (!mxVirtualBufferDevice->DrawPolyLineDirect(
basegfx::B2DHomMatrix(),
aPolygon,
fLineWidth,
fTransparency,
nullptr, // MM01
basegfx::B2DLineJoin::Round))
{ // no transparency, draw without
mxVirtualBufferDevice->DrawPolyLine(
aPolygon,
fLineWidth);
}
}
Point ScreenshotAnnotationDlg_Impl::GetOffsetInPicture() const
{ const Size aPixelSizeTarget(maPicture.GetOutputSizePixel());
if (bIsAntiAliasing)
{
mxVirtualBufferDevice->SetAntialiasing(nOldAA);
}
}
void ScreenshotAnnotationDlg_Impl::RepaintPictureElement()
{ if (mxPicture && mxVirtualBufferDevice)
{ // reset image in buffer, use dimmed version and allow highlight
RepaintToBuffer(true, true);
mxPicture->queue_draw();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.