summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/fontworkgallery.hxx22
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx73
-rw-r--r--svx/source/toolbars/fontworkbar.cxx23
-rw-r--r--svx/uiconfig/ui/fontworkgallerydialog.ui35
-rw-r--r--sw/source/uibase/uiview/viewdraw.cxx21
5 files changed, 81 insertions, 93 deletions
diff --git a/include/svx/fontworkgallery.hxx b/include/svx/fontworkgallery.hxx
index 5699f1791cfc..58ff23d34698 100644
--- a/include/svx/fontworkgallery.hxx
+++ b/include/svx/fontworkgallery.hxx
@@ -27,6 +27,7 @@
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/field.hxx>
+#include <vcl/weld.hxx>
#include <svtools/valueset.hxx>
@@ -59,31 +60,30 @@ public:
sal_Int32 getScale() const;
};
-class SAL_WARN_UNUSED SVX_DLLPUBLIC FontWorkGalleryDialog : public ModalDialog
+class SAL_WARN_UNUSED SVX_DLLPUBLIC FontWorkGalleryDialog : public weld::GenericDialogController
{
- VclPtr<ValueSet> mpCtlFavorites;
- VclPtr<OKButton> mpOKButton;
-
sal_uInt16 mnThemeId;
-
SdrView* mpSdrView;
- DECL_LINK( DoubleClickFavoriteHdl, ValueSet*, void );
- DECL_LINK( ClickOKHdl, Button*, void );
-
SdrObject** mppSdrObject;
SdrModel* mpDestModel;
+ std::vector<BitmapEx> maFavoritesHorizontal;
+
+ SvtValueSet maCtlFavorites;
+ std::unique_ptr<weld::CustomWeld> mxCtlFavorites;
+ std::unique_ptr<weld::Button> mxOKButton;
+
void initFavorites(sal_uInt16 nThemeId);
void insertSelectedFontwork();
void fillFavorites(sal_uInt16 nThemeId);
- std::vector< BitmapEx> maFavoritesHorizontal;
+ DECL_LINK(DoubleClickFavoriteHdl, SvtValueSet*, void);
+ DECL_LINK(ClickOKHdl, weld::Button&, void );
public:
- FontWorkGalleryDialog( SdrView* pView, vcl::Window* pParent );
+ FontWorkGalleryDialog(weld::Window* pParent, SdrView* pView);
virtual ~FontWorkGalleryDialog() override;
- virtual void dispose() override;
// SJ: if the SdrObject** is set, the SdrObject is not inserted into the page when executing the dialog
void SetSdrObjectRef( SdrObject**, SdrModel* pModel );
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index e5e40c9e06a8..65243aad0fc2 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -65,25 +65,25 @@ namespace svx
const int nColCount = 4;
const int nLineCount = 4;
-FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, vcl::Window* pParent ) :
- ModalDialog(pParent, "FontworkGalleryDialog", "svx/ui/fontworkgallerydialog.ui" ),
- mnThemeId ( 0xffff ),
- mpSdrView ( pSdrView ),
- mppSdrObject ( nullptr ),
- mpDestModel ( nullptr )
-{
- get(mpOKButton, "ok");
- get(mpCtlFavorites, "ctlFavorites");
- Size aSize(LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont)));
- mpCtlFavorites->set_width_request(aSize.Width());
- mpCtlFavorites->set_height_request(aSize.Height());
-
- mpCtlFavorites->SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
- mpOKButton->SetClickHdl( LINK( this, FontWorkGalleryDialog, ClickOKHdl ) );
-
- mpCtlFavorites->SetColCount( nColCount );
- mpCtlFavorites->SetLineCount( nLineCount );
- mpCtlFavorites->SetExtraSpacing( 3 );
+FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView* pSdrView)
+ : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
+ , mnThemeId(0xffff)
+ , mpSdrView(pSdrView)
+ , mppSdrObject(nullptr)
+ , mpDestModel(nullptr)
+ , maCtlFavorites(m_xBuilder->weld_scrolled_window("ctlFavoriteswin"))
+ , mxCtlFavorites(new weld::CustomWeld(*m_xBuilder, "ctlFavorites", maCtlFavorites))
+ , mxOKButton(m_xBuilder->weld_button("ok"))
+{
+ Size aSize(maCtlFavorites.GetDrawingArea()->get_ref_device().LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont)));
+ mxCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
+
+ maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
+ mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl));
+
+ maCtlFavorites.SetColCount( nColCount );
+ maCtlFavorites.SetLineCount( nLineCount );
+ maCtlFavorites.SetExtraSpacing( 3 );
initFavorites( GALLERY_THEME_FONTWORK );
fillFavorites( GALLERY_THEME_FONTWORK );
@@ -91,14 +91,6 @@ FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, vcl::Window* pP
FontWorkGalleryDialog::~FontWorkGalleryDialog()
{
- disposeOnce();
-}
-
-void FontWorkGalleryDialog::dispose()
-{
- mpCtlFavorites.clear();
- mpOKButton.clear();
- ModalDialog::dispose();
}
void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
@@ -121,8 +113,8 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
ScopedVclPtrInstance< VirtualDevice > pVDev;
const Point aNull(0, 0);
- if (GetDPIScaleFactor() > 1)
- aThumb.Scale(GetDPIScaleFactor(), GetDPIScaleFactor());
+ if (pVDev->GetDPIScaleFactor() > 1)
+ aThumb.Scale(pVDev->GetDPIScaleFactor(), pVDev->GetDPIScaleFactor());
const Size aSize(aThumb.GetSizePixel());
@@ -147,7 +139,7 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
{
mnThemeId = nThemeId;
- Size aThumbSize( mpCtlFavorites->GetSizePixel() );
+ Size aThumbSize(maCtlFavorites.GetOutputSizePixel());
aThumbSize.setWidth( aThumbSize.Width() / nColCount );
aThumbSize.setHeight( aThumbSize.Height() / nLineCount );
aThumbSize.AdjustWidth( -12 );
@@ -158,12 +150,12 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
// ValueSet favorites
if( nFavCount > (nColCount * nLineCount) )
{
- WinBits nWinBits = mpCtlFavorites->GetStyle();
+ WinBits nWinBits = maCtlFavorites.GetStyle();
nWinBits |= WB_VSCROLL;
- mpCtlFavorites->SetStyle( nWinBits );
+ maCtlFavorites.SetStyle( nWinBits );
}
- mpCtlFavorites->Clear();
+ maCtlFavorites.Clear();
for( std::vector<Bitmap *>::size_type nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
{
@@ -171,7 +163,7 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
aStr += " ";
aStr += OUString::number(nFavorite);
Image aThumbImage( maFavoritesHorizontal[nFavorite-1] );
- mpCtlFavorites->InsertItem( static_cast<sal_uInt16>(nFavorite), aThumbImage, aStr );
+ maCtlFavorites.InsertItem( static_cast<sal_uInt16>(nFavorite), aThumbImage, aStr );
}
}
@@ -183,7 +175,7 @@ void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel*
void FontWorkGalleryDialog::insertSelectedFontwork()
{
- sal_uInt16 nItemId = mpCtlFavorites->GetSelectedItemId();
+ sal_uInt16 nItemId = maCtlFavorites.GetSelectedItemId();
if( nItemId > 0 )
{
@@ -258,21 +250,18 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
}
}
-
-IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl, Button*, void)
+IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl, weld::Button&, void)
{
insertSelectedFontwork();
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
-
-IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, ValueSet*, void)
+IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, SvtValueSet*, void)
{
insertSelectedFontwork();
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
-
class FontworkAlignmentWindow : public ToolbarMenu
{
public:
diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx
index b4679ba0eff0..f5283818191b 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -204,25 +204,6 @@ FontworkBar::~FontworkBar()
SetRepeatTarget(nullptr);
}
-static vcl::Window* ImpGetViewWin(SdrView const * pView)
-{
- if( pView )
- {
- const sal_uInt32 nCount(pView->PaintWindowCount());
- for(sal_uInt32 nNum(0); nNum < nCount; nNum++)
- {
- OutputDevice* pOut = &(pView->GetPaintWindow(nNum)->GetOutputDevice());
-
- if(OUTDEV_WINDOW == pOut->GetOutDevType())
- {
- return static_cast<vcl::Window*>(pOut);
- }
- }
- }
-
- return nullptr;
-}
-
namespace svx {
bool checkForSelectedFontWork( SdrView const * pSdrView, sal_uInt32& nCheckStatus )
{
@@ -431,8 +412,8 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin
{
case SID_FONTWORK_GALLERY_FLOATER:
{
- ScopedVclPtrInstance< FontWorkGalleryDialog > aDlg( pSdrView, ImpGetViewWin(pSdrView) );
- aDlg->Execute();
+ FontWorkGalleryDialog aDlg(rReq.GetFrameWeld(), pSdrView);
+ aDlg.run();
}
break;
diff --git a/svx/uiconfig/ui/fontworkgallerydialog.ui b/svx/uiconfig/ui/fontworkgallerydialog.ui
index e0b62dcc2cca..5fe62cd15f06 100644
--- a/svx/uiconfig/ui/fontworkgallerydialog.ui
+++ b/svx/uiconfig/ui/fontworkgallerydialog.ui
@@ -1,14 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="FontworkGalleryDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="fontworkgallerydialog|FontworkGalleryDialog">Fontwork Gallery</property>
<property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -78,14 +83,16 @@
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="fontworkgallerydialog|label1">Select a Fontwork style:</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -93,11 +100,29 @@
</packing>
</child>
<child>
- <object class="svtlo-ValueSet" id="ctlFavorites:border">
+ <object class="GtkScrolledWindow" id="ctlFavoriteswin">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkDrawingArea" id="ctlFavorites">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index d1939e6df0b6..8a94bb84f346 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -144,10 +144,9 @@ void SwView::ExecDraw(SfxRequest& rReq)
}
else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
{
- vcl::Window* pWin = &( m_pWrtShell->GetView().GetViewFrame()->GetWindow() );
+ vcl::Window& rWin = m_pWrtShell->GetView().GetViewFrame()->GetWindow();
- if ( pWin )
- pWin->EnterWait();
+ rWin.EnterWait();
if( !m_pWrtShell->HasDrawView() )
m_pWrtShell->MakeDrawView();
@@ -156,9 +155,9 @@ void SwView::ExecDraw(SfxRequest& rReq)
if ( pSdrView )
{
SdrObject* pObj = nullptr;
- ScopedVclPtrInstance< svx::FontWorkGalleryDialog > aDlg( pSdrView, pWin );
- aDlg->SetSdrObjectRef( &pObj, pSdrView->GetModel() );
- aDlg->Execute();
+ svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), pSdrView);
+ aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
+ aDlg.run();
if ( pObj )
{
Size aDocSize( m_pWrtShell->GetDocSize() );
@@ -174,12 +173,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
if( aPrefSize.Width() && aPrefSize.Height() )
- {
- if( pWin )
- aSize = pWin->PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
- else
- aSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
- }
+ aSize = rWin.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
else
aSize = Size( 2835, 2835 );
@@ -188,8 +182,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
rReq.Ignore ();
}
}
- if( pWin )
- pWin->LeaveWait();
+ rWin.LeaveWait();
}
else if ( m_nFormSfxId != USHRT_MAX )
GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE );