1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
)
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 );
56 OTableWindowTitle::~OTableWindowTitle()
61 void OTableWindowTitle::dispose()
67 void OTableWindowTitle::GetFocus()
70 m_pTabWin
->GetFocus();
72 FixedText::GetFocus();
75 void OTableWindowTitle::LoseFocus()
78 m_pTabWin
->LoseFocus();
80 FixedText::LoseFocus();
83 void OTableWindowTitle::RequestHelp( const HelpEvent
& rHEvt
)
87 OUString aHelpText
= m_pTabWin
->GetComposedName();
88 if( !aHelpText
.isEmpty())
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
);
102 Help::ShowQuickHelp( this, aItemRect
, aHelpText
);
107 void OTableWindowTitle::Command( const CommandEvent
& rEvt
)
109 if ( rEvt
.GetCommand() == CommandEventId::ContextMenu
)
114 // tdf#94709 - protect shutdown code-path.
115 VclPtr
<OTableWindow
> xTabWin(m_pTabWin
);
116 xTabWin
->Command( rEvt
);
119 Control::Command(rEvt
);
123 void OTableWindowTitle::KeyInput( const KeyEvent
& rEvt
)
126 m_pTabWin
->KeyInput( rEvt
);
129 void OTableWindowTitle::MouseButtonDown( const MouseEvent
& rEvt
)
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())
148 pView
->InvalidateConnections();
149 pView
->getDesignView()->getController().setModified(true);
150 pView
->Invalidate(InvalidateFlags::NoChildren
);
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
);
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
);
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */