LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableWindowTitle.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 84 0.0 %
Date: 2014-04-14 Functions: 0 11 0.0 %
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 :     Font aFont( GetFont() );
      52           0 :     aFont.SetTransparent( true );
      53           0 :     SetFont( aFont );
      54           0 : }
      55             : 
      56           0 : OTableWindowTitle::~OTableWindowTitle()
      57             : {
      58           0 :     m_pTabWin = NULL;
      59           0 : }
      60             : 
      61           0 : void OTableWindowTitle::GetFocus()
      62             : {
      63           0 :     if(m_pTabWin)
      64           0 :         m_pTabWin->GetFocus();
      65           0 : }
      66             : 
      67           0 : void OTableWindowTitle::LoseFocus()
      68             : {
      69           0 :     m_pTabWin->LoseFocus();
      70           0 : }
      71             : 
      72           0 : void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
      73             : {
      74           0 :     if(m_pTabWin)
      75             :     {
      76           0 :         OUString aHelpText = m_pTabWin->GetComposedName();
      77           0 :         if( !aHelpText.isEmpty())
      78             :         {
      79             :             // show help
      80           0 :             Rectangle aItemRect(Point(0,0),GetSizePixel());
      81           0 :             aItemRect = LogicToPixel( aItemRect );
      82           0 :             Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
      83           0 :             aItemRect.Left()   = aPt.X();
      84           0 :             aItemRect.Top()    = aPt.Y();
      85           0 :             aPt = OutputToScreenPixel( aItemRect.BottomRight() );
      86           0 :             aItemRect.Right()  = aPt.X();
      87           0 :             aItemRect.Bottom() = aPt.Y();
      88           0 :             if( rHEvt.GetMode() == HELPMODE_BALLOON )
      89           0 :                 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
      90             :             else
      91           0 :                 Help::ShowQuickHelp( this, aItemRect, aHelpText );
      92           0 :         }
      93             :     }
      94           0 : }
      95             : 
      96           0 : void OTableWindowTitle::Command( const CommandEvent& rEvt )
      97             : {
      98           0 :     switch( rEvt.GetCommand() )
      99             :     {
     100             :         case COMMAND_CONTEXTMENU:
     101             :         {
     102           0 :             GrabFocus();
     103           0 :             if ( m_pTabWin )
     104           0 :                 m_pTabWin->Command( rEvt );
     105             :             else
     106           0 :                 Control::Command(rEvt);
     107             :         }
     108             :     }
     109           0 : }
     110             : 
     111           0 : void OTableWindowTitle::KeyInput( const KeyEvent& rEvt )
     112             : {
     113           0 :     if ( m_pTabWin )
     114           0 :         m_pTabWin->KeyInput( rEvt );
     115           0 : }
     116             : 
     117           0 : void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
     118             : {
     119           0 :     if( rEvt.IsLeft() )
     120             :     {
     121           0 :         if( rEvt.GetClicks() == 2)
     122             :         {
     123           0 :             Size aSize(GetTextWidth(GetText()) + 20,
     124           0 :                         m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height());
     125             : 
     126           0 :             aSize.Height() += (m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight();
     127           0 :             if(m_pTabWin->GetSizePixel() != aSize)
     128             :             {
     129           0 :                 m_pTabWin->SetSizePixel(aSize);
     130             : 
     131           0 :                 OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
     132             :                 OSL_ENSURE(pView,"No OJoinTableView!");
     133           0 :                 const ::std::vector<OTableConnection*>* pConns = pView->getTableConnections();
     134             :                 ::std::for_each(pConns->begin(),
     135             :                                 pConns->end(),
     136           0 :                                 ::std::mem_fun(&OTableConnection::RecalcLines));
     137             : 
     138           0 :                 pView->InvalidateConnections();
     139           0 :                 pView->getDesignView()->getController().setModified(sal_True);
     140           0 :                 pView->Invalidate(INVALIDATE_NOCHILDREN);
     141             :             }
     142             :         }
     143             :         else
     144             :         {
     145           0 :             Point aPos = rEvt.GetPosPixel();
     146           0 :             aPos = OutputToScreenPixel( aPos );
     147           0 :             OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
     148             :             OSL_ENSURE(pView,"No OJoinTableView!");
     149           0 :             pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
     150             :         }
     151           0 :         GrabFocus();
     152             :     }
     153             :     else
     154           0 :         Control::MouseButtonDown( rEvt );
     155           0 : }
     156             : 
     157           0 : void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt)
     158             : {
     159           0 :     if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
     160             :     {
     161             :         // assume worst-case: colours have changed, therefore I have to adept
     162           0 :         StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
     163           0 :         SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
     164           0 :         SetTextColor(aSystemStyle.GetButtonTextColor());
     165             :     }
     166           0 : }
     167             : 
     168           0 : void OTableWindowTitle::StateChanged( StateChangedType nType )
     169             : {
     170           0 :     Window::StateChanged( nType );
     171             : 
     172           0 :     if ( nType == STATE_CHANGE_ZOOM )
     173             :     {
     174           0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     175             : 
     176           0 :         Font aFont = rStyleSettings.GetGroupFont();
     177           0 :         if ( IsControlFont() )
     178           0 :             aFont.Merge( GetControlFont() );
     179           0 :         SetZoomedPointFont( aFont );
     180             : 
     181           0 :         Resize();
     182             :     }
     183           0 : }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10