diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-02-16 09:42:07 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-02-16 15:57:32 +0100 |
commit | 807317255a655372e3b602a80cec2989776804c5 (patch) | |
tree | 3b6cd86b3ed51e02391a3c70371599958ae3bc12 /dbaccess/source/ui | |
parent | 96d839a991d7d271adce37a41bccf54b015c9c35 (diff) |
weld OTableWindowTitle
Change-Id: I466b73b1135c1336e3c94432f220b52343fe00d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110984
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r-- | dbaccess/source/ui/inc/TableWindow.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/TableWindowTitle.hxx | 18 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/TableWindow.cxx | 31 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/TableWindowTitle.cxx | 122 |
4 files changed, 39 insertions, 133 deletions
diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx index 9e616e9fc135..cb8a210f527a 100644 --- a/dbaccess/source/ui/inc/TableWindow.hxx +++ b/dbaccess/source/ui/inc/TableWindow.hxx @@ -25,6 +25,7 @@ #include "TableWindowData.hxx" #include "TableWindowListBox.hxx" #include <vector> +#include <vcl/fixed.hxx> #include <vcl/window.hxx> #include <comphelper/containermultiplexer.hxx> diff --git a/dbaccess/source/ui/inc/TableWindowTitle.hxx b/dbaccess/source/ui/inc/TableWindowTitle.hxx index d60f7389a4f8..04e612de58ad 100644 --- a/dbaccess/source/ui/inc/TableWindowTitle.hxx +++ b/dbaccess/source/ui/inc/TableWindowTitle.hxx @@ -18,30 +18,24 @@ */ #pragma once -#include <vcl/fixed.hxx> +#include <vcl/InterimItemWindow.hxx> namespace dbaui { class OTableWindow; - class OTableWindowTitle : public FixedText + class OTableWindowTitle final : public InterimItemWindow { VclPtr<OTableWindow> m_pTabWin; + std::unique_ptr<weld::Label> m_xLabel; - protected: - virtual void Command(const CommandEvent& rEvt) override; - virtual void MouseButtonDown( const MouseEvent& rEvt ) override; - virtual void KeyInput( const KeyEvent& rEvt ) override; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + DECL_LINK(MousePressHdl, const MouseEvent&, bool); public: OTableWindowTitle( OTableWindow* pParent ); virtual ~OTableWindowTitle() override; virtual void dispose() override; - virtual void LoseFocus() override; - virtual void GetFocus() override; - virtual void RequestHelp( const HelpEvent& rHEvt ) override; - // window override - virtual void StateChanged( StateChangedType nStateChange ) override; + + weld::Label& GetLabel() { return *m_xLabel; } }; } diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index 200c39ebe006..db0119ce89da 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -87,16 +87,15 @@ void Draw3DBorder(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR } OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData ) - : ::comphelper::OContainerListener(m_aMutex) - ,Window( pParent, WB_3DLOOK|WB_MOVEABLE ) - ,m_aTypeImage( VclPtr<FixedImage>::Create(this) ) - ,m_xTitle( VclPtr<OTableWindowTitle>::Create(this) ) - ,m_pData( pTabWinData ) - ,m_nMoveCount(0) - ,m_nMoveIncrement(1) - ,m_nSizingFlags( SizingFlags::NONE ) + : ::comphelper::OContainerListener(m_aMutex) + , Window( pParent, WB_3DLOOK|WB_MOVEABLE ) + , m_aTypeImage( VclPtr<FixedImage>::Create(this) ) + , m_xTitle( VclPtr<OTableWindowTitle>::Create(this) ) + , m_pData( pTabWinData ) + , m_nMoveCount(0) + , m_nMoveIncrement(1) + , m_nSizingFlags( SizingFlags::NONE ) { - // Set position and size if( GetData()->HasPosition() ) SetPosPixel( GetData()->GetPosition() ); @@ -294,7 +293,9 @@ bool OTableWindow::Init() } // Set the title - m_xTitle->SetText( m_pData->GetWinName() ); + weld::Label& rLabel = m_xTitle->GetLabel(); + rLabel.set_label(m_pData->GetWinName()); + rLabel.set_tooltip_text(GetComposedName()); m_xTitle->Show(); m_xListBox->Show(); @@ -459,10 +460,10 @@ void OTableWindow::Resize() void OTableWindow::SetBoldTitle( bool bBold ) { - vcl::Font aFont = m_xTitle->GetFont(); - aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL ); - m_xTitle->SetFont( aFont ); - m_xTitle->Invalidate(); + weld::Label& rLabel = m_xTitle->GetLabel(); + vcl::Font aFont = rLabel.get_font(); + aFont.SetWeight(bBold ? WEIGHT_BOLD : WEIGHT_NORMAL); + rLabel.set_font(aFont); } void OTableWindow::GetFocus() @@ -710,7 +711,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt) OUString OTableWindow::getTitle() const { - return m_xTitle->GetText(); + return m_xTitle->GetLabel().get_label(); } void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx index 5157db77eda4..a2a569fc8679 100644 --- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx @@ -31,18 +31,12 @@ using namespace dbaui; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; -OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) : - FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER ) - ,m_pTabWin( pParent ) +OTableWindowTitle::OTableWindowTitle(OTableWindow* pParent) + : InterimItemWindow(pParent, "dbaccess/ui/tabletitle.ui", "TableTitle") + , m_pTabWin( pParent ) + , m_xLabel(m_xBuilder->weld_label("label")) { - // set background- and text colour - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); - SetBackground(Wallpaper(aSystemStyle.GetFaceColor())); - SetTextColor(aSystemStyle.GetButtonTextColor()); - - vcl::Font aFont( GetFont() ); - aFont.SetTransparent( true ); - SetFont( aFont ); + m_xLabel->connect_mouse_press(LINK(this, OTableWindowTitle, MousePressHdl)); } OTableWindowTitle::~OTableWindowTitle() @@ -52,75 +46,14 @@ OTableWindowTitle::~OTableWindowTitle() void OTableWindowTitle::dispose() { + m_xLabel.reset(); m_pTabWin.clear(); - FixedText::dispose(); -} - -void OTableWindowTitle::GetFocus() -{ - if(m_pTabWin) - m_pTabWin->GetFocus(); - else - FixedText::GetFocus(); -} - -void OTableWindowTitle::LoseFocus() -{ - if (m_pTabWin) - m_pTabWin->LoseFocus(); - else - FixedText::LoseFocus(); -} - -void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt ) -{ - if(!m_pTabWin) - return; - - OUString aHelpText = m_pTabWin->GetComposedName(); - if( aHelpText.isEmpty()) - return; - - // show help - tools::Rectangle aItemRect(Point(0,0),GetSizePixel()); - aItemRect = LogicToPixel( aItemRect ); - Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); - aItemRect.SetLeft( aPt.X() ); - aItemRect.SetTop( aPt.Y() ); - aPt = OutputToScreenPixel( aItemRect.BottomRight() ); - aItemRect.SetRight( aPt.X() ); - aItemRect.SetBottom( aPt.Y() ); - if( rHEvt.GetMode() == HelpEventMode::BALLOON ) - Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText); - else - Help::ShowQuickHelp( this, aItemRect, aHelpText ); -} - -void OTableWindowTitle::Command( const CommandEvent& rEvt ) -{ - if ( rEvt.GetCommand() == CommandEventId::ContextMenu ) - { - GrabFocus(); - if ( m_pTabWin ) - { - // tdf#94709 - protect shutdown code-path. - VclPtr<OTableWindow> xTabWin(m_pTabWin); - xTabWin->Command( rEvt ); - } - else - Control::Command(rEvt); - } + InterimItemWindow::dispose(); } -void OTableWindowTitle::KeyInput( const KeyEvent& rEvt ) +IMPL_LINK(OTableWindowTitle, MousePressHdl, const MouseEvent&, rEvt, bool) { - if ( m_pTabWin ) - m_pTabWin->KeyInput( rEvt ); -} - -void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) -{ - if( rEvt.IsLeft() ) + if (rEvt.IsLeft()) { if( rEvt.GetClicks() == 2) { @@ -129,7 +62,7 @@ void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) weld::TreeView& rTreeView = m_pTabWin->GetListBox()->get_widget(); aSize.AdjustHeight(rTreeView.get_height_rows(rTreeView.n_children() + 2)); - if(m_pTabWin->GetSizePixel() != aSize) + if (m_pTabWin->GetSizePixel() != aSize) { m_pTabWin->SetSizePixel(aSize); @@ -151,38 +84,15 @@ void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) OSL_ENSURE(pView,"No OJoinTableView!"); pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos ); } - GrabFocus(); } - else - Control::MouseButtonDown( rEvt ); -} - -void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt) -{ - if (rDCEvt.GetType() == DataChangedEventType::SETTINGS) + else if (rEvt.IsRight()) { - // assume worst-case: colours have changed, therefore I have to adept - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); - SetBackground(Wallpaper(aSystemStyle.GetFaceColor())); - SetTextColor(aSystemStyle.GetButtonTextColor()); - } -} - -void OTableWindowTitle::StateChanged( StateChangedType nType ) -{ - Window::StateChanged( nType ); - - if ( nType == StateChangedType::Zoom ) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - vcl::Font aFont = rStyleSettings.GetGroupFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont(*this, aFont); - - Resize(); + CommandEvent aCEvt(rEvt.GetPosPixel(), CommandEventId::ContextMenu, true); + // tdf#94709 - protect shutdown code-path. + VclPtr<OTableWindow> xTabWin(m_pTabWin); + xTabWin->Command(aCEvt); } + return false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |