1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <tools/helpers.hxx>
23 #include <svl/eitem.hxx>
24 #include <sfx2/ctrlitem.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/module.hxx>
27 #include <unotools/localedatawrapper.hxx>
29 #include <svx/svxids.hrc>
30 #include <svx/contdlg.hxx>
31 #include "contimp.hxx"
32 #include "contwnd.hxx"
33 #include <svx/svdopath.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/settings.hxx>
36 #include <vcl/virdev.hxx>
37 #include "dlgunit.hxx"
38 #include <vcl/weld.hxx>
40 SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(SvxContourDlgChildWindow
, SID_CONTOUR_DLG
);
42 SvxContourDlgItem::SvxContourDlgItem( SvxSuperContourDlg
& rContourDlg
, SfxBindings
& rBindings
) :
43 SfxControllerItem ( SID_CONTOUR_EXEC
, rBindings
),
48 void SvxContourDlgItem::StateChangedAtToolBoxControl( sal_uInt16 nSID
, SfxItemState
/*eState*/, const SfxPoolItem
* pItem
)
50 if ( pItem
&& ( SID_CONTOUR_EXEC
== nSID
) )
52 const SfxBoolItem
* pStateItem
= dynamic_cast<const SfxBoolItem
*>( pItem
);
53 assert(pStateItem
); //SfxBoolItem expected
55 rDlg
.SetExecState(!pStateItem
->GetValue());
59 SvxContourDlgChildWindow::SvxContourDlgChildWindow(vcl::Window
* _pParent
, sal_uInt16 nId
,
60 SfxBindings
* pBindings
, SfxChildWinInfo
const * pInfo
)
61 : SfxChildWindow( _pParent
, nId
)
63 SetController(std::make_shared
<SvxContourDlg
>(pBindings
, this, _pParent
->GetFrameWeld()));
64 SvxContourDlg
* pDlg
= static_cast<SvxContourDlg
*>(GetController().get());
65 pDlg
->Initialize( pInfo
);
68 SvxContourDlg::SvxContourDlg(SfxBindings
* _pBindings
, SfxChildWindow
* pCW
,
69 weld::Window
* _pParent
)
70 : SfxModelessDialogController(_pBindings
, pCW
, _pParent
, "svx/ui/floatingcontour.ui", "FloatingContour")
71 , m_xImpl(std::make_unique
<SvxSuperContourDlg
>(*m_xBuilder
, *m_xDialog
, _pBindings
))
75 SvxContourDlg::~SvxContourDlg()
79 tools::PolyPolygon
SvxContourDlg::CreateAutoContour( const Graphic
& rGraphic
,
80 const tools::Rectangle
* pRect
)
83 bool bContourEdgeDetect
= false;
85 if ( rGraphic
.GetType() == GraphicType::Bitmap
)
87 if( rGraphic
.IsAnimated() )
89 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
91 const Animation
aAnim( rGraphic
.GetAnimation() );
92 const Size
& rSizePix
= aAnim
.GetDisplaySizePixel();
93 const sal_uInt16 nCount
= aAnim
.Count();
95 if ( pVDev
->SetOutputSizePixel( rSizePix
) )
97 pVDev
->SetLineColor( COL_BLACK
);
98 pVDev
->SetFillColor( COL_BLACK
);
100 for( sal_uInt16 i
= 0; i
< nCount
; i
++ )
102 const AnimationFrame
& rStepBmp
= aAnim
.Get( i
);
104 // Push Polygon output to the right place; this is the
105 // offset of the sub-image within the total animation
106 aTransMap
.SetOrigin( Point( rStepBmp
.maPositionPixel
.X(), rStepBmp
.maPositionPixel
.Y() ) );
107 pVDev
->SetMapMode( aTransMap
);
108 pVDev
->DrawPolyPolygon( CreateAutoContour( rStepBmp
.maBitmapEx
, pRect
) );
111 aTransMap
.SetOrigin( Point() );
112 pVDev
->SetMapMode( aTransMap
);
113 aBmp
= pVDev
->GetBitmap( Point(), rSizePix
);
114 aBmp
.Convert( BmpConversion::N1BitThreshold
);
117 else if( rGraphic
.IsTransparent() )
118 aBmp
= rGraphic
.GetBitmapEx().GetAlphaMask();
121 aBmp
= rGraphic
.GetBitmapEx().GetBitmap();
122 bContourEdgeDetect
= true;
125 else if( rGraphic
.GetType() != GraphicType::NONE
)
127 const Graphic
aTmpGrf( rGraphic
.GetGDIMetaFile().GetMonochromeMtf( COL_BLACK
) );
128 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
129 Size
aSizePix( pVDev
->LogicToPixel( aTmpGrf
.GetPrefSize(), aTmpGrf
.GetPrefMapMode() ) );
131 if( aSizePix
.Width() && aSizePix
.Height() && ( aSizePix
.Width() > 512 || aSizePix
.Height() > 512 ) )
133 double fWH
= static_cast<double>(aSizePix
.Width()) / aSizePix
.Height();
137 aSizePix
.setHeight(512);
138 aSizePix
.setWidth( FRound( ( aSizePix
.Height() ) * fWH
) );
142 aSizePix
.setWidth(512);
143 aSizePix
.setHeight( FRound( ( aSizePix
.Width() ) / fWH
) );
147 if( pVDev
->SetOutputSizePixel( aSizePix
) )
150 aTmpGrf
.Draw(*pVDev
, aPt
, aSizePix
);
151 aBmp
= pVDev
->GetBitmap( aPt
, aSizePix
);
154 bContourEdgeDetect
= true;
157 aBmp
.SetPrefSize( rGraphic
.GetPrefSize() );
158 aBmp
.SetPrefMapMode( rGraphic
.GetPrefMapMode() );
160 return tools::PolyPolygon( BitmapEx(aBmp
).GetContour( bContourEdgeDetect
, pRect
) );
163 // Loop through to super class, no virtual Methods to not become incompatible
166 const Graphic
& SvxContourDlg::GetGraphic() const
168 return m_xImpl
->GetGraphic();
171 bool SvxContourDlg::IsGraphicChanged() const
173 return m_xImpl
->IsGraphicChanged();
176 tools::PolyPolygon
SvxContourDlg::GetPolyPolygon()
178 return m_xImpl
->GetPolyPolygon();
181 const void* SvxContourDlg::GetEditingObject() const
183 return m_xImpl
->GetEditingObject();
186 void SvxContourDlg::Update( const Graphic
& rGraphic
, bool bGraphicLinked
,
187 const tools::PolyPolygon
* pPolyPoly
, void* pEditingObj
)
189 m_xImpl
->UpdateGraphic( rGraphic
, bGraphicLinked
, pPolyPoly
, pEditingObj
);
192 SvxSuperContourDlg::SvxSuperContourDlg(weld::Builder
& rBuilder
,
193 weld::Dialog
& rDialog
, SfxBindings
* pBindings
)
194 : aUpdateIdle( "SvxSuperContourDlg UpdateIdle" )
195 , aCreateIdle( "SvxSuperContourDlg CreateIdle" )
196 , mpBindings(pBindings
)
197 , pUpdateEditingObject( nullptr )
198 , pCheckObj( nullptr )
199 , aContourItem( *this, *pBindings
)
201 , bExecState( false )
202 , bUpdateGraphicLinked( false )
203 , bGraphicLinked( false )
205 , m_xContourWnd(new ContourWindow(&rDialog
))
206 , m_xStbStatusColor(new StatusColor(*m_xContourWnd
))
207 , m_xTbx1(rBuilder
.weld_toolbar("toolbar"))
208 , m_xMtfTolerance(rBuilder
.weld_metric_spin_button("spinbutton", FieldUnit::PERCENT
))
209 , m_xStbStatus2(rBuilder
.weld_label("statuspos"))
210 , m_xStbStatus3(rBuilder
.weld_label("statussize"))
211 , m_xCancelBtn(rBuilder
.weld_button("cancel"))
212 , m_xStbStatusColorWeld(new weld::CustomWeld(rBuilder
, "statuscolor", *m_xStbStatusColor
))
213 , m_xContourWndWeld(new weld::CustomWeld(rBuilder
, "container", *m_xContourWnd
))
215 m_xCancelBtn
->connect_clicked(LINK(this, SvxSuperContourDlg
, CancelHdl
));
217 m_xContourWnd
->SetMousePosLink( LINK( this, SvxSuperContourDlg
, MousePosHdl
) );
218 m_xContourWnd
->SetGraphSizeLink( LINK( this, SvxSuperContourDlg
, GraphSizeHdl
) );
219 m_xContourWnd
->SetUpdateLink( LINK( this, SvxSuperContourDlg
, StateHdl
) );
220 m_xContourWnd
->SetPipetteHdl( LINK( this, SvxSuperContourDlg
, PipetteHdl
) );
221 m_xContourWnd
->SetPipetteClickHdl( LINK( this, SvxSuperContourDlg
, PipetteClickHdl
) );
222 m_xContourWnd
->SetWorkplaceClickHdl( LINK( this, SvxSuperContourDlg
, WorkplaceClickHdl
) );
224 m_xTbx1
->connect_clicked( LINK( this, SvxSuperContourDlg
, Tbx1ClickHdl
) );
226 m_xMtfTolerance
->set_value(10, FieldUnit::PERCENT
);
228 aUpdateIdle
.SetInvokeHandler( LINK( this, SvxSuperContourDlg
, UpdateHdl
) );
230 aCreateIdle
.SetPriority( TaskPriority::RESIZE
);
231 aCreateIdle
.SetInvokeHandler( LINK( this, SvxSuperContourDlg
, CreateHdl
) );
234 SvxSuperContourDlg::~SvxSuperContourDlg()
236 m_xContourWnd
->SetUpdateLink( Link
<GraphCtrl
*,void>() );
237 m_xContourWnd
.reset();
240 IMPL_LINK_NOARG(SvxSuperContourDlg
, CancelHdl
, weld::Button
&, void)
244 if (m_xTbx1
->get_item_sensitive("TBI_APPLY"))
246 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(&m_rDialog
, "svx/ui/querysavecontchangesdialog.ui"));
247 std::unique_ptr
<weld::MessageDialog
> xQBox(xBuilder
->weld_message_dialog("QuerySaveContourChangesDialog"));
248 const short nRet
= xQBox
->run();
250 if ( nRet
== RET_YES
)
252 SfxBoolItem
aBoolItem( SID_CONTOUR_EXEC
, true );
253 GetBindings().GetDispatcher()->ExecuteList(
254 SID_CONTOUR_EXEC
, SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
257 else if ( nRet
== RET_CANCEL
)
262 m_rDialog
.response(RET_CANCEL
);
265 // Enabled or disabled all Controls
267 void SvxSuperContourDlg::SetExecState( bool bEnable
)
269 bExecState
= bEnable
;
272 void SvxSuperContourDlg::SetGraphic( const Graphic
& rGraphic
)
274 aUndoGraphic
= aRedoGraphic
= Graphic();
277 m_xContourWnd
->SetGraphic( aGraphic
);
280 void SvxSuperContourDlg::SetPolyPolygon( const tools::PolyPolygon
& rPolyPoly
)
282 DBG_ASSERT( m_xContourWnd
->GetGraphic().GetType() != GraphicType::NONE
, "Graphic must've been set first!" );
284 tools::PolyPolygon
aPolyPoly( rPolyPoly
);
285 const MapMode
aMap100( MapUnit::Map100thMM
);
286 const MapMode
aGrfMap( aGraphic
.GetPrefMapMode() );
287 OutputDevice
* pOutDev
= Application::GetDefaultDevice();
288 bool bPixelMap
= aGrfMap
.GetMapUnit() == MapUnit::MapPixel
;
290 for ( sal_uInt16 j
= 0, nPolyCount
= aPolyPoly
.Count(); j
< nPolyCount
; j
++ )
292 tools::Polygon
& rPoly
= aPolyPoly
[ j
];
294 for ( sal_uInt16 i
= 0, nCount
= rPoly
.GetSize(); i
< nCount
; i
++ )
296 Point
& rPt
= rPoly
[ i
];
299 rPt
= pOutDev
->LogicToPixel( rPt
, aGrfMap
);
301 rPt
= pOutDev
->PixelToLogic( rPt
, aMap100
);
305 m_xContourWnd
->SetPolyPolygon( aPolyPoly
);
306 m_xContourWnd
->GetSdrModel()->SetChanged();
309 tools::PolyPolygon
SvxSuperContourDlg::GetPolyPolygon()
311 tools::PolyPolygon
aRetPolyPoly( m_xContourWnd
->GetPolyPolygon() );
313 const MapMode
aMap100( MapUnit::Map100thMM
);
314 const MapMode
aGrfMap( aGraphic
.GetPrefMapMode() );
315 OutputDevice
* pOutDev
= Application::GetDefaultDevice();
316 bool bPixelMap
= aGrfMap
.GetMapUnit() == MapUnit::MapPixel
;
318 for ( sal_uInt16 j
= 0, nPolyCount
= aRetPolyPoly
.Count(); j
< nPolyCount
; j
++ )
320 tools::Polygon
& rPoly
= aRetPolyPoly
[ j
];
322 for ( sal_uInt16 i
= 0, nCount
= rPoly
.GetSize(); i
< nCount
; i
++ )
324 Point
& rPt
= rPoly
[ i
];
326 rPt
= pOutDev
->LogicToPixel( rPt
, aMap100
);
329 rPt
= pOutDev
->PixelToLogic( rPt
, aGrfMap
);
336 void SvxSuperContourDlg::UpdateGraphic( const Graphic
& rGraphic
, bool _bGraphicLinked
,
337 const tools::PolyPolygon
* pPolyPoly
, void* pEditingObj
)
339 aUpdateGraphic
= rGraphic
;
340 bUpdateGraphicLinked
= _bGraphicLinked
;
341 pUpdateEditingObject
= pEditingObj
;
344 aUpdatePolyPoly
= *pPolyPoly
;
346 aUpdatePolyPoly
= tools::PolyPolygon();
351 // Click handler for ToolBox
353 IMPL_LINK(SvxSuperContourDlg
, Tbx1ClickHdl
, const OUString
&, rId
, void)
355 if (rId
== "TBI_APPLY")
357 SfxBoolItem
aBoolItem( SID_CONTOUR_EXEC
, true );
358 GetBindings().GetDispatcher()->ExecuteList(
359 SID_CONTOUR_EXEC
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
,
362 else if (rId
== "TBI_WORKPLACE")
364 if (m_xTbx1
->get_item_active("TBI_WORKPLACE"))
366 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(&m_rDialog
, "svx/ui/querydeletecontourdialog.ui"));
367 std::unique_ptr
<weld::MessageDialog
> xQBox(xBuilder
->weld_message_dialog("QueryDeleteContourDialog"));
369 if (!m_xContourWnd
->IsContourChanged() || (xQBox
->run() == RET_YES
))
370 m_xContourWnd
->SetWorkplaceMode( true );
372 m_xTbx1
->set_item_active("TBI_WORKPLACE", false);
375 m_xContourWnd
->SetWorkplaceMode( false );
377 else if (rId
== "TBI_SELECT")
380 m_xContourWnd
->SetEditMode( true );
382 else if (rId
== "TBI_RECT")
385 m_xContourWnd
->SetObjKind( SdrObjKind::Rectangle
);
387 else if (rId
== "TBI_CIRCLE")
390 m_xContourWnd
->SetObjKind( SdrObjKind::CircleOrEllipse
);
392 else if (rId
== "TBI_POLY")
395 m_xContourWnd
->SetObjKind( SdrObjKind::Polygon
);
397 else if (rId
== "TBI_POLYEDIT")
399 m_xContourWnd
->SetPolyEditMode(m_xTbx1
->get_item_active("TBI_POLYEDIT") ? SID_BEZIER_MOVE
: 0);
401 else if (rId
== "TBI_POLYMOVE")
404 m_xContourWnd
->SetPolyEditMode( SID_BEZIER_MOVE
);
406 else if (rId
== "TBI_POLYINSERT")
409 m_xContourWnd
->SetPolyEditMode( SID_BEZIER_INSERT
);
411 else if (rId
== "TBI_POLYDELETE")
413 m_xContourWnd
->GetSdrView()->DeleteMarkedPoints();
415 else if (rId
== "TBI_UNDO")
417 mnGrfChanged
= mnGrfChanged
? mnGrfChanged
- 1 : 0;
418 aRedoGraphic
= aGraphic
;
419 aGraphic
= aUndoGraphic
;
420 aUndoGraphic
= Graphic();
421 m_xContourWnd
->SetGraphic( aGraphic
, false );
423 else if (rId
== "TBI_REDO")
426 aUndoGraphic
= aGraphic
;
427 aGraphic
= aRedoGraphic
;
428 aRedoGraphic
= Graphic();
429 m_xContourWnd
->SetGraphic( aGraphic
, false );
431 else if (rId
== "TBI_AUTOCONTOUR")
435 else if (rId
== "TBI_PIPETTE")
437 bool bPipette
= m_xTbx1
->get_item_active("TBI_PIPETTE");
440 m_xStbStatusColor
->Invalidate();
441 else if ( bGraphicLinked
)
443 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(&m_rDialog
, "svx/ui/queryunlinkgraphicsdialog.ui"));
444 std::unique_ptr
<weld::MessageDialog
> xQBox(xBuilder
->weld_message_dialog("QueryUnlinkGraphicsDialog"));
446 if (xQBox
->run() != RET_YES
)
449 m_xTbx1
->set_item_active("TBI_PIPETTE", bPipette
);
450 m_xStbStatusColor
->Invalidate();
454 m_xContourWnd
->SetPipetteMode( bPipette
);
456 m_xContourWnd
->QueueIdleUpdate();
459 void SvxSuperContourDlg::SetActiveTool(std::u16string_view rId
)
461 m_xTbx1
->set_item_active("TBI_SELECT", rId
== u
"TBI_SELECT");
462 m_xTbx1
->set_item_active("TBI_RECT", rId
== u
"TBI_RECT");
463 m_xTbx1
->set_item_active("TBI_CIRCLE", rId
== u
"TBI_CIRCLE");
464 m_xTbx1
->set_item_active("TBI_POLY", rId
== u
"TBI_POLY");
467 void SvxSuperContourDlg::SetActivePoly(std::u16string_view rId
)
469 m_xTbx1
->set_item_active("TBI_POLYMOVE", rId
== u
"TBI_POLYMOVE");
470 m_xTbx1
->set_item_active("TBI_POLYINSERT", rId
== u
"TBI_POLYINSERT");
473 IMPL_LINK( SvxSuperContourDlg
, MousePosHdl
, GraphCtrl
*, pWnd
, void )
476 const FieldUnit eFieldUnit
= GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
477 const Point
& rMousePos
= pWnd
->GetMousePos();
478 const LocaleDataWrapper
& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
479 const sal_Unicode cSep
= rLocaleWrapper
.getNumDecimalSep()[0];
481 aStr
= GetUnitString( rMousePos
.X(), eFieldUnit
, cSep
)
483 + GetUnitString( rMousePos
.Y(), eFieldUnit
, cSep
);
485 m_xStbStatus2
->set_label( aStr
);
488 IMPL_LINK( SvxSuperContourDlg
, GraphSizeHdl
, GraphCtrl
*, pWnd
, void )
491 const FieldUnit eFieldUnit
= GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
492 const Size
& rSize
= pWnd
->GetGraphicSize();
493 const LocaleDataWrapper
& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
494 const sal_Unicode cSep
= rLocaleWrapper
.getNumDecimalSep()[0];
496 aStr
= GetUnitString( rSize
.Width(), eFieldUnit
, cSep
)
498 + GetUnitString( rSize
.Height(), eFieldUnit
, cSep
);
500 m_xStbStatus3
->set_label( aStr
);
503 IMPL_LINK_NOARG(SvxSuperContourDlg
, UpdateHdl
, Timer
*, void)
507 if ( pUpdateEditingObject
!= pCheckObj
)
509 if( !GetEditingObject() )
510 m_xContourWnd
->GrabFocus();
512 SetGraphic( aUpdateGraphic
);
513 SetPolyPolygon( aUpdatePolyPoly
);
514 pCheckObj
= pUpdateEditingObject
;
515 bGraphicLinked
= bUpdateGraphicLinked
;
517 aUpdateGraphic
= Graphic();
518 aUpdatePolyPoly
= tools::PolyPolygon();
519 bUpdateGraphicLinked
= false;
521 m_xContourWnd
->GetSdrModel()->SetChanged( false );
524 GetBindings().Invalidate( SID_CONTOUR_EXEC
);
525 m_xContourWnd
->QueueIdleUpdate();
528 IMPL_LINK_NOARG(SvxSuperContourDlg
, CreateHdl
, Timer
*, void)
532 const tools::Rectangle aWorkRect
= m_xContourWnd
->GetDrawingArea()->get_ref_device().LogicToPixel(
533 m_xContourWnd
->GetWorkRect(), MapMode( MapUnit::Map100thMM
));
535 const Graphic
& rGraphic
= m_xContourWnd
->GetGraphic();
536 const bool bValid
= aWorkRect
.Left() != aWorkRect
.Right() && aWorkRect
.Top() != aWorkRect
.Bottom();
538 weld::WaitObject
aWaitObj(&m_rDialog
);
539 SetPolyPolygon( SvxContourDlg::CreateAutoContour( rGraphic
, bValid
? &aWorkRect
: nullptr ) );
542 IMPL_LINK( SvxSuperContourDlg
, StateHdl
, GraphCtrl
*, pWnd
, void )
544 const SdrObject
* pObj
= pWnd
->GetSelectedSdrObject();
545 const SdrView
* pView
= pWnd
->GetSdrView();
546 const bool bPolyEdit
= ( pObj
!= nullptr ) && dynamic_cast<const SdrPathObj
*>( pObj
) != nullptr;
547 const bool bDrawEnabled
= !(bPolyEdit
&& m_xTbx1
->get_item_active("TBI_POLYEDIT"));
548 const bool bPipette
= m_xTbx1
->get_item_active("TBI_PIPETTE");
549 const bool bWorkplace
= m_xTbx1
->get_item_active("TBI_WORKPLACE");
550 const bool bDontHide
= !( bPipette
|| bWorkplace
);
551 const bool bBitmap
= pWnd
->GetGraphic().GetType() == GraphicType::Bitmap
;
553 m_xTbx1
->set_item_sensitive("TBI_APPLY", bDontHide
&& bExecState
&& pWnd
->IsChanged());
555 m_xTbx1
->set_item_sensitive("TBI_WORKPLACE", !bPipette
&& bDrawEnabled
);
557 m_xTbx1
->set_item_sensitive("TBI_SELECT", bDontHide
&& bDrawEnabled
);
558 m_xTbx1
->set_item_sensitive("TBI_RECT", bDontHide
&& bDrawEnabled
);
559 m_xTbx1
->set_item_sensitive("TBI_CIRCLE", bDontHide
&& bDrawEnabled
);
560 m_xTbx1
->set_item_sensitive("TBI_POLY", bDontHide
&& bDrawEnabled
);
562 m_xTbx1
->set_item_sensitive("TBI_POLYEDIT", bDontHide
&& bPolyEdit
);
563 m_xTbx1
->set_item_sensitive("TBI_POLYMOVE", bDontHide
&& !bDrawEnabled
);
564 m_xTbx1
->set_item_sensitive("TBI_POLYINSERT", bDontHide
&& !bDrawEnabled
);
565 m_xTbx1
->set_item_sensitive("TBI_POLYDELETE", bDontHide
&& !bDrawEnabled
&& pView
->IsDeleteMarkedPointsPossible());
567 m_xTbx1
->set_item_sensitive("TBI_AUTOCONTOUR", bDontHide
&& bDrawEnabled
);
568 m_xTbx1
->set_item_sensitive("TBI_PIPETTE", !bWorkplace
&& bDrawEnabled
&& bBitmap
);
570 m_xTbx1
->set_item_sensitive("TBI_UNDO", bDontHide
&& aUndoGraphic
.GetType() != GraphicType::NONE
);
571 m_xTbx1
->set_item_sensitive("TBI_REDO", bDontHide
&& aRedoGraphic
.GetType() != GraphicType::NONE
);
575 switch( pWnd
->GetPolyEditMode() )
577 case SID_BEZIER_MOVE
:
578 SetActivePoly(u
"TBI_POLYMOVE");
580 case SID_BEZIER_INSERT
:
581 SetActivePoly(u
"TBI_POLYINSERT");
589 m_xTbx1
->set_item_active("TBI_POLYEDIT", false);
590 SetActivePoly(u
"TBI_POLYMOVE");
591 pWnd
->SetPolyEditMode( 0 );
595 IMPL_LINK_NOARG(SvxSuperContourDlg
, PipetteHdl
, ContourWindow
&, void)
597 m_xStbStatusColor
->Invalidate();
600 void StatusColor::Paint(vcl::RenderContext
& rDevice
, const tools::Rectangle
&)
602 const Color
& rOldLineColor
= rDevice
.GetLineColor();
603 const Color
& rOldFillColor
= rDevice
.GetFillColor();
605 tools::Rectangle
aRect(Point(), GetOutputSizePixel());
606 const Color
& rColor
= m_rWnd
.GetPipetteColor();
608 rDevice
.SetLineColor(rColor
);
609 rDevice
.SetFillColor(rColor
);
611 aRect
.AdjustLeft(4 );
613 aRect
.AdjustRight( -4 );
614 aRect
.AdjustBottom( -4 );
616 rDevice
.DrawRect( aRect
);
618 rDevice
.SetLineColor(rOldLineColor
);
619 rDevice
.SetFillColor(rOldFillColor
);
622 IMPL_LINK( SvxSuperContourDlg
, PipetteClickHdl
, ContourWindow
&, rWnd
, void )
624 if ( rWnd
.IsClickValid() )
626 const Color
& rColor
= rWnd
.GetPipetteColor();
628 weld::WaitObject
aWaitObj(&m_rDialog
);
630 if( aGraphic
.GetType() == GraphicType::Bitmap
)
632 const tools::Long nTol
= static_cast<tools::Long
>(m_xMtfTolerance
->get_value(FieldUnit::PERCENT
) * 255 / 100);
634 Bitmap aMask
= aGraphic
.GetBitmapEx().GetBitmap().CreateMask( rColor
, nTol
);
636 if( aGraphic
.IsTransparent() )
637 aMask
.CombineOr( aGraphic
.GetBitmapEx().GetAlphaMask() );
639 if( !aMask
.IsEmpty() )
641 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(&m_rDialog
, "svx/ui/querynewcontourdialog.ui"));
642 std::unique_ptr
<weld::MessageDialog
> xQBox(xBuilder
->weld_message_dialog("QueryNewContourDialog"));
646 aRedoGraphic
= Graphic();
647 aUndoGraphic
= aGraphic
;
648 Bitmap aBmp
= aGraphic
.GetBitmapEx().GetBitmap();
649 aGraphic
= Graphic( BitmapEx( aBmp
, aMask
) );
652 bNewContour
= (xQBox
->run() == RET_YES
);
653 rWnd
.SetGraphic( aGraphic
, bNewContour
);
661 m_xTbx1
->set_item_active("TBI_PIPETTE", false);
662 rWnd
.SetPipetteMode( false );
663 m_xStbStatusColor
->Invalidate();
666 IMPL_LINK( SvxSuperContourDlg
, WorkplaceClickHdl
, ContourWindow
&, rWnd
, void )
668 m_xTbx1
->set_item_active("TBI_WORKPLACE", false);
669 m_xTbx1
->set_item_active("TBI_SELECT", true);
670 rWnd
.SetWorkplaceMode( false );
672 m_xContourWnd
->QueueIdleUpdate();
675 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */