1 /* 2 * Copyright 2008-2010, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Pfeiffer <laplace@users.sourceforge.net> 7 */ 8 #ifndef WIZARD_CONTROLLER_H 9 #define WIZARD_CONTROLLER_H 10 11 12 #include <SupportDefs.h> 13 14 15 class WizardView; 16 class WizardPageView; 17 18 19 class WizardController { 20 public: 21 WizardController(); 22 virtual ~WizardController(); 23 24 virtual void Initialize(WizardView* wizard); 25 virtual void Next(WizardView* wizard); 26 virtual void Previous(WizardView* wizard); 27 28 protected: 29 virtual int32 InitialState() = 0; 30 virtual int32 NextState(int32 state) = 0; 31 virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0; 32 33 private: 34 class StateStack { 35 public: 36 StateStack(int32 state, StateStack* next) 37 : 38 fState(state), 39 fNext(next) 40 { 41 } 42 43 int32 State() 44 { 45 return fState; 46 } 47 48 StateStack* Next() 49 { 50 return fNext; 51 } 52 53 void MakeEmpty(); 54 55 private: 56 int32 fState; 57 StateStack* fNext; 58 }; 59 60 void _PushState(int32 state); 61 void _ShowPage(WizardView* wizard); 62 63 private: 64 StateStack* fStack; 65 }; 66 67 68 #endif // WIZARD_CONTROLLER_H 69