Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <vcl/split.hxx>
31 : : #include <vcl/ctrl.hxx>
32 : : #include <unotools/pathoptions.hxx>
33 : : #include <sfx2/app.hxx>
34 : : #include <sfx2/sfxsids.hrc>
35 : : #include "gallery.hrc"
36 : : #include "svx/galmisc.hxx"
37 : : #include "svx/gallery1.hxx"
38 : : #include "galbrws1.hxx"
39 : : #include "galbrws2.hxx"
40 : : #include "svx/galbrws.hxx"
41 : :
42 : : // -------------------
43 : : // - GallerySplitter -
44 : : // -------------------
45 : :
46 : : class GallerySplitter : public Splitter
47 : : {
48 : : protected:
49 : :
50 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
51 : :
52 : : public:
53 : :
54 : : GallerySplitter( Window* pParent, const ResId& rResId );
55 : : virtual ~GallerySplitter();
56 : : };
57 : :
58 : : // -----------------------------------------------------------------------------
59 : :
60 : 0 : GallerySplitter::GallerySplitter( Window* pParent, const ResId& rResId ) :
61 : 0 : Splitter( pParent, rResId )
62 : : {
63 : 0 : }
64 : :
65 : : // -----------------------------------------------------------------------------
66 : :
67 : 0 : GallerySplitter::~GallerySplitter()
68 : : {
69 [ # # ]: 0 : }
70 : :
71 : : // -----------------------------------------------------------------------------
72 : :
73 : 0 : void GallerySplitter::DataChanged( const DataChangedEvent& rDCEvt )
74 : : {
75 : 0 : Splitter::DataChanged( rDCEvt );
76 : 0 : static_cast< GalleryBrowser* >( GetParent() )->InitSettings();
77 : 0 : }
78 : :
79 : : // -------------------------
80 : : // - SvxGalleryChildWindow -
81 : : // -------------------------
82 : :
83 : 0 : GalleryChildWindow::GalleryChildWindow( Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
84 : 0 : SfxChildWindow( _pParent, nId )
85 : : {
86 [ # # ][ # # ]: 0 : pWindow = new GalleryBrowser( pBindings, this, _pParent, GAL_RES( RID_SVXDLG_GALLERYBROWSER ) );
[ # # ]
87 : 0 : eChildAlignment = SFX_ALIGN_TOP;
88 [ # # ]: 0 : ( (GalleryBrowser*) pWindow )->Initialize( pInfo );
89 : 0 : };
90 : :
91 : : // -----------------------------------------------------------------------------
92 : :
93 : 0 : GalleryChildWindow::~GalleryChildWindow()
94 : : {
95 [ # # ]: 0 : }
96 : :
97 : : // -----------------------------------------------------------------------------
98 : :
99 [ # # ][ + - ]: 775 : SFX_IMPL_DOCKINGWINDOW_WITHID( GalleryChildWindow, SID_GALLERY )
[ # # ]
100 : :
101 : : // ------------------
102 : : // - GalleryBrowser -
103 : : // ------------------
104 : :
105 : 0 : GalleryBrowser::GalleryBrowser( SfxBindings* _pBindings, SfxChildWindow* pCW,
106 : : Window* pParent, const ResId& rResId ) :
107 : 0 : SfxDockingWindow( _pBindings, pCW, pParent, rResId )
108 : : {
109 [ # # ]: 0 : mpGallery = Gallery::GetGalleryInstance();
110 [ # # ][ # # ]: 0 : mpBrowser1 = new GalleryBrowser1( this, GAL_RES( GALLERY_BROWSER1 ), mpGallery );
[ # # ]
111 [ # # ][ # # ]: 0 : mpSplitter = new GallerySplitter( this, GAL_RES( GALLERY_SPLITTER ) );
[ # # ]
112 [ # # ][ # # ]: 0 : mpBrowser2 = new GalleryBrowser2( this, GAL_RES( GALLERY_BROWSER2 ), mpGallery );
[ # # ]
113 : :
114 [ # # ]: 0 : FreeResource();
115 [ # # ][ # # ]: 0 : SetMinOutputSizePixel( maLastSize = GetOutputSizePixel() );
116 : :
117 [ # # ]: 0 : mpBrowser1->SelectTheme( 0 );
118 [ # # ]: 0 : mpBrowser1->Show( sal_True );
119 [ # # ]: 0 : mpBrowser2->Show( sal_True );
120 : :
121 [ # # ]: 0 : mpSplitter->SetSplitHdl( LINK( this, GalleryBrowser, SplitHdl ) );
122 [ # # ]: 0 : mpSplitter->Show( sal_True );
123 : :
124 [ # # ]: 0 : InitSettings();
125 : 0 : }
126 : :
127 : : // -----------------------------------------------------------------------------
128 : :
129 : 0 : GalleryBrowser::~GalleryBrowser()
130 : : {
131 [ # # ][ # # ]: 0 : delete mpBrowser2;
132 [ # # ][ # # ]: 0 : delete mpSplitter;
133 [ # # ][ # # ]: 0 : delete mpBrowser1;
134 [ # # ]: 0 : }
135 : :
136 : : // -----------------------------------------------------------------------------
137 : :
138 : 0 : void GalleryBrowser::InitSettings()
139 : : {
140 [ # # ]: 0 : SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
141 : 0 : SetControlBackground( GALLERY_DLG_COLOR );
142 : 0 : SetControlForeground( GALLERY_DLG_COLOR );
143 : :
144 [ # # ]: 0 : mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
145 : 0 : mpSplitter->SetControlBackground( GALLERY_DLG_COLOR );
146 : 0 : mpSplitter->SetControlForeground( GALLERY_DLG_COLOR );
147 : :
148 [ # # ]: 0 : mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
149 : 0 : mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR );
150 : 0 : mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR );
151 : :
152 [ # # ]: 0 : mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
153 : 0 : mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR );
154 : 0 : mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR );
155 : 0 : }
156 : :
157 : : // -----------------------------------------------------------------------------
158 : :
159 : 0 : void GalleryBrowser::Resize()
160 : : {
161 [ # # ]: 0 : SfxDockingWindow::Resize();
162 : :
163 [ # # ][ # # ]: 0 : const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
[ # # ]
164 : 0 : const long nFrameWidth2 = nFrameWidth << 1;
165 [ # # ]: 0 : Size aNewSize( GetOutputSizePixel() );
166 [ # # ]: 0 : Point aSplitPos( mpSplitter->GetPosPixel() );
167 : 0 : const Size aSplitSize( mpSplitter->GetOutputSizePixel() );
168 : :
169 : : mpBrowser1->SetPosSizePixel( Point( nFrameWidth, nFrameWidth ),
170 [ # # ]: 0 : Size( aSplitPos.X() - nFrameWidth, aNewSize.Height() - nFrameWidth2 ) );
171 : :
172 [ # # ]: 0 : mpSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aNewSize.Height() ) );
173 [ # # ][ # # ]: 0 : mpSplitter->SetDragRectPixel( Rectangle( Point( nFrameWidth2, 0 ), Size( aNewSize.Width() - ( nFrameWidth2 << 1 ) - aSplitSize.Width(), aNewSize.Height() ) ) );
174 : :
175 : 0 : mpBrowser2->SetPosSizePixel( Point( aSplitPos.X() + aSplitSize.Width(), nFrameWidth ),
176 [ # # ]: 0 : Size( aNewSize.Width() - aSplitSize.Width() - aSplitPos.X() - nFrameWidth, aNewSize.Height() - nFrameWidth2 ) );
177 : :
178 : 0 : maLastSize = aNewSize;
179 : 0 : }
180 : :
181 : : // -----------------------------------------------------------------------------
182 : :
183 : 0 : sal_Bool GalleryBrowser::KeyInput( const KeyEvent& rKEvt, Window* )
184 : : {
185 : 0 : const sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
186 : 0 : sal_Bool bRet = ( !rKEvt.GetKeyCode().IsMod1() &&
187 [ # # ][ # # ]: 0 : ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) );
[ # # ][ # # ]
188 : :
189 [ # # ]: 0 : if( bRet )
190 : : {
191 [ # # ]: 0 : if( !rKEvt.GetKeyCode().IsShift() )
192 : : {
193 [ # # ]: 0 : if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) )
194 : 0 : mpBrowser2->GetViewWindow()->GrabFocus();
195 [ # # ]: 0 : else if( mpBrowser2->GetViewWindow()->HasFocus() )
196 : 0 : mpBrowser2->maViewBox.GrabFocus();
197 [ # # ]: 0 : else if( mpBrowser2->maViewBox.HasFocus() )
198 : 0 : mpBrowser1->maNewTheme.GrabFocus();
199 : : else
200 : 0 : mpBrowser1->mpThemes->GrabFocus();
201 : : }
202 : : else
203 : : {
204 [ # # ]: 0 : if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) )
205 : 0 : mpBrowser1->maNewTheme.GrabFocus();
206 [ # # ]: 0 : else if( mpBrowser1->maNewTheme.HasFocus() )
207 : 0 : mpBrowser2->maViewBox.GrabFocus();
208 [ # # ]: 0 : else if( mpBrowser2->maViewBox.HasFocus() )
209 : 0 : mpBrowser2->GetViewWindow()->GrabFocus();
210 : : else
211 : 0 : mpBrowser1->mpThemes->GrabFocus();
212 : : }
213 : : }
214 : :
215 : 0 : return bRet;
216 : : }
217 : :
218 : : // -----------------------------------------------------------------------------
219 : :
220 : 0 : sal_Bool GalleryBrowser::Close()
221 : : {
222 : 0 : return SfxDockingWindow::Close();
223 : : }
224 : :
225 : : // -----------------------------------------------------------------------------
226 : :
227 : 0 : void GalleryBrowser::GetFocus()
228 : : {
229 : 0 : SfxDockingWindow::GetFocus();
230 : 0 : mpBrowser1->GrabFocus();
231 : 0 : }
232 : :
233 : : // -----------------------------------------------------------------------------
234 : :
235 : 0 : void GalleryBrowser::ThemeSelectionHasChanged()
236 : : {
237 [ # # ]: 0 : mpBrowser2->SelectTheme( mpBrowser1->GetSelectedTheme() );
238 : 0 : }
239 : :
240 : : // -----------------------------------------------------------------------------
241 : :
242 : 0 : INetURLObject GalleryBrowser::GetURL() const
243 : : {
244 : 0 : return mpBrowser2->GetURL();
245 : : }
246 : :
247 : : // -----------------------------------------------------------------------------
248 : :
249 : 0 : String GalleryBrowser::GetFilterName() const
250 : : {
251 : 0 : return mpBrowser2->GetFilterName();
252 : : }
253 : :
254 : : // -----------------------------------------------------------------------------
255 : :
256 : 0 : Graphic GalleryBrowser::GetGraphic() const
257 : : {
258 : 0 : return mpBrowser2->GetGraphic();
259 : : }
260 : :
261 : : // -----------------------------------------------------------------------------
262 : :
263 : 0 : sal_Bool GalleryBrowser::IsLinkage() const
264 : : {
265 : 0 : return mpBrowser2->IsLinkage();
266 : : }
267 : :
268 : : // -----------------------------------------------------------------------------
269 : :
270 : 0 : IMPL_LINK_NOARG(GalleryBrowser, SplitHdl)
271 : : {
272 [ # # ]: 0 : mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) );
273 : 0 : Resize();
274 : :
275 : 0 : return 0L;
276 : : }
277 : :
278 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|