1*01aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01aa44aaSAndrew Rist * distributed with this work for additional information 6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 10*01aa44aaSAndrew Rist * 11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*01aa44aaSAndrew Rist * 13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an 15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 17*01aa44aaSAndrew Rist * specific language governing permissions and limitations 18*01aa44aaSAndrew Rist * under the License. 19*01aa44aaSAndrew Rist * 20*01aa44aaSAndrew Rist *************************************************************/ 21*01aa44aaSAndrew Rist 22*01aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX 25cdf0e10cSrcweir #define SVTOOLS_INC_ROADMAPWIZARD_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svtools/svtdllapi.h" 28cdf0e10cSrcweir #include <svtools/wizardmachine.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir //........................................................................ 31cdf0e10cSrcweir namespace svt 32cdf0e10cSrcweir { 33cdf0e10cSrcweir //........................................................................ 34cdf0e10cSrcweir 35cdf0e10cSrcweir struct RoadmapWizardImpl; 36cdf0e10cSrcweir class RoadmapWizard; 37cdf0e10cSrcweir 38cdf0e10cSrcweir struct RoadmapWizardTypes 39cdf0e10cSrcweir { 40cdf0e10cSrcweir public: 41cdf0e10cSrcweir typedef sal_Int16 PathId; 42cdf0e10cSrcweir typedef ::std::vector< WizardTypes::WizardState > WizardPath; 43cdf0e10cSrcweir typedef TabPage* (* RoadmapPageFactory)( RoadmapWizard& ); 44cdf0e10cSrcweir }; 45cdf0e10cSrcweir 46cdf0e10cSrcweir //==================================================================== 47cdf0e10cSrcweir //= RoadmapWizard 48cdf0e10cSrcweir //==================================================================== 49cdf0e10cSrcweir /** is - no, not a wizard for a raodmap, but the base class for wizards 50cdf0e10cSrcweir <em>supporting</em> a roadmap. 51cdf0e10cSrcweir 52cdf0e10cSrcweir The basic new concept introduced is a <em>path</em>:<br/> 53cdf0e10cSrcweir A <em>path</em> is a sequence of states, which are to be executed in a linear order. 54cdf0e10cSrcweir Elements in the path can be skipped, depending on choices the user makes. 55cdf0e10cSrcweir 56cdf0e10cSrcweir In the most simple wizards, you will have only one path consisting of <code>n</code> elements, 57cdf0e10cSrcweir which are to be visited successively. 58cdf0e10cSrcweir 59cdf0e10cSrcweir In a slightly more complex wizard, you will have one linear path, were certain 60cdf0e10cSrcweir steps might be skipped due to user input. For instance, the user may decide to not specify 61cdf0e10cSrcweir certain aspects of the to-be-created object (e.g. by unchecking a check box), 62cdf0e10cSrcweir and the wizard then will simply disable the step which corresponds to this step. 63cdf0e10cSrcweir 64cdf0e10cSrcweir In a yet more advanced wizards, you will have several paths of length <code>n1</code> and 65cdf0e10cSrcweir <code>n2</code>, which share at least the first <code>k</code> states (where <code>k</code> 66cdf0e10cSrcweir is at least 1), and an arbitrary number of other states. 67cdf0e10cSrcweir */ 68cdf0e10cSrcweir class SVT_DLLPUBLIC RoadmapWizard : public OWizardMachine, public RoadmapWizardTypes 69cdf0e10cSrcweir { 70cdf0e10cSrcweir private: 71cdf0e10cSrcweir RoadmapWizardImpl* m_pImpl; 72cdf0e10cSrcweir 73cdf0e10cSrcweir public: 74cdf0e10cSrcweir RoadmapWizard( 75cdf0e10cSrcweir Window* _pParent, 76cdf0e10cSrcweir const ResId& _rRes, 77cdf0e10cSrcweir sal_uInt32 _nButtonFlags = WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP 78cdf0e10cSrcweir ); 79cdf0e10cSrcweir RoadmapWizard( 80cdf0e10cSrcweir Window* _pParent, 81cdf0e10cSrcweir const WinBits i_nStyle, 82cdf0e10cSrcweir sal_uInt32 _nButtonFlags = WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP 83cdf0e10cSrcweir ); 84cdf0e10cSrcweir ~RoadmapWizard( ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir void SetRoadmapBitmap( const BitmapEx& _rBitmap ); 87cdf0e10cSrcweir const BitmapEx& GetRoadmapBitmap( ) const; 88cdf0e10cSrcweir 89cdf0e10cSrcweir void SetRoadmapHelpId( const rtl::OString& _rId ); 90cdf0e10cSrcweir const rtl::OString& GetRoadmapHelpId() const; 91cdf0e10cSrcweir 92cdf0e10cSrcweir void SetRoadmapInteractive( sal_Bool _bInteractive ); 93cdf0e10cSrcweir sal_Bool IsRoadmapInteractive(); 94cdf0e10cSrcweir virtual void Resize(); 95cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir // returns whether a given state is enabled 98cdf0e10cSrcweir bool isStateEnabled( WizardState _nState ) const; 99cdf0e10cSrcweir 100cdf0e10cSrcweir // WizardDialog overridables 101cdf0e10cSrcweir virtual bool canAdvance() const; 102cdf0e10cSrcweir virtual void updateTravelUI(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir protected: 105cdf0e10cSrcweir /** declares a valid path in the wizard 106cdf0e10cSrcweir 107cdf0e10cSrcweir The very first path which is declared is automatically activated. 108cdf0e10cSrcweir 109cdf0e10cSrcweir Note that all paths which are declared must have the very first state in 110cdf0e10cSrcweir common. Also note that due to a restriction of the very base class (<type>WizardDialog</type>), 111cdf0e10cSrcweir this common first state must be 0. 112cdf0e10cSrcweir 113cdf0e10cSrcweir You cannot declare new paths once the wizard started, so it's recommended that 114cdf0e10cSrcweir you do all declarations within your derivee's constructor. 115cdf0e10cSrcweir 116cdf0e10cSrcweir @see activatePath 117cdf0e10cSrcweir 118cdf0e10cSrcweir @param _nId 119cdf0e10cSrcweir the unique id you wish to give this path. This id can later on be used 120cdf0e10cSrcweir to refer to the path which you just declared 121cdf0e10cSrcweir 122cdf0e10cSrcweir @param _nFirstState 123cdf0e10cSrcweir the first state in this path. Must not be WZS_INVALID_STATE.<br/> 124cdf0e10cSrcweir Declare an arbitrary number of states after this one, and terminate the sequence 125cdf0e10cSrcweir with a WZS_INVALID_STATE. 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir void declarePath( PathId _nPathId, WizardState _nFirstState, ... ); 128cdf0e10cSrcweir void declarePath( PathId _nPathId, const WizardPath& _lWizardStates); 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** provides basic information about a state 131cdf0e10cSrcweir 132cdf0e10cSrcweir The given display name is used in the default implementation of getStateDisplayName, 133cdf0e10cSrcweir and the given factory is used in the default implementation of createPage. 134cdf0e10cSrcweir */ 135cdf0e10cSrcweir void describeState( WizardState _nState, const String& _rStateDisplayName, RoadmapPageFactory _pPageFactory ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir /** activates a path which has previously been declared with <member>declarePath</member> 138cdf0e10cSrcweir 139cdf0e10cSrcweir You can only activate paths which share the first <code>k</code> states with the path 140cdf0e10cSrcweir which is previously active (if any), where <code>k</code> is the index of the 141cdf0e10cSrcweir current state within the current path. 142cdf0e10cSrcweir 143cdf0e10cSrcweir <example> 144cdf0e10cSrcweir Say you have paths, <code>(0,1,2,5)</code> and <code>(0,1,4,5)</code>. This means that after 145cdf0e10cSrcweir step <code>1</code>, you either continue with state <code>2</code> or state <code>4</code>, 146cdf0e10cSrcweir and after this, you finish in state <code>5</code>.<br/> 147cdf0e10cSrcweir Now if the first path is active, and your current state is <code>1</code>, then you can 148cdf0e10cSrcweir easily switch to the second path, since both paths start with <code>(0,1)</code>.<br/> 149cdf0e10cSrcweir However, if your current state is <code>2</code>, then you can not switch to the second 150cdf0e10cSrcweir path anymore. 151cdf0e10cSrcweir </example> 152cdf0e10cSrcweir 153cdf0e10cSrcweir @param _nPathId 154cdf0e10cSrcweir the id of the path. The path must have been declared (under this id) with 155cdf0e10cSrcweir <member>declarePath</member> before it can be activated. 156cdf0e10cSrcweir 157cdf0e10cSrcweir @param _bDecideForIt 158cdf0e10cSrcweir If <TRUE/>, the path will be completely activated, even if it is a conflicting path 159cdf0e10cSrcweir (i.e. there is another path which shares the first <code>k</code> states with 160cdf0e10cSrcweir the to-be-activated path.)<br/> 161cdf0e10cSrcweir If <FALSE/>, then the new path is checked for conflicts with other paths. If such 162cdf0e10cSrcweir conflicts exists, the path is not completely activated, but only up to the point 163cdf0e10cSrcweir where it does <em>not</em> conflict.<br/> 164cdf0e10cSrcweir With the paths in the example above, if you activate the second path (when both are 165cdf0e10cSrcweir already declared), then only steps <code>0</code> and <code>1</code> are activated, 166cdf0e10cSrcweir since they are common to both paths. 167cdf0e10cSrcweir */ 168cdf0e10cSrcweir void activatePath( PathId _nPathId, bool _bDecideForIt = false ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir /** determine the next state to travel from the given one 171cdf0e10cSrcweir 172cdf0e10cSrcweir This method (which is declared in <type>OWizardMachine</type> and overwritten here) 173cdf0e10cSrcweir ensures that traveling happens along the active path. 174cdf0e10cSrcweir 175cdf0e10cSrcweir @see activatePath 176cdf0e10cSrcweir */ 177cdf0e10cSrcweir virtual WizardState determineNextState( WizardState _nCurrentState ) const; 178cdf0e10cSrcweir 179cdf0e10cSrcweir /** en- or disables a state 180cdf0e10cSrcweir 181cdf0e10cSrcweir In the wizard's roadmap, states to travel to can be freely chosen. To prevent 182cdf0e10cSrcweir users from selecting a state which is currently not available, you can declare this 183cdf0e10cSrcweir state as being disabled. 184cdf0e10cSrcweir 185cdf0e10cSrcweir A situation where you need this may be when you have a checkbox which, when checked 186cdf0e10cSrcweir by the user, enables a page with additional settings. As long as this checkbox is 187cdf0e10cSrcweir not checked, the respective state would be disabled. 188cdf0e10cSrcweir 189cdf0e10cSrcweir Note that in theory, you can declare multiple paths, instead of disabling states. 190cdf0e10cSrcweir For instance, if you have a path where one state can be potentially disabled, then 191cdf0e10cSrcweir you could declare a second path, which does not contain this state. However, the 192cdf0e10cSrcweir disadvantage is that then, not the complete path would be visible in the roadmap, 193cdf0e10cSrcweir but only all steps up to the point where the both paths diverge.<br/> 194cdf0e10cSrcweir Another disadvantage is that the number of needed paths grows exponentially with 195cdf0e10cSrcweir the number of states which can be potentially disabled. 196cdf0e10cSrcweir 197cdf0e10cSrcweir @see declarePath 198cdf0e10cSrcweir */ 199cdf0e10cSrcweir void enableState( WizardState _nState, bool _bEnable = true ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir /** returns true if and only if the given state is known in at least one declared path 202cdf0e10cSrcweir */ 203cdf0e10cSrcweir bool knowsState( WizardState _nState ) const; 204cdf0e10cSrcweir 205cdf0e10cSrcweir // OWizardMachine overriables 206cdf0e10cSrcweir virtual void enterState( WizardState _nState ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir /** returns a human readable name for a given state 209cdf0e10cSrcweir 210cdf0e10cSrcweir There is a default implementation for this method, which returns the display name 211cdf0e10cSrcweir as given in a call to describeState. If there is no description for the given state, 212cdf0e10cSrcweir this is worth an assertion in a non-product build, and then an empty string is 213cdf0e10cSrcweir returned. 214cdf0e10cSrcweir */ 215cdf0e10cSrcweir virtual String getStateDisplayName( WizardState _nState ) const; 216cdf0e10cSrcweir 217cdf0e10cSrcweir /** creates a page for a given state 218cdf0e10cSrcweir 219cdf0e10cSrcweir This member is inherited from OWizardMachine, and default-implemented in this class 220cdf0e10cSrcweir for all states which have been described using describeState. 221cdf0e10cSrcweir */ 222cdf0e10cSrcweir virtual TabPage* createPage( WizardState _nState ); 223cdf0e10cSrcweir 224cdf0e10cSrcweir /** asks for a new label of the wizard page 225cdf0e10cSrcweir 226cdf0e10cSrcweir */ 227cdf0e10cSrcweir void updateRoadmapItemLabel( WizardState _nState ); 228cdf0e10cSrcweir 229cdf0e10cSrcweir protected: 230cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 231cdf0e10cSrcweir const sal_Char* checkInvariants() const; 232cdf0e10cSrcweir friend const char* CheckInvariants( const void* pVoid ); 233cdf0e10cSrcweir #endif 234cdf0e10cSrcweir 235cdf0e10cSrcweir private: 236cdf0e10cSrcweir SVT_DLLPRIVATE void ResizeFixedLine(); 237cdf0e10cSrcweir 238cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( OnRoadmapItemSelected, void* ); 239cdf0e10cSrcweir 240cdf0e10cSrcweir /** updates the roadmap control to show the given path, as far as possible 241cdf0e10cSrcweir (modulo conflicts with other paths) 242cdf0e10cSrcweir */ 243cdf0e10cSrcweir SVT_DLLPRIVATE void implUpdateRoadmap( ); 244cdf0e10cSrcweir 245cdf0e10cSrcweir private: 246cdf0e10cSrcweir SVT_DLLPRIVATE void impl_construct(); 247cdf0e10cSrcweir }; 248cdf0e10cSrcweir 249cdf0e10cSrcweir //........................................................................ 250cdf0e10cSrcweir } // namespace svt 251cdf0e10cSrcweir //........................................................................ 252cdf0e10cSrcweir 253cdf0e10cSrcweir #endif // OOO_SVTOOLS_INC_ROADMAPWIZARD_HXX 254