tdf#119209: Windows share has inappropriate server suggestion
[LibreOffice.git] / include / svtools / roadmapwizard.hxx
blob30f58d6f13d3f7367b2b113dcece1779d9e03b06
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 .
20 #ifndef INCLUDED_SVTOOLS_ROADMAPWIZARD_HXX
21 #define INCLUDED_SVTOOLS_ROADMAPWIZARD_HXX
23 #include <memory>
24 #include <svtools/svtdllapi.h>
25 #include <svtools/wizardmachine.hxx>
28 namespace svt
30 struct RoadmapWizardImpl;
31 class RoadmapWizard;
33 struct RoadmapWizardTypes
35 public:
36 typedef sal_Int16 PathId;
37 typedef ::std::vector< WizardTypes::WizardState > WizardPath;
38 typedef VclPtr<TabPage> (* RoadmapPageFactory)( RoadmapWizard& );
42 //= RoadmapWizard
44 /** is - no, not a wizard for a roadmap, but the base class for wizards
45 <em>supporting</em> a roadmap.
47 The basic new concept introduced is a <em>path</em>:<br/>
48 A <em>path</em> is a sequence of states, which are to be executed in a linear order.
49 Elements in the path can be skipped, depending on choices the user makes.
51 In the most simple wizards, you will have only one path consisting of <code>n</code> elements,
52 which are to be visited successively.
54 In a slightly more complex wizard, you will have one linear path, were certain
55 steps might be skipped due to user input. For instance, the user may decide to not specify
56 certain aspects of the to-be-created object (e.g. by unchecking a check box),
57 and the wizard then will simply disable the step which corresponds to this step.
59 In a yet more advanced wizards, you will have several paths of length <code>n1</code> and
60 <code>n2</code>, which share at least the first <code>k</code> states (where <code>k</code>
61 is at least 1), and an arbitrary number of other states.
63 class SVT_DLLPUBLIC RoadmapWizard : public OWizardMachine, public RoadmapWizardTypes
65 private:
66 std::unique_ptr<RoadmapWizardImpl> m_pImpl;
68 public:
69 RoadmapWizard(
70 vcl::Window* _pParent
72 virtual ~RoadmapWizard( ) override;
73 virtual void dispose() override;
75 void SetRoadmapHelpId( const OString& _rId );
77 void SetRoadmapInteractive( bool _bInteractive );
79 // returns whether a given state is enabled
80 bool isStateEnabled( WizardState _nState ) const;
82 // WizardDialog overridables
83 virtual bool canAdvance() const override;
84 virtual void updateTravelUI() override;
86 protected:
87 /** declares a valid path in the wizard
89 The very first path which is declared is automatically activated.
91 Note that all paths which are declared must have the very first state in
92 common. Also note that due to a restriction of the very base class (WizardDialog),
93 this common first state must be 0.
95 You cannot declare new paths once the wizard started, so it's recommended that
96 you do all declarations within your derivee's constructor.
98 @see activatePath
100 @param _nId
101 the unique id you wish to give this path. This id can later on be used
102 to refer to the path which you just declared
104 void declarePath( PathId _nPathId, const WizardPath& _lWizardStates);
106 /** provides basic information about a state
108 The given display name is used in the default implementation of getStateDisplayName,
109 and the given factory is used in the default implementation of createPage.
111 void describeState( WizardState _nState, const OUString& _rStateDisplayName, RoadmapPageFactory _pPageFactory );
113 /** activates a path which has previously been declared with <member>declarePath</member>
115 You can only activate paths which share the first <code>k</code> states with the path
116 which is previously active (if any), where <code>k</code> is the index of the
117 current state within the current path.
119 <example>
120 Say you have paths, <code>(0,1,2,5)</code> and <code>(0,1,4,5)</code>. This means that after
121 step <code>1</code>, you either continue with state <code>2</code> or state <code>4</code>,
122 and after this, you finish in state <code>5</code>.<br/>
123 Now if the first path is active, and your current state is <code>1</code>, then you can
124 easily switch to the second path, since both paths start with <code>(0,1)</code>.<br/>
125 However, if your current state is <code>2</code>, then you can not switch to the second
126 path anymore.
127 </example>
129 @param _nPathId
130 the id of the path. The path must have been declared (under this id) with
131 <member>declarePath</member> before it can be activated.
133 @param _bDecideForIt
134 If <TRUE/>, the path will be completely activated, even if it is a conflicting path
135 (i.e. there is another path which shares the first <code>k</code> states with
136 the to-be-activated path.)<br/>
137 If <FALSE/>, then the new path is checked for conflicts with other paths. If such
138 conflicts exists, the path is not completely activated, but only up to the point
139 where it does <em>not</em> conflict.<br/>
140 With the paths in the example above, if you activate the second path (when both are
141 already declared), then only steps <code>0</code> and <code>1</code> are activated,
142 since they are common to both paths.
144 void activatePath( PathId _nPathId, bool _bDecideForIt = false );
146 /** determine the next state to travel from the given one
148 This method (which is declared in OWizardMachine and overwritten here)
149 ensures that traveling happens along the active path.
151 @see activatePath
153 virtual WizardState determineNextState( WizardState _nCurrentState ) const override;
155 /** en- or disables a state
157 In the wizard's roadmap, states to travel to can be freely chosen. To prevent
158 users from selecting a state which is currently not available, you can declare this
159 state as being disabled.
161 A situation where you need this may be when you have a checkbox which, when checked
162 by the user, enables a page with additional settings. As long as this checkbox is
163 not checked, the respective state would be disabled.
165 Note that in theory, you can declare multiple paths, instead of disabling states.
166 For instance, if you have a path where one state can be potentially disabled, then
167 you could declare a second path, which does not contain this state. However, the
168 disadvantage is that then, not the complete path would be visible in the roadmap,
169 but only all steps up to the point where the both paths diverge.<br/>
170 Another disadvantage is that the number of needed paths grows exponentially with
171 the number of states which can be potentially disabled.
173 @see declarePath
175 void enableState( WizardState _nState, bool _bEnable = true );
177 /** returns true if and only if the given state is known in at least one declared path
179 bool knowsState( WizardState _nState ) const;
181 // OWizardMachine overriables
182 virtual void enterState( WizardState _nState ) override;
184 /** returns a human readable name for a given state
186 There is a default implementation for this method, which returns the display name
187 as given in a call to describeState. If there is no description for the given state,
188 this is worth an assertion in a non-product build, and then an empty string is
189 returned.
191 virtual OUString getStateDisplayName( WizardState _nState ) const;
193 /** creates a page for a given state
195 This member is inherited from OWizardMachine, and default-implemented in this class
196 for all states which have been described using describeState.
198 virtual VclPtr<TabPage> createPage( WizardState _nState ) override;
200 /** asks for a new label of the wizard page
203 void updateRoadmapItemLabel( WizardState _nState );
205 private:
206 DECL_DLLPRIVATE_LINK( OnRoadmapItemSelected, LinkParamNone*, void );
208 /** updates the roadmap control to show the given path, as far as possible
209 (modulo conflicts with other paths)
211 SVT_DLLPRIVATE void implUpdateRoadmap( );
213 private:
214 SVT_DLLPRIVATE void impl_construct();
218 } // namespace svt
221 #endif // OOO_ INCLUDED_SVTOOLS_ROADMAPWIZARD_HXX
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */