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

weld FontWorkGalleryDialog

Change-Id: I6a3a2b445d6f79d0c259c69176e1b23de1ff05d3
Reviewed-on: https://gerrit.libreoffice.org/61474Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 7aa30262
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <vcl/button.hxx> #include <vcl/button.hxx>
#include <vcl/dialog.hxx> #include <vcl/dialog.hxx>
#include <vcl/field.hxx> #include <vcl/field.hxx>
#include <vcl/weld.hxx>
#include <svtools/valueset.hxx> #include <svtools/valueset.hxx>
...@@ -59,31 +60,30 @@ public: ...@@ -59,31 +60,30 @@ public:
sal_Int32 getScale() const; 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; sal_uInt16 mnThemeId;
SdrView* mpSdrView; SdrView* mpSdrView;
DECL_LINK( DoubleClickFavoriteHdl, ValueSet*, void );
DECL_LINK( ClickOKHdl, Button*, void );
SdrObject** mppSdrObject; SdrObject** mppSdrObject;
SdrModel* mpDestModel; 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 initFavorites(sal_uInt16 nThemeId);
void insertSelectedFontwork(); void insertSelectedFontwork();
void fillFavorites(sal_uInt16 nThemeId); void fillFavorites(sal_uInt16 nThemeId);
std::vector< BitmapEx> maFavoritesHorizontal; DECL_LINK(DoubleClickFavoriteHdl, SvtValueSet*, void);
DECL_LINK(ClickOKHdl, weld::Button&, void );
public: public:
FontWorkGalleryDialog( SdrView* pView, vcl::Window* pParent ); FontWorkGalleryDialog(weld::Window* pParent, SdrView* pView);
virtual ~FontWorkGalleryDialog() override; 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 // SJ: if the SdrObject** is set, the SdrObject is not inserted into the page when executing the dialog
void SetSdrObjectRef( SdrObject**, SdrModel* pModel ); void SetSdrObjectRef( SdrObject**, SdrModel* pModel );
......
...@@ -65,25 +65,25 @@ namespace svx ...@@ -65,25 +65,25 @@ namespace svx
const int nColCount = 4; const int nColCount = 4;
const int nLineCount = 4; const int nLineCount = 4;
FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, vcl::Window* pParent ) : FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView* pSdrView)
ModalDialog(pParent, "FontworkGalleryDialog", "svx/ui/fontworkgallerydialog.ui" ), : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
mnThemeId ( 0xffff ), , mnThemeId(0xffff)
mpSdrView ( pSdrView ), , mpSdrView(pSdrView)
mppSdrObject ( nullptr ), , mppSdrObject(nullptr)
mpDestModel ( nullptr ) , mpDestModel(nullptr)
{ , maCtlFavorites(m_xBuilder->weld_scrolled_window("ctlFavoriteswin"))
get(mpOKButton, "ok"); , mxCtlFavorites(new weld::CustomWeld(*m_xBuilder, "ctlFavorites", maCtlFavorites))
get(mpCtlFavorites, "ctlFavorites"); , mxOKButton(m_xBuilder->weld_button("ok"))
Size aSize(LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont))); {
mpCtlFavorites->set_width_request(aSize.Width()); Size aSize(maCtlFavorites.GetDrawingArea()->get_ref_device().LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont)));
mpCtlFavorites->set_height_request(aSize.Height()); mxCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
mpCtlFavorites->SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) ); maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
mpOKButton->SetClickHdl( LINK( this, FontWorkGalleryDialog, ClickOKHdl ) ); mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl));
mpCtlFavorites->SetColCount( nColCount ); maCtlFavorites.SetColCount( nColCount );
mpCtlFavorites->SetLineCount( nLineCount ); maCtlFavorites.SetLineCount( nLineCount );
mpCtlFavorites->SetExtraSpacing( 3 ); maCtlFavorites.SetExtraSpacing( 3 );
initFavorites( GALLERY_THEME_FONTWORK ); initFavorites( GALLERY_THEME_FONTWORK );
fillFavorites( GALLERY_THEME_FONTWORK ); fillFavorites( GALLERY_THEME_FONTWORK );
...@@ -91,14 +91,6 @@ FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, vcl::Window* pP ...@@ -91,14 +91,6 @@ FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, vcl::Window* pP
FontWorkGalleryDialog::~FontWorkGalleryDialog() FontWorkGalleryDialog::~FontWorkGalleryDialog()
{ {
disposeOnce();
}
void FontWorkGalleryDialog::dispose()
{
mpCtlFavorites.clear();
mpOKButton.clear();
ModalDialog::dispose();
} }
void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId) void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
...@@ -121,8 +113,8 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId) ...@@ -121,8 +113,8 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
ScopedVclPtrInstance< VirtualDevice > pVDev; ScopedVclPtrInstance< VirtualDevice > pVDev;
const Point aNull(0, 0); const Point aNull(0, 0);
if (GetDPIScaleFactor() > 1) if (pVDev->GetDPIScaleFactor() > 1)
aThumb.Scale(GetDPIScaleFactor(), GetDPIScaleFactor()); aThumb.Scale(pVDev->GetDPIScaleFactor(), pVDev->GetDPIScaleFactor());
const Size aSize(aThumb.GetSizePixel()); const Size aSize(aThumb.GetSizePixel());
...@@ -147,7 +139,7 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId) ...@@ -147,7 +139,7 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
{ {
mnThemeId = nThemeId; mnThemeId = nThemeId;
Size aThumbSize( mpCtlFavorites->GetSizePixel() ); Size aThumbSize(maCtlFavorites.GetOutputSizePixel());
aThumbSize.setWidth( aThumbSize.Width() / nColCount ); aThumbSize.setWidth( aThumbSize.Width() / nColCount );
aThumbSize.setHeight( aThumbSize.Height() / nLineCount ); aThumbSize.setHeight( aThumbSize.Height() / nLineCount );
aThumbSize.AdjustWidth( -12 ); aThumbSize.AdjustWidth( -12 );
...@@ -158,12 +150,12 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId) ...@@ -158,12 +150,12 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
// ValueSet favorites // ValueSet favorites
if( nFavCount > (nColCount * nLineCount) ) if( nFavCount > (nColCount * nLineCount) )
{ {
WinBits nWinBits = mpCtlFavorites->GetStyle(); WinBits nWinBits = maCtlFavorites.GetStyle();
nWinBits |= WB_VSCROLL; nWinBits |= WB_VSCROLL;
mpCtlFavorites->SetStyle( nWinBits ); maCtlFavorites.SetStyle( nWinBits );
} }
mpCtlFavorites->Clear(); maCtlFavorites.Clear();
for( std::vector<Bitmap *>::size_type nFavorite = 1; nFavorite <= nFavCount; nFavorite++ ) for( std::vector<Bitmap *>::size_type nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
{ {
...@@ -171,7 +163,7 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId) ...@@ -171,7 +163,7 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
aStr += " "; aStr += " ";
aStr += OUString::number(nFavorite); aStr += OUString::number(nFavorite);
Image aThumbImage( maFavoritesHorizontal[nFavorite-1] ); 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* ...@@ -183,7 +175,7 @@ void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel*
void FontWorkGalleryDialog::insertSelectedFontwork() void FontWorkGalleryDialog::insertSelectedFontwork()
{ {
sal_uInt16 nItemId = mpCtlFavorites->GetSelectedItemId(); sal_uInt16 nItemId = maCtlFavorites.GetSelectedItemId();
if( nItemId > 0 ) if( nItemId > 0 )
{ {
...@@ -258,21 +250,18 @@ void FontWorkGalleryDialog::insertSelectedFontwork() ...@@ -258,21 +250,18 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
} }
} }
IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl, weld::Button&, void)
IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl, Button*, void)
{ {
insertSelectedFontwork(); insertSelectedFontwork();
EndDialog( RET_OK ); m_xDialog->response(RET_OK);
} }
IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, SvtValueSet*, void)
IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, ValueSet*, void)
{ {
insertSelectedFontwork(); insertSelectedFontwork();
EndDialog( RET_OK ); m_xDialog->response(RET_OK);
} }
class FontworkAlignmentWindow : public ToolbarMenu class FontworkAlignmentWindow : public ToolbarMenu
{ {
public: public:
......
...@@ -204,25 +204,6 @@ FontworkBar::~FontworkBar() ...@@ -204,25 +204,6 @@ FontworkBar::~FontworkBar()
SetRepeatTarget(nullptr); 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 { namespace svx {
bool checkForSelectedFontWork( SdrView const * pSdrView, sal_uInt32& nCheckStatus ) bool checkForSelectedFontWork( SdrView const * pSdrView, sal_uInt32& nCheckStatus )
{ {
...@@ -431,8 +412,8 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin ...@@ -431,8 +412,8 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin
{ {
case SID_FONTWORK_GALLERY_FLOATER: case SID_FONTWORK_GALLERY_FLOATER:
{ {
ScopedVclPtrInstance< FontWorkGalleryDialog > aDlg( pSdrView, ImpGetViewWin(pSdrView) ); FontWorkGalleryDialog aDlg(rReq.GetFrameWeld(), pSdrView);
aDlg->Execute(); aDlg.run();
} }
break; break;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="svx"> <interface domain="svx">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="FontworkGalleryDialog"> <object class="GtkDialog" id="FontworkGalleryDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="fontworkgallerydialog|FontworkGalleryDialog">Fontwork Gallery</property> <property name="title" translatable="yes" context="fontworkgallerydialog|FontworkGalleryDialog">Fontwork Gallery</property>
<property name="resizable">False</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> <property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -78,14 +83,16 @@ ...@@ -78,14 +83,16 @@
<object class="GtkGrid" id="grid1"> <object class="GtkGrid" id="grid1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <child>
<object class="GtkLabel" id="label1"> <object class="GtkLabel" id="label1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</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="label" translatable="yes" context="fontworkgallerydialog|label1">Select a Fontwork style:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -93,11 +100,29 @@ ...@@ -93,11 +100,29 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="svtlo-ValueSet" id="ctlFavorites:border"> <object class="GtkScrolledWindow" id="ctlFavoriteswin">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">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> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
......
...@@ -144,10 +144,9 @@ void SwView::ExecDraw(SfxRequest& rReq) ...@@ -144,10 +144,9 @@ void SwView::ExecDraw(SfxRequest& rReq)
} }
else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER ) 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 ) rWin.EnterWait();
pWin->EnterWait();
if( !m_pWrtShell->HasDrawView() ) if( !m_pWrtShell->HasDrawView() )
m_pWrtShell->MakeDrawView(); m_pWrtShell->MakeDrawView();
...@@ -156,9 +155,9 @@ void SwView::ExecDraw(SfxRequest& rReq) ...@@ -156,9 +155,9 @@ void SwView::ExecDraw(SfxRequest& rReq)
if ( pSdrView ) if ( pSdrView )
{ {
SdrObject* pObj = nullptr; SdrObject* pObj = nullptr;
ScopedVclPtrInstance< svx::FontWorkGalleryDialog > aDlg( pSdrView, pWin ); svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), pSdrView);
aDlg->SetSdrObjectRef( &pObj, pSdrView->GetModel() ); aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
aDlg->Execute(); aDlg.run();
if ( pObj ) if ( pObj )
{ {
Size aDocSize( m_pWrtShell->GetDocSize() ); Size aDocSize( m_pWrtShell->GetDocSize() );
...@@ -174,12 +173,7 @@ void SwView::ExecDraw(SfxRequest& rReq) ...@@ -174,12 +173,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() ); aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
if( aPrefSize.Width() && aPrefSize.Height() ) if( aPrefSize.Width() && aPrefSize.Height() )
{ aSize = rWin.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
if( pWin )
aSize = pWin->PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
else
aSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
}
else else
aSize = Size( 2835, 2835 ); aSize = Size( 2835, 2835 );
...@@ -188,8 +182,7 @@ void SwView::ExecDraw(SfxRequest& rReq) ...@@ -188,8 +182,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
rReq.Ignore (); rReq.Ignore ();
} }
} }
if( pWin ) rWin.LeaveWait();
pWin->LeaveWait();
} }
else if ( m_nFormSfxId != USHRT_MAX ) else if ( m_nFormSfxId != USHRT_MAX )
GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE ); GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE );
......
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