2
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; version 2 of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
#ifndef _WIZARDFORM_H_
21
#define _WIZARDFORM_H_
27
#include "grt/common.h"
29
#include "wbpublic_public_interface.h"
30
#include "base/string_utilities.h"
32
#include "mforms/wizard.h"
33
#include "mforms/box.h"
34
#include "mforms/filechooser.h"
48
class WBPUBLICBACKEND_PUBLIC_FUNC WizardForm : public ::mforms::Wizard
51
WizardForm(bec::GRTManager *mgr);
52
virtual ~WizardForm();
54
virtual bool run_modal();
56
void add_page(WizardPage *page);
58
void update_buttons();
59
void update_heading();
61
void set_problem(const std::string &text);
66
void switch_to_page(WizardPage *page, bool advancing);
67
WizardPage *get_active_page() { return _active_page; }
68
int get_active_page_number();
70
WizardPage *get_page_with_id(const std::string &id);
72
bec::GRTManager *grtm() { return _grtm; }
74
grt::DictRef values() { return _values; }
77
// util stuff for storing state
78
void set_wizard_option(const std::string &key, const std::string &value);
79
std::string string_wizard_option(const std::string &key, const std::string &default_value= "");
81
void set_wizard_option(const std::string &key, int value);
82
int int_wizard_option(const std::string &key, int default_value= 0);
89
WizardPage *_active_page;
90
std::vector<WizardPage*> _pages;
91
std::list<WizardPage*> _turned_pages;
95
bec::GRTManager *_grtm;
97
virtual WizardPage *get_next_page(WizardPage *current);
98
void refresh_step_list();
100
void extra_clicked();
106
virtual bool cancel();
110
/** A page of a wizard.
112
class WBPUBLICBACKEND_PUBLIC_FUNC WizardPage : public ::mforms::Box
115
WizardPage(WizardForm *form, const std::string &pageid);
117
std::string get_id() const { return _id; }
119
std::string get_title() const { return _title; }
120
std::string get_short_title() const { return _short_title; }
122
void set_title(const std::string &title);
123
void set_short_title(const std::string &title);
127
boost::signals2::signal<void (bool)>* signal_enter() { return &_signal_enter; }
128
boost::signals2::signal<void (bool)>* signal_leave() { return &_signal_leave; }
134
friend class WizardForm;
136
grt::DictRef values() { return _form->values(); }
138
//! Subclasses must override this to implement validation.
139
//! If there is a validation error, it must call _form->set_problem()
140
virtual void do_validate() { }
142
virtual int load() { return -1; } // delme XXX
144
virtual bool pre_load();
145
virtual void enter(bool advancing);
146
virtual bool advance();
147
virtual void leave(bool advancing);
149
virtual bool allow_next() { return true; }
150
virtual bool allow_back() { return true; }
151
virtual bool allow_cancel() { return true; }
152
virtual bool skip_page() { return false; } // Return true if the page should not be displayed (due to some condition).
154
//! return true if this is the last page and pressing next should close wizard
155
virtual bool next_closes_wizard() { return false; }
157
//! overrider may return "" for default caption
158
virtual std::string next_button_caption() { return ""; }
160
virtual std::string extra_button_caption() { return ""; }
162
std::string finish_button_caption() const
166
#elif defined(_WIN32)
173
virtual void extra_clicked() {}
178
boost::signals2::signal<void (bool)> _signal_enter;
179
boost::signals2::signal<void (bool)> _signal_leave;
181
std::string _short_title;
183
std::string execute_caption() const
187
#elif defined(_WIN32)
188
return _("_Execute >");
190
return _("_Execute");
194
std::string finish_caption() const
203
virtual std::string close_caption() const
213
void filename_changed(mforms::TextEntry *entry);
214
void browse_file_callback(mforms::TextEntry *entry, mforms::FileChooserType type,
215
const std::string &extensions);