NCBI C++ ToolKit
wizard_dlg.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: wizard_dlg.cpp 43611 2019-08-08 18:36:29Z filippov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 ////@begin includes
35 ////@end includes
36 
38 
39 #include <wx/panel.h>
40 #include <wx/button.h>
41 #include <wx/sizer.h>
42 #include <wx/hyperlink.h>
44 
45 DEFINE_EVENT_TYPE(CEVT_WIZARD_DLG_EVENT)
46 
47 IMPLEMENT_DYNAMIC_CLASS( CWizardDlg, CDialog )
48 
49 BEGIN_EVENT_TABLE( CWizardDlg, CDialog )
50 
51 ////@begin CWizardDlg event table entries
52  EVT_BUTTON( ID_BUTTON_OPTIONS, CWizardDlg::OnButtonOptionsClick )
53 
54  EVT_BUTTON( wxID_BACKWARD, CWizardDlg::OnBackwardClick )
55 
56  EVT_BUTTON( wxID_FORWARD, CWizardDlg::OnForwardClick )
57 
58 ////@end CWizardDlg event table entries
59 
60  EVT_MENU(eCmdUpdateButtons, CWizardDlg::OnUpdateButtons)
61 
63 
65  : m_CurrentPage()
66 {
67  Init();
68 }
69 
70 CWizardDlg::CWizardDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
71  : m_CurrentPage()
72 {
73  Init();
74  Create(parent, id, caption, pos, size, style);
75 }
76 
77 bool CWizardDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
78 {
79 ////@begin CWizardDlg creation
80  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
81  CDialog::Create( parent, id, caption, pos, size, style );
82 
84  if (GetSizer())
85  {
86  GetSizer()->SetSizeHints(this);
87  }
88  Centre();
89 ////@end CWizardDlg creation
90  return true;
91 }
92 
94 {
95 ////@begin CWizardDlg destruction
96 ////@end CWizardDlg destruction
97 }
98 
100 {
101 ////@begin CWizardDlg member initialisation
103  m_OptionsBtn = NULL;
104  m_BackBtn = NULL;
105  m_NextBtn = NULL;
106  m_Help = NULL;
107 ////@end CWizardDlg member initialisation
108 }
109 
111 {
112 ////@begin CWizardDlg content construction
113  CWizardDlg* itemCDialog1 = this;
114 
115  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
116  itemCDialog1->SetSizer(itemBoxSizer2);
117 
118  wxStaticLine* itemStaticLine3 = new wxStaticLine( itemCDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
119  itemBoxSizer2->Add(itemStaticLine3, 0, wxGROW|wxALL, 5);
120 
121  m_ButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
122  itemBoxSizer2->Add(m_ButtonsSizer, 0, wxGROW|wxALL, 5);
123 
124  m_Help = new wxHyperlinkCtrl( itemCDialog1, ID_HELP_LINK, _("Help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
125  m_Help->SetForegroundColour(wxColour(192, 192, 192));
126  m_ButtonsSizer->Add(m_Help, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
127  m_Help->Hide();
128 
129  m_ButtonsSizer->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
130 
131  m_OptionsBtn = new wxButton( itemCDialog1, ID_BUTTON_OPTIONS, _("Options"), wxDefaultPosition, wxDefaultSize, 0 );
132  m_OptionsBtn->Show(false);
133  m_ButtonsSizer->Add(m_OptionsBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1);
134 
135  m_BackBtn = new wxButton( itemCDialog1, wxID_BACKWARD, _("&Back"), wxDefaultPosition, wxDefaultSize, 0 );
136  m_ButtonsSizer->Add(m_BackBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1);
137 
138  m_NextBtn = new wxButton( itemCDialog1, wxID_FORWARD, _("&Forward"), wxDefaultPosition, wxDefaultSize, 0 );
139  m_NextBtn->SetDefault();
140  m_ButtonsSizer->Add(m_NextBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1);
141 
142  m_ButtonsSizer->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
143 
144  wxButton* itemButton11 = new wxButton( itemCDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
145  m_ButtonsSizer->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
146 
147 ////@end CWizardDlg content construction
148 
149 
150  CreatePages();
151  UpdateButtons();
152 }
153 
154 void CWizardDlg::SetHelpUrl(const wxString &url)
155 {
156  m_Help->SetURL(url);
157  m_Help->Show(!url.IsEmpty());
158 }
159 
160 
162 {
163  if (m_CurrentPage == page)
164  return;
165 
166  wxPanel* panel = m_CurrentPage ? m_CurrentPage->GetPanel() : 0;
167  if (panel) {
168  panel->Hide();
169  }
170 
171  m_CurrentPage = page;
172  if (!m_CurrentPage)
173  return;
174 
175  panel = m_CurrentPage->GetPanel();
176 
177  if (panel->GetParent() != this) {
178  panel->Reparent(this);
179  }
180 
181  if (panel->GetContainingSizer() != GetSizer()) {
182  GetSizer()->Insert(0, panel, 1, wxEXPAND | wxALL, 5);
183  }
184 
185  panel->Show();
186  panel->SetFocus();
187 
188  UpdateButtons();
189 
190  this->Layout();
191 }
192 
194 {
195  IWizardPage *next = 0, *prev = 0, *options = 0;
196  if (m_CurrentPage) {
199  options = m_CurrentPage->GetOptionsPage();
200  }
201 
202  m_OptionsBtn->Show(options != 0);
203  m_BackBtn->Show(prev != 0);
204  m_NextBtn->SetLabel(next ? wxT("Next >") : wxT("Finish"));
205  m_ButtonsSizer->Layout();
206 }
207 
209 {
210  return true;
211 }
212 wxBitmap CWizardDlg::GetBitmapResource( const wxString& name )
213 {
214  // Bitmap retrieval
215 ////@begin CWizardDlg bitmap retrieval
216  wxUnusedVar(name);
217  return wxNullBitmap;
218 ////@end CWizardDlg bitmap retrieval
219 }
220 wxIcon CWizardDlg::GetIconResource( const wxString& name )
221 {
222  // Icon retrieval
223 ////@begin CWizardDlg icon retrieval
224  wxUnusedVar(name);
225  return wxNullIcon;
226 ////@end CWizardDlg icon retrieval
227 }
228 
229 
230 /*!
231  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BACKWARD
232  */
233 
234 void CWizardDlg::OnBackwardClick( wxCommandEvent& WXUNUSED(event) )
235 {
236  if (m_CurrentPage) {
238  if (prev && m_CurrentPage->CanLeavePage(false))
240  }
241 }
242 
243 
244 /*!
245  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FORWARD
246  */
247 
248 void CWizardDlg::OnForwardClick( wxCommandEvent& WXUNUSED(event) )
249 {
250  if (m_CurrentPage) {
252  if (m_CurrentPage->CanLeavePage(true)) {
253  if (next)
255  else
256  EndModal(wxID_OK);
257  }
258  }
259 }
260 
261 /*!
262  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_OPTIONS
263  */
264 
265 void CWizardDlg::OnButtonOptionsClick( wxCommandEvent& WXUNUSED(event) )
266 {
267  if (m_CurrentPage) {
269  if (next != 0 && m_CurrentPage->CanLeavePage(true)) {
271  }
272  }
273 }
274 
CDialog.
Definition: dialog.hpp:47
virtual void EndModal(int retCode)
Definition: dialog.cpp:142
wxButton * m_OptionsBtn
Definition: wizard_dlg.hpp:136
virtual void CreatePages()
Definition: wizard_dlg.hpp:101
void SetCurrentPage(IWizardPage *page)
Definition: wizard_dlg.cpp:161
void OnForwardClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_FORWARD
Definition: wizard_dlg.cpp:248
void UpdateButtons()
Definition: wizard_dlg.cpp:193
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
Definition: wizard_dlg.cpp:212
void Init()
Definition: wizard_dlg.cpp:99
void OnButtonOptionsClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_OPTIONS
Definition: wizard_dlg.cpp:265
wxHyperlinkCtrl * m_Help
Definition: wizard_dlg.hpp:139
wxBoxSizer * m_ButtonsSizer
Definition: wizard_dlg.hpp:135
static bool ShowToolTips()
Definition: wizard_dlg.cpp:208
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
Definition: wizard_dlg.cpp:220
bool Create(wxWindow *parent, wxWindowID id=ID_CWIZARDDLG, const wxString &caption=_("WizardDlg"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Definition: wizard_dlg.cpp:77
void OnUpdateButtons(wxCommandEvent &)
Definition: wizard_dlg.hpp:119
void OnBackwardClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_BACKWARD
Definition: wizard_dlg.cpp:234
wxButton * m_BackBtn
Definition: wizard_dlg.hpp:137
void CreateControls()
Definition: wizard_dlg.cpp:110
wxButton * m_NextBtn
Definition: wizard_dlg.hpp:138
IWizardPage * m_CurrentPage
Definition: wizard_dlg.hpp:150
void SetHelpUrl(const wxString &url)
Definition: wizard_dlg.cpp:154
virtual IWizardPage * GetPrevPage()=0
virtual IWizardPage * GetOptionsPage()=0
virtual IWizardPage * GetNextPage()=0
virtual wxPanel * GetPanel()=0
virtual bool CanLeavePage(bool forward)=0
#define _(proto)
Definition: ct_nlmzip_i.h:78
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:61
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:56
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
Modified on Wed Sep 04 15:02:39 2024 by modify_doxy.py rev. 669887