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 : : #ifndef _ICCDLG_HXX
29 : : #define _ICCDLG_HXX
30 : :
31 : : #include <vcl/tabpage.hxx>
32 : : #include <vcl/msgbox.hxx>
33 : : #include <vcl/dialog.hxx>
34 : : #include <vcl/button.hxx>
35 : : #include <vcl/image.hxx>
36 : : #include <svtools/ivctrl.hxx>
37 : : #include <svl/itempool.hxx>
38 : : #include <svl/itemset.hxx>
39 : : #include <tools/string.hxx>
40 : : #include <vector>
41 : :
42 : : #define CTRLS_OFFSET 3
43 : : #define RET_USER 100
44 : : #define RET_USER_CANCEL 101
45 : :
46 : : // forward-declarations
47 : : struct IconChoicePageData;
48 : : class IconChoiceDialog;
49 : : class IconChoicePage;
50 : :
51 : : // Create-Function
52 : : typedef IconChoicePage* (*CreatePage)(Window *pParent, const SfxItemSet &rAttrSet);
53 : : typedef sal_uInt16* (*GetPageRanges)(); // gives international Which-value
54 : :
55 : : // position of iconchoicectrl
56 : : enum EIconChoicePos { PosLeft, PosRight, PosTop, PosBottom };
57 : :
58 : : /// Data-structure for pages in dialog
59 : : struct IconChoicePageData
60 : : {
61 : : sal_uInt16 nId;
62 : : CreatePage fnCreatePage; ///< pointer to the factory
63 : : GetPageRanges fnGetRanges; ///< pointer to the ranges-function
64 : : IconChoicePage* pPage; ///< the TabPage itself
65 : : sal_Bool bOnDemand; ///< Flag: ItemSet onDemand
66 : : sal_Bool bRefresh; ///< Flag: page has to be newly initialized
67 : :
68 : : // constructor
69 : 0 : IconChoicePageData( sal_uInt16 Id, CreatePage fnPage, GetPageRanges fnRanges, sal_Bool bDemand )
70 : : : nId ( Id ),
71 : : fnCreatePage ( fnPage ),
72 : : fnGetRanges ( fnRanges ),
73 : : pPage ( NULL ),
74 : : bOnDemand ( bDemand ),
75 : 0 : bRefresh ( sal_False )
76 : 0 : {}
77 : : };
78 : :
79 : : class IconChoicePage : public TabPage
80 : : {
81 : : using TabPage::ActivatePage;
82 : : using TabPage::DeactivatePage;
83 : :
84 : : private :
85 : : const SfxItemSet* pSet;
86 : : String aUserString;
87 : : sal_Bool bHasExchangeSupport;
88 : : IconChoiceDialog* pDialog;
89 : : sal_Bool bStandard;
90 : :
91 : : void SetDialog( IconChoiceDialog* pNew ) { pDialog = pNew; }
92 : : IconChoiceDialog* GetDialog() const { return pDialog; }
93 : :
94 : : void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
95 : :
96 : : void ImplInitSettings();
97 : :
98 : : protected :
99 : : IconChoicePage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet );
100 : :
101 : : sal_uInt16 GetSlot( sal_uInt16 nWhich ) const { return pSet->GetPool()->GetSlotId( nWhich ); }
102 : 0 : sal_uInt16 GetWhich( sal_uInt16 nSlot ) const { return pSet->GetPool()->GetWhich( nSlot ); }
103 : :
104 : : public :
105 : : virtual ~IconChoicePage();
106 : :
107 : 0 : const SfxItemSet& GetItemSet() const { return *pSet; }
108 : :
109 : : virtual sal_Bool FillItemSet( SfxItemSet& ) = 0;
110 : : virtual void Reset( const SfxItemSet& ) = 0;
111 : :
112 : 0 : sal_Bool HasExchangeSupport() const { return bHasExchangeSupport; }
113 : 0 : void SetExchangeSupport( sal_Bool bNew = sal_True ) { bHasExchangeSupport = bNew; }
114 : :
115 : : enum {
116 : : KEEP_PAGE = 0x0000, ///< error handling
117 : : /** 2nd filling of an ItemSet for updating superior examples;
118 : : this pointer can always be NULL!! */
119 : : LEAVE_PAGE = 0x0001,
120 : : /// refresh set and update other pages
121 : : REFRESH_SET = 0x0002
122 : : };
123 : :
124 : : virtual void ActivatePage( const SfxItemSet& );
125 : : virtual int DeactivatePage( SfxItemSet* pSet = 0 );
126 : 0 : void SetUserData(const String& rString) { aUserString = rString; }
127 : 0 : String GetUserData() { return aUserString; }
128 : : virtual void FillUserData();
129 : : virtual sal_Bool IsReadOnly() const;
130 : : virtual sal_Bool QueryClose();
131 : :
132 : : void StateChanged( StateChangedType nType );
133 : : void DataChanged( const DataChangedEvent& rDCEvt );
134 : : };
135 : :
136 : : class IconChoiceDialog : public ModalDialog
137 : : {
138 : : private :
139 : : friend class IconChoicePage;
140 : :
141 : : EIconChoicePos meChoicePos;
142 : : ::std::vector< IconChoicePageData* > maPageList;
143 : :
144 : : SvtIconChoiceCtrl maIconCtrl;
145 : :
146 : : sal_uInt16 mnCurrentPageId;
147 : :
148 : : // Buttons
149 : : OKButton aOKBtn;
150 : : CancelButton aCancelBtn;
151 : : HelpButton aHelpBtn;
152 : : PushButton aResetBtn;
153 : :
154 : : const SfxItemSet* pSet;
155 : : SfxItemSet* pOutSet;
156 : : SfxItemSet* pExampleSet;
157 : : sal_uInt16* pRanges;
158 : :
159 : : sal_uInt32 nResId;
160 : :
161 : : sal_Bool bHideResetBtn;
162 : : sal_Bool bModal;
163 : : sal_Bool bInOK;
164 : : sal_Bool bModified;
165 : : sal_Bool bItemsReset;
166 : :
167 : : DECL_LINK ( ChosePageHdl_Impl, void * );
168 : : DECL_LINK(OkHdl, void *);
169 : : DECL_LINK(ResetHdl, void *);
170 : : DECL_LINK(CancelHdl, void *);
171 : :
172 : : IconChoicePageData* GetPageData ( sal_uInt16 nId );
173 : : void Start_Impl();
174 : : sal_Bool OK_Impl();
175 : :
176 : : void SetPosSizeCtrls ( sal_Bool bInit = sal_False );
177 : : void SetPosSizePages ( sal_uInt16 nId );
178 : :
179 : : void FocusOnIcon ( sal_uInt16 nId );
180 : :
181 : : protected :
182 : : void ShowPageImpl ( IconChoicePageData* pData );
183 : : void HidePageImpl ( IconChoicePageData* pData );
184 : :
185 : : virtual void PageCreated( sal_uInt16 nId, IconChoicePage& rPage );
186 : : virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
187 : : inline SfxItemSet* GetInputSetImpl() { return (SfxItemSet*)pSet; }
188 : 0 : inline IconChoicePage* GetTabPage( sal_uInt16 nPageId )
189 [ # # ]: 0 : { return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); }
190 : : const SfxItemSet* GetRefreshedSet();
191 : :
192 : : void ActivatePageImpl ();
193 : : sal_Bool DeActivatePageImpl ();
194 : : void ResetPageImpl ();
195 : :
196 : : short Ok();
197 : :
198 : : public :
199 : :
200 : : // the IconChoiceCtrl's could also be set in the Ctor
201 : : IconChoiceDialog ( Window* pParent, const ResId &rResId,
202 : : const EIconChoicePos ePos = PosLeft, const SfxItemSet * pItemSet = 0 );
203 : : ~IconChoiceDialog ();
204 : :
205 : : virtual void Paint( const Rectangle& rRect );
206 : : virtual void Resize();
207 : :
208 : : // interface
209 : : SvxIconChoiceCtrlEntry* AddTabPage(
210 : : sal_uInt16 nId, const String& rIconText, const Image& rChoiceIcon,
211 : : CreatePage pCreateFunc /* != NULL */, GetPageRanges pRangesFunc = NULL /* NULL allowed*/,
212 : : sal_Bool bItemsOnDemand = sal_False, sal_uLong nPos = LIST_APPEND );
213 : :
214 : 0 : void SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
215 : 0 : sal_uInt16 GetCurPageId() const { return mnCurrentPageId; }
216 : : void ShowPage( sal_uInt16 nId );
217 : :
218 : : /// gives via map converted local slots if applicable
219 : : const sal_uInt16* GetInputRanges( const SfxItemPool& );
220 : : void SetInputSet( const SfxItemSet* pInSet );
221 : : const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
222 : :
223 : : const OKButton& GetOKButton() const { return aOKBtn; }
224 : 0 : OKButton& GetOKButton() { return aOKBtn; }
225 : : const CancelButton& GetCancelButton() const { return aCancelBtn; }
226 : 0 : CancelButton& GetCancelButton() { return aCancelBtn; }
227 : : const HelpButton& GetHelpButton() const { return aHelpBtn; }
228 : : HelpButton& GetHelpButton() { return aHelpBtn; }
229 : :
230 : : short Execute();
231 : : void Start( sal_Bool bShow = sal_True );
232 : : sal_Bool QueryClose();
233 : :
234 : : const SfxItemSet* GetExampleSet() const { return pExampleSet; }
235 : :
236 : : EIconChoicePos SetCtrlPos ( const EIconChoicePos& rPos );
237 : : };
238 : :
239 : : #endif //_ICCDLG_HXX
240 : :
241 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|