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 :
21 : #include <vcl/split.hxx>
22 : #include <vcl/ctrl.hxx>
23 : #include <unotools/pathoptions.hxx>
24 : #include <sfx2/app.hxx>
25 : #include <sfx2/sfxsids.hrc>
26 : #include "gallery.hrc"
27 : #include "svx/galmisc.hxx"
28 : #include "svx/gallery1.hxx"
29 : #include "galbrws1.hxx"
30 : #include "galbrws2.hxx"
31 : #include "svx/galbrws.hxx"
32 :
33 : // -------------------
34 : // - GallerySplitter -
35 : // -------------------
36 : DBG_NAME(GallerySplitter)
37 :
38 : class GallerySplitter : public Splitter
39 : {
40 : protected:
41 :
42 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
43 :
44 : public:
45 :
46 : GallerySplitter( Window* pParent, const ResId& rResId );
47 : virtual ~GallerySplitter();
48 : };
49 :
50 : // -----------------------------------------------------------------------------
51 :
52 0 : GallerySplitter::GallerySplitter( Window* pParent, const ResId& rResId ) :
53 0 : Splitter( pParent, rResId )
54 : {
55 : DBG_CTOR(GallerySplitter,NULL);
56 0 : }
57 :
58 : // -----------------------------------------------------------------------------
59 :
60 0 : GallerySplitter::~GallerySplitter()
61 : {
62 : DBG_DTOR(GallerySplitter,NULL);
63 0 : }
64 :
65 : // -----------------------------------------------------------------------------
66 :
67 0 : void GallerySplitter::DataChanged( const DataChangedEvent& rDCEvt )
68 : {
69 0 : Splitter::DataChanged( rDCEvt );
70 0 : static_cast< GalleryBrowser* >( GetParent() )->InitSettings();
71 0 : }
72 :
73 : // -------------------------
74 : // - SvxGalleryChildWindow -
75 : // -------------------------
76 : DBG_NAME(GalleryChildWindow)
77 :
78 0 : GalleryChildWindow::GalleryChildWindow( Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
79 0 : SfxChildWindow( _pParent, nId )
80 : {
81 : DBG_CTOR(GalleryChildWindow,NULL);
82 :
83 0 : pWindow = new GalleryBrowser( pBindings, this, _pParent, GAL_RES( RID_SVXDLG_GALLERYBROWSER ) );
84 0 : eChildAlignment = SFX_ALIGN_TOP;
85 0 : ( (GalleryBrowser*) pWindow )->Initialize( pInfo );
86 0 : };
87 :
88 : // -----------------------------------------------------------------------------
89 :
90 0 : GalleryChildWindow::~GalleryChildWindow()
91 : {
92 : DBG_DTOR(GalleryChildWindow,NULL);
93 0 : }
94 :
95 : // -----------------------------------------------------------------------------
96 :
97 39 : SFX_IMPL_DOCKINGWINDOW_WITHID( GalleryChildWindow, SID_GALLERY )
98 :
99 : // ------------------
100 : // - GalleryBrowser -
101 : // ------------------
102 : DBG_NAME(GalleryBrowser)
103 :
104 0 : GalleryBrowser::GalleryBrowser( SfxBindings* _pBindings, SfxChildWindow* pCW,
105 : Window* pParent, const ResId& rResId ) :
106 0 : SfxDockingWindow( _pBindings, pCW, pParent, rResId )
107 : {
108 : DBG_CTOR(GalleryBrowser,NULL);
109 :
110 0 : mpGallery = Gallery::GetGalleryInstance();
111 0 : mpBrowser1 = new GalleryBrowser1( this, GAL_RES( GALLERY_BROWSER1 ), mpGallery );
112 0 : mpSplitter = new GallerySplitter( this, GAL_RES( GALLERY_SPLITTER ) );
113 0 : mpBrowser2 = new GalleryBrowser2( this, GAL_RES( GALLERY_BROWSER2 ), mpGallery );
114 :
115 0 : FreeResource();
116 0 : SetMinOutputSizePixel( maLastSize = GetOutputSizePixel() );
117 :
118 0 : mpBrowser1->SelectTheme( 0 );
119 0 : mpBrowser1->Show( sal_True );
120 0 : mpBrowser2->Show( sal_True );
121 :
122 0 : mpSplitter->SetSplitHdl( LINK( this, GalleryBrowser, SplitHdl ) );
123 0 : mpSplitter->Show( sal_True );
124 :
125 0 : InitSettings();
126 0 : }
127 :
128 : // -----------------------------------------------------------------------------
129 :
130 0 : GalleryBrowser::~GalleryBrowser()
131 : {
132 0 : delete mpBrowser2;
133 0 : delete mpSplitter;
134 0 : delete mpBrowser1;
135 :
136 : DBG_DTOR(GalleryBrowser,NULL);
137 0 : }
138 :
139 : // -----------------------------------------------------------------------------
140 :
141 0 : void GalleryBrowser::InitSettings()
142 : {
143 0 : SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
144 0 : SetControlBackground( GALLERY_DLG_COLOR );
145 0 : SetControlForeground( GALLERY_DLG_COLOR );
146 :
147 0 : mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
148 0 : mpSplitter->SetControlBackground( GALLERY_DLG_COLOR );
149 0 : mpSplitter->SetControlForeground( GALLERY_DLG_COLOR );
150 :
151 0 : mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
152 0 : mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR );
153 0 : mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR );
154 :
155 0 : mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
156 0 : mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR );
157 0 : mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR );
158 0 : }
159 :
160 : // -----------------------------------------------------------------------------
161 :
162 0 : void GalleryBrowser::Resize()
163 : {
164 0 : SfxDockingWindow::Resize();
165 :
166 0 : const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
167 0 : const long nFrameWidth2 = nFrameWidth << 1;
168 0 : Size aNewSize( GetOutputSizePixel() );
169 0 : Point aSplitPos( mpSplitter->GetPosPixel() );
170 0 : const Size aSplitSize( mpSplitter->GetOutputSizePixel() );
171 :
172 : mpBrowser1->SetPosSizePixel( Point( nFrameWidth, nFrameWidth ),
173 0 : Size( aSplitPos.X() - nFrameWidth, aNewSize.Height() - nFrameWidth2 ) );
174 :
175 0 : mpSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aNewSize.Height() ) );
176 0 : mpSplitter->SetDragRectPixel( Rectangle( Point( nFrameWidth2, 0 ), Size( aNewSize.Width() - ( nFrameWidth2 << 1 ) - aSplitSize.Width(), aNewSize.Height() ) ) );
177 :
178 0 : mpBrowser2->SetPosSizePixel( Point( aSplitPos.X() + aSplitSize.Width(), nFrameWidth ),
179 0 : Size( aNewSize.Width() - aSplitSize.Width() - aSplitPos.X() - nFrameWidth, aNewSize.Height() - nFrameWidth2 ) );
180 :
181 0 : maLastSize = aNewSize;
182 0 : }
183 :
184 : // -----------------------------------------------------------------------------
185 :
186 0 : sal_Bool GalleryBrowser::KeyInput( const KeyEvent& rKEvt, Window* )
187 : {
188 0 : const sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
189 0 : sal_Bool bRet = ( !rKEvt.GetKeyCode().IsMod1() &&
190 0 : ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) );
191 :
192 0 : if( bRet )
193 : {
194 0 : if( !rKEvt.GetKeyCode().IsShift() )
195 : {
196 0 : if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) )
197 0 : mpBrowser2->GetViewWindow()->GrabFocus();
198 0 : else if( mpBrowser2->GetViewWindow()->HasFocus() )
199 0 : mpBrowser2->maViewBox.GrabFocus();
200 0 : else if( mpBrowser2->maViewBox.HasFocus() )
201 0 : mpBrowser1->maNewTheme.GrabFocus();
202 : else
203 0 : mpBrowser1->mpThemes->GrabFocus();
204 : }
205 : else
206 : {
207 0 : if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) )
208 0 : mpBrowser1->maNewTheme.GrabFocus();
209 0 : else if( mpBrowser1->maNewTheme.HasFocus() )
210 0 : mpBrowser2->maViewBox.GrabFocus();
211 0 : else if( mpBrowser2->maViewBox.HasFocus() )
212 0 : mpBrowser2->GetViewWindow()->GrabFocus();
213 : else
214 0 : mpBrowser1->mpThemes->GrabFocus();
215 : }
216 : }
217 :
218 0 : return bRet;
219 : }
220 :
221 : // -----------------------------------------------------------------------------
222 :
223 0 : sal_Bool GalleryBrowser::Close()
224 : {
225 0 : return SfxDockingWindow::Close();
226 : }
227 :
228 : // -----------------------------------------------------------------------------
229 :
230 0 : void GalleryBrowser::GetFocus()
231 : {
232 0 : SfxDockingWindow::GetFocus();
233 0 : mpBrowser1->GrabFocus();
234 0 : }
235 :
236 : // -----------------------------------------------------------------------------
237 :
238 0 : void GalleryBrowser::ThemeSelectionHasChanged()
239 : {
240 0 : mpBrowser2->SelectTheme( mpBrowser1->GetSelectedTheme() );
241 0 : }
242 :
243 : // -----------------------------------------------------------------------------
244 :
245 0 : INetURLObject GalleryBrowser::GetURL() const
246 : {
247 0 : return mpBrowser2->GetURL();
248 : }
249 :
250 : // -----------------------------------------------------------------------------
251 :
252 0 : String GalleryBrowser::GetFilterName() const
253 : {
254 0 : return mpBrowser2->GetFilterName();
255 : }
256 :
257 : // -----------------------------------------------------------------------------
258 :
259 0 : Graphic GalleryBrowser::GetGraphic() const
260 : {
261 0 : return mpBrowser2->GetGraphic();
262 : }
263 :
264 : // -----------------------------------------------------------------------------
265 :
266 0 : sal_Bool GalleryBrowser::IsLinkage() const
267 : {
268 0 : return mpBrowser2->IsLinkage();
269 : }
270 :
271 : // -----------------------------------------------------------------------------
272 :
273 0 : IMPL_LINK_NOARG(GalleryBrowser, SplitHdl)
274 : {
275 0 : mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) );
276 0 : Resize();
277 :
278 0 : return 0L;
279 : }
280 :
281 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|