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 <tools/debug.hxx>
27 #include "dbustrings.hrc"
28 #include <sfx2/cntids.hrc>
29 #include "TableWindowListBox.hxx"
30 #include "TableConnection.hxx"
31 #include "dbu_qry.hrc"
32 #include "QueryDesignView.hxx"
33 #include "JoinController.hxx"
37 using namespace dbaui
;
38 using namespace ::com::sun::star::beans
;
39 using namespace ::com::sun::star::uno
;
40 //==================================================================
41 // class OTableWindowTitle
42 //==================================================================
43 DBG_NAME(OTableWindowTitle
)
44 //------------------------------------------------------------------------------
45 OTableWindowTitle::OTableWindowTitle( OTableWindow
* pParent
) :
46 FixedText( pParent
, WB_3DLOOK
|WB_LEFT
|WB_NOLABEL
|WB_VCENTER
)
49 DBG_CTOR(OTableWindowTitle
,NULL
);
50 // set background- and text colour
51 StyleSettings aSystemStyle
= Application::GetSettings().GetStyleSettings();
52 SetBackground(Wallpaper(Color(aSystemStyle
.GetFaceColor())));
53 SetTextColor(aSystemStyle
.GetButtonTextColor());
55 Font
aFont( GetFont() );
56 aFont
.SetTransparent( sal_True
);
60 //------------------------------------------------------------------------------
61 OTableWindowTitle::~OTableWindowTitle()
63 DBG_DTOR(OTableWindowTitle
,NULL
);
67 //------------------------------------------------------------------------------
68 void OTableWindowTitle::GetFocus()
71 m_pTabWin
->GetFocus();
74 //------------------------------------------------------------------------------
75 void OTableWindowTitle::LoseFocus()
77 m_pTabWin
->LoseFocus();
79 //------------------------------------------------------------------------------
80 void OTableWindowTitle::RequestHelp( const HelpEvent
& rHEvt
)
84 String aHelpText
= m_pTabWin
->GetComposedName();
88 Rectangle
aItemRect(Point(0,0),GetSizePixel());
89 aItemRect
= LogicToPixel( aItemRect
);
90 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
91 aItemRect
.Left() = aPt
.X();
92 aItemRect
.Top() = aPt
.Y();
93 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
94 aItemRect
.Right() = aPt
.X();
95 aItemRect
.Bottom() = aPt
.Y();
96 if( rHEvt
.GetMode() == HELPMODE_BALLOON
)
97 Help::ShowBalloon( this, aItemRect
.Center(), aItemRect
, aHelpText
);
99 Help::ShowQuickHelp( this, aItemRect
, aHelpText
);
104 //------------------------------------------------------------------------------
105 void OTableWindowTitle::Command( const CommandEvent
& rEvt
)
107 switch( rEvt
.GetCommand() )
109 case COMMAND_CONTEXTMENU
:
113 m_pTabWin
->Command( rEvt
);
115 Control::Command(rEvt
);
120 //------------------------------------------------------------------------------
121 void OTableWindowTitle::KeyInput( const KeyEvent
& rEvt
)
124 m_pTabWin
->KeyInput( rEvt
);
127 //------------------------------------------------------------------------------
128 void OTableWindowTitle::MouseButtonDown( const MouseEvent
& rEvt
)
132 if( rEvt
.GetClicks() == 2)
134 Size
aSize(GetTextWidth(GetText()) + 20,
135 m_pTabWin
->GetSizePixel().Height() - m_pTabWin
->GetListBox()->GetSizePixel().Height());
137 aSize
.Height() += (m_pTabWin
->GetListBox()->GetEntryCount() + 2) * m_pTabWin
->GetListBox()->GetEntryHeight();
138 if(m_pTabWin
->GetSizePixel() != aSize
)
140 m_pTabWin
->SetSizePixel(aSize
);
142 OJoinTableView
* pView
= static_cast<OJoinTableView
*>(m_pTabWin
->getTableView());
143 OSL_ENSURE(pView
,"No OJoinTableView!");
144 const ::std::vector
<OTableConnection
*>* pConns
= pView
->getTableConnections();
145 ::std::for_each(pConns
->begin(),
147 ::std::mem_fun(&OTableConnection::RecalcLines
));
149 pView
->InvalidateConnections();
150 pView
->getDesignView()->getController().setModified(sal_True
);
151 pView
->Invalidate(INVALIDATE_NOCHILDREN
);
156 Point aPos
= rEvt
.GetPosPixel();
157 aPos
= OutputToScreenPixel( aPos
);
158 OJoinTableView
* pView
= static_cast<OJoinTableView
*>(m_pTabWin
->getTableView());
159 OSL_ENSURE(pView
,"No OJoinTableView!");
160 pView
->NotifyTitleClicked( static_cast<OTableWindow
*>(GetParent()), aPos
);
165 Control::MouseButtonDown( rEvt
);
169 //------------------------------------------------------------------------------
170 void OTableWindowTitle::DataChanged(const DataChangedEvent
& rDCEvt
)
172 if (rDCEvt
.GetType() == DATACHANGED_SETTINGS
)
174 // assume worst-case: colours have changed, therefore I have to adept
175 StyleSettings aSystemStyle
= Application::GetSettings().GetStyleSettings();
176 SetBackground(Wallpaper(Color(aSystemStyle
.GetFaceColor())));
177 SetTextColor(aSystemStyle
.GetButtonTextColor());
180 // -----------------------------------------------------------------------------
181 void OTableWindowTitle::StateChanged( StateChangedType nType
)
183 Window::StateChanged( nType
);
185 if ( nType
== STATE_CHANGE_ZOOM
)
187 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
189 Font aFont
= rStyleSettings
.GetGroupFont();
190 if ( IsControlFont() )
191 aFont
.Merge( GetControlFont() );
192 SetZoomedPointFont( aFont
);
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */