1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef _ICCDLG_HXX 28*cdf0e10cSrcweir #define _ICCDLG_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <vcl/tabpage.hxx> 31*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 32*cdf0e10cSrcweir #include <vcl/dialog.hxx> 33*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 34*cdf0e10cSrcweir #include <vcl/button.hxx> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #include <vcl/image.hxx> 37*cdf0e10cSrcweir #include <svtools/ivctrl.hxx> 38*cdf0e10cSrcweir #include <svl/itempool.hxx> 39*cdf0e10cSrcweir #include <svl/itemset.hxx> 40*cdf0e10cSrcweir #include <tools/list.hxx> 41*cdf0e10cSrcweir #include <tools/string.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #define CTRLS_OFFSET 3 44*cdf0e10cSrcweir #define BUTTON_DISTANCE 8 45*cdf0e10cSrcweir #define RET_USER 100 46*cdf0e10cSrcweir #define RET_USER_CANCEL 101 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // forward-declarations 49*cdf0e10cSrcweir struct IconChoicePageData; 50*cdf0e10cSrcweir class IconChoiceDialog; 51*cdf0e10cSrcweir class IconChoicePage; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // Create-Function 54*cdf0e10cSrcweir typedef IconChoicePage* (*CreatePage)(Window *pParent, const SfxItemSet &rAttrSet); 55*cdf0e10cSrcweir typedef sal_uInt16* (*GetPageRanges)(); // liefert internationale Which-Wert 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir // page-list 58*cdf0e10cSrcweir DECLARE_LIST( IconChoicePageList, IconChoicePageData * ) 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // position of iconchoicectrl 61*cdf0e10cSrcweir enum EIconChoicePos { PosLeft, PosRight, PosTop, PosBottom }; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir /********************************************************************** 64*cdf0e10cSrcweir | 65*cdf0e10cSrcweir | Data-structure for pages in dialog 66*cdf0e10cSrcweir | 67*cdf0e10cSrcweir \**********************************************************************/ 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir struct IconChoicePageData 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir sal_uInt16 nId; // Die ID 72*cdf0e10cSrcweir CreatePage fnCreatePage; // Pointer auf die Factory 73*cdf0e10cSrcweir GetPageRanges fnGetRanges;// Pointer auf die Ranges-Funktion 74*cdf0e10cSrcweir IconChoicePage* pPage; // die TabPage selber 75*cdf0e10cSrcweir sal_Bool bOnDemand; // Flag: ItemSet onDemand 76*cdf0e10cSrcweir sal_Bool bRefresh; // Flag: Seite mu\s neu initialisiert werden 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // Konstruktor 79*cdf0e10cSrcweir IconChoicePageData( sal_uInt16 Id, CreatePage fnPage, GetPageRanges fnRanges, sal_Bool bDemand ) 80*cdf0e10cSrcweir : nId ( Id ), 81*cdf0e10cSrcweir fnCreatePage ( fnPage ), 82*cdf0e10cSrcweir fnGetRanges ( fnRanges ), 83*cdf0e10cSrcweir pPage ( NULL ), 84*cdf0e10cSrcweir bOnDemand ( bDemand ), 85*cdf0e10cSrcweir bRefresh ( sal_False ) 86*cdf0e10cSrcweir {} 87*cdf0e10cSrcweir }; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir /********************************************************************** 90*cdf0e10cSrcweir | 91*cdf0e10cSrcweir | IconChoicePage 92*cdf0e10cSrcweir | 93*cdf0e10cSrcweir \**********************************************************************/ 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir class IconChoicePage : public TabPage 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir using TabPage::ActivatePage; 98*cdf0e10cSrcweir using TabPage::DeactivatePage; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir private : 101*cdf0e10cSrcweir const SfxItemSet* pSet; 102*cdf0e10cSrcweir String aUserString; 103*cdf0e10cSrcweir sal_Bool bHasExchangeSupport; 104*cdf0e10cSrcweir IconChoiceDialog* pDialog; 105*cdf0e10cSrcweir sal_Bool bStandard; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir void SetDialog( IconChoiceDialog* pNew ) { pDialog = pNew; } 108*cdf0e10cSrcweir IconChoiceDialog* GetDialog() const { return pDialog; } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir void SetInputSet( const SfxItemSet* pNew ) { pSet = pNew; } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void ImplInitSettings(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir protected : 115*cdf0e10cSrcweir IconChoicePage( Window *pParent, const ResId &, const SfxItemSet &rAttrSet ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir sal_uInt16 GetSlot( sal_uInt16 nWhich ) const { return pSet->GetPool()->GetSlotId( nWhich ); } 118*cdf0e10cSrcweir sal_uInt16 GetWhich( sal_uInt16 nSlot ) const { return pSet->GetPool()->GetWhich( nSlot ); } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir public : 121*cdf0e10cSrcweir virtual ~IconChoicePage(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir const SfxItemSet& GetItemSet() const { return *pSet; } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir virtual sal_Bool FillItemSet( SfxItemSet& ) = 0; 126*cdf0e10cSrcweir virtual void Reset( const SfxItemSet& ) = 0; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir sal_Bool HasExchangeSupport() const { return bHasExchangeSupport; } 129*cdf0e10cSrcweir void SetExchangeSupport( sal_Bool bNew = sal_True ) { bHasExchangeSupport = bNew; } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir enum { 132*cdf0e10cSrcweir KEEP_PAGE = 0x0000, // Fehlerbehandlung; Seite nicht wechseln 133*cdf0e10cSrcweir // 2. F"ullen eines ItemSets f"ur die Aktualilsierung 134*cdf0e10cSrcweir // "ubergeordneter Beispiele; dieser Pointer kann immer 135*cdf0e10cSrcweir // NULL sein!! 136*cdf0e10cSrcweir LEAVE_PAGE = 0x0001, 137*cdf0e10cSrcweir // Set aktualisieren und andere Page aktualisieren 138*cdf0e10cSrcweir REFRESH_SET = 0x0002 139*cdf0e10cSrcweir }; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir virtual void ActivatePage( const SfxItemSet& ); 142*cdf0e10cSrcweir virtual int DeactivatePage( SfxItemSet* pSet = 0 ); 143*cdf0e10cSrcweir void SetUserData(const String& rString) { aUserString = rString; } 144*cdf0e10cSrcweir String GetUserData() { return aUserString; } 145*cdf0e10cSrcweir virtual void FillUserData(); 146*cdf0e10cSrcweir virtual sal_Bool IsReadOnly() const; 147*cdf0e10cSrcweir virtual sal_Bool QueryClose(); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir void StateChanged( StateChangedType nType ); 150*cdf0e10cSrcweir void DataChanged( const DataChangedEvent& rDCEvt ); 151*cdf0e10cSrcweir }; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir /********************************************************************** 154*cdf0e10cSrcweir | 155*cdf0e10cSrcweir | IconChoiceDialog 156*cdf0e10cSrcweir | 157*cdf0e10cSrcweir \**********************************************************************/ 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir class IconChoiceDialog : public ModalDialog 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir private : 162*cdf0e10cSrcweir friend class IconChoicePage; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir EIconChoicePos meChoicePos; // Position des IconChoiceCtrl's 165*cdf0e10cSrcweir IconChoicePageList maPageList; // Liste von PageData-Pointer 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir SvtIconChoiceCtrl maIconCtrl; // DAS IconChoice-Control 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir sal_uInt16 mnCurrentPageId; // Id der aktuell sichtbaren Page 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir // Buttons 172*cdf0e10cSrcweir OKButton aOKBtn; 173*cdf0e10cSrcweir CancelButton aCancelBtn; 174*cdf0e10cSrcweir HelpButton aHelpBtn; 175*cdf0e10cSrcweir PushButton aResetBtn; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir const SfxItemSet* pSet; 178*cdf0e10cSrcweir SfxItemSet* pOutSet; 179*cdf0e10cSrcweir SfxItemSet* pExampleSet; 180*cdf0e10cSrcweir sal_uInt16* pRanges; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir sal_uInt32 nResId; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir sal_Bool bHideResetBtn; 185*cdf0e10cSrcweir sal_Bool bModal; 186*cdf0e10cSrcweir sal_Bool bInOK; 187*cdf0e10cSrcweir sal_Bool bModified; 188*cdf0e10cSrcweir sal_Bool bItemsReset; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir DECL_LINK ( ChosePageHdl_Impl, void * ); 191*cdf0e10cSrcweir DECL_LINK ( OkHdl, Button * ); 192*cdf0e10cSrcweir DECL_LINK ( ResetHdl, Button * ); 193*cdf0e10cSrcweir DECL_LINK ( CancelHdl, Button * ); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir IconChoicePageData* GetPageData ( sal_uInt16 nId ); 196*cdf0e10cSrcweir void Start_Impl(); 197*cdf0e10cSrcweir sal_Bool OK_Impl(); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir void SetPosSizeCtrls ( sal_Bool bInit = sal_False ); 200*cdf0e10cSrcweir void SetPosSizePages ( sal_uInt16 nId ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir void FocusOnIcon ( sal_uInt16 nId ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir protected : 205*cdf0e10cSrcweir void ShowPageImpl ( IconChoicePageData* pData ); 206*cdf0e10cSrcweir void HidePageImpl ( IconChoicePageData* pData ); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir virtual void PageCreated( sal_uInt16 nId, IconChoicePage& rPage ); 209*cdf0e10cSrcweir virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId ); 210*cdf0e10cSrcweir inline SfxItemSet* GetInputSetImpl() { return (SfxItemSet*)pSet; } 211*cdf0e10cSrcweir inline IconChoicePage* GetTabPage( sal_uInt16 nPageId ) 212*cdf0e10cSrcweir { return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); } 213*cdf0e10cSrcweir const SfxItemSet* GetRefreshedSet(); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir void ActivatePageImpl (); 216*cdf0e10cSrcweir sal_Bool DeActivatePageImpl (); 217*cdf0e10cSrcweir void ResetPageImpl (); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir short Ok(); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir public : 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir // im Ctor k�nnte auch die Position des IconChoiceCtrl's gesetzt werden. 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir IconChoiceDialog ( Window* pParent, const ResId &rResId, 226*cdf0e10cSrcweir const EIconChoicePos ePos = PosLeft, const SfxItemSet * pItemSet = 0 ); 227*cdf0e10cSrcweir ~IconChoiceDialog (); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////// 230*cdf0e10cSrcweir // virtuelle Methoden 231*cdf0e10cSrcweir // 232*cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 233*cdf0e10cSrcweir virtual void Resize(); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////// 236*cdf0e10cSrcweir // Schnittstelle 237*cdf0e10cSrcweir // 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* AddTabPage( 240*cdf0e10cSrcweir sal_uInt16 nId, const String& rIconText, const Image& rChoiceIcon, const Image& rChoiceIconHC, 241*cdf0e10cSrcweir CreatePage pCreateFunc /* != NULL */, GetPageRanges pRangesFunc = NULL /* NULL allowed*/, 242*cdf0e10cSrcweir sal_Bool bItemsOnDemand = sal_False, sal_uLong nPos = LIST_APPEND ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir void SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); } 245*cdf0e10cSrcweir sal_uInt16 GetCurPageId() const { return mnCurrentPageId; } 246*cdf0e10cSrcweir void ShowPage( sal_uInt16 nId ); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir // liefert ggf. per Map konvertierte lokale Slots 249*cdf0e10cSrcweir const sal_uInt16* GetInputRanges( const SfxItemPool& ); 250*cdf0e10cSrcweir void SetInputSet( const SfxItemSet* pInSet ); 251*cdf0e10cSrcweir const SfxItemSet* GetOutputItemSet() const { return pOutSet; } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir const OKButton& GetOKButton() const { return aOKBtn; } 254*cdf0e10cSrcweir OKButton& GetOKButton() { return aOKBtn; } 255*cdf0e10cSrcweir const CancelButton& GetCancelButton() const { return aCancelBtn; } 256*cdf0e10cSrcweir CancelButton& GetCancelButton() { return aCancelBtn; } 257*cdf0e10cSrcweir const HelpButton& GetHelpButton() const { return aHelpBtn; } 258*cdf0e10cSrcweir HelpButton& GetHelpButton() { return aHelpBtn; } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir short Execute(); 261*cdf0e10cSrcweir void Start( sal_Bool bShow = sal_True ); 262*cdf0e10cSrcweir sal_Bool QueryClose(); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir const SfxItemSet* GetExampleSet() const { return pExampleSet; } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir EIconChoicePos SetCtrlPos ( const EIconChoicePos& rPos ); 267*cdf0e10cSrcweir }; 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir #endif //_ICCDLG_HXX 270*cdf0e10cSrcweir 271