summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-06 16:27:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-06 21:58:10 +0200
commitb8633c58dc7fa43076abeeb7e53a931d92119f26 (patch)
treea83e2d579ce00ce5416ca5b45e5f4dc1511b6576 /svx
parent7aa30262d543ed87d673264d6f51146694120d94 (diff)
weld FontWorkGalleryDialog
Change-Id: I6a3a2b445d6f79d0c259c69176e1b23de1ff05d3 Reviewed-on: https://gerrit.libreoffice.org/61474 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx73
-rw-r--r--svx/source/toolbars/fontworkbar.cxx23
-rw-r--r--svx/uiconfig/ui/fontworkgallerydialog.ui35
3 files changed, 63 insertions, 68 deletions
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>