xref: /trunk/main/cui/source/inc/iconcdlg.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*c4eee24dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c4eee24dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c4eee24dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c4eee24dSAndrew Rist  * distributed with this work for additional information
6*c4eee24dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c4eee24dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c4eee24dSAndrew Rist  * "License"); you may not use this file except in compliance
9*c4eee24dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*c4eee24dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*c4eee24dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c4eee24dSAndrew Rist  * software distributed under the License is distributed on an
15*c4eee24dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c4eee24dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c4eee24dSAndrew Rist  * specific language governing permissions and limitations
18*c4eee24dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*c4eee24dSAndrew Rist  *************************************************************/
21*c4eee24dSAndrew Rist 
22*c4eee24dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _ICCDLG_HXX
24cdf0e10cSrcweir #define _ICCDLG_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <vcl/tabpage.hxx>
27cdf0e10cSrcweir #include <vcl/msgbox.hxx>
28cdf0e10cSrcweir #include <vcl/dialog.hxx>
29cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
30cdf0e10cSrcweir #include <vcl/button.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <vcl/image.hxx>
33cdf0e10cSrcweir #include <svtools/ivctrl.hxx>
34cdf0e10cSrcweir #include <svl/itempool.hxx>
35cdf0e10cSrcweir #include <svl/itemset.hxx>
36cdf0e10cSrcweir #include <tools/list.hxx>
37cdf0e10cSrcweir #include <tools/string.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #define CTRLS_OFFSET        3
40cdf0e10cSrcweir #define BUTTON_DISTANCE     8
41cdf0e10cSrcweir #define RET_USER        100
42cdf0e10cSrcweir #define RET_USER_CANCEL 101
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // forward-declarations
45cdf0e10cSrcweir struct IconChoicePageData;
46cdf0e10cSrcweir class IconChoiceDialog;
47cdf0e10cSrcweir class IconChoicePage;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir // Create-Function
50cdf0e10cSrcweir typedef IconChoicePage* (*CreatePage)(Window *pParent, const SfxItemSet &rAttrSet);
51cdf0e10cSrcweir typedef sal_uInt16*         (*GetPageRanges)(); // liefert internationale Which-Wert
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // page-list
54cdf0e10cSrcweir DECLARE_LIST( IconChoicePageList, IconChoicePageData * )
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // position of iconchoicectrl
57cdf0e10cSrcweir enum EIconChoicePos { PosLeft, PosRight, PosTop, PosBottom };
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /**********************************************************************
60cdf0e10cSrcweir |
61cdf0e10cSrcweir | Data-structure for pages in dialog
62cdf0e10cSrcweir |
63cdf0e10cSrcweir \**********************************************************************/
64cdf0e10cSrcweir 
65cdf0e10cSrcweir struct IconChoicePageData
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     sal_uInt16 nId;                  // Die ID
68cdf0e10cSrcweir     CreatePage fnCreatePage;     // Pointer auf die Factory
69cdf0e10cSrcweir     GetPageRanges fnGetRanges;// Pointer auf die Ranges-Funktion
70cdf0e10cSrcweir     IconChoicePage* pPage;       // die TabPage selber
71cdf0e10cSrcweir     sal_Bool bOnDemand;              // Flag: ItemSet onDemand
72cdf0e10cSrcweir     sal_Bool bRefresh;               // Flag: Seite mu\s neu initialisiert werden
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     // Konstruktor
IconChoicePageDataIconChoicePageData75cdf0e10cSrcweir     IconChoicePageData( sal_uInt16 Id, CreatePage fnPage, GetPageRanges fnRanges, sal_Bool bDemand )
76cdf0e10cSrcweir         : nId           ( Id ),
77cdf0e10cSrcweir           fnCreatePage  ( fnPage ),
78cdf0e10cSrcweir           fnGetRanges   ( fnRanges ),
79cdf0e10cSrcweir           pPage         ( NULL ),
80cdf0e10cSrcweir           bOnDemand     ( bDemand ),
81cdf0e10cSrcweir           bRefresh      ( sal_False )
82cdf0e10cSrcweir     {}
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir /**********************************************************************
86cdf0e10cSrcweir |
87cdf0e10cSrcweir | IconChoicePage
88cdf0e10cSrcweir |
89cdf0e10cSrcweir \**********************************************************************/
90cdf0e10cSrcweir 
91cdf0e10cSrcweir class IconChoicePage : public TabPage
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     using TabPage::ActivatePage;
94cdf0e10cSrcweir     using TabPage::DeactivatePage;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir private :
97cdf0e10cSrcweir     const SfxItemSet*   pSet;
98cdf0e10cSrcweir     String              aUserString;
99cdf0e10cSrcweir     sal_Bool                bHasExchangeSupport;
100cdf0e10cSrcweir     IconChoiceDialog*   pDialog;
101cdf0e10cSrcweir     sal_Bool                bStandard;
102cdf0e10cSrcweir 
SetDialog(IconChoiceDialog * pNew)103cdf0e10cSrcweir     void                SetDialog( IconChoiceDialog* pNew ) { pDialog = pNew; }
GetDialog() const104cdf0e10cSrcweir     IconChoiceDialog*   GetDialog() const { return pDialog; }
105cdf0e10cSrcweir 
SetInputSet(const SfxItemSet * pNew)106cdf0e10cSrcweir     void                SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     void                ImplInitSettings();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir protected :
111cdf0e10cSrcweir     IconChoicePage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet );
112cdf0e10cSrcweir 
GetSlot(sal_uInt16 nWhich) const113cdf0e10cSrcweir     sal_uInt16              GetSlot( sal_uInt16 nWhich ) const  { return pSet->GetPool()->GetSlotId( nWhich ); }
GetWhich(sal_uInt16 nSlot) const114cdf0e10cSrcweir     sal_uInt16              GetWhich( sal_uInt16 nSlot ) const  { return pSet->GetPool()->GetWhich( nSlot ); }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir public :
117cdf0e10cSrcweir     virtual             ~IconChoicePage();
118cdf0e10cSrcweir 
GetItemSet() const119cdf0e10cSrcweir     const SfxItemSet&   GetItemSet() const { return *pSet; }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual sal_Bool        FillItemSet( SfxItemSet& ) = 0;
122cdf0e10cSrcweir     virtual void        Reset( const SfxItemSet& ) = 0;
123cdf0e10cSrcweir 
HasExchangeSupport() const124cdf0e10cSrcweir     sal_Bool                HasExchangeSupport() const              { return bHasExchangeSupport; }
SetExchangeSupport(sal_Bool bNew=sal_True)125cdf0e10cSrcweir     void                SetExchangeSupport( sal_Bool bNew = sal_True )  { bHasExchangeSupport = bNew; }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     enum {
128cdf0e10cSrcweir         KEEP_PAGE = 0x0000,     // Fehlerbehandlung; Seite nicht wechseln
129cdf0e10cSrcweir             // 2. F"ullen eines ItemSets f"ur die Aktualilsierung
130cdf0e10cSrcweir             // "ubergeordneter Beispiele; dieser Pointer kann immer
131cdf0e10cSrcweir             // NULL sein!!
132cdf0e10cSrcweir         LEAVE_PAGE = 0x0001,
133cdf0e10cSrcweir             // Set aktualisieren und andere Page aktualisieren
134cdf0e10cSrcweir         REFRESH_SET = 0x0002
135cdf0e10cSrcweir     };
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     virtual void        ActivatePage( const SfxItemSet& );
138cdf0e10cSrcweir     virtual int         DeactivatePage( SfxItemSet* pSet = 0 );
SetUserData(const String & rString)139cdf0e10cSrcweir     void                SetUserData(const String& rString)  { aUserString = rString; }
GetUserData()140cdf0e10cSrcweir     String              GetUserData() { return aUserString; }
141cdf0e10cSrcweir     virtual void        FillUserData();
142cdf0e10cSrcweir     virtual sal_Bool        IsReadOnly() const;
143cdf0e10cSrcweir     virtual sal_Bool    QueryClose();
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     void                StateChanged( StateChangedType nType );
146cdf0e10cSrcweir     void                DataChanged( const DataChangedEvent& rDCEvt );
147cdf0e10cSrcweir };
148cdf0e10cSrcweir 
149cdf0e10cSrcweir /**********************************************************************
150cdf0e10cSrcweir |
151cdf0e10cSrcweir | IconChoiceDialog
152cdf0e10cSrcweir |
153cdf0e10cSrcweir \**********************************************************************/
154cdf0e10cSrcweir 
155cdf0e10cSrcweir class IconChoiceDialog : public ModalDialog
156cdf0e10cSrcweir {
157cdf0e10cSrcweir private :
158cdf0e10cSrcweir     friend class IconChoicePage;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     EIconChoicePos          meChoicePos;    // Position des IconChoiceCtrl's
161cdf0e10cSrcweir     IconChoicePageList      maPageList;     // Liste von PageData-Pointer
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     SvtIconChoiceCtrl       maIconCtrl;     // DAS IconChoice-Control
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     sal_uInt16                  mnCurrentPageId;    // Id der aktuell sichtbaren Page
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     // Buttons
168cdf0e10cSrcweir     OKButton                aOKBtn;
169cdf0e10cSrcweir     CancelButton            aCancelBtn;
170cdf0e10cSrcweir     HelpButton              aHelpBtn;
171cdf0e10cSrcweir     PushButton              aResetBtn;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     const SfxItemSet*       pSet;
174cdf0e10cSrcweir     SfxItemSet*             pOutSet;
175cdf0e10cSrcweir     SfxItemSet*             pExampleSet;
176cdf0e10cSrcweir     sal_uInt16*                 pRanges;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     sal_uInt32              nResId;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     sal_Bool                    bHideResetBtn;
181cdf0e10cSrcweir     sal_Bool                    bModal;
182cdf0e10cSrcweir     sal_Bool                    bInOK;
183cdf0e10cSrcweir     sal_Bool                    bModified;
184cdf0e10cSrcweir     sal_Bool                    bItemsReset;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     DECL_LINK ( ChosePageHdl_Impl, void * );
187cdf0e10cSrcweir     DECL_LINK ( OkHdl,             Button * );
188cdf0e10cSrcweir     DECL_LINK ( ResetHdl,          Button * );
189cdf0e10cSrcweir     DECL_LINK ( CancelHdl,         Button * );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     IconChoicePageData*     GetPageData ( sal_uInt16 nId );
192cdf0e10cSrcweir     void                    Start_Impl();
193cdf0e10cSrcweir     sal_Bool                    OK_Impl();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     void                    SetPosSizeCtrls ( sal_Bool bInit = sal_False );
196cdf0e10cSrcweir     void                    SetPosSizePages ( sal_uInt16 nId );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     void                    FocusOnIcon ( sal_uInt16 nId );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir protected :
201cdf0e10cSrcweir     void                    ShowPageImpl ( IconChoicePageData* pData );
202cdf0e10cSrcweir     void                    HidePageImpl ( IconChoicePageData* pData );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     virtual void            PageCreated( sal_uInt16 nId, IconChoicePage& rPage );
205cdf0e10cSrcweir     virtual SfxItemSet*     CreateInputItemSet( sal_uInt16 nId );
GetInputSetImpl()206cdf0e10cSrcweir     inline SfxItemSet*      GetInputSetImpl() { return (SfxItemSet*)pSet; }
GetTabPage(sal_uInt16 nPageId)207cdf0e10cSrcweir     inline IconChoicePage*  GetTabPage( sal_uInt16 nPageId )
208cdf0e10cSrcweir                                 { return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); }
209cdf0e10cSrcweir     const SfxItemSet*       GetRefreshedSet();
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     void                    ActivatePageImpl ();
212cdf0e10cSrcweir     sal_Bool                    DeActivatePageImpl ();
213cdf0e10cSrcweir     void                    ResetPageImpl ();
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     short                   Ok();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir public :
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     // im Ctor k�nnte auch die Position des IconChoiceCtrl's gesetzt werden.
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     IconChoiceDialog ( Window* pParent, const ResId &rResId,
222cdf0e10cSrcweir                        const EIconChoicePos ePos = PosLeft, const SfxItemSet * pItemSet = 0 );
223cdf0e10cSrcweir     ~IconChoiceDialog ();
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     ///////////////////////////////////////////////////////////////////////////////////
226cdf0e10cSrcweir     // virtuelle Methoden
227cdf0e10cSrcweir     //
228cdf0e10cSrcweir     virtual void        Paint( const Rectangle& rRect );
229cdf0e10cSrcweir     virtual void        Resize();
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     ///////////////////////////////////////////////////////////////////////////////////
232cdf0e10cSrcweir     // Schnittstelle
233cdf0e10cSrcweir     //
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     SvxIconChoiceCtrlEntry* AddTabPage(
236cdf0e10cSrcweir         sal_uInt16 nId, const String& rIconText, const Image& rChoiceIcon, const Image& rChoiceIconHC,
237cdf0e10cSrcweir         CreatePage pCreateFunc /* != NULL */, GetPageRanges pRangesFunc = NULL /* NULL allowed*/,
238cdf0e10cSrcweir         sal_Bool bItemsOnDemand = sal_False, sal_uLong nPos = LIST_APPEND );
239cdf0e10cSrcweir 
SetCurPageId(sal_uInt16 nId)240cdf0e10cSrcweir     void                SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
GetCurPageId() const241cdf0e10cSrcweir     sal_uInt16              GetCurPageId() const       { return mnCurrentPageId; }
242cdf0e10cSrcweir     void                ShowPage( sal_uInt16 nId );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir                         // liefert ggf. per Map konvertierte lokale Slots
245cdf0e10cSrcweir     const sal_uInt16*       GetInputRanges( const SfxItemPool& );
246cdf0e10cSrcweir     void                SetInputSet( const SfxItemSet* pInSet );
GetOutputItemSet() const247cdf0e10cSrcweir     const SfxItemSet*   GetOutputItemSet() const { return pOutSet; }
248cdf0e10cSrcweir 
GetOKButton() const249cdf0e10cSrcweir     const OKButton&     GetOKButton() const { return aOKBtn; }
GetOKButton()250cdf0e10cSrcweir     OKButton&           GetOKButton() { return aOKBtn; }
GetCancelButton() const251cdf0e10cSrcweir     const CancelButton& GetCancelButton() const { return aCancelBtn; }
GetCancelButton()252cdf0e10cSrcweir     CancelButton&       GetCancelButton() { return aCancelBtn; }
GetHelpButton() const253cdf0e10cSrcweir     const HelpButton&   GetHelpButton() const { return aHelpBtn; }
GetHelpButton()254cdf0e10cSrcweir     HelpButton&         GetHelpButton() { return aHelpBtn; }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     short               Execute();
257cdf0e10cSrcweir     void                Start( sal_Bool bShow = sal_True );
258cdf0e10cSrcweir     sal_Bool            QueryClose();
259cdf0e10cSrcweir 
GetExampleSet() const260cdf0e10cSrcweir     const SfxItemSet*   GetExampleSet() const { return pExampleSet; }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     EIconChoicePos      SetCtrlPos   ( const EIconChoicePos& rPos );
263cdf0e10cSrcweir };
264cdf0e10cSrcweir 
265cdf0e10cSrcweir #endif //_ICCDLG_HXX
266