include/vcl/toolkit/combobox.hxx |    4 ++++
 vcl/inc/salvtables.hxx           |    8 +++++---
 vcl/source/control/combobox.cxx  |   35 ++++++++++++++++++++---------------
 3 files changed, 29 insertions(+), 18 deletions(-)

New commits:
commit 88cca903a88902e51c24853f1d10aeae39b39cdd
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Apr 5 21:05:23 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Apr 6 10:53:12 2021 +0200

    be more explicit in setting the parent of the buttons in the style dropdown
    
    set their parent explicitly to the desired combobo dropdown area instead
    of knowing that parent is available as GetWindow in UserDrawEvent
    
    Change-Id: I22210d242ab2b847fdba8bcc9dacee393905e872
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113624
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/vcl/toolkit/combobox.hxx b/include/vcl/toolkit/combobox.hxx
index 97e5ef18dad7..105c5dcb0c95 100644
--- a/include/vcl/toolkit/combobox.hxx
+++ b/include/vcl/toolkit/combobox.hxx
@@ -31,6 +31,7 @@
 #define COMBOBOX_ENTRY_NOTFOUND     (SAL_MAX_INT32)
 #define COMBOBOX_MAX_ENTRIES        (SAL_MAX_INT32 - 1)
 
+class ImplListBoxWindow;
 class UserDrawEvent;
 
 /// A widget used to choose from a list of items and which has an entry.
@@ -183,6 +184,9 @@ public:
 
     tools::Long GetDropDownEntryHeight() const;
 
+    // the drop down window container
+    ImplListBoxWindow* GetMainWindow() const;
+
     virtual bool set_property(const OString &rKey, const OUString &rValue) 
override;
 
     virtual FactoryFunction GetUITestFactory() const override;
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 88bda40618b6..1afffdfe280d 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -23,11 +23,12 @@
 #include <vcl/toolkit/combobox.hxx>
 #include <vcl/tabctrl.hxx>
 #include <vcl/layout.hxx>
-#include "messagedialog.hxx"
 #include <vcl/toolkit/svtabbx.hxx>
 #include <vcl/toolkit/svlbitm.hxx>
 #include <o3tl/sorted_vector.hxx>
 #include "iconview.hxx"
+#include "listbox.hxx"
+#include "messagedialog.hxx"
 
 class SalInstanceBuilder : public weld::Builder
 {
@@ -811,8 +812,9 @@ public:
 
         if (m_xMenuButton && m_xMenuButton->IsVisible() && m_sMenuButtonRow == 
sId)
         {
-            if (m_xMenuButton->GetParent() != pEvent->GetWindow())
-                m_xMenuButton->SetParent(pEvent->GetWindow());
+            vcl::Window* pEventWindow = m_xComboBox->GetMainWindow();
+            if (m_xMenuButton->GetParent() != pEventWindow)
+                m_xMenuButton->SetParent(pEventWindow);
             int nButtonWidth = get_menu_button_width();
             m_xMenuButton->SetSizePixel(Size(nButtonWidth, rRect.GetHeight()));
             m_xMenuButton->SetPosPixel(Point(rRect.GetWidth() - nButtonWidth, 
rRect.getY()));
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index acf3a0c26d36..6ba717abab5a 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -245,7 +245,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits 
nStyle )
     if (m_pImpl->m_pFloatWin)
         m_pImpl->m_pFloatWin->SetImplListBox( m_pImpl->m_pImplLB );
     else
-        m_pImpl->m_pImplLB->GetMainWindow()->AllowGrabFocus( true );
+        GetMainWindow()->AllowGrabFocus( true );
 
     ImplCalcEditHeight();
 
@@ -610,7 +610,7 @@ void ComboBox::FillLayoutData() const
     mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
     AppendLayoutData( *m_pImpl->m_pSubEdit );
     m_pImpl->m_pSubEdit->SetLayoutDataParent( this );
-    ImplListBoxWindow* rMainWindow = m_pImpl->m_pImplLB->GetMainWindow();
+    ImplListBoxWindow* rMainWindow = GetMainWindow();
     if (m_pImpl->m_pFloatWin)
     {
         // dropdown mode
@@ -676,7 +676,7 @@ void ComboBox::StateChanged( StateChangedType nType )
     else if ( nType == StateChangedType::Style )
     {
         SetStyle( ImplInitStyle( GetStyle() ) );
-        m_pImpl->m_pImplLB->GetMainWindow()->EnableSort( ( GetStyle() & 
WB_SORT ) != 0 );
+        GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) != 0 );
     }
     else if( nType == StateChangedType::Mirroring )
     {
@@ -794,7 +794,7 @@ bool ComboBox::EventNotify( NotifyEvent& rNEvt )
         }
     }
     else if ((rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN)
-            && (rNEvt.GetWindow() == m_pImpl->m_pImplLB->GetMainWindow()))
+            && (rNEvt.GetWindow() == GetMainWindow()))
     {
         m_pImpl->m_pSubEdit->GrabFocus();
     }
