bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / inc / iconcdlg.hxx
blob1944cb459106b15fb01290e0aa292fb130caceaa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
22 #include <rtl/ustring.hxx>
23 #include <svl/itempool.hxx>
24 #include <svl/itemset.hxx>
25 #include <svtools/ivctrl.hxx>
26 #include <vcl/tabpage.hxx>
27 #include <vcl/msgbox.hxx>
28 #include <vcl/dialog.hxx>
29 #include <vcl/button.hxx>
30 #include <vcl/image.hxx>
31 #include <vcl/layout.hxx>
32 #include <vector>
34 #define RET_USER 100
35 #define RET_USER_CANCEL 101
37 // forward-declarations
38 struct IconChoicePageData;
39 class IconChoiceDialog;
40 class IconChoicePage;
42 // Create-Function
43 typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet &rAttrSet);
44 typedef const sal_uInt16* (*GetPageRanges)(); // gives international Which-value
46 /// Data-structure for pages in dialog
47 struct IconChoicePageData
49 sal_uInt16 nId;
50 CreatePage fnCreatePage; ///< pointer to the factory
51 GetPageRanges fnGetRanges; ///< pointer to the ranges-function
52 VclPtr<IconChoicePage> pPage; ///< the TabPage itself
53 bool bOnDemand; ///< Flag: ItemSet onDemand
54 bool bRefresh; ///< Flag: page has to be newly initialized
56 // constructor
57 IconChoicePageData( sal_uInt16 Id, CreatePage fnPage, GetPageRanges fnRanges, bool bDemand )
58 : nId ( Id ),
59 fnCreatePage ( fnPage ),
60 fnGetRanges ( fnRanges ),
61 pPage ( NULL ),
62 bOnDemand ( bDemand ),
63 bRefresh ( false )
67 class IconChoicePage : public TabPage
69 using TabPage::ActivatePage;
70 using TabPage::DeactivatePage;
72 private :
73 const SfxItemSet* pSet;
74 OUString aUserString;
75 bool bHasExchangeSupport;
76 VclPtr<IconChoiceDialog> pDialog;
78 void SetDialog( IconChoiceDialog* pNew ) { pDialog = pNew; }
79 IconChoiceDialog* GetDialog() const { return pDialog; }
81 void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
83 void ImplInitSettings();
85 protected :
86 IconChoicePage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet );
88 sal_uInt16 GetSlot( sal_uInt16 nWhich ) const { return pSet->GetPool()->GetSlotId( nWhich ); }
89 sal_uInt16 GetWhich( sal_uInt16 nSlot ) const { return pSet->GetPool()->GetWhich( nSlot ); }
91 public :
92 virtual ~IconChoicePage();
93 virtual void dispose() SAL_OVERRIDE;
95 const SfxItemSet& GetItemSet() const { return *pSet; }
97 virtual bool FillItemSet( SfxItemSet* ) = 0;
98 virtual void Reset( const SfxItemSet& ) = 0;
100 bool HasExchangeSupport() const { return bHasExchangeSupport; }
101 void SetExchangeSupport( bool bNew = true ) { bHasExchangeSupport = bNew; }
103 enum {
104 KEEP_PAGE = 0x0000, ///< error handling
105 /** 2nd filling of an ItemSet for updating superior examples;
106 this pointer can always be NULL!! */
107 LEAVE_PAGE = 0x0001,
108 /// refresh set and update other pages
109 REFRESH_SET = 0x0002
112 virtual void ActivatePage( const SfxItemSet& );
113 virtual int DeactivatePage( SfxItemSet* pSet = 0 );
114 void SetUserData(const OUString& rString) { aUserString = rString; }
115 OUString GetUserData() { return aUserString; }
116 virtual bool QueryClose();
118 void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
119 void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
122 class IconChoiceDialog : public ModalDialog
124 private :
125 friend class IconChoicePage;
127 ::std::vector< IconChoicePageData* > maPageList;
129 VclPtr<SvtIconChoiceCtrl> m_pIconCtrl;
131 sal_uInt16 mnCurrentPageId;
133 // Buttons
134 VclPtr<OKButton> m_pOKBtn;
135 VclPtr<PushButton> m_pApplyBtn;
136 VclPtr<CancelButton> m_pCancelBtn;
137 VclPtr<HelpButton> m_pHelpBtn;
138 VclPtr<PushButton> m_pResetBtn;
140 VclPtr<VclVBox> m_pTabContainer;
141 const SfxItemSet* pSet;
142 SfxItemSet* pOutSet;
143 SfxItemSet* pExampleSet;
144 sal_uInt16* pRanges;
146 bool bHideResetBtn;
147 bool bModal;
148 bool bInOK;
149 bool bItemsReset;
151 DECL_LINK ( ChosePageHdl_Impl, void * );
152 DECL_LINK(OkHdl, void *);
153 DECL_LINK(ApplyHdl, void *);
154 DECL_LINK(ResetHdl, void *);
155 DECL_LINK(CancelHdl, void *);
157 IconChoicePageData* GetPageData ( sal_uInt16 nId );
158 void Start_Impl();
159 bool OK_Impl();
161 void FocusOnIcon ( sal_uInt16 nId );
163 protected :
164 static void ShowPageImpl ( IconChoicePageData* pData );
165 static void HidePageImpl ( IconChoicePageData* pData );
167 virtual void PageCreated( sal_uInt16 nId, IconChoicePage& rPage );
168 static SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
169 inline SfxItemSet* GetInputSetImpl() { return const_cast<SfxItemSet*>(pSet); }
170 inline IconChoicePage* GetTabPage( sal_uInt16 nPageId )
171 { return ( GetPageData (nPageId)->pPage ? GetPageData (nPageId)->pPage.get() : NULL); }
172 static void RefreshInputSet();
174 void ActivatePageImpl ();
175 bool DeActivatePageImpl ();
176 void ResetPageImpl ();
178 short Ok();
180 public :
182 // the IconChoiceCtrl's could also be set in the Ctor
183 IconChoiceDialog ( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription,
184 const SfxItemSet * pItemSet = 0 );
185 virtual ~IconChoiceDialog ();
186 virtual void dispose() SAL_OVERRIDE;
188 // interface
189 SvxIconChoiceCtrlEntry* AddTabPage(
190 sal_uInt16 nId, const OUString& rIconText, const Image& rChoiceIcon,
191 CreatePage pCreateFunc /* != NULL */, GetPageRanges pRangesFunc = NULL /* NULL allowed*/,
192 bool bItemsOnDemand = false, sal_uLong nPos = TREELIST_APPEND );
194 void SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
195 sal_uInt16 GetCurPageId() const { return mnCurrentPageId; }
196 void ShowPage( sal_uInt16 nId );
198 /// gives via map converted local slots if applicable
199 const sal_uInt16* GetInputRanges( const SfxItemPool& );
200 void SetInputSet( const SfxItemSet* pInSet );
201 const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
203 const OKButton& GetOKButton() const { return *m_pOKBtn; }
204 OKButton& GetOKButton() { return *m_pOKBtn; }
205 const PushButton& GetApplyButton() const { return *m_pApplyBtn; }
206 PushButton& GetApplyButton() { return *m_pApplyBtn; }
207 const CancelButton& GetCancelButton() const { return *m_pCancelBtn; }
208 CancelButton& GetCancelButton() { return *m_pCancelBtn; }
209 const HelpButton& GetHelpButton() const { return *m_pHelpBtn; }
210 HelpButton& GetHelpButton() { return *m_pHelpBtn; }
212 short Execute() SAL_OVERRIDE;
213 void Start( bool bShow = true );
214 bool QueryClose();
216 const SfxItemSet* GetExampleSet() const { return pExampleSet; }
218 void SetCtrlStyle();
221 #endif // INCLUDED_CUI_SOURCE_INC_ICONCDLG_HXX
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */