1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dbaccess.hxx" 30 #ifndef DBAUI_TABLEWINDOWTITLE_HXX 31 #include "TableWindowTitle.hxx" 32 #endif 33 #ifndef DBAUI_TABLEWINDOW_HXX 34 #include "TableWindow.hxx" 35 #endif 36 #ifndef DBAUI_QUERYTABLEVIEW_HXX 37 #include "QueryTableView.hxx" 38 #endif 39 #ifndef _SV_SVAPP_HXX 40 #include <vcl/svapp.hxx> 41 #endif 42 #ifndef _SV_HELP_HXX 43 #include <vcl/help.hxx> 44 #endif 45 #ifndef _SV_MENU_HXX 46 #include <vcl/menu.hxx> 47 #endif 48 #ifndef _TOOLS_DEBUG_HXX 49 #include <tools/debug.hxx> 50 #endif 51 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 52 #include "dbustrings.hrc" 53 #endif 54 #ifndef _CNTIDS_HRC 55 #include <sfx2/cntids.hrc> 56 #endif 57 #ifndef DBAUI_TABLEWINDOWLISTBOX_HXX 58 #include "TableWindowListBox.hxx" 59 #endif 60 #ifndef DBAUI_TABLECONNECTION_HXX 61 #include "TableConnection.hxx" 62 #endif 63 #ifndef _DBU_QRY_HRC_ 64 #include "dbu_qry.hrc" 65 #endif 66 #ifndef DBAUI_QUERYDESIGNVIEW_HXX 67 #include "QueryDesignView.hxx" 68 #endif 69 #ifndef DBAUI_JOINCONTROLLER_HXX 70 #include "JoinController.hxx" 71 #endif 72 73 #include <algorithm> 74 75 using namespace dbaui; 76 using namespace ::com::sun::star::beans; 77 using namespace ::com::sun::star::uno; 78 //================================================================== 79 // class OTableWindowTitle 80 //================================================================== 81 DBG_NAME(OTableWindowTitle) 82 //------------------------------------------------------------------------------ 83 OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) : 84 FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER ) 85 ,m_pTabWin( pParent ) 86 { 87 DBG_CTOR(OTableWindowTitle,NULL); 88 // Hintergrund- und Textfarbe setzen 89 StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); 90 SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor()))); 91 SetTextColor(aSystemStyle.GetButtonTextColor()); 92 93 Font aFont( GetFont() ); 94 aFont.SetTransparent( sal_True ); 95 SetFont( aFont ); 96 } 97 98 //------------------------------------------------------------------------------ 99 OTableWindowTitle::~OTableWindowTitle() 100 { 101 DBG_DTOR(OTableWindowTitle,NULL); 102 m_pTabWin = NULL; 103 } 104 105 //------------------------------------------------------------------------------ 106 void OTableWindowTitle::GetFocus() 107 { 108 if(m_pTabWin) 109 m_pTabWin->GetFocus(); 110 } 111 112 //------------------------------------------------------------------------------ 113 void OTableWindowTitle::LoseFocus() 114 { 115 m_pTabWin->LoseFocus(); 116 } 117 //------------------------------------------------------------------------------ 118 void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt ) 119 { 120 if(m_pTabWin) 121 { 122 String aHelpText = m_pTabWin->GetComposedName(); 123 if( aHelpText.Len()) 124 { 125 // Hilfe anzeigen 126 Rectangle aItemRect(Point(0,0),GetSizePixel()); 127 aItemRect = LogicToPixel( aItemRect ); 128 Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); 129 aItemRect.Left() = aPt.X(); 130 aItemRect.Top() = aPt.Y(); 131 aPt = OutputToScreenPixel( aItemRect.BottomRight() ); 132 aItemRect.Right() = aPt.X(); 133 aItemRect.Bottom() = aPt.Y(); 134 if( rHEvt.GetMode() == HELPMODE_BALLOON ) 135 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText); 136 else 137 Help::ShowQuickHelp( this, aItemRect, aHelpText ); 138 } 139 } 140 } 141 142 //------------------------------------------------------------------------------ 143 void OTableWindowTitle::Command( const CommandEvent& rEvt ) 144 { 145 switch( rEvt.GetCommand() ) 146 { 147 case COMMAND_CONTEXTMENU: 148 { 149 GrabFocus(); 150 if ( m_pTabWin ) 151 m_pTabWin->Command( rEvt ); 152 else 153 Control::Command(rEvt); 154 } 155 } 156 } 157 158 //------------------------------------------------------------------------------ 159 //void OTableWindowTitle::Paint( const Rectangle& rRect ) 160 //{ 161 // ////////////////////////////////////////////////////////////////////// 162 // // Ausgabe des Textes in der Titelzeile 163 // Rectangle aWinRect( Point(0,0), GetSizePixel() ); 164 // DrawText( aWinRect, GetText(), TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER|TEXT_DRAW_ENDELLIPSIS ); 165 //} 166 167 //------------------------------------------------------------------------------ 168 void OTableWindowTitle::KeyInput( const KeyEvent& rEvt ) 169 { 170 if ( m_pTabWin ) 171 m_pTabWin->KeyInput( rEvt ); 172 } 173 174 //------------------------------------------------------------------------------ 175 void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) 176 { 177 if( rEvt.IsLeft() ) 178 { 179 if( rEvt.GetClicks() == 2) 180 { 181 Size aSize(GetTextWidth(GetText()) + 20, 182 m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height()); 183 184 aSize.Height() += (m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight(); 185 if(m_pTabWin->GetSizePixel() != aSize) 186 { 187 m_pTabWin->SetSizePixel(aSize); 188 189 OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView()); 190 OSL_ENSURE(pView,"No OJoinTableView!"); 191 const ::std::vector<OTableConnection*>* pConns = pView->getTableConnections(); 192 ::std::for_each(pConns->begin(), 193 pConns->end(), 194 ::std::mem_fun(&OTableConnection::RecalcLines)); 195 196 pView->InvalidateConnections(); 197 pView->getDesignView()->getController().setModified(sal_True); 198 pView->Invalidate(INVALIDATE_NOCHILDREN); 199 } 200 } 201 else 202 { 203 Point aPos = rEvt.GetPosPixel(); 204 aPos = OutputToScreenPixel( aPos ); 205 OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView()); 206 OSL_ENSURE(pView,"No OJoinTableView!"); 207 pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos ); 208 } 209 GrabFocus(); 210 } 211 else 212 Control::MouseButtonDown( rEvt ); 213 } 214 215 216 //------------------------------------------------------------------------------ 217 void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt) 218 { 219 if (rDCEvt.GetType() == DATACHANGED_SETTINGS) 220 { 221 // nehmen wir den worst-case an : die Farben haben sich geaendert, also 222 // mich anpassen 223 StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); 224 SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor()))); 225 SetTextColor(aSystemStyle.GetButtonTextColor()); 226 } 227 } 228 // ----------------------------------------------------------------------------- 229 void OTableWindowTitle::StateChanged( StateChangedType nType ) 230 { 231 Window::StateChanged( nType ); 232 233 if ( nType == STATE_CHANGE_ZOOM ) 234 { 235 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 236 237 Font aFont = rStyleSettings.GetGroupFont(); 238 if ( IsControlFont() ) 239 aFont.Merge( GetControlFont() ); 240 SetZoomedPointFont( aFont ); 241 242 Resize(); 243 } 244 } 245 246 247 248 249