add a SystemChildWindow::GetOptimalSize override

Change-Id: I812d996e78a6d627fda6612307ca4cb2f111b6a9
Reviewed-on: https://gerrit.libreoffice.org/85325
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2019-12-17 17:25:57 +00:00
parent b37540b1b3
commit 0c764bfd7a
5 changed files with 28 additions and 0 deletions

View file

@ -41,6 +41,7 @@ public:
// create a SystemChildWindow using the given SystemWindowData
explicit SystemChildWindow( vcl::Window* pParent, WinBits nStyle, SystemWindowData *pData, bool bShow = true );
virtual ~SystemChildWindow() override;
virtual Size GetOptimalSize() const override;
virtual void dispose() override;
virtual const SystemEnvData* GetSystemData() const override;

View file

@ -55,6 +55,8 @@ public:
virtual const SystemEnvData* GetSystemData() const = 0;
virtual Size GetOptimalSize() const { return Size(); }
void SetCallback( SystemChildWindow* pInst, SALOBJECTPROC pProc )
{ m_pInst = pInst; m_pCallback = pProc; }
void CallCallback( SalObjEvent nEvent )

View file

@ -52,6 +52,8 @@ public:
virtual void SetForwardKey( bool bEnable ) override;
virtual const SystemEnvData* GetSystemData() const override;
virtual Size GetOptimalSize() const override;
};
#endif // INCLUDED_VCL_INC_UNX_GTK_GTKOBJECT_HXX

View file

@ -140,6 +140,13 @@ void SystemChildWindow::EnableEraseBackground( bool bEnable )
mpWindowImpl->mpSysObj->EnableEraseBackground( bEnable );
}
Size SystemChildWindow::GetOptimalSize() const
{
if (mpWindowImpl->mpSysObj)
return mpWindowImpl->mpSysObj->GetOptimalSize();
return vcl::Window::GetOptimalSize();
}
void SystemChildWindow::SetLeaveEnterBackgrounds(const css::uno::Sequence<css::uno::Any>& rLeaveArgs, const css::uno::Sequence<css::uno::Any>& rEnterArgs)
{
if (mpWindowImpl->mpSysObj)

View file

@ -156,6 +156,22 @@ void GtkSalObject::Show( bool bVisible )
}
}
Size GtkSalObject::GetOptimalSize() const
{
if (m_pSocket)
{
bool bVisible = gtk_widget_get_visible(m_pSocket);
if (!bVisible)
gtk_widget_set_visible(m_pSocket, true);
GtkRequisition size;
gtk_widget_get_preferred_size(m_pSocket, nullptr, &size);
if (!bVisible)
gtk_widget_set_visible(m_pSocket, false);
return Size(size.width, size.height);
}
return Size();
}
const SystemEnvData* GtkSalObject::GetSystemData() const
{
return &m_aSystemData;