LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableWindowTitle.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 91 1.1 %
Date: 2015-06-13 12:38:46 Functions: 2 14 14.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      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"
      35             : 
      36             : #include <algorithm>
      37             : 
      38             : using namespace dbaui;
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::com::sun::star::uno;
      41             : // class OTableWindowTitle
      42           0 : OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) :
      43             :      FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER )
      44           0 :     ,m_pTabWin( pParent )
      45             : {
      46             :     // set background- and text colour
      47           0 :     StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
      48           0 :     SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
      49           0 :     SetTextColor(aSystemStyle.GetButtonTextColor());
      50             : 
      51           0 :     vcl::Font aFont( GetFont() );
      52           0 :     aFont.SetTransparent( true );
      53           0 :     SetFont( aFont );
      54           0 : }
      55             : 
      56           0 : OTableWindowTitle::~OTableWindowTitle()
      57             : {
      58           0 :     disposeOnce();
      59           0 : }
      60             : 
      61           0 : void OTableWindowTitle::dispose()
      62             : {
      63           0 :     m_pTabWin.clear();
      64           0 :     FixedText::dispose();
      65           0 : }
      66             : 
      67           0 : void OTableWindowTitle::GetFocus()
      68             : {
      69           0 :     if(m_pTabWin)
      70           0 :         m_pTabWin->GetFocus();
      71             :     else
      72           0 :         FixedText::GetFocus();
      73           0 : }
      74             : 
      75           0 : void OTableWindowTitle::LoseFocus()
      76             : {
      77           0 :     if (m_pTabWin)
      78           0 :         m_pTabWin->LoseFocus();
      79             :     else
      80           0 :         FixedText::LoseFocus();
      81           0 : }
      82             : 
      83           0 : void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
      84             : {
      85           0 :     if(m_pTabWin)
      86             :     {
      87           0 :         OUString aHelpText = m_pTabWin->GetComposedName();
      88           0 :         if( !aHelpText.isEmpty())
      89             :         {
      90             :             // show help
      91           0 :             Rectangle aItemRect(Point(0,0),GetSizePixel());
      92           0 :             aItemRect = LogicToPixel( aItemRect );
      93           0 :             Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
      94           0 :             aItemRect.Left()   = aPt.X();
      95           0 :             aItemRect.Top()    = aPt.Y();
      96           0 :             aPt = OutputToScreenPixel( aItemRect.BottomRight() );
      97           0 :             aItemRect.Right()  = aPt.X();
      98           0 :             aItemRect.Bottom() = aPt.Y();
      99           0 :             if( rHEvt.GetMode() == HelpEventMode::BALLOON )
     100           0 :                 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
     101             :             else
     102           0 :                 Help::ShowQuickHelp( this, aItemRect, aHelpText );
     103           0 :         }
     104             :     }
     105           0 : }
     106             : 
     107           0 : void OTableWindowTitle::Command( const CommandEvent& rEvt )
     108             : {
     109           0 :     if ( rEvt.GetCommand() == CommandEventId::ContextMenu )
     110             :     {
     111           0 :         GrabFocus();
     112           0 :         if ( m_pTabWin )
     113           0 :             m_pTabWin->Command( rEvt );
     114             :         else
     115           0 :             Control::Command(rEvt);
     116             :     }
     117           0 : }
     118             : 
     119           0 : void OTableWindowTitle::KeyInput( const KeyEvent& rEvt )
     120             : {
     121           0 :     if ( m_pTabWin )
     122           0 :         m_pTabWin->KeyInput( rEvt );
     123           0 : }
     124             : 
     125           0 : void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
     126             : {
     127           0 :     if( rEvt.IsLeft() )
     128             :     {
     129           0 :         if( rEvt.GetClicks() == 2)
     130             :         {
     131           0 :             Size aSize(GetTextWidth(GetText()) + 20,
     132           0 :                         m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height());
     133             : 
     134           0 :             aSize.Height() += (m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight();
     135           0 :             if(m_pTabWin->GetSizePixel() != aSize)
     136             :             {
     137           0 :                 m_pTabWin->SetSizePixel(aSize);
     138             : 
     139           0 :                 OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
     140             :                 OSL_ENSURE(pView,"No OJoinTableView!");
     141           0 :                 for (auto conn : pView->getTableConnections())
     142           0 :                     conn->RecalcLines();
     143             : 
     144           0 :                 pView->InvalidateConnections();
     145           0 :                 pView->getDesignView()->getController().setModified(sal_True);
     146           0 :                 pView->Invalidate(InvalidateFlags::NoChildren);
     147             :             }
     148             :         }
     149             :         else
     150             :         {
     151           0 :             Point aPos = rEvt.GetPosPixel();
     152           0 :             aPos = OutputToScreenPixel( aPos );
     153           0 :             OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
     154             :             OSL_ENSURE(pView,"No OJoinTableView!");
     155           0 :             pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
     156             :         }
     157           0 :         GrabFocus();
     158             :     }
     159             :     else
     160           0 :         Control::MouseButtonDown( rEvt );
     161           0 : }
     162             : 
     163           0 : void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt)
     164             : {
     165           0 :     if (rDCEvt.GetType() == DataChangedEventType::SETTINGS)
     166             :     {
     167             :         // assume worst-case: colours have changed, therefore I have to adept
     168           0 :         StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
     169           0 :         SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
     170           0 :         SetTextColor(aSystemStyle.GetButtonTextColor());
     171             :     }
     172           0 : }
     173             : 
     174           0 : void OTableWindowTitle::StateChanged( StateChangedType nType )
     175             : {
     176           0 :     Window::StateChanged( nType );
     177             : 
     178           0 :     if ( nType == StateChangedType::Zoom )
     179             :     {
     180           0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     181             : 
     182           0 :         vcl::Font aFont = rStyleSettings.GetGroupFont();
     183           0 :         if ( IsControlFont() )
     184           0 :             aFont.Merge( GetControlFont() );
     185           0 :         SetZoomedPointFont(*this, aFont);
     186             : 
     187           0 :         Resize();
     188             :     }
     189          36 : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11