1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableWindowTitle.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_TABLEWINDOWTITLE_HXX
34 #include "TableWindowTitle.hxx"
36 #ifndef DBAUI_TABLEWINDOW_HXX
37 #include "TableWindow.hxx"
39 #ifndef DBAUI_QUERYTABLEVIEW_HXX
40 #include "QueryTableView.hxx"
43 #include <vcl/svapp.hxx>
46 #include <vcl/help.hxx>
49 #include <vcl/menu.hxx>
51 #ifndef _TOOLS_DEBUG_HXX
52 #include <tools/debug.hxx>
54 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
55 #include "dbustrings.hrc"
58 #include <sfx2/cntids.hrc>
60 #ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
61 #include "TableWindowListBox.hxx"
63 #ifndef DBAUI_TABLECONNECTION_HXX
64 #include "TableConnection.hxx"
67 #include "dbu_qry.hrc"
69 #ifndef DBAUI_QUERYDESIGNVIEW_HXX
70 #include "QueryDesignView.hxx"
72 #ifndef DBAUI_JOINCONTROLLER_HXX
73 #include "JoinController.hxx"
78 using namespace dbaui
;
79 using namespace ::com::sun::star::beans
;
80 using namespace ::com::sun::star::uno
;
81 //==================================================================
82 // class OTableWindowTitle
83 //==================================================================
84 DBG_NAME(OTableWindowTitle
)
85 //------------------------------------------------------------------------------
86 OTableWindowTitle::OTableWindowTitle( OTableWindow
* pParent
) :
87 FixedText( pParent
, WB_3DLOOK
|WB_LEFT
|WB_NOLABEL
|WB_VCENTER
)
90 DBG_CTOR(OTableWindowTitle
,NULL
);
91 // Hintergrund- und Textfarbe setzen
92 StyleSettings aSystemStyle
= Application::GetSettings().GetStyleSettings();
93 SetBackground(Wallpaper(Color(aSystemStyle
.GetFaceColor())));
94 SetTextColor(aSystemStyle
.GetButtonTextColor());
96 Font
aFont( GetFont() );
97 aFont
.SetTransparent( TRUE
);
101 //------------------------------------------------------------------------------
102 OTableWindowTitle::~OTableWindowTitle()
104 DBG_DTOR(OTableWindowTitle
,NULL
);
108 //------------------------------------------------------------------------------
109 void OTableWindowTitle::GetFocus()
112 m_pTabWin
->GetFocus();
115 //------------------------------------------------------------------------------
116 void OTableWindowTitle::LoseFocus()
118 m_pTabWin
->LoseFocus();
120 //------------------------------------------------------------------------------
121 void OTableWindowTitle::RequestHelp( const HelpEvent
& rHEvt
)
125 String aHelpText
= m_pTabWin
->GetComposedName();
129 Rectangle
aItemRect(Point(0,0),GetSizePixel());
130 aItemRect
= LogicToPixel( aItemRect
);
131 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
132 aItemRect
.Left() = aPt
.X();
133 aItemRect
.Top() = aPt
.Y();
134 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
135 aItemRect
.Right() = aPt
.X();
136 aItemRect
.Bottom() = aPt
.Y();
137 if( rHEvt
.GetMode() == HELPMODE_BALLOON
)
138 Help::ShowBalloon( this, aItemRect
.Center(), aItemRect
, aHelpText
);
140 Help::ShowQuickHelp( this, aItemRect
, aHelpText
);
145 //------------------------------------------------------------------------------
146 void OTableWindowTitle::Command( const CommandEvent
& rEvt
)
148 switch( rEvt
.GetCommand() )
150 case COMMAND_CONTEXTMENU
:
154 m_pTabWin
->Command( rEvt
);
156 Control::Command(rEvt
);
161 //------------------------------------------------------------------------------
162 //void OTableWindowTitle::Paint( const Rectangle& rRect )
164 // //////////////////////////////////////////////////////////////////////
165 // // Ausgabe des Textes in der Titelzeile
166 // Rectangle aWinRect( Point(0,0), GetSizePixel() );
167 // DrawText( aWinRect, GetText(), TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER|TEXT_DRAW_ENDELLIPSIS );
170 //------------------------------------------------------------------------------
171 void OTableWindowTitle::KeyInput( const KeyEvent
& rEvt
)
174 m_pTabWin
->KeyInput( rEvt
);
177 //------------------------------------------------------------------------------
178 void OTableWindowTitle::MouseButtonDown( const MouseEvent
& rEvt
)
182 if( rEvt
.GetClicks() == 2)
184 Size
aSize(GetTextWidth(GetText()) + 20,
185 m_pTabWin
->GetSizePixel().Height() - m_pTabWin
->GetListBox()->GetSizePixel().Height());
187 aSize
.Height() += (m_pTabWin
->GetListBox()->GetEntryCount() + 2) * m_pTabWin
->GetListBox()->GetEntryHeight();
188 if(m_pTabWin
->GetSizePixel() != aSize
)
190 m_pTabWin
->SetSizePixel(aSize
);
192 OJoinTableView
* pView
= static_cast<OJoinTableView
*>(m_pTabWin
->getTableView());
193 OSL_ENSURE(pView
,"No OJoinTableView!");
194 const ::std::vector
<OTableConnection
*>* pConns
= pView
->getTableConnections();
195 ::std::for_each(pConns
->begin(),
197 ::std::mem_fun(&OTableConnection::RecalcLines
));
199 pView
->InvalidateConnections();
200 pView
->getDesignView()->getController().setModified(sal_True
);
201 pView
->Invalidate(INVALIDATE_NOCHILDREN
);
206 Point aPos
= rEvt
.GetPosPixel();
207 aPos
= OutputToScreenPixel( aPos
);
208 OJoinTableView
* pView
= static_cast<OJoinTableView
*>(m_pTabWin
->getTableView());
209 OSL_ENSURE(pView
,"No OJoinTableView!");
210 pView
->NotifyTitleClicked( static_cast<OTableWindow
*>(GetParent()), aPos
);
215 Control::MouseButtonDown( rEvt
);
219 //------------------------------------------------------------------------------
220 void OTableWindowTitle::DataChanged(const DataChangedEvent
& rDCEvt
)
222 if (rDCEvt
.GetType() == DATACHANGED_SETTINGS
)
224 // nehmen wir den worst-case an : die Farben haben sich geaendert, also
226 StyleSettings aSystemStyle
= Application::GetSettings().GetStyleSettings();
227 SetBackground(Wallpaper(Color(aSystemStyle
.GetFaceColor())));
228 SetTextColor(aSystemStyle
.GetButtonTextColor());
231 // -----------------------------------------------------------------------------
232 void OTableWindowTitle::StateChanged( StateChangedType nType
)
234 Window::StateChanged( nType
);
236 if ( nType
== STATE_CHANGE_ZOOM
)
238 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
240 Font aFont
= rStyleSettings
.GetGroupFont();
241 if ( IsControlFont() )
242 aFont
.Merge( GetControlFont() );
243 SetZoomedPointFont( aFont
);