fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / querydesign / TableWindowTitle.cxx
blobc029b85d88cd391da943c8978ea6ab2989a574fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "TableWindowTitle.hxx"
21 #include "TableWindow.hxx"
22 #include "QueryTableView.hxx"
23 #include <vcl/svapp.hxx>
24 #include <vcl/help.hxx>
25 #include <vcl/menu.hxx>
26 #include <vcl/settings.hxx>
27 #include <tools/debug.hxx>
28 #include "dbustrings.hrc"
29 #include <sfx2/cntids.hrc>
30 #include "TableWindowListBox.hxx"
31 #include "TableConnection.hxx"
32 #include "dbu_qry.hrc"
33 #include "QueryDesignView.hxx"
34 #include "JoinController.hxx"
36 #include <algorithm>
38 using namespace dbaui;
39 using namespace ::com::sun::star::beans;
40 using namespace ::com::sun::star::uno;
41 // class OTableWindowTitle
42 OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) :
43 FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER )
44 ,m_pTabWin( pParent )
46 // set background- and text colour
47 StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
48 SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
49 SetTextColor(aSystemStyle.GetButtonTextColor());
51 vcl::Font aFont( GetFont() );
52 aFont.SetTransparent( true );
53 SetFont( aFont );
56 OTableWindowTitle::~OTableWindowTitle()
58 disposeOnce();
61 void OTableWindowTitle::dispose()
63 m_pTabWin.clear();
64 FixedText::dispose();
67 void OTableWindowTitle::GetFocus()
69 if(m_pTabWin)
70 m_pTabWin->GetFocus();
71 else
72 FixedText::GetFocus();
75 void OTableWindowTitle::LoseFocus()
77 if (m_pTabWin)
78 m_pTabWin->LoseFocus();
79 else
80 FixedText::LoseFocus();
83 void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
85 if(m_pTabWin)
87 OUString aHelpText = m_pTabWin->GetComposedName();
88 if( !aHelpText.isEmpty())
90 // show help
91 Rectangle aItemRect(Point(0,0),GetSizePixel());
92 aItemRect = LogicToPixel( aItemRect );
93 Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
94 aItemRect.Left() = aPt.X();
95 aItemRect.Top() = aPt.Y();
96 aPt = OutputToScreenPixel( aItemRect.BottomRight() );
97 aItemRect.Right() = aPt.X();
98 aItemRect.Bottom() = aPt.Y();
99 if( rHEvt.GetMode() == HelpEventMode::BALLOON )
100 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
101 else
102 Help::ShowQuickHelp( this, aItemRect, aHelpText );
107 void OTableWindowTitle::Command( const CommandEvent& rEvt )
109 if ( rEvt.GetCommand() == CommandEventId::ContextMenu )
111 GrabFocus();
112 if ( m_pTabWin )
114 // tdf#94709 - protect shutdown code-path.
115 VclPtr<OTableWindow> xTabWin(m_pTabWin);
116 xTabWin->Command( rEvt );
118 else
119 Control::Command(rEvt);
123 void OTableWindowTitle::KeyInput( const KeyEvent& rEvt )
125 if ( m_pTabWin )
126 m_pTabWin->KeyInput( rEvt );
129 void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
131 if( rEvt.IsLeft() )
133 if( rEvt.GetClicks() == 2)
135 Size aSize(GetTextWidth(GetText()) + 20,
136 m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height());
138 aSize.Height() += (m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight();
139 if(m_pTabWin->GetSizePixel() != aSize)
141 m_pTabWin->SetSizePixel(aSize);
143 OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
144 OSL_ENSURE(pView,"No OJoinTableView!");
145 for (auto conn : pView->getTableConnections())
146 conn->RecalcLines();
148 pView->InvalidateConnections();
149 pView->getDesignView()->getController().setModified(sal_True);
150 pView->Invalidate(INVALIDATE_NOCHILDREN);
153 else
155 Point aPos = rEvt.GetPosPixel();
156 aPos = OutputToScreenPixel( aPos );
157 OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
158 OSL_ENSURE(pView,"No OJoinTableView!");
159 pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
161 GrabFocus();
163 else
164 Control::MouseButtonDown( rEvt );
167 void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt)
169 if (rDCEvt.GetType() == DataChangedEventType::SETTINGS)
171 // assume worst-case: colours have changed, therefore I have to adept
172 StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
173 SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
174 SetTextColor(aSystemStyle.GetButtonTextColor());
178 void OTableWindowTitle::StateChanged( StateChangedType nType )
180 Window::StateChanged( nType );
182 if ( nType == StateChangedType::Zoom )
184 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
186 vcl::Font aFont = rStyleSettings.GetGroupFont();
187 if ( IsControlFont() )
188 aFont.Merge( GetControlFont() );
189 SetZoomedPointFont(*this, aFont);
191 Resize();
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */