diff options
Diffstat (limited to 'svx/source/sidebar/graphic')
-rw-r--r-- | svx/source/sidebar/graphic/GraphicPropertyPanel.cxx | 246 | ||||
-rw-r--r-- | svx/source/sidebar/graphic/GraphicPropertyPanel.hxx | 89 |
2 files changed, 335 insertions, 0 deletions
diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx new file mode 100644 index 000000000..550364955 --- /dev/null +++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx @@ -0,0 +1,246 @@ +/* -*- 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 "GraphicPropertyPanel.hxx" +#include <svx/strings.hrc> +#include <svx/svxids.hrc> +#include <svx/dialmgr.hxx> +#include <svl/intitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> + +using namespace css; +using namespace css::uno; + + +// namespace open + +namespace svx::sidebar { + + +GraphicPropertyPanel::GraphicPropertyPanel( + weld::Widget* pParent, + SfxBindings* pBindings) +: PanelLayout(pParent, "GraphicPropertyPanel", "svx/ui/sidebargraphic.ui"), + maBrightControl(SID_ATTR_GRAF_LUMINANCE, *pBindings, *this), + maContrastControl(SID_ATTR_GRAF_CONTRAST, *pBindings, *this), + maTransparenceControl(SID_ATTR_GRAF_TRANSPARENCE, *pBindings, *this), + maRedControl(SID_ATTR_GRAF_RED, *pBindings, *this), + maGreenControl(SID_ATTR_GRAF_GREEN, *pBindings, *this), + maBlueControl(SID_ATTR_GRAF_BLUE, *pBindings, *this), + maGammaControl(SID_ATTR_GRAF_GAMMA, *pBindings, *this), + maModeControl(SID_ATTR_GRAF_MODE, *pBindings, *this), + mpBindings(pBindings), + mxMtrBrightness(m_xBuilder->weld_metric_spin_button("setbrightness", FieldUnit::PERCENT)), + mxMtrContrast(m_xBuilder->weld_metric_spin_button("setcontrast", FieldUnit::PERCENT)), + mxLBColorMode(m_xBuilder->weld_combo_box("setcolormode")), + mxMtrTrans(m_xBuilder->weld_metric_spin_button("setgraphtransparency", FieldUnit::PERCENT)) +{ + mxLBColorMode->set_size_request(mxLBColorMode->get_preferred_size().Width(), -1); + Initialize(); +} + +GraphicPropertyPanel::~GraphicPropertyPanel() +{ + mxMtrBrightness.reset(); + mxMtrContrast.reset(); + mxLBColorMode.reset(); + mxMtrTrans.reset(); + + maBrightControl.dispose(); + maContrastControl.dispose(); + maTransparenceControl.dispose(); + maRedControl.dispose(); + maGreenControl.dispose(); + maBlueControl.dispose(); + maGammaControl.dispose(); + maModeControl.dispose(); +} + +void GraphicPropertyPanel::Initialize() +{ + mxMtrBrightness->connect_value_changed( LINK( this, GraphicPropertyPanel, ModifyBrightnessHdl ) ); + mxMtrContrast->connect_value_changed( LINK( this, GraphicPropertyPanel, ModifyContrastHdl ) ); + mxMtrTrans->connect_value_changed( LINK( this, GraphicPropertyPanel, ModifyTransHdl ) ); + + mxLBColorMode->append_text(SvxResId(RID_SVXSTR_GRAFMODE_STANDARD)); + mxLBColorMode->append_text(SvxResId(RID_SVXSTR_GRAFMODE_GREYS)); + mxLBColorMode->append_text(SvxResId(RID_SVXSTR_GRAFMODE_MONO)); + mxLBColorMode->append_text(SvxResId(RID_SVXSTR_GRAFMODE_WATERMARK)); + mxLBColorMode->connect_changed( LINK( this, GraphicPropertyPanel, ClickColorModeHdl )); +} + +IMPL_LINK_NOARG( GraphicPropertyPanel, ModifyBrightnessHdl, weld::MetricSpinButton&, void ) +{ + const sal_Int16 nBright = mxMtrBrightness->get_value(FieldUnit::PERCENT); + const SfxInt16Item aBrightItem( SID_ATTR_GRAF_LUMINANCE, nBright ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_GRAF_LUMINANCE, + SfxCallMode::RECORD, { &aBrightItem }); +} + + +IMPL_LINK_NOARG( GraphicPropertyPanel, ModifyContrastHdl, weld::MetricSpinButton&, void ) +{ + const sal_Int16 nContrast = mxMtrContrast->get_value(FieldUnit::PERCENT); + const SfxInt16Item aContrastItem( SID_ATTR_GRAF_CONTRAST, nContrast ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_GRAF_CONTRAST, + SfxCallMode::RECORD, { &aContrastItem }); +} + + +IMPL_LINK_NOARG( GraphicPropertyPanel, ModifyTransHdl, weld::MetricSpinButton&, void ) +{ + const sal_Int16 nTrans = mxMtrTrans->get_value(FieldUnit::PERCENT); + const SfxUInt16Item aTransItem( SID_ATTR_GRAF_TRANSPARENCE, nTrans ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_GRAF_TRANSPARENCE, + SfxCallMode::RECORD, { &aTransItem }); +} + + +IMPL_LINK_NOARG( GraphicPropertyPanel, ClickColorModeHdl, weld::ComboBox&, void ) +{ + const sal_Int16 nTrans = mxLBColorMode->get_active(); + const SfxUInt16Item aTransItem( SID_ATTR_GRAF_MODE, nTrans ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_GRAF_MODE, + SfxCallMode::RECORD, { &aTransItem }); +} + +std::unique_ptr<PanelLayout> GraphicPropertyPanel::Create ( + weld::Widget* pParent, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw lang::IllegalArgumentException("no parent Window given to GraphicPropertyPanel::Create", nullptr, 0); + if (pBindings == nullptr) + throw lang::IllegalArgumentException("no SfxBindings given to GraphicPropertyPanel::Create", nullptr, 2); + + return std::make_unique<GraphicPropertyPanel>(pParent, pBindings); +} + +void GraphicPropertyPanel::NotifyItemUpdate( + sal_uInt16 nSID, + SfxItemState eState, + const SfxPoolItem* pState) +{ + switch( nSID ) + { + case SID_ATTR_GRAF_LUMINANCE: + { + if(eState >= SfxItemState::DEFAULT) + { + mxMtrBrightness->set_sensitive(true); + const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState); + + if(pItem) + { + const sal_Int64 nBright = pItem->GetValue(); + mxMtrBrightness->set_value(nBright, FieldUnit::PERCENT); + } + } + else if(SfxItemState::DISABLED == eState) + { + mxMtrBrightness->set_sensitive(false); + } + else + { + mxMtrBrightness->set_sensitive(true); + mxMtrBrightness->set_text(OUString()); + } + break; + } + case SID_ATTR_GRAF_CONTRAST: + { + if(eState >= SfxItemState::DEFAULT) + { + mxMtrContrast->set_sensitive(true); + const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState); + + if(pItem) + { + const sal_Int64 nContrast = pItem->GetValue(); + mxMtrContrast->set_value(nContrast, FieldUnit::PERCENT); + } + } + else if(SfxItemState::DISABLED == eState) + { + mxMtrContrast->set_sensitive(false); + } + else + { + mxMtrContrast->set_sensitive(true); + mxMtrContrast->set_text(OUString()); + } + break; + } + case SID_ATTR_GRAF_TRANSPARENCE: + { + if(eState >= SfxItemState::DEFAULT) + { + mxMtrTrans->set_sensitive(true); + const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState); + + if(pItem) + { + const sal_Int64 nTrans = pItem->GetValue(); + mxMtrTrans->set_value(nTrans, FieldUnit::PERCENT); + } + } + else if(SfxItemState::DISABLED == eState) + { + mxMtrTrans->set_sensitive(false); + } + else + { + mxMtrTrans->set_sensitive(true); + mxMtrTrans->set_text(OUString()); + } + break; + } + case SID_ATTR_GRAF_MODE: + { + if(eState >= SfxItemState::DEFAULT) + { + mxLBColorMode->set_sensitive(true); + + if(pState) + { + const sal_uInt16 nTrans = static_cast< const SfxUInt16Item* >(pState)->GetValue(); + mxLBColorMode->set_active(nTrans); + } + } + else if(SfxItemState::DISABLED == eState) + { + mxLBColorMode->set_sensitive(false); + } + else + { + mxLBColorMode->set_sensitive(true); + mxLBColorMode->set_active(-1); + } + break; + } + } +} + +// namespace close + +} // end of namespace svx::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx new file mode 100644 index 000000000..e7fd4914b --- /dev/null +++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx @@ -0,0 +1,89 @@ +/* -*- 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_SOURCE_SIDEBAR_GRAPHIC_GRAPHICPROPERTYPANEL_HXX +#define INCLUDED_SVX_SOURCE_SIDEBAR_GRAPHIC_GRAPHICPROPERTYPANEL_HXX + +#include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include <vcl/weld.hxx> + +namespace svx::sidebar { + +class GraphicPropertyPanel +: public PanelLayout, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +public: + virtual ~GraphicPropertyPanel() override; + + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, + SfxBindings* pBindings); + + virtual void NotifyItemUpdate( + const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState( + const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override {}; + + SfxBindings* GetBindings() { return mpBindings;} + + // constructor/destructor + GraphicPropertyPanel( + weld::Widget* pParent, + SfxBindings* pBindings); + +private: + ::sfx2::sidebar::ControllerItem maBrightControl; + ::sfx2::sidebar::ControllerItem maContrastControl; + ::sfx2::sidebar::ControllerItem maTransparenceControl; + ::sfx2::sidebar::ControllerItem maRedControl; + ::sfx2::sidebar::ControllerItem maGreenControl; + ::sfx2::sidebar::ControllerItem maBlueControl; + ::sfx2::sidebar::ControllerItem maGammaControl; + ::sfx2::sidebar::ControllerItem maModeControl; + + SfxBindings* mpBindings; + + //ui controls + std::unique_ptr<weld::MetricSpinButton> mxMtrBrightness; + std::unique_ptr<weld::MetricSpinButton> mxMtrContrast; + std::unique_ptr<weld::ComboBox> mxLBColorMode; + std::unique_ptr<weld::MetricSpinButton> mxMtrTrans; + std::unique_ptr<weld::MetricSpinButton> mxMtrRed; + std::unique_ptr<weld::MetricSpinButton> mxMtrGreen; + std::unique_ptr<weld::MetricSpinButton> mxMtrBlue; + std::unique_ptr<weld::SpinButton> mxMtrGamma; + + DECL_LINK( ModifyBrightnessHdl, weld::MetricSpinButton&, void ); + DECL_LINK( ModifyContrastHdl, weld::MetricSpinButton&, void ); + DECL_LINK( ModifyTransHdl, weld::MetricSpinButton&, void ); + DECL_LINK( ClickColorModeHdl, weld::ComboBox&, void ); + + void Initialize(); +}; + +} // end of namespace svx::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |