1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef FRAMEWORK_BACKINGWINDOW_HXX
25 #define FRAMEWORK_BACKINGWINDOW_HXX
26 
27 #include "rtl/ustring.hxx"
28 
29 #include "vcl/button.hxx"
30 #include "vcl/menubtn.hxx"
31 #include "vcl/fixed.hxx"
32 #include "vcl/bitmapex.hxx"
33 #include "vcl/toolbox.hxx"
34 
35 #include "unotools/moduleoptions.hxx"
36 #include "svtools/acceleratorexecute.hxx"
37 
38 #include "com/sun/star/frame/XDispatchProvider.hpp"
39 #include "com/sun/star/frame/XDesktop.hpp"
40 #include "com/sun/star/frame/XFrame.hpp"
41 #include "com/sun/star/frame/XTerminateListener.hpp"
42 #include "com/sun/star/document/XEventListener.hpp"
43 #include "com/sun/star/document/XEventBroadcaster.hpp"
44 #include "com/sun/star/util/XURLTransformer.hpp"
45 #include "com/sun/star/ui/dialogs/XFilePicker.hpp"
46 #include "com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp"
47 #include "com/sun/star/ui/dialogs/XFilterManager.hpp"
48 #include "com/sun/star/ui/dialogs/XFolderPicker.hpp"
49 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
50 #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
51 
52 #include <set>
53 
54 class MnemonicGenerator;
55 
56 namespace framework
57 {
58         // To get the transparent mouse-over look, the closer is actually a toolbox
59     // overload DataChange to handle style changes correctly
60     class DecoToolBox : public ToolBox
61     {
62         Size maMinSize;
63 
64         using Window::ImplInit;
65     public:
66                 DecoToolBox( Window* pParent, WinBits nStyle = 0 );
67                 DecoToolBox( Window* pParent, const ResId& rResId );
68 
69         void    DataChanged( const DataChangedEvent& rDCEvt );
70 
71         void    calcMinSize();
72         Size    getMinSize();
73     };
74 
75     class BackingWindow : public Window
76     {
77         struct LoadRecentFile
78         {
79             rtl::OUString                                                             aTargetURL;
80             com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >     aArgSeq;
81         };
82 
83         com::sun::star::uno::Reference<com::sun::star::frame::XDesktop>                  mxDesktop;
84         com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider >        mxDesktopDispatchProvider;
85         com::sun::star::uno::Reference<com::sun::star::frame::XFrame>                    mxFrame;
86         com::sun::star::uno::Reference<com::sun::star::document::XEventBroadcaster>      mxBroadcaster;
87 
88         FixedText                       maWelcome;
89         Size                            maWelcomeSize;
90         FixedText                       maProduct;
91         Size                            maProductSize;
92         ImageButton                     maWriterButton;
93         ImageButton                     maCalcButton;
94         ImageButton                     maImpressButton;
95         MenuButton                      maOpenButton;
96         ImageButton                     maDrawButton;
97         ImageButton                     maDBButton;
98         ImageButton                     maMathButton;
99         ImageButton                     maTemplateButton;
100 
101         DecoToolBox                     maToolbox;
102 
103         BitmapEx                        maBackgroundLeft;
104         BitmapEx                        maBackgroundMiddle;
105         BitmapEx                        maBackgroundRight;
106 
107         String                          maWelcomeString;
108         String                          maProductString;
109         String                          maCreateString;
110         String                          maOpenString;
111         String                          maTemplateString;
112 
113         Font                            maTextFont;
114         Rectangle                       maControlRect;
115 
116         long                            mnColumnWidth[2];
117         long                            mnTextColumnWidth[2];
118         Color                           maLabelTextColor;
119         Color                           maWelcomeTextColor;
120 
121         Size                            maButtonImageSize;
122 
123         bool                            mbInitControls;
124         sal_Int32                       mnLayoutStyle;
125         svt::AcceleratorExecute*        mpAccExec;
126         long                            mnBtnPos;
127         long                            mnBtnTop;
128 
129         PopupMenu*                      mpRecentMenu;
130         std::vector< LoadRecentFile >   maRecentFiles;
131 
132         static const int nItemId_Extensions = 1;
133         static const int nItemId_Reg = 2;
134         static const int nItemId_Info = 3;
135         static const int nItemId_TplRep = 4;
136         static const int nShadowTop = 32;
137         static const int nShadowLeft = 35;
138         static const int nShadowRight = 45;
139         static const int nShadowBottom = 50;
140 
141         void loadImage( const ResId& i_rId, PushButton& i_rButton );
142 
143         void layoutButton( const char* i_pURL, int nColumn, const std::set<rtl::OUString>& i_rURLS,
144                            SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod,
145                            PushButton& i_rBtn,
146                            MnemonicGenerator& i_rMnemonicGen,
147                            const String& i_rStr = String()
148                            );
149 
150         void dispatchURL( const rtl::OUString& i_rURL,
151                           const rtl::OUString& i_rTarget = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ),
152                           const com::sun::star::uno::Reference< com::sun::star::frame::XDispatchProvider >& i_xProv = com::sun::star::uno::Reference< com::sun::star::frame::XDispatchProvider >(),
153                           const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& = com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >()
154                           );
155 
156         DECL_LINK( ClickHdl, Button* );
157         DECL_LINK( SelectHdl, Button* );
158         DECL_LINK( ActivateHdl, Button* );
159         DECL_LINK( ToolboxHdl, void* );
160 
161         void initControls();
162         void initBackground();
163         void prepareRecentFileMenu();
164         public:
165         BackingWindow( Window* pParent );
166         ~BackingWindow();
167 
168         virtual void        Paint( const Rectangle& rRect );
169         virtual void        Resize();
170         virtual long        Notify( NotifyEvent& rNEvt );
171         virtual void        DataChanged( const DataChangedEvent& rDCEvt );
172         virtual void        GetFocus();
173 
174         void setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame );
175     };
176 
177 }
178 
179 #endif
180 
181