@@ -1136,7 +1136,7 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& 
rnCols, sal_uInt16& rnLines
     tools::Long nCharWidth = GetTextWidth(OUString(u'x'));
     if ( !IsDropDownBox() )
     {
-        Size aOutSz = 
m_pImpl->m_pImplLB->GetMainWindow()->GetOutputSizePixel();
+        Size aOutSz = GetMainWindow()->GetOutputSizePixel();
         rnCols = (nCharWidth > 0) ? 
static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1;
         rnLines = 
static_cast<sal_uInt16>(aOutSz.Height()/GetDropDownEntryHeight());
     }
@@ -1150,11 +1150,11 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& 
rnCols, sal_uInt16& rnLines
 
 void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags )
 {
-    m_pImpl->m_pImplLB->GetMainWindow()->ApplySettings(*pDev);
+    GetMainWindow()->ApplySettings(*pDev);
 
     Point aPos = pDev->LogicToPixel( rPos );
     Size aSize = GetSizePixel();
-    vcl::Font aFont = m_pImpl->m_pImplLB->GetMainWindow()->GetDrawPixelFont( 
pDev );
+    vcl::Font aFont = GetMainWindow()->GetDrawPixelFont( pDev );
 
     pDev->Push();
     pDev->SetMapMode();
@@ -1263,23 +1263,23 @@ void ComboBox::SetUserDrawHdl(const 
Link<UserDrawEvent*, void>& rLink)
 
 void ComboBox::SetUserItemSize( const Size& rSz )
 {
-    m_pImpl->m_pImplLB->GetMainWindow()->SetUserItemSize( rSz );
+    GetMainWindow()->SetUserItemSize( rSz );
 }
 
 void ComboBox::EnableUserDraw( bool bUserDraw )
 {
-    m_pImpl->m_pImplLB->GetMainWindow()->EnableUserDraw( bUserDraw );
+    GetMainWindow()->EnableUserDraw( bUserDraw );
 }
 
 bool ComboBox::IsUserDrawEnabled() const
 {
-    return m_pImpl->m_pImplLB->GetMainWindow()->IsUserDrawEnabled();
+    return GetMainWindow()->IsUserDrawEnabled();
 }
 
 void ComboBox::DrawEntry(const UserDrawEvent& rEvt)
 {
-    SAL_WARN_IF(rEvt.GetWindow() != m_pImpl->m_pImplLB->GetMainWindow(), 
"vcl", "DrawEntry?!");
-    m_pImpl->m_pImplLB->GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), 
rEvt.GetItemId(), /*bDrawImage*/false, /*bDrawText*/false);
+    SAL_WARN_IF(rEvt.GetWindow() != GetMainWindow(), "vcl", "DrawEntry?!");
+    GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), rEvt.GetItemId(), 
/*bDrawImage*/false, /*bDrawText*/false);
 }
 
 void ComboBox::AddSeparator( sal_Int32 n )
@@ -1390,8 +1390,8 @@ void ComboBox::SetNoSelection()
 
 tools::Rectangle ComboBox::GetBoundingRectangle( sal_Int32 nItem ) const
 {
-    tools::Rectangle aRect = 
m_pImpl->m_pImplLB->GetMainWindow()->GetBoundingRectangle( nItem );
-    tools::Rectangle aOffset = 
m_pImpl->m_pImplLB->GetMainWindow()->GetWindowExtentsRelative( 
static_cast<vcl::Window*>(const_cast<ComboBox *>(this)) );
+    tools::Rectangle aRect = GetMainWindow()->GetBoundingRectangle( nItem );
+    tools::Rectangle aOffset = GetMainWindow()->GetWindowExtentsRelative( 
static_cast<vcl::Window*>(const_cast<ComboBox *>(this)) );
     aRect.Move( aOffset.Left(), aOffset.Top() );
     return aRect;
 }
@@ -1406,6 +1406,11 @@ void ComboBox::SetBorderStyle( WindowBorderStyle 
nBorderStyle )
     }
 }
 
+ImplListBoxWindow* ComboBox::GetMainWindow() const
+{
+    return m_pImpl->m_pImplLB->GetMainWindow();
+}
+
 tools::Long ComboBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) 
const
 {
     if( !HasLayoutData() )
@@ -1417,7 +1422,7 @@ tools::Long ComboBox::GetIndexForPoint( const Point& 
rPoint, sal_Int32& rPos ) c
     {
         // point must be either in main list window
         // or in impl window (dropdown case)
-        ImplListBoxWindow* rMain = m_pImpl->m_pImplLB->GetMainWindow();
+        ImplListBoxWindow* rMain = GetMainWindow();
 
         // convert coordinates to ImplListBoxWindow pixel coordinate space
         Point aConvPoint = LogicToPixel( rPoint );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to