Kaydet (Commit) 3120c972 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SvxConnectionPage

Change-Id: I155f0c037f0d1879cec4d0b511d60a276466b1bb
Reviewed-on: https://gerrit.libreoffice.org/61077
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 45c753af
...@@ -21,10 +21,8 @@ ...@@ -21,10 +21,8 @@
#include <svx/connctrl.hxx> #include <svx/connctrl.hxx>
#include <sfx2/tabdlg.hxx> #include <sfx2/tabdlg.hxx>
#include <vcl/fixed.hxx> #include <vcl/customweld.hxx>
#include <vcl/field.hxx> #include <vcl/weld.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/group.hxx>
#include <sfx2/basedlgs.hxx> #include <sfx2/basedlgs.hxx>
class SdrView; class SdrView;
...@@ -34,36 +32,33 @@ class SvxConnectionPage : public SfxTabPage ...@@ -34,36 +32,33 @@ class SvxConnectionPage : public SfxTabPage
{ {
private: private:
static const sal_uInt16 pRanges[]; static const sal_uInt16 pRanges[];
VclPtr<ListBox> m_pLbType;
VclPtr<FixedText> m_pFtLine1;
VclPtr<MetricField> m_pMtrFldLine1;
VclPtr<FixedText> m_pFtLine2;
VclPtr<MetricField> m_pMtrFldLine2;
VclPtr<FixedText> m_pFtLine3;
VclPtr<MetricField> m_pMtrFldLine3;
VclPtr<MetricField> m_pMtrFldHorz1;
VclPtr<MetricField> m_pMtrFldVert1;
VclPtr<MetricField> m_pMtrFldHorz2;
VclPtr<MetricField> m_pMtrFldVert2;
VclPtr<SvxXConnectionPreview> m_pCtlPreview;
const SfxItemSet& rOutAttrs; const SfxItemSet& rOutAttrs;
SfxItemSet aAttrSet; SfxItemSet aAttrSet;
const SdrView* pView; const SdrView* pView;
MapUnit eUnit; MapUnit eUnit;
SvxXConnectionPreview m_aCtlPreview;
std::unique_ptr<weld::ComboBox> m_xLbType;
std::unique_ptr<weld::Label> m_xFtLine1;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldLine1;
std::unique_ptr<weld::Label> m_xFtLine2;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldLine2;
std::unique_ptr<weld::Label> m_xFtLine3;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldLine3;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldHorz1;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldVert1;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldHorz2;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldVert2;
std::unique_ptr<weld::CustomWeld> m_xCtlPreview;
void FillTypeLB(); void FillTypeLB();
DECL_LINK( ChangeAttrEditHdl_Impl, Edit&, void ); DECL_LINK(ChangeAttrEditHdl_Impl, weld::MetricSpinButton&, void);
DECL_LINK( ChangeAttrListBoxHdl_Impl, ListBox&, void ); DECL_LINK(ChangeAttrListBoxHdl_Impl, weld::ComboBox&, void);
void ChangeAttrHdl_Impl(void const *);
public: public:
SvxConnectionPage( vcl::Window* pWindow, const SfxItemSet& rInAttrs ); SvxConnectionPage(TabPageParent pWindow, const SfxItemSet& rInAttrs);
virtual ~SvxConnectionPage() override; virtual ~SvxConnectionPage() override;
virtual void dispose() override; virtual void dispose() override;
......
This diff is collapsed.
...@@ -200,9 +200,6 @@ ...@@ -200,9 +200,6 @@
<glade-widget-class title="SvxXLinePreview" name="svxlo-SvxXLinePreview" <glade-widget-class title="SvxXLinePreview" name="svxlo-SvxXLinePreview"
generic-name="Line Preview Window" parent="GtkDrawingArea" generic-name="Line Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/> icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="SvxXConnectionPreview" name="svxlo-SvxXConnectionPreview"
generic-name="Connector Line Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Svx 3D Light Control" name="svxlo-SvxLightCtl3D" <glade-widget-class title="Svx 3D Light Control" name="svxlo-SvxLightCtl3D"
generic-name="3D Light Control" parent="GtkDrawingArea" generic-name="3D Light Control" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/> icon-name="widget-gtk-drawingarea"/>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <tools/wintypes.hxx> #include <tools/wintypes.hxx>
#include <vcl/ctrl.hxx> #include <vcl/customweld.hxx>
#include <vcl/event.hxx> #include <vcl/event.hxx>
#include <vcl/outdev.hxx> #include <vcl/outdev.hxx>
#include <memory> #include <memory>
...@@ -40,34 +40,33 @@ class SdrPage; ...@@ -40,34 +40,33 @@ class SdrPage;
|* SvxXConnectionPreview |* SvxXConnectionPreview
|* |*
\************************************************************************/ \************************************************************************/
class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXConnectionPreview : public Control class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXConnectionPreview : public weld::CustomWidgetController
{ {
friend class SvxConnectionPage; friend class SvxConnectionPage;
private: private:
MapMode aNewMapMode;
SdrEdgeObj* pEdgeObj; SdrEdgeObj* pEdgeObj;
std::unique_ptr<SdrPage> pSdrPage; std::unique_ptr<SdrPage> pSdrPage;
const SdrView* pView; const SdrView* pView;
SVX_DLLPRIVATE void SetStyles();
SVX_DLLPRIVATE void AdaptSize(); SVX_DLLPRIVATE void AdaptSize();
SVX_DLLPRIVATE void SetMapMode(const MapMode& rNewMapMode) { aNewMapMode = rNewMapMode; }
SVX_DLLPRIVATE const MapMode& GetMapMode() const { return aNewMapMode; }
public: public:
SvxXConnectionPreview( vcl::Window* pParent, WinBits nStyle); SvxXConnectionPreview();
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual ~SvxXConnectionPreview() override; virtual ~SvxXConnectionPreview() override;
virtual void dispose() override;
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
virtual void Resize() override; virtual void Resize() override;
virtual Size GetOptimalSize() const override; virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
void SetAttributes( const SfxItemSet& rInAttrs ); void SetAttributes( const SfxItemSet& rInAttrs );
sal_uInt16 GetLineDeltaCount(); sal_uInt16 GetLineDeltaCount();
void Construct(); void Construct();
void SetView( const SdrView* pSdrView ) { pView = pSdrView; } void SetView( const SdrView* pSdrView ) { pView = pSdrView; }
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
}; };
#endif // INCLUDED_SVX_CONNCTRL_HXX #endif // INCLUDED_SVX_CONNCTRL_HXX
......
...@@ -35,42 +35,32 @@ ...@@ -35,42 +35,32 @@
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <memory> #include <memory>
SvxXConnectionPreview::SvxXConnectionPreview( vcl::Window* pParent, WinBits nStyle) SvxXConnectionPreview::SvxXConnectionPreview()
: Control(pParent, nStyle) : pEdgeObj(nullptr)
, pEdgeObj(nullptr)
, pView(nullptr) , pView(nullptr)
{ {
SetMapMode(MapMode(MapUnit::Map100thMM)); SetMapMode(MapMode(MapUnit::Map100thMM));
SetStyles();
} }
VCL_BUILDER_FACTORY_CONSTRUCTOR(SvxXConnectionPreview, 0) void SvxXConnectionPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
SvxXConnectionPreview::~SvxXConnectionPreview()
{ {
disposeOnce(); weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(118 , 121), MapMode(MapUnit::MapAppFont)));
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
SetOutputSizePixel(aSize);
} }
void SvxXConnectionPreview::dispose() SvxXConnectionPreview::~SvxXConnectionPreview()
{ {
pSdrPage.reset();
Control::dispose();
} }
void SvxXConnectionPreview::Resize() void SvxXConnectionPreview::Resize()
{ {
Control::Resize();
AdaptSize(); AdaptSize();
Invalidate(); Invalidate();
} }
Size SvxXConnectionPreview::GetOptimalSize() const
{
return LogicToPixel(Size(118 , 121), MapMode(MapUnit::MapAppFont));
}
void SvxXConnectionPreview::AdaptSize() void SvxXConnectionPreview::AdaptSize()
{ {
// Adapt size // Adapt size
...@@ -89,7 +79,7 @@ void SvxXConnectionPreview::AdaptSize() ...@@ -89,7 +79,7 @@ void SvxXConnectionPreview::AdaptSize()
MapMode aDisplayMap( aMapMode ); MapMode aDisplayMap( aMapMode );
Point aNewPos; Point aNewPos;
Size aNewSize; Size aNewSize;
const Size aWinSize = PixelToLogic( GetOutputSizePixel(), aDisplayMap ); const Size aWinSize = GetDrawingArea()->get_ref_device().PixelToLogic(GetOutputSizePixel(), aDisplayMap);
const long nWidth = aWinSize.Width(); const long nWidth = aWinSize.Width();
const long nHeight = aWinSize.Height(); const long nHeight = aWinSize.Height();
if (aRect.GetHeight() == 0) if (aRect.GetHeight() == 0)
...@@ -123,7 +113,7 @@ void SvxXConnectionPreview::AdaptSize() ...@@ -123,7 +113,7 @@ void SvxXConnectionPreview::AdaptSize()
aNewPos.setX( ( nWidth - aNewSize.Width() ) >> 1 ); aNewPos.setX( ( nWidth - aNewSize.Width() ) >> 1 );
aNewPos.setY( ( nHeight - aNewSize.Height() ) >> 1 ); aNewPos.setY( ( nHeight - aNewSize.Height() ) >> 1 );
aDisplayMap.SetOrigin( LogicToLogic( aNewPos, aMapMode, aDisplayMap ) ); aDisplayMap.SetOrigin(OutputDevice::LogicToLogic(aNewPos, aMapMode, aDisplayMap));
SetMapMode( aDisplayMap ); SetMapMode( aDisplayMap );
// Origin // Origin
...@@ -206,6 +196,14 @@ void SvxXConnectionPreview::Construct() ...@@ -206,6 +196,14 @@ void SvxXConnectionPreview::Construct()
void SvxXConnectionPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) void SvxXConnectionPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{ {
rRenderContext.Push(PushFlags::ALL);
rRenderContext.SetMapMode(GetMapMode());
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
rRenderContext.SetDrawMode(rStyles.GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
rRenderContext.SetBackground(Wallpaper(rStyles.GetFieldColor()));
if (pSdrPage) if (pSdrPage)
{ {
// This will not work anymore. To not start at Adam and Eve, i will // This will not work anymore. To not start at Adam and Eve, i will
...@@ -231,6 +229,8 @@ void SvxXConnectionPreview::Paint(vcl::RenderContext& rRenderContext, const tool ...@@ -231,6 +229,8 @@ void SvxXConnectionPreview::Paint(vcl::RenderContext& rRenderContext, const tool
// do processing // do processing
aPainter.ProcessDisplay(aDisplayInfo); aPainter.ProcessDisplay(aDisplayInfo);
} }
rRenderContext.Pop();
} }
void SvxXConnectionPreview::SetAttributes( const SfxItemSet& rInAttrs ) void SvxXConnectionPreview::SetAttributes( const SfxItemSet& rInAttrs )
...@@ -240,7 +240,6 @@ void SvxXConnectionPreview::SetAttributes( const SfxItemSet& rInAttrs ) ...@@ -240,7 +240,6 @@ void SvxXConnectionPreview::SetAttributes( const SfxItemSet& rInAttrs )
Invalidate(); Invalidate();
} }
// Get number of lines which are offset based on the preview object // Get number of lines which are offset based on the preview object
sal_uInt16 SvxXConnectionPreview::GetLineDeltaCount() sal_uInt16 SvxXConnectionPreview::GetLineDeltaCount()
...@@ -291,7 +290,8 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -291,7 +290,8 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt )
aMapMode.SetScaleY( aYFrac ); aMapMode.SetScaleY( aYFrac );
SetMapMode( aMapMode ); SetMapMode( aMapMode );
Size aOutSize( GetOutputSize() ); Size aOutSize(GetOutputSizePixel());
aOutSize = GetDrawingArea()->get_ref_device().PixelToLogic(aOutSize);
Point aPt( aMapMode.GetOrigin() ); Point aPt( aMapMode.GetOrigin() );
long nX = static_cast<long>( ( static_cast<double>(aOutSize.Width()) - ( static_cast<double>(aOutSize.Width()) * static_cast<double>(*pMultFrac) ) ) / 2.0 + 0.5 ); long nX = static_cast<long>( ( static_cast<double>(aOutSize.Width()) - ( static_cast<double>(aOutSize.Width()) * static_cast<double>(*pMultFrac) ) ) / 2.0 + 0.5 );
...@@ -307,21 +307,4 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -307,21 +307,4 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt )
} }
} }
void SvxXConnectionPreview::SetStyles()
{
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
SetBackground( Wallpaper( rStyles.GetFieldColor() ) );
}
void SvxXConnectionPreview::DataChanged( const DataChangedEvent& rDCEvt )
{
Control::DataChanged( rDCEvt );
if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
{
SetStyles();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment