Branch data 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 <tools/debug.hxx>
27 : : #include "dbustrings.hrc"
28 : : #include <sfx2/cntids.hrc>
29 : : #include "TableWindowListBox.hxx"
30 : : #include "TableConnection.hxx"
31 : : #include "dbu_qry.hrc"
32 : : #include "QueryDesignView.hxx"
33 : : #include "JoinController.hxx"
34 : :
35 : : #include <algorithm>
36 : :
37 : : using namespace dbaui;
38 : : using namespace ::com::sun::star::beans;
39 : : using namespace ::com::sun::star::uno;
40 : : //==================================================================
41 : : // class OTableWindowTitle
42 : : //==================================================================
43 : : DBG_NAME(OTableWindowTitle)
44 : : //------------------------------------------------------------------------------
45 : 0 : OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) :
46 : : FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER )
47 [ # # ]: 0 : ,m_pTabWin( pParent )
48 : : {
49 : : DBG_CTOR(OTableWindowTitle,NULL);
50 : : // Hintergrund- und Textfarbe setzen
51 [ # # ][ # # ]: 0 : StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
52 [ # # ][ # # ]: 0 : SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
[ # # ]
53 [ # # ]: 0 : SetTextColor(aSystemStyle.GetButtonTextColor());
54 : :
55 [ # # ]: 0 : Font aFont( GetFont() );
56 [ # # ]: 0 : aFont.SetTransparent( sal_True );
57 [ # # ][ # # ]: 0 : SetFont( aFont );
[ # # ]
58 : 0 : }
59 : :
60 : : //------------------------------------------------------------------------------
61 : 0 : OTableWindowTitle::~OTableWindowTitle()
62 : : {
63 : : DBG_DTOR(OTableWindowTitle,NULL);
64 : 0 : m_pTabWin = NULL;
65 [ # # ]: 0 : }
66 : :
67 : : //------------------------------------------------------------------------------
68 : 0 : void OTableWindowTitle::GetFocus()
69 : : {
70 [ # # ]: 0 : if(m_pTabWin)
71 : 0 : m_pTabWin->GetFocus();
72 : 0 : }
73 : :
74 : : //------------------------------------------------------------------------------
75 : 0 : void OTableWindowTitle::LoseFocus()
76 : : {
77 : 0 : m_pTabWin->LoseFocus();
78 : 0 : }
79 : : //------------------------------------------------------------------------------
80 : 0 : void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
81 : : {
82 [ # # ]: 0 : if(m_pTabWin)
83 : : {
84 [ # # ][ # # ]: 0 : String aHelpText = m_pTabWin->GetComposedName();
85 [ # # ]: 0 : if( aHelpText.Len())
86 : : {
87 : : // Hilfe anzeigen
88 [ # # ][ # # ]: 0 : Rectangle aItemRect(Point(0,0),GetSizePixel());
89 [ # # ]: 0 : aItemRect = LogicToPixel( aItemRect );
90 [ # # ]: 0 : Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
91 : 0 : aItemRect.Left() = aPt.X();
92 : 0 : aItemRect.Top() = aPt.Y();
93 [ # # ][ # # ]: 0 : aPt = OutputToScreenPixel( aItemRect.BottomRight() );
94 : 0 : aItemRect.Right() = aPt.X();
95 : 0 : aItemRect.Bottom() = aPt.Y();
96 [ # # ]: 0 : if( rHEvt.GetMode() == HELPMODE_BALLOON )
97 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
98 : : else
99 [ # # ]: 0 : Help::ShowQuickHelp( this, aItemRect, aHelpText );
100 [ # # ]: 0 : }
101 : : }
102 : 0 : }
103 : :
104 : : //------------------------------------------------------------------------------
105 : 0 : void OTableWindowTitle::Command( const CommandEvent& rEvt )
106 : : {
107 [ # # ]: 0 : switch( rEvt.GetCommand() )
108 : : {
109 : : case COMMAND_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 : : }
118 : 0 : }
119 : :
120 : : //------------------------------------------------------------------------------
121 : 0 : void OTableWindowTitle::KeyInput( const KeyEvent& rEvt )
122 : : {
123 [ # # ]: 0 : if ( m_pTabWin )
124 : 0 : m_pTabWin->KeyInput( rEvt );
125 : 0 : }
126 : :
127 : : //------------------------------------------------------------------------------
128 : 0 : void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
129 : : {
130 [ # # ]: 0 : if( rEvt.IsLeft() )
131 : : {
132 [ # # ]: 0 : if( rEvt.GetClicks() == 2)
133 : : {
134 [ # # # # ]: 0 : Size aSize(GetTextWidth(GetText()) + 20,
[ # # ]
135 [ # # ][ # # ]: 0 : m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height());
136 : :
137 : 0 : aSize.Height() += (m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight();
138 [ # # ][ # # ]: 0 : if(m_pTabWin->GetSizePixel() != aSize)
139 : : {
140 [ # # ]: 0 : m_pTabWin->SetSizePixel(aSize);
141 : :
142 [ # # ]: 0 : OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
143 : : OSL_ENSURE(pView,"No OJoinTableView!");
144 : 0 : const ::std::vector<OTableConnection*>* pConns = pView->getTableConnections();
145 : : ::std::for_each(pConns->begin(),
146 : : pConns->end(),
147 [ # # ][ # # ]: 0 : ::std::mem_fun(&OTableConnection::RecalcLines));
148 : :
149 [ # # ]: 0 : pView->InvalidateConnections();
150 [ # # ]: 0 : pView->getDesignView()->getController().setModified(sal_True);
151 [ # # ]: 0 : pView->Invalidate(INVALIDATE_NOCHILDREN);
152 : : }
153 : : }
154 : : else
155 : : {
156 : 0 : Point aPos = rEvt.GetPosPixel();
157 [ # # ]: 0 : aPos = OutputToScreenPixel( aPos );
158 [ # # ]: 0 : OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
159 : : OSL_ENSURE(pView,"No OJoinTableView!");
160 [ # # ][ # # ]: 0 : pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
[ # # ]
161 : : }
162 : 0 : GrabFocus();
163 : : }
164 : : else
165 : 0 : Control::MouseButtonDown( rEvt );
166 : 0 : }
167 : :
168 : :
169 : : //------------------------------------------------------------------------------
170 : 0 : void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt)
171 : : {
172 [ # # ]: 0 : if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
173 : : {
174 : : // nehmen wir den worst-case an : die Farben haben sich geaendert, also
175 : : // mich anpassen
176 [ # # ][ # # ]: 0 : StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
177 [ # # ][ # # ]: 0 : SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
[ # # ]
178 [ # # ][ # # ]: 0 : SetTextColor(aSystemStyle.GetButtonTextColor());
179 : : }
180 : 0 : }
181 : : // -----------------------------------------------------------------------------
182 : 0 : void OTableWindowTitle::StateChanged( StateChangedType nType )
183 : : {
184 : 0 : Window::StateChanged( nType );
185 : :
186 [ # # ]: 0 : if ( nType == STATE_CHANGE_ZOOM )
187 : : {
188 : 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
189 : :
190 [ # # ]: 0 : Font aFont = rStyleSettings.GetGroupFont();
191 [ # # ][ # # ]: 0 : if ( IsControlFont() )
192 [ # # ][ # # ]: 0 : aFont.Merge( GetControlFont() );
[ # # ]
193 [ # # ]: 0 : SetZoomedPointFont( aFont );
194 : :
195 [ # # ][ # # ]: 0 : Resize();
196 : : }
197 : 0 : }
198 : :
199 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|