update dev300-m58
[ooovba.git] / dbaccess / source / ui / querydesign / TableWindowTitle.cxx
blob661c957a302f09181dfba47e548e01ea033d13bc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableWindowTitle.cxx,v $
10 * $Revision: 1.25 $
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"
35 #endif
36 #ifndef DBAUI_TABLEWINDOW_HXX
37 #include "TableWindow.hxx"
38 #endif
39 #ifndef DBAUI_QUERYTABLEVIEW_HXX
40 #include "QueryTableView.hxx"
41 #endif
42 #ifndef _SV_SVAPP_HXX
43 #include <vcl/svapp.hxx>
44 #endif
45 #ifndef _SV_HELP_HXX
46 #include <vcl/help.hxx>
47 #endif
48 #ifndef _SV_MENU_HXX
49 #include <vcl/menu.hxx>
50 #endif
51 #ifndef _TOOLS_DEBUG_HXX
52 #include <tools/debug.hxx>
53 #endif
54 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
55 #include "dbustrings.hrc"
56 #endif
57 #ifndef _CNTIDS_HRC
58 #include <sfx2/cntids.hrc>
59 #endif
60 #ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
61 #include "TableWindowListBox.hxx"
62 #endif
63 #ifndef DBAUI_TABLECONNECTION_HXX
64 #include "TableConnection.hxx"
65 #endif
66 #ifndef _DBU_QRY_HRC_
67 #include "dbu_qry.hrc"
68 #endif
69 #ifndef DBAUI_QUERYDESIGNVIEW_HXX
70 #include "QueryDesignView.hxx"
71 #endif
72 #ifndef DBAUI_JOINCONTROLLER_HXX
73 #include "JoinController.hxx"
74 #endif
76 #include <algorithm>
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 )
88 ,m_pTabWin( pParent )
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 );
98 SetFont( aFont );
101 //------------------------------------------------------------------------------
102 OTableWindowTitle::~OTableWindowTitle()
104 DBG_DTOR(OTableWindowTitle,NULL);
105 m_pTabWin = NULL;
108 //------------------------------------------------------------------------------
109 void OTableWindowTitle::GetFocus()
111 if(m_pTabWin)
112 m_pTabWin->GetFocus();
115 //------------------------------------------------------------------------------
116 void OTableWindowTitle::LoseFocus()
118 m_pTabWin->LoseFocus();
120 //------------------------------------------------------------------------------
121 void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
123 if(m_pTabWin)
125 String aHelpText = m_pTabWin->GetComposedName();
126 if( aHelpText.Len())
128 // Hilfe anzeigen
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);
139 else
140 Help::ShowQuickHelp( this, aItemRect, aHelpText );
145 //------------------------------------------------------------------------------
146 void OTableWindowTitle::Command( const CommandEvent& rEvt )
148 switch( rEvt.GetCommand() )
150 case COMMAND_CONTEXTMENU:
152 GrabFocus();
153 if ( m_pTabWin )
154 m_pTabWin->Command( rEvt );
155 else
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 )
173 if ( m_pTabWin )
174 m_pTabWin->KeyInput( rEvt );
177 //------------------------------------------------------------------------------
178 void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
180 if( rEvt.IsLeft() )
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(),
196 pConns->end(),
197 ::std::mem_fun(&OTableConnection::RecalcLines));
199 pView->InvalidateConnections();
200 pView->getDesignView()->getController().setModified(sal_True);
201 pView->Invalidate(INVALIDATE_NOCHILDREN);
204 else
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 );
212 GrabFocus();
214 else
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
225 // mich anpassen
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 );
245 Resize